akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
  int i,j,flag;
  int n,a;
  int count = 0;

  scanf("%d",&n);
  int data[n];
  for(i = 0;i < n;i++){
    scanf("%d",&a);
    data[i] = a;
  }

  for(i = 0;i < n;i++){
    int key;
    flag = 1;
    while(flag){
      flag = 0;
      for(j = n-1;j > 0;j--) {
        if(data[j] < data[j-1]){
	  key = data[j-1];
          data[j-1] = data[j];
          data[j] = key;
	  flag = 1;
	  count++;
	}
      }
    }
    for(i = 0;i < n;i++){
    printf("%d",data[i]);
    if(i==n-1) break;
    printf(" ");
    }
  printf("\n");
  printf("%d\n",count);
  }

  return 0;
}



Measured memory_bytes: 2068
#include<bits/stdc++.h>

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

int main(){
	ll a, b, c, d; scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	printf("%lld\n", max(max(a * c, a * d), max(b * c, b * d)));
	return 0;
}


Measured memory_bytes: 3800
#pragma region GNUC
//以下を参考にした
//https://yukicoder.me/wiki/auto_vectorization
#ifdef __GNUC__
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#endif
#pragma endregion

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>

#include <string>
#include <cstring>
#include <vector>
#include <valarray>
//#include <array>//x C++ (G++ 4.6.4)

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <cassert>//assert();
#include <fstream>
#include <random>
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)

/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#define PII pair<int,int>
/////////
using namespace::std;

// 最大公約数
template<class T>
inline T gcd(T a, T b){return b ? gcd(b, a % b) : a;}
//inline T gcd(T a, T b){return b == 0 ? a : gcd(b, a % b);}

// 最小公倍数
template<class T>
inline T lcm(T a, T b){return a / gcd(a, b) * b;}
//inline T lcm(T a, T b){return a * b / gcd(a, b);}

template<class T>
T pow(T x,int n){
	T mul = x;
	T ans = (T)1;
	while(n){
		if(n&1){
			ans *= mul;
		}
		mul *= mul;
		n >>= 1;
	}
	return ans;
}
////////////////////////////////

void solve(){
	int N,K;
	cin >> N >> K;
	cout << K * pow(K-1,N-1);
}

signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	//std::cout << std::fixed;//小数を10進数表示
	//cout << setprecision(16);//小数点以下の桁数を指定
	
	solve();
}


Measured memory_bytes: 256
import sys
N = int(input())
A = list(map(int, input().split()))

ans = N
if N == 1:
    print(1)
    sys.exit()
j = 1
s = A[0] + A[1]
x = A[0] ^ A[1]
for i, a in enumerate(A):
    if j == i:
        j += 1
        if j == N:
            break
        x = x ^ A[j]
        s += A[j]

    while True:
        if j == N:
            break
        if s == x:
            ans += j-i
            j += 1
            if j == N:
                break
            s += A[j]
            x = x ^ A[j]
        else:
            s -= a
            x = x ^ a
            break
    if j == N:
        break

print(ans)




Measured memory_bytes: 24840
//答え見ました
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

struct Edge {int to, id;};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c=-1, int p=-1){
 int k=1;
 for(int i=0; i<g[v].size(); i++){
  int u = g[v][i].to , ei= g[v][i].id;
  if(u==p) continue;
  if(k==c) k++;
  ans[ei] = k; k++;
  dfs(u,ans[ei],v);
 }
}

int main(){
  int n;
  cin >> n;
  g.resize(n);
  ans = vector<int>(n-1);
  for(int i=0; i<n-1; i++){
    int x,y;
    cin >> x >> y;
    x--; y--;
    g[x].push_back((Edge){y,i});
    g[y].push_back((Edge){x,i});
    
  }
  
  dfs(0);
  int mx = 0;
  for(int i=0; i<n; i++) mx = max(mx,int(g[i].size()));
  cout << mx << endl;
  
  for(int i=0; i<n-1; i++) cout << ans[i] << endl;
  
  return 0;
  
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;

int main() {
    string n;
    string real;
    int counter = 0;
    cin >> n;
    cin >> real;
    if (n[0] == real[0]){
        counter ++;
    }
    if(n[1] == real[1]){
        counter ++;
    }
    if(n[2] == real[2]){
        counter ++;
    }

    cout << counter;



}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  ll ans = 0;
  map<int, int> mp;
  REP(i, n) {
    ans += mp[i - a[i]];
    ++mp[a[i] + i];
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 21080
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
const int INF = 1e9+5;

int main(){
	int l;
	cin >> l;
    vector<int> dp(3,0);
    for(int day=0;day<l;++day){
	    vector<int> new_dp(3,0);
	    vector<int> d(3);
	    for(auto &x:d){
		     int w;
		     cin >> w;
		     x = w;	
		}  
	    for(int i=0;i<3;++i){
			for(int j=0;j<3;j++){
				if (i!=j){
					new_dp[j] = max(new_dp[j],dp[i] + d[j]);
				}
		    }
	    }
	    dp = new_dp;
	}
	cout << max({dp[0],dp[1],dp[2]});
}







Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete
signed main(){

    int R;
    cin>>R;
    cout<<setprecision(20)<<fixed<<2.*R*M_PI<<endl;

    return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Fri Mar 20 14:03:30 JST 2020
 **/

signed main() {
    Int n;
    cin >> n;
    if (n == 1) {
        cout << "1\n0\n";
    } else if (n == 2) {
        cout << "2\n0\n11\n";
    } else {
        cout << n - 1 << endl;
        REP(i, 2, n + 1) {
            cout << 1;
            REP(j, i - 2) cout << 0;
            cout << "1\n";
        }
    }
}



Measured memory_bytes: 3220
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    string s;
    cin>>s;
    int w=0;
    int b;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0') w++;
        else b++;
    }
    if(w<=b) cout<<w*2<<endl;
    else cout<<b*2<<endl;



    return 0;
}

Measured memory_bytes: 512
N,M = map(int,input().split())
ks = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int,input().split()))
ans=0
for i in range(2**N):
    b="0"*(N-len(bin(i)[2:]))+bin(i)[2:]
    #print(b)
    on=0
    for j in range(M):#各電球ごと　#電球1はスイッチ1,2,5のうち奇数個ついていればよい
        c=0#その電球に必要なスイッチの数用のカウント
        for k in range(N):
            if k+1 in ks[j][1:]:#例えばスイッチ1が電球1に必要なスイッチのリストふ含まれているとき
                if b[k]=="1":
                    c+=1
        if c%2==p[j]:
            on+=1
    if on==M:
        ans+=1
print(ans)

Measured memory_bytes: 9196
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
    	//int M = sc.nextInt();
      	//String S = sc.next();
      	//int list[] = new int[N];
      	//for(int i=0;i<N;i++){
        //	list[i] = sc.nextInt();
        //}
      	//Arrays.sort(list);
		if(N%2==0){
        	System.out.println(N);
        }else{
        	System.out.println(N*2);
        }
      	
    }
}

Measured memory_bytes: 21844
#include<iostream>  
#include<cstring>  
#include<string>  
#include<cstdio>  
#include<cmath>  
#include<vector>  
#include<queue>  
#include<algorithm>  
using namespace std;
#define inf 0x3f3f3f3f  
#define ll long long  
const int maxn = 1e5 + 500;
int pri[maxn],sum[maxn],top;
int ans[10];
void fun() {
	int  k,cnt=0;
	top = 1;
	for (int i = 2; i <= 55555; i++) {
		k = 1;
		for (int j = 2; j <= sqrt(i); j++)
			if (i%j == 0) {
				k = 0; break;
			}
		if (k) { 
			pri[top++] = i; 
			if (i % 10 == 1)ans[cnt++] = i;
		}
	}	
}
int main()
{
	fun();
	int n,sum;
	while (~scanf("%d", &n))
	{	
		for (int i = 1;i<=n;i++)
				printf("%d%c", ans[i], i == n ? '\n' : ' ');
	}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int s,t;
int n,m;
const int maxn=1e5+10;
int dp[maxn][10];
vector<int> vs[maxn];
int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++) {
        int x,y; cin>>x>>y;
        vs[x].push_back(y);
    }
    for(int i=1;i<=n;i++){
        dp[i][0]=dp[i][1]=dp[i][2]=2e9+10;
    }
    cin>>s>>t;
    queue<int> qu;
    dp[s][0]=0;
    qu.push(s);
    while(!qu.empty()){
        int x=qu.front(); qu.pop();
        for(int i=0;i<vs[x].size();i++){
            int u=vs[x][i];
            if(dp[x][0]+1<dp[u][1]  || dp[x][1]+1<dp[u][2] || dp[x][2]+1<dp[u][0] ){
                qu.push(u);
            }
            dp[u][1]=min(dp[x][0]+1,dp[u][1]);
            dp[u][2]=min(dp[x][1]+1,dp[u][2]);
            dp[u][0]=min(dp[x][2]+1,dp[u][0]);
        }
       // if(qu.size()==1000000) break;
    }
    if(dp[t][0]==2000000000+10){
        cout<<-1<<endl;
    }else {
        cout<<dp[t][0]/3<<endl;
    }
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    const int MAX = 1299709;
    vi isprime(MAX+1, 1);
    isprime[0] = isprime[1] = 0;
    vi primes;
    FOR(i, 2, MAX+1) {
        if (!isprime[i]) continue;
        primes.push_back(i);
        for (int j = 2*i; j <= MAX; j += i) {
            isprime[j] = 0;
        }
    }

    for (;;) {
        int k; cin >> k;
        if (k == 0) break;
        if (isprime[k]) {
            cout << 0 << endl;
            continue;
        }
        int ub = upper_bound(ALL(primes), k) - primes.begin();
        int ans = primes[ub] - primes[ub-1];
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 8412
#include <stdio.h>

int main() {
  double w, h, x, y;
  scanf("%lf %lf %lf %lf", &w, &h, &x, &y);
  double s = (w * h) / 2.00;
  int boo;
  boo = (x != w/2.00) ? 0 :
        (y != h/2.00) ? 0 : 1;
  printf("%lf %d\n", s, boo);
  return 0;
}


Measured memory_bytes: 128
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
 
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define T int t = 0; cin >> t; while(t--)
#define pr(a) for(int i = 0; i < (int)a.size(); ++i)cout << a[i] << " ";cout << endl;
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef long double lld;
const ll mod = 1e15;
const ll mx = 2e6;
const ll inf = 1e9;
const int sz = 26;
typedef long long ll;

void input(){
    IOS;
    ll n, k;
    cin >> n >> k;
    vector<ll>a(n);
    f(i, n)cin >> a[i];
    ll low = 0, high = 1e9;
    auto possible = [&](ll x){
        if(x == 0)return false;
        ll cnt = 0;
        f(i, n){
            cnt += (a[i] - 1) / x;
        }
        return cnt <= k;
    };
    while(low < high){
        
        ll mid = (low + high) / 2LL ;
        //cout << high << " "<< low << endl;
        if(possible(mid)){
            high = mid;
        }else low = mid + 1;
    }
    cout << low << endl;
}

int main(){
    input();
    return 0;
} 
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/


Measured memory_bytes: 4752
#include <bits/stdc++.h>
using namespace std;
int main()
  {int64_t N, K, ans{}; cin >> N >> K;
  for (auto i{K}; i <= N + 1; ++i) ans = (ans + i * (N - i + 1) + 1) % 1000000007;
  cout << ans;}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
class abc{
    public:int row,col,total;
};
void trozen()
{
    int n,m,to;
    cin>>n>>m>>to;
    vector<int> row(n+1),col(m+1);
    set<pair<int,int> >s1;
    //rep(i,n+1) rep(j,m+1) arr[i][j]=0;
    int x,y;
    rep(i,to)cin>>x>>y,row[x]++,col[y]++,s1.insert(make_pair(x,y));
    int maxe=INT_MIN,rows,cols;
    for(int i=1;i<=n;i++) if(maxe<row[i]) maxe=row[i],rows=i;
    int mine=INT_MIN;
    for(int i=1;i<=m;i++) if(mine<col[i]) mine=col[i],cols=i;
    vector<int> row1,col1;
    for(int i=1;i<=n;i++) if(row[i]==maxe) row1.push_back(i);
    for(int j=1;j<=m;j++) if(col[j]==mine) col1.push_back(j);
    for(auto i:row1)
    {
        for(auto j:col1)
        {
            if(s1.find({i,j})==s1.end())
            {
                cout<<(maxe+mine)<<endl;
                return;
            }

        }
    }
    cout<<(maxe+mine-1)<<endl;
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


Measured memory_bytes: 34976
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]

c = {}
for s in S:
    c[s] = c.get(s, 0) + 1
for s in T:
    c[s] = c.get(s, 0) - 1

print(max(0, max(c.values())))


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define toupper(S) transform(S.begin(),S.end(),S.begin(),toupper)
#define tolower(S) transform(S.begin(),S.end(),S.begin(),tolower)


int main() {
	lint a, b;
	cin >> a >> b;
	if (a * b <= 0) {
		cout << "Zero" << endl;
	}
	else {
		if (a > 0) {
			cout << "Positive" << endl;
			}
		else {
			if (abs(b - a) % 2 == 0) {
				cout << "Negative" << endl;
			}
			else {
				cout << "Positive" << endl;
			}
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;

#define N 100000
#define Q
#define INF 1<<18
#define MIN(X,Y) ((X)<(Y)?(X):(Y))
#define ABS(X) ((X)<0?-(X):(X))

int dp[N+1];


int main(void){
  int n;
  int h[N+1];
  
  cin >> n;
  for (int i=1; i<=n; i++){
    cin >> h[i];
    dp[i] = INF;
  }
  
  dp[1] = 0;
  for (int i=2; i<=n; i++){
    dp[i] = dp[i-1]+ABS(h[i]-h[i-1]);
    if (i-2>=1) dp[i] = MIN(dp[i], dp[i-2]+ABS(h[i]-h[i-2]));
    //cout << dp[i] << " ";
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

#define int ll

const int mod = 1e9 + 7;

template <int Modulus>
struct modint {
    ll x;  // typedef long long ll;
    modint(ll x = 0) : x((x % mod + mod) % mod) {}
    modint operator-() const { return modint(-x); }
    modint& operator+=(const modint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    modint& operator-=(const modint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    modint& operator*=(const modint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    modint operator+(const modint a) const { return modint(*this) += a; }
    modint operator-(const modint a) const { return modint(*this) -= a; }
    modint operator*(const modint a) const { return modint(*this) *= a; }
    modint pow(ll t) const {
        if (!t) return 1;
        modint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    modint inv() const { return pow(mod - 2); }
    modint& operator/=(const modint a) { return *this *= a.inv(); }
    modint operator/(const modint a) const { return modint(*this) /= a; }
};
template <int Modulus>
istream& operator>>(istream& is, modint<Modulus>& a) {
    return is >> a.x;
}
template <int Modulus>
ostream& operator<<(ostream& os, const modint<Modulus>& a) {
    return os << a.x;
}

using mint = modint<mod>;

signed main() {
    ll n, k;
    bool an = true;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll& i : a) {
        cin >> i;
        if (i >= 0) an = false;
    }
    if (an && k % 2 || n == k) {
        sort(a.begin(), a.end(), greater<>());
        mint r = 1;
        for (int i = 0; i < k; ++i) r *= a[i];
        cout << r;
        return 0;
    }
    sort(a.begin(), a.end(), [](ll l, ll r) { return abs(l) > abs(r); });
    vector<ll> pos, neg;
    for (int i = 0; i < n; ++i) {
        if (a[i] >= 0)
            pos.push_back(a[i]);
        else
            neg.push_back(-a[i]);
    }
    int sp = 0, sn = 0, tk = k;
    mint r = 1;
    for (int i = 0; i < n && tk > 0; ++i) {
        if (tk <= 1) {
            if (pos.size() - sp >= 1)
                r *= pos[sp++], --tk;
            else
                break;
        }
        else if (neg.size() - sn <= 1)
            r *= pos[sp++], --tk;
        else if (pos.size() - sp == 0) {
            r *= neg[sn++];
            --tk;
            r *= neg[sn++];
            --tk;
        }
        else {
            if (pos[sp] * pos[sp + 1] >= neg[sn] * neg[sn + 1])
                r *= pos[sp++], --tk;
            else {
                r *= neg[sn++];
                --tk;
                r *= neg[sn++];
                --tk;
            }
        }
    }
    assert(tk <= 1);
    cout << r;
}


Measured memory_bytes: 6932
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        K: i64,
        Q: usize,
        A: [usize; Q]
    }
    let mut point = vec![0; N];
    for a in A{
        point[a-1] += 1;
    }
    for p in point{
        if p+K > Q as i64 {
            println!("Yes");
        }else{
            println!("No");
        }
    }
}


Measured memory_bytes: 6780
#include<stdio.h>
#include<stdlib.h>

int w,h;
int a[20][20];

int curling(int sh,int sw,int d)
{
	int i,c=-1,tmp;
	if(d>10){return -1;}
	else{
		if(sw-1>=0 && a[sh][sw-1]!=1)
			{
				for(i=sw-1;i>=0;i--)
				{
					if(a[sh][i]==1)
						{
							a[sh][i]=0;
							tmp = curling(sh,i+1,d+1);
							if(c < 0 || (c > tmp && tmp > 0))
							{c = tmp;}
							a[sh][i]=1;
							break;
						}
					if(a[sh][i]==3)
						{
						  return d;
						}
				}
			}
	
		if(sw+1>=0 && a[sh][sw+1]!=1)
			{
				for(i=sw+1;i<w;i++)
				{
					if(a[sh][i]==1)
						{
							a[sh][i]=0;
							tmp = curling(sh,i-1,d+1);
							if(c < 0 || (c > tmp && tmp > 0))
							{c = tmp;}
							a[sh][i]=1;
							break;
						}
					if(a[sh][i]==3)
						{
						  return d;
						}
				}
			}

		if(sh-1>=0 && a[sh-1][sw]!=1)
		{
			for(i=sh-1;i>=0;i--)
			{
				if(a[i][sw]==1)
					{
						a[i][sw]=0;
						tmp = curling(i+1,sw,d+1);
						if(c < 0 || (c > tmp && tmp > 0))
						{c = tmp;}
						a[i][sw]=1;
						break;
					}
				if(a[i][sw]==3)
					{
						return d;
					}
			}
		}
		
		if(sh+1>=0 && a[sh+1][sw]!=1)
		{
			for(i=sh+1;i<h;i++)
			{
				if(a[i][sw]==1)
					{
						a[i][sw]=0;
						tmp =  curling(i-1,sw,d+1);
						if(c < 0 || (c > tmp && tmp > 0))
						{c = tmp;}
						a[i][sw]=1;
						break;
					}
				if(a[i][sw]==3)
					{
						return d;
					}
			}
		}
	}
	return c;
}


int main(void)
{
	int i,j;
	int sw,sh,gw,gh;
	
	while(1)
	{
		scanf("%d %d ",&w,&h);
		if(w == 0 && h == 0)break;
		
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				scanf("%d ",&a[i][j]);
				if(a[i][j] == 2){sh=i;sw=j;}
			}
		}
		
		printf("%d\n",curling(sh,sw,1));
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
string s,t,d;
cin>>s>>t;
string c=s;
int l=s.size() ,f=0,p=1;
for(int j=0 ; j<l ; j++){
    for (int i=0 ;i<l;i++){
        d[(i+1)%l]=s[i];
    }
    for(int k=0 ; k<l ; k++){
        if(d[k]!=t[k]){
            f=1;
            break;
        }
    }
    if(f==1){
        for(int a=0 ;a<l;a++){
            s[a]=d[a];
        }
        f=0;
    }
    else{
        p=0;
        break;
    }
}
if( p==0 || c==t  ) cout<<"Yes";
else cout<<"No";
return 0;
}


Measured memory_bytes: 256
MOD = 10**9+7

N,M = gets.split.map &:to_i

fact = [1,1]
fact_inv = [1,1]
2.upto(M) do |i|
    fact[i] = (fact[i-1] * i) % MOD
    inv = i.pow(MOD-2, MOD)
    fact_inv[i] = (fact_inv[i-1] * inv) % MOD
end

ans = fact[M] * fact_inv[M-N] % MOD
ans = (ans * ans) % MOD

1.upto(N) do |i|
    a = fact[M] * fact_inv[M-i] % MOD
    comb = fact[N]*fact_inv[N-i]*fact_inv[i] % MOD
    b = fact[M-i] * fact_inv[M-N] % MOD
    b *= b
    p = (a*comb*b) % MOD
    p *= -1 if i%2==0
    ans -= p
    ans %= MOD
end

p ans

Measured memory_bytes: 22172
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>

using namespace std;



int main(){
    int n,m;
    cin >> n >> m;
    int s[m+10][n+10];// 電球、スイッチ
    int k[m+10];//電球に関係するスイッチ
    for (int i=0;i<m;i++){
        cin >>k[i];
        for (int j=0;j<k[i];j++){
            cin >> s[i][j];
        }
    }
    int p[m+10];//判定
    for (int i=0;i<m;i++){
        cin >>p[i];
    }
    int ans=0;
    for (int i=0;i<pow(2,n);i++){// 全探索開始
        int count1=0;//ついてる電球の数
        for(int j=0;j<m;j++){//j番目の電球ついてる？
            int count=0;//関係するスイッチ何個ついてる？
            for(int l=0;l<k[j];l++){
                int t=pow(2,s[j][l]-1);
                int a=i/t;
                if(a%2==0)count++;
            }
            if(count%2==p[j]) count1++;
        }
        if(count1==m) ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;

int main(void){
    int n, taro = 0, hanako = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        string t, h;
        cin >> t >> h;
        if(t > h) taro += 3;
        else if(t < h) hanako += 3;
        else {taro += 1; hanako += 1;}
    }
    cout << taro << " " << hanako << endl;

    return 0;
}



Measured memory_bytes: 3140
#include <stdio.h>

int main(void)
{
    long int matrixa[100][100], matrixb[100][100], matrixans[100][100];
    int n, m, l;
    int i, j, k;

    scanf("%d%d%d", &n, &m, &l);

    for(i = 0; i < n; i++){
        for(j = 0; j < l; j++){
            matrixans[i][j] = 0;
        }
    }

    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            scanf("%d", &matrixa[i][j]);
        }
    }

    for(i = 0; i < m; i++){
        for(j = 0; j < l; j++){
            scanf("%d", &matrixb[i][j]);
        }
    }

    /*
    putchar('\n');
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            printf("%d ", matrixa[i][j]);
        }
        putchar('\n');
    }

    for(i = 0; i < m; i++){
        for(j = 0; j < l; j++){
            printf("%d ", matrixb[i][j]);
        }
        putchar('\n');
    }
    */

   for(i = 0; i < n; i++){
        for(j = 0; j < l; j++){
            for(k = 0; k < m; k++){
                matrixans[i][j] += (matrixa[i][k] * matrixb[k][j]);
                //printf("%d ", matrixans[i][j]);
            }
            //putchar('\n');
        }
    }
    //putchar('\n');
    for(i = 0; i < n; i++){
        printf("%ld", matrixans[i][0]);
        for(j = 1; j < l; j++){
            printf(" %ld", matrixans[i][j]);
        }
        putchar('\n');
    }
    //putchar('\n');
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll N;
  cin >> N;
  N %= 10;
  vector<ll> hon = {2, 4, 5, 7, 9};
  vector<ll> pon = {0, 1, 6, 8};
  vector<ll> bon = {3};
  for (ll i = 0; i < 5; ++i) {
    if (hon.at(i) == N) {
      cout << "hon" << "\n";
    }
  }
  for (ll i = 0; i < 4; ++i) {
    if (pon.at(i) == N) {
      cout << "pon" << "\n";
    }
  }
  if (N == 3) {
    cout << "bon" << "\n";
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <iostream>

using namespace std;

#define fo(i,n) for(int i=0; i<n; i++)
#define Fo(i,k,n) for(int i=k; i<n; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

int N;
vvi a;
const int mod = 1e9+7;
vl dp;

void add_self(ll &a, int b){
    a += b;
    if(a>=mod)a-=mod;
}

int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    cin>>N;
    a.resize(N, vi(N));
    fo(i,N)
        fo(j,N)
            cin>>a[i][j];
    dp.resize(1<<N);
    dp[0]=1;
    for(int mask=0; mask<(1<<N)-1; mask++){
        int man = __builtin_popcount(mask);
        for(int woman = 0; woman<N; woman++){
            if(a[man][woman] && !(mask&(1<<woman))){
                int mask2 = mask|(1<<woman);
                add_self(dp[mask2], dp[mask]);
                // bitset<10>m(mask), m2(mask2);
                // cout<<m<<" "<<m2<<" "<<dp[mask2]<<" "<<dp[mask]<<endl;
            }
        }
    }
    cout<<dp[(1<<N)-1]<<endl;
    
    return 0;
}

Measured memory_bytes: 16640
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
    int a,b,k;
    cin>>k;
    cin>>a>>b;
    int i;
    int j=0;
    for(i=a;i<=b;i++)
    {
    if(i%k==0)
    {
    j++;
    break;
    }
    }
    if(j)
    cout<<"OK"<<endl;
    else
    cout<<"NG"<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int k;
vi a,b;

int dis(int x,int y){
	return abs(x)+abs(y);
}

void f(int x,int y){
	a.push_back(x);
	b.push_back(y);
	int d=dis(x,y);
	if(d==k) return;
	if(d<=2*k&&!(k%2==1&&d%2==1)){
		for(int j=0;j<4;j++) for(int i=0;i<=k;i++){
			int X=x+(j/2==1?i:-i),Y=y+(j%2==1?k-i:i-k),d=dis(X,Y);
			if(d==k){
				f(X,Y);
				return;
			}
			i+=max(0,abs(d-k)/2-2);
		}
	}
	pip p={inf,{0,0}};
	for(int i=0;i<4;i++){
		int X=x+dx[i]*k,Y=y+dy[i]*k;
		p=min(p,{dis(X,Y),{X,Y}});
	}
	P q=p.second;
	f(q.first,q.second);
}

int main(){
	int x,y;
	cin>>k>>x>>y;
	int d=dis(x,y);
	if(k%2==0&&d%2==1){
		cout<<-1<<endl;
		return 0;
	}f(x,y);
	int n=a.size();
	cout<<n<<endl;
	for(int i=n-1;i>=0;i--) cout<<a[i]<<' '<<b[i]<<endl;
}

Measured memory_bytes: 19692
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    cout << "2018/01/";
    cout << s[8] << s[9];
}


Measured memory_bytes: 3648
N = int(input())
List = list(map(int,input().split()))

aa = 0

for i in range(1,len(List)):
  a = List[i]
  aa = aa ^ a
  

bb = List[0]
arr = [aa]
for i in range(1,len(List)):
  a = List[i]
  b = bb ^ a
  c = b ^ aa
  arr.append(c)
  
print(*arr)

Measured memory_bytes: 31452
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<iostream>
#define M 100005
using namespace std;
template <class T>
inline void Rd(T &res){
	char c;res=0;int k=1;
	while(c=getchar(),c<48&&c!='-');
	if(c=='-'){k=-1;c='0';}
	do{
		res=(res<<3)+(res<<1)+(c^48);
	}while(c=getchar(),c>=48);
	res*=k;
}
template <class T>
inline void Pt(T res){
	if(res<0){
		putchar('-');
		res=-res;
	}
	if(res>=10)Pt(res/10);
	putchar(res%10+48);
}
vector<int>edge[M];
int Get_sg(int x,int pre){
	int res=0;
	for(int i=0;i<edge[x].size();i++)
		if(edge[x][i]!=pre)res^=(Get_sg(edge[x][i],x)+1);
	return res;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	if(Get_sg(1,-1))puts("Alice");
	else puts("Bob");  
	return 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <math.h>
using namespace std;
 
void Factorization(int v){
    int k = 2;
    while (v != 1 && k <= sqrt((double) v)){
        if (v % k == 0){
            v = v / k;
            cout<<" "<<k;
            k = 2;
        }
        else
            k++;
    }
    if(v == 1) return;
    cout<<" "<<v;
}
 
int main(){
    int n;
    cin>>n;
    cout<<n<<":";
    Factorization(n);
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3096
input_int = lambda:int(input())
input_ints = lambda:map(int,input().split())
input_ints_list = lambda:list(input_ints())
input_str = lambda:input()
input_strs = lambda:input().split()
input_lines = lambda n,f:[f() for _ in range(n)]

import functools,fractions
import numpy as np
gcd = lambda a:functools.reduce(fractions.gcd,a) # 最大公約数（リスト）
lcm_base = lambda a,b:(a*b)//fractions.gcd(a,b) # 最小公倍数(2値)
lcm = lambda a:functools.reduce(lcm_base,a,1) # 最小公倍数(リスト)

init_dp = lambda v,n:[v]*(n)

import math
# 四捨五入はround
ceil = lambda a:math.ceil(a) # 切り上げ
floor = lambda a:math.floor(a) # 切り捨て

def solution():
    N,M = input_ints()
    As = input_ints_list()
    w = [0,2,5,5,4,5,6,3,7,6]

    dp = init_dp(-1,N+1)
    dp[0] = 0
    for i in range(N+1):
        for v in As:
            if i+w[v] < N+1:
                dp[i+w[v]] = max(dp[i+w[v]],dp[i]*10+v)
    print(dp[N])
    
if __name__ == '__main__':
    solution()

Measured memory_bytes: 24636
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<queue>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,n) for(int i=1;i<=n;i++)

int canmake[1100000];
int sosu[1100000];

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		
		if(n==0 && m==0)break;
		
		rep(i,1100000)canmake[i]=sosu[i]=0;
		
		
		sosu[0]=sosu[1]=1;
		for(int i=2;i<=1000000;i++){
			if(sosu[i]==1)continue;
			for(int j=i*2;j<1000000;j+=i){
				sosu[j]=1;
			}
		}
		
		
		canmake[0]=1;
		
		int sina[100];
		rep(i,n)cin>>sina[i];
		for(int i=0;i<1000000;i++){
			if(canmake[i]==0)continue;
			rep(j,n){
				if(i+sina[j]<=1000000){
					canmake[i+sina[j]]=1;
				}
			}
		}
		
		
		int ans=-1;
		for(int i=m;i>=0;i--){
			if(sosu[i] == 0 && canmake[i]==1){
				ans =i;
				break;
			}
		}
		
		
		if(ans==-1){
			puts("NA");
		}else{
			printf("%d\n",ans);
		}
	}
}

Measured memory_bytes: 9464
#include <stdio.h>

int main(void){	
	int i, j, k, n, x, c;
	while(1){
		c = 0;
		scanf("%d %d", &n, &x);
		if(n == 0 && x == 0){
			break;
		}
		for(i = 1; i <= n; i++){
			for(j = i + 1; j <= n; j++){
				for(k = j + 1; k <= n; k++){
					if(i + j + k == x){
						c++;
					}
				}
			}
		}
		printf("%d\n", c);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll a,b;
  cin >> a >> b;
  if(a<=5) pr(0);
  else if(a<=12) pr(b/2);
  else pr(b);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i=0; i<n; ++i) cin >> a.at(i);

    int cnt = 0;
    vector<int> imos(n+1);
    for (int i=0; i<k && cnt < n; ++i) {
        cnt = 0;
        imos.assign(n+1, 0);
        for (int j=0; j<n; ++j) {
            ++imos.at(max(0, j-a.at(j)));
            --imos.at(min(n, j+a.at(j)+1));
        }
        for (int j=1; j<n+1; ++j) imos.at(j) += imos.at(j-1);
        for (int j=0; j<n; ++j) {
            a.at(j) = imos.at(j);
            if (a.at(j) == n) ++cnt;
        }
    }
    for (int i=0; i<n; ++i) {
        cout << a.at(i);
        if (i == n-1) cout << '\n';
        else cout << ' ';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 4784
//srinivas
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
// using namespace __gnu_pbds;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define fr(x,in,n,r) for(x=in;x<n;x+=r)
#define ifr(x,n) for(x=0;x<n;x++)
#define dfr(x,n) for(x=n-1;x>=0;x--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pof(a) pop_front(a)
#define pob(a) pop_back(a)
#define eb(a) emplace_back(a)
#define ef(a) emplace_front(a)
typedef long long ll;
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    ll n,a,b,m,l,r,i;
	cin>>n>>m;
	ifr(i,m){
		cin>>a>>b;
		if(i==0)l=a,r=b;
		else{
			l=max(l,a);
			r=min(r,b);
		}
	}
	cout<<max(0ll,r-l+1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stdio.h>
using namespace std;
int main(){
  int n,last,tail;
  cin>>n;
  vector<int> a(n,0);
  for(int i=0;i<n;i++)
    cin>>a[i];
  vector<vector<int> > next_table(20,vector<int>(n+1,n));
  for(int s=0;s<20;s++){
    last=n;
    for(int i=n-1;i>=0;i--){
      next_table[s][i]=last;
      if(a[i] & (1<<s))
        last=i;
      }}
  /*for(int s=0;s<20;s++){
      for(int i=0;i<n;i++)
        cout<<next_table[s][i]<<" ";
      cout<<endl;}
    cout<<endl;*/
    long long res=0;
    for(int i=0;i<n;i++){
      tail=n;
      //cout<<"i="<<i<<endl;
      for(int s=0;s<20;s++){
        if(a[i] & (1<<s))
          tail=min(tail,next_table[s][i]);
        else
          tail=min(tail,next_table[s][next_table[s][i]]);}
        //cout<<"s="<<s<<"    "<<"tail="<<tail<<endl;}
      res+= tail-i; } 
      //cout<<"res="<<res<<endl<<endl;}  
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 17536
/*****************************************************************\
    |     IN THE NAME OF ALLAH, MOST GRACIOUS AND MOST MERCIFUL       |
    |                                                                 |
    |     Author     : Mahabub Rahman                                 |
    |     Email      : mahabubrahman618@gmail.com                     |
    |     University : Comilla University, Bangladesh		          |
    |                  Department of Computer Science & Engineering   |
    \*****************************************************************/


    /*...................................Data_Types............................................*/
    #include<bits/stdc++.h>

    using namespace std;
    #define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
    #define       ll                  long long int
    #define       ull                  unsigned long long int
    #define       veci                 vector<int>
    #define       vecc                 vector<char>
    #define       vecs                 vector<string>
    #define       vecl                 vector<long long int>
    #define       vecp                 vector<  pair<int,int> >
    #define       mapstrint            map< string , int >
    #define       mapstrstr            map< string , string >
    #define       mapint               map< int, int >
    #define       pb                   push_back
    #define       pob                  pop_back
    #define       mp                   make_pair
    ////============ CONSTANT ===============////
    #define mx9   1000000007
    #define mx7   10000007
    #define mx6   1000006
    #define mx5   200005
    #define inf   1<<30                                           //infinity value
    #define eps   1e-9
    #define pai   pair<int, int>
    #define pac   pair<char, int>

    #define mod   1000000007
    ////=====================================////

    long double PI = acosl(-1);
    bool compare_int(int a, int b) //This function is use for descending order.
    {
        return (a>b);
    }
    bool compare_string (string a, string b)
    {
        return a.size() < b.size();
    }
    bool compare_pair(const pair<int,int> &a,
                  const pair<int,int> &b)
    {
        if(a.second==b.second) return a.first>b.first;
        else return (a.second > b.second);
    }
    /*ll fact(ll n)
    {
        if(n==0 || n==1) return 1;
        else return n*fact(n-1);
    }*/

    ////======================================////
    /*bool check(int n)
    {
        for(int i=2; i<=sqrt(n); i++)
        {
            if(n%i==0)
            {
                return false;
            }
        }
        return true;
    }*/
    int32_t main()
    {
        FastIO;
        ll n, tot=0;

        cin >> n;
        for(int i=1; i<=n; i++)
        {
            if(i%3!=0 and i%5!=0) tot+=i;
        }
        cout << tot << endl;
    }


Measured memory_bytes: 3640