akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A;
string S, T;

void input() {
  cin >> N;
  A.resize(N);
  rep(i, 0, N - 1) { cin >> A[i]; }
}

deque<int> B;
void solve() {
  //愚直にやってみる
  // for (auto x : A) {
  //   B.push_back(x);
  //   reverse(all(B));
  // }
  // for (auto x : B) {
  //   cout << x << " ";
  // }
  // cout << endl;

  // N%2で場合分け
  rep(i, 0, N - 1) {
    if (i % 2) {
      B.push_back(A[i]);
    } else
      B.push_front(A[i]);
  }

  if (N % 2 == 0) reverse(all(B));
  for (auto x : B) {
    cout << x << " ";
  }
  cout << endl;

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
int main()
{
	int n, k;
	char s[10] = { 0 };
	cin >> n >> s >> k;
	for (int i = 0; i < n; i++) {
		if (s[i] == s[k - 1]) {

		}
		else { s[i] = '*'; }
	}
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
using namespace std;

int INF=1e9;

int main(){  
    int N; cin>>N;
    vector<int>W(N);
    int S1=0,S2=0;
    for(int i=0;i<N;i++){
        cin>>W[i];
    }
    int sum=0,ans=INF;
    for(int i=0;i<N;i++){
        sum+=W[i];
    }
    int SUB;
    for(int T=0;T<N-1;T++){
        S1=0,S2=0;
        for(int i=0;i<=T;i++){
            S1+=W[i];
            S2=sum-S1;
        }
        SUB=abs(S2-S1);
        ans=min(SUB,ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
using namespace std;
int main() {
    int n;
    while(scanf("%d",&n)!=EOF){
        if(n<1200) printf("ABC\n");
        else printf("ARC\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


int main(){

  int N; cin >> N;
  vector < pair<int, int> > graph[N];
  vector < pair< pair<int, int>, int> > edge(N + 1);
  for (int i = 0; i < N - 1; i++){
    int A, B; cin >> A >> B;
    A--; B--;
    graph[A].push_back(make_pair(B, i));
    graph[B].push_back(make_pair(A, i));
  }
  
  int K = 0, start = 0;
  for (int i = 0; i < N; i++){
    if (graph[i].size() > K){
      K = graph[i].size();
      start = i; 
    }
  }
  
  cout << K << endl;

  vector <int> have[N];

  vector <int> ans(N);
  queue <int> que;
  vector <bool> visited(N); visited[start] = true;
  for (int i = 0; i < graph[start].size(); i++){
    int now = graph[start][i].second;
    have[start].push_back(i + 1);
    ans[now] = i + 1;
    que.push(graph[start][i].first);
    visited[graph[start][i].first] = true;
    have[graph[start][i].first].push_back(i + 1);
  }
  
  while (!que.empty()){
    int Q = que.front(); que.pop();

    for (int i = 0; i < graph[Q].size(); i++){
      int next_node = graph[Q][i].first;

      if (visited[next_node] == false){
        visited[next_node] = true;
        que.push(next_node);
      }

      int next_edge = graph[Q][i].second;
      if (ans[next_edge] == 0){
        
        vector <bool> checked(K + 1);
        for (int j = 0; j < have[Q].size(); j++){
          checked[have[Q][j]] = true;
        }
        
        int cnt = 0;
        for (int j = 1; j < K + 1; j++){
          if (checked[j] == false){
            cnt = j; break;
          }
        }
        ans[next_edge] = cnt;
        have[Q].push_back(cnt);
        have[next_node].push_back(cnt);
      }
      
    }
    
  }
  


  for (int i = 0; i < N - 1; i++){
    cout << ans[i] << endl;
  }
  
  


  return 0;
}


Measured memory_bytes: 13696
#include <stdio.h>
int main(void){
    
   int i,j,H,W;
   
   while(H!=0 || W!=0){
    
   scanf("%d %d",&H,&W);
   
   for ( i = 0; i < H; i++ ){
    for ( j = 0; j < W; j++ ){
        printf("#");
    }
    printf("\n");
}
    if (H!=0 || W!=0)
    printf("\n");
   }
   return 0;

   }
   


Measured memory_bytes: 2104
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////
const ll M = 998244353;
ll add(ll x, ll y) {return (x+y) % M;}
ll sub(ll x, ll y) {return (x-y+M) % M;}
ll mult(ll x, ll y) {return (x*y) % M;}

// Finds constants {u, v} s.t. a*u+b*v = g for g = gcd(a, b)
// Call with egcd(a, b)
pll egcd(ll a, ll b, pll x = {1, 0}, pll y = {0, 1}) {
	return (b == 0) ? x : egcd(b, a % b, y, {x.first - a/b * y.first, x.second - a/b * y.second});
}

// Finds x s.t. (a*x) % n == 1
// Assumes a is not zero divisor (i.e. gcd(a, n) == 1)
ll modInv(ll a, ll n) {
	return ((egcd(a, n).first % n) + n) % n;
}

const ll N = 3e5+1;
ll n, a, b, k, ans, Ncr[N];


void addpair(ll x, ll y) {
	ans = add(ans, mult(Ncr[x], Ncr[y]));
}

int main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    cin >> n >> a >> b >> k;
    Ncr[0] = 1;
    FOR(i, 1, n) {
    	Ncr[i] = mult(Ncr[i-1], n+1-i);
    	// DEBUG(i);
    	// DEBUG(modInv(i, M));
    	Ncr[i] = mult(Ncr[i], modInv(i, M));
    }
    // FOR(i, 0, n) cout << Ncr[i] << ' ';
    // cout << endl;
    FOR(i, 0, n) {
    	ll j = (k-a*i)/b;
    	// DEBUG(i);
    	// DEBUG(j);
    	if(j >= 0 && j <= n && a*i+b*j == k) addpair(i, j);
    	// DEBUG(ans);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC059A___Three_letter_acronym
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            string result = "";

            foreach (string sentence in input)
            {
                result += sentence.ToUpper().First();
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<vector>
//#include<algorithm>
//#include<string>
//#include<queue>
//#include<set>
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef double db;
const int MOD = 1e9 + 7;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	vector<ll> G(n, 0);
	for (int i = 0; i < n - 1; ++i)
	{
		int x, y;
		cin >> x >> y;
		--x, --y;
		if (x > y)
			swap(x, y);
		G[y] += x + 1;
	}
	ll ans = 0, cur = 0;
	for (int i = 0; i < n; ++i)
	{
		cur += i + 1 - G[i];
		ans += cur;
	}
	cout << ans;
	return 0;
}

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

int main(void){
  while(1){
    int x,y;
    int s;
    cin >> x;
    cin >> y;
    cin >> s;

    if(x == 0 && y == 0 && s == 0){return 0;}

    int max = -1;
    for(int i = 1 ; i < s ; i++){
      for(int j = 1 ; j < s ; j++){
          if( i * (100 + x) / 100 + j * (100 + x) / 100 == s){
            int temp = i * (100 + y) / 100 + j * (100 + y) / 100;
            if(max < temp){max = temp;}
          }
      }
    }

    cout << max << "\n";
  }

}

Measured memory_bytes: 2980
#include<iostream>
#include<cstring>
#include<math.h>
#include<stdlib.h>
#include<cstring>
#include<cstdio>
#include<utility>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
const int Max = 1e5+5;
const int mod = 1e9+7;
const int Hash = 10000;
const int INF = 1<<30;
const ll llINF = 1e18;

int n, m;
ll arr[Max];
void init( )
{
    arr[0] = 1;
    for(int i=1; i<1e5+1; i++)
        arr[i] = (arr[i-1]*i)%mod;
}
int main( )
{
    //freopen("input.txt", "r", stdin);
    init( );//预处理
    while(~scanf("%d%d", &n,&m))
    {
        if(abs(m-n) > 1)
            cout<<0<<endl;
        else if(abs(m-n) == 1)
        {
            int ans = (arr[m]*arr[n])%mod;
            cout<<ans<<endl;
        }
        else
        {
            int ans = (arr[m]*arr[n])%mod;
            ans = (ans*2)%mod;
            cout<<ans<<endl;
        }
    }
    return 0;
}


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V
const double PI=3.14159265358979323846;

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

ll gcd(ll a, ll b){
    ll tmp;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }

    ll r = a%b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int main() {
    int n;
    cin >> n;
    vector<ll> t(n);
    REP(i, n) cin >> t[i];
    ll ans = t[0];

    REPN(i, 1, n) {
        ll ab = gcd(ans, t[i]);
        ans = ans /ab * t[i];
    }

    cout << ans << endl;

    return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int h[100000],maxn=-1e9,ans,k;
int main() {
	cin>>s;
	for(int i=0; i<s.size(); i++) {
		if(h[i]==0) {
			ans=0;
			k=i;
			while(k<=s.size()-1) {
				if(s[k]=='A'||s[k]=='T'||s[k]=='C'||s[k]=='G') {
					h[k]=1;
					ans++;
					k++;
				}
				else break;
			}
			if(ans>maxn) maxn=ans;
		}
	}
	cout<<maxn;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

//AtCoder Beginner Contest 157
//C	Guess The Number
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		int ans = -1;
		if (M == 0) {
			sc.close();
			if (N == 1) ans = 0;
			else if (N == 2) ans = 10;
			else ans = 100;
			System.out.println(ans);
		} else {
			Map<Integer,Integer> m = new HashMap<>();
			for (int i = 0; i < M; i++) {
				Integer s = Integer.valueOf(sc.next());
				if (m.containsKey(s)) {
					Integer c = Integer.valueOf(sc.next());
					if (!m.get(s).equals(c)) {
						sc.close();
						System.out.println(ans);
						return;
					}
				} else {
					Integer c = Integer.valueOf(sc.next());
					if ((N == 3 || N == 2) && s == 1 && c == 0) {
						sc.close();
						System.out.println(ans);
						return;
					}
					m.put(s, c);
				}
			}
			sc.close();

			int[] aaa = new int[N];
			for (Entry<Integer, Integer> e : m.entrySet()) {
				aaa[e.getKey()-1] = e.getValue();
			}
			if (N == 3) {
				if (aaa[0] == 0) {
					aaa[0] = 1;
				}
				System.out.print(aaa[0]);
				System.out.print(aaa[1]);
				System.out.print(aaa[2]);
			} else if (N == 2) {
				if (aaa[0] == 0) {
					aaa[0] = 1;
				}
				System.out.print(aaa[0]);
				System.out.print(aaa[1]);
			} else {
				System.out.print(aaa[0]);
			}
		}
	}
}


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

int main(){
   int a,b,c;
   cin >> a >> b >> c;
   if(a < b && b < c){
      cout << "Yes" << endl;
   }
   if(a > b && b > c ){
      cout << "No" << endl;
   }
   if(a > b && b < c ){
      cout << "No" << endl;
   }
   if(a < b && b > c ){
      cout << "No" << endl;
   }
   if(a == b && b == c ){
      cout << "No" << endl;
   }
   if(a == b && b > c ){
      cout << "No" << endl;
   }
   if(a == b && b < c ){
      cout << "No" << endl;
   }
   if(a < b && b == c ){
      cout << "No" << endl;
   }
   if(a > b && b == c ){
      cout << "No" << endl;
   }
   return 0;
}

Measured memory_bytes: 1160
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<vector>

using namespace std;

int main() {

	string N;
	int red_num = 0;
	int blue_num = 0;
	cin >> N;

	int removed = 0;
	for (auto i = 0; i < N.length(); i++) {
		if (N[i] == '0') {
			red_num += 1;
		}
		else {
			blue_num += 1;
		}

		removed = N.length() - abs(red_num - blue_num);

	}
	cout << removed << endl;


	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
typedef long long i64;

#define MAX_SIZE 100
int W, H, N;
int rectangle[MAX_SIZE + 10][MAX_SIZE + 10];
int x[MAX_SIZE + 10], y[MAX_SIZE + 10], a[MAX_SIZE + 10];

void Solve()
{
  for (int i = 0; i < N; ++i){
    switch(a[i]){
      int ix, iy;
      case 1:
        for (iy = 0; iy < H; ++iy)
          for (ix = 0; ix < x[i]; ++ix)
            rectangle[ix][iy] = 1;
        break;
      case 2:
        for (iy = 0; iy < H; ++iy)
          for (ix = x[i]; ix < W; ++ix)
            rectangle[ix][iy] = 1;
        break;
      case 3:
        for (ix = 0; ix < W; ++ix)
          for (iy = 0; iy < y[i]; ++iy)
            rectangle[ix][iy] = 1;
        break;
      case 4:
        for (ix = 0; ix < W; ++ix)
          for (iy = y[i]; iy < H; ++iy)
            rectangle[ix][iy] = 1;
        break;
    }
/*
      for (int jy = H - 1; jy >= 0; --jy){
      cout << "[";
      for (int jx = 0; jx < W; ++jx)
        cout << rectangle[jx][jy] << " ";
      cout << "]" << endl;
    }
    cout << endl;
*/
  }
  int ans = 0;
  for (int jy = H - 1; jy >= 0; --jy)
    for (int jx = 0; jx < W; ++jx)
      if (!rectangle[jx][jy])
        ++ans;
  cout << ans << endl;
}

void Init()
{
  cin >> W >> H >> N;
  for (int iy = 0; iy < H; ++iy)
    for (int ix = 0; ix < W; ++ix)
      rectangle[ix][iy] = 0;
  for (int i = 0; i < N; ++i)
    cin >> x[i] >> y[i] >> a[i];
}

void Clean(){}

int main(){ Init(); Solve(); Clean(); return 0; }


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var S = Console.ReadLine();

            var l = 0;
            var r = S.Length - 1;
            var hugCount = 0;
            for (int index = 0; index < S.Length / 2; index++)
            {
                if (S[l + index] != S[r - index])
                {
                    hugCount++;
                }
            }


            Console.WriteLine(hugCount);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
    int n,m;
    cin>>n>>m;
    int ax[50],ay[50];
    for(int i=0;i<n;i++){
        cin>>ax[i]>>ay[i];
    }
    int tx[50],ty[50];
    for(int i=0;i<m;i++){
        cin>>tx[i]>>ty[i];
    }
    for(int i=0;i<n;i++){
        ll c=400000000;
        int ans=0;
        for(int j=0;j<m;j++){
            if(c>abs(ax[i]-tx[j])+abs(ay[i]-ty[j])){
                c=abs(ax[i]-tx[j])+abs(ay[i]-ty[j]);
                ans=j+1;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}




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

int main(){
    ll n,x[101],sum=0,min=mod;
    cin>>n;
    rep(i,n){
        cin>>x[i];
    }
    rep(i,100){
        sum=0;
        rep(j,n){
            sum+=(x[j]-i)*(x[j]-i);
        }
        if(min>sum){min=sum;}
    }
    cout<<min;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


int N, K, Q;
int A[100000];
int point[100000];

signed main(){
    cin >> N >> K >> Q;
    REP(i, N) point[i] = K - Q;
    REP(i, Q){
        cin >> A[i];
        point[A[i] - 1]++;
    }
    REP(i, N){
        if(point[i] > 0) PRINT("Yes");
        else PRINT("No");
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    sort(ALL(A));
    vector<ll> cum(N);
    cum[0] = A[0];
    for (int i = 1; i < N; i++) cum[i] = A[i] + cum[i-1];
    int ans = 1;
    for (int i = N - 2; i >= 0; i--) {
        if (cum[i] * 2 < A[i+1]) break;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<4;i++){
		cout<<s[i];
	}
	cout<<" ";
	for(int i=4;i<s.size();i++){
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}

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

int main(){
    int N;
    cin>>N;
    pair<double,string> x[10];
    for(int i=0;i<N;i++){
        double t;
        string in;
        cin>>t>>in;
        x[i]=make_pair(t,in);
    }

    double sum=0;
    for(int i=0;i<N;i++){
        if(x[i].second=="JPY") sum+=x[i].first;
        else sum+=x[i].first*380000;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
int main() {
    ll n , a , b , c , d;
    cin >> n >> a >> b >> c >> d;
    ll gg = a - b;
    int flag = 0;
    for(ll i = 0 ; i < n ; i++) {
        ll x = i , y = n - i - 1;
        ll Min = x * c - y * d;
        ll Max = x * d - y * c;
        if(gg <= Max && gg >= Min) {
            flag = 1;
            break;
        }
    }
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  const n = parseInt(input[0],10);
  var a_n = input[1].split(" ");;
  let ans = 0;
  let a_i = 0;
  let end = 0;
  while (end === 0) {
    let a = parseInt(a_n[a_i],10)
    if (a % 2 === 0) {
      a /= 2;
    } else {
      end = 1;
    }
    a_n[a_i] = a;
    a_i++;
    if(a_i === n){
      a_i = 0;
      ans++;
    }
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29548
from collections import defaultdict

N, K = map(int, input().split())

A = list(map(int, input().split()))

visited = [0] * N

current = 0
i = 1
while i <= K:
    current = A[current] - 1
    if visited[current] == 0:
        visited[current] = i
    else:
        loop = i - visited[current]
        num_loop = (K - i) // loop
        i += loop * num_loop

    i += 1

ans = current + 1
print(ans)

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int a;
  cin >> a;

  cout << a + powl(a, 2) + powl(a, 3) << '\n';
  return 0;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007

ll findpow(ll a,ll b){
    ll cnt=0,i,j;
    while(a>1){
        a=a/b;
        cnt++;
    }
    return cnt;
}

int main(){
    ll i,j,k,sum=0,n;
  cin>>i>>j>>n;
  cout<<(i+j)*(n/2)<<endl;
    
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  char a, b;
  cin >> a >> b;

  if (a == 'H' && b == 'H')
    cout << 'H' << endl;
  else if (a == 'H' && b == 'D')
    cout << 'D' << endl;
  else if (a == 'D' && b == 'H')
    cout << 'D' << endl;
  else // (a == 'D' && b == 'D')
    cout << 'H' << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#define REP(i,n) for(int i = 0; i < (n); i++)
#define REPC(x,c) for(auto x:(c))
#define FOR(i, b, e) for(int i = (b); i < (e); i++)
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>

using namespace std;

int main() {
	string str;
	int k;
	cin >> str >> k;


	VS list;
	char ch = 'a';

	while (true) {
		REP(c, str.size()) {
			if (str[c] == ch) {
				FOR(i, 1, k + 1) {
					list.push_back(str.substr(c, i));
				}
			}
		}

		sort(list.begin(), list.end());
		list.erase(unique(list.begin(), list.end()), list.end());

		if (list.size() >= k) {
			break;
		}
		ch++;
	}

	cout << list[k-1] << endl;


}

Measured memory_bytes: 1660
#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<cassert>
#include<algorithm>
#include<numeric>
#include<vector>
#include<string>
#include<map>
#include<unordered_map>
#include<queue>
#include<tuple>
using namespace std;
typedef long long int lnt;
typedef unsigned long long int unt;
typedef unsigned ust;
typedef double dou;
typedef pair<int,int> P;
#define FZ(i,n)       for(int i=0;i<(n);++i)
#define FB(i,n)       for(int i=(n)-1;i>=0;--i)
#define FV(i,st,ed)   for(int i{st};i<(ed);++i)
#define FC(i,n)       for(int i{n};i;--i)
#define FZU(i,n)      for(ust i{0};i!=(n);++i)
#define FVU(i,st,ed)  for(ust i{st};i<(ed);++i)
#define FCU(i,n)      for(ust i{n};i;--i)
#define SZ(x)         ((int)x.size())
#define ALL(x)        std::begin(x),std::end(x)
#define likely(x)     __builtin_expect(!!(x), 1)
#define unlikely(x)   __builtin_expect(!!(x), 0)

#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d %d",&(x),&(y))
#define RS(x) scanf("%s",x)
#define RI64(x) scanf("%I64d",&(x))
#define RII64(x,y) scanf("%I64d%I64d",&(x),&(y))

#define FIR first
#define SEC second
#define pritnf printf
constexpr ust N = 100514u;
char s[N];
void sol(){
    int k;RI(k);
    for(int i=0;s[i];i++){
        if(s[i]!='a'&&k>=('z'+1-s[i])){
            k-=('z'+1-s[i]);
            s[i] = 'a';
        }
    }
    auto l=strlen(s)-1;
    k%=26;
    for(;k;--k){
        if(++s[l]=='z'+1)s[l]='a';
    }
    puts(s);
}
int main(){
	while(RS(s)!=EOF)sol();
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
const int MOD = 1000000007;
int main(){
	int N,M,S[2000],T[2000];
	int dp[2000][2000]={0};
	cin>>N>>M;
	for(int i=0;i<N;i++)cin>>S[i];
	for(int i=0;i<M;i++)cin>>T[i];
	dp[0][0]=S[0]==T[0];
	for(int i=1;i<N;i++)dp[i][0]=dp[i-1][0]+(S[i]==T[0]);
	for(int i=1;i<M;i++)dp[0][i]=dp[0][i-1]+(S[0]==T[i]);
	for(int i=1;i<N;i++)dp[i][0]=dp[i-1][0]+(S[i]==T[0]);
	for(int i=1;i<M;i++)dp[0][i]=dp[0][i-1]+(S[0]==T[i]);
	for(int i=1;i<N;i++)for(int j=1;j<M;j++){
		if(S[i]==T[j])dp[i][j]=dp[i][j-1]+dp[i-1][j]+1;
		else dp[i][j]=dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1];
		dp[i][j]=(dp[i][j]%MOD+MOD)%MOD;
	}
	cout<<dp[N-1][M-1]+1;
	return 0;
}


Measured memory_bytes: 15872
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

int main () {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    /*int mx = *max_element(all(a));
    if (a[0] == mx) {
        cout << 1000 << endl;
        return 0;
    }*/
    vector<int> buy, sell;
    if (a[0] <= a[1]) buy.push_back(0);
    rep(i, n-2) {
        if (a[i] > a[i+1] && a[i+1] <= a[i+2]) buy.push_back(i+1);
        if (a[i] <= a[i+1] && a[i+1] > a[i+2]) sell.push_back(i+1);
    }
    if (a[n-2] <= a[n-1]) sell.push_back(n-1);
    int l = min(buy.size(), sell.size());
    /*
    cout << "buy:";
    rep(i, buy.size()) printf("%d ", buy[i] + 1);
    cout << endl <<  "sell:";
    rep(i, sell.size()) printf("%d ", sell[i] + 1);
    cout << endl;
    */

    ll m = 1000;
    ll stock = 0;
    rep(i, l) {
        stock = m / a[buy[i]];
        m -= stock * a[buy[i]];
        //cout << m << endl;
        m += stock * a[sell[i]];
        stock = 0;
        //cout << m << endl;
    }
    cout << m << endl;

    return 0;
}

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

using namespace std;

int main() {
    int N;

    cin>>N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin>>A[i];
    }

    sort(A.begin(), A.end());

    printf("%d\n", A[N - 1] - A[0]);

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC117B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt;
            var L = ReadInts;
            int sum = L.Sum();
            if (L.Max() < L.Sum() - L.Max()) Console.WriteLine("Yes");
            else Console.WriteLine("No");


        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13396
while 1:
    try:
        s = raw_input()
        a = b = 0
        for i in xrange(len(s)-2):
            if s[i:i+3]=="JOI": a+=1
            if s[i:i+3]=="IOI": b+=1
        print "%d\n%d"%(a,b)
    except EOFError:
        break

Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#define YesNo(c) ((c) ? "Yes" : "No")
#ifdef LOCAL
#define dump(x) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] " << #x " = " << (x) << endl;
#else
#define dump(x)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.fst << ", " << p.snd << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.fst >> p.snd; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
////////////////////////////////

int n;
string s;

int32_t main() {
    cin >> n >> s;
    int sum = 0;
    rep (k,1<<n) {
        string a,b;
        rep (i,n) (k&(1<<i) ? a : b).push_back(s[n+i]);
        reverse(all(a)); reverse(all(b));
    
        int dp[20][20] = {}; // dp[i+1][j+1] : a[0..i], b[0..j]
        if (!a.empty() && a[0] == s[0]) dp[1][0] = 1;
        if (!b.empty() && b[0] == s[0]) dp[0][1] = 1;
        rep (i,a.size()) if (a[i] == s[i]) dp[i+1][0] += dp[i][0];
        rep (j,b.size()) if (b[j] == s[j]) dp[0][j+1] += dp[0][j];
        rep (i,a.size()) rep (j,b.size()) {
            if (a[i] == s[(i+1)+(j+1)-1]) dp[i+1][j+1] += dp[i][j+1];
            if (b[j] == s[(i+1)+(j+1)-1]) dp[i+1][j+1] += dp[i+1][j];
        }
        sum += dp[a.size()][b.size()];
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
use std::cmp::max;
use std::io;
fn main() {
    let mut buft = String::new();
    io::stdin().read_line(&mut buft).unwrap();
    let n: i64 = buft.trim().parse().unwrap();
    buft.clear();
    let mut ans : i64 = 0;
    // ans += 1;
    ans += (1 + n-1) * (n-1) / 2;
    println!("{}", ans);
}


Measured memory_bytes: 4352
from sys import stdin
input = stdin.readline

from collections import deque

X = int(input())
s = {}
q = deque()
q.append((1, 0))
done = {(1, 0)}

while True:
	ab = q.popleft()
	tx = ab[0] ** 5 - ab[1] ** 5
	#print(ab)
	if (tx == X):
		print(ab[0], ab[1])
		quit()
	elif (tx > X):
		if ((ab[0] - 1, ab[1]) not in done):
			q.append((ab[0] - 1, ab[1]))
			done.add((ab[0] - 1, ab[1]))
		if (ab[1] > 0 or (ab[0], ab[1] + 1) not in done):
			q.append((ab[0], ab[1] + 1))
			done.add((ab[0], ab[1] + 1))
		if (ab[1] <= 0 or (ab[0], ab[1] - 1) not in done):
			q.append((ab[0], ab[1] - 1))
			done.add((ab[0], ab[1] - 1))
	else:
		if ((ab[0] + 1, ab[1]) not in done):
			q.append((ab[0] + 1, ab[1]))
			done.add((ab[0] + 1, ab[1]))
		if (ab[1] <= 0 or (ab[0], ab[1] - 1) not in done):
			q.append((ab[0], ab[1] - 1))
			done.add((ab[0], ab[1] - 1))


Measured memory_bytes: 13796
N = int(input())
A = sorted(list(map(int,input().split())))
B = []


mod = 10**9+7
if N % 2 == 0:
    for i in range(1,N,2):
        B.append(i)
        B.append(i)
    for i in range(N):
        if A[i] != B[i]:
            print(0)
            exit()

    print(2**(N//2) % mod)
else:
    B.append(0)
    for i in range(2,N,2):
        B.append(i)
        B.append(i)
    for i in range(N):
        if A[i] != B[i]:
            print(0)
            exit()

    print(2**((N-1)//2) % mod)


Measured memory_bytes: 14008
import java.util.Scanner;
class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int []d = new int [n];
		
		for(int i = 0; i< n ;i++) {
			d[i] = sc.nextInt();
		}

		int sum = 0;
		
		for(int i = 0; i < n ;i++) {
			for(int j = i+1; j < n;j++) {
				sum += d[i] * d[j];
			}
		}
		System.out.println(sum);
	}

}


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

long long N, A, B;
long long v[100];

//vector<vector<long long> > comb;
//
//void combination(int n)
//{
//	comb.assign(n+1, vector<long long>(n+1, 0));
//	for(int i=0; i<=n; ++i){
//		comb[i][0] = 1;
//		for(int j=1; j<=i; ++j){
//			comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
//		}
//	}
//}
//C[n][k]->nCk
long long C[52][52];
void comb_table(int N){
    for(int i=0;i<=N;i++){
        for(int j=0;j<=i;j++){
            if(j==0 or j==i){
                C[i][j]=1ll;
            }else{
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}

int main(){
	cin >> N >> A >> B;
	for(long long i = 0; i < N; i++){
		cin >> v[i];
	}

	sort(v, v + N, greater<long long>());

	double ans = 0;
	for(long long i = 0; i < A; i++){
		ans += (double)v[i];
	}

	ans /= (double)A;

	long long lval = 0;
	long long rval = 0;
	for(long long i = 0; i < N; i++){
		if(v[i] == v[A-1]){
			lval++;
			if(i<A)
				rval++;
		}
	}


	printf("%.10f\n", ans);
	//combination(N);
	comb_table(N);

	if(rval == A){
		long long ret = 0;
		for(long long i = A; i <= B; i++){
			ret +=  C[lval][i]; 
		}
		cout << ret << endl;
	}else{
		cout << C[lval][rval] << endl;
	}
}


Measured memory_bytes: 256
import numpy as np
n, m = map(int, input().split())
ab = np.array([list(map(int, input().split())) for x in range(m)]) - 1

to = list(range(n))
ranks = [0] * n
nodes = [1] * n

def find(x):
    if to[x] == x:
        return x
    else:
        root = find(to[x])
        to[x] = root
        return root

entire = (n - 1) * n // 2
def merge(x, y):
    global entire
    xroot = find(x)
    yroot = find(y)
    if xroot == yroot:
        return
    if ranks[xroot] < ranks[yroot]:
        to[xroot] = yroot
        entire -= nodes[yroot] * nodes[xroot]
        nodes[yroot] += nodes[xroot]
    else:
        to[yroot] = xroot
        entire -= nodes[yroot] * nodes[xroot]
        nodes[xroot] += nodes[yroot]
        if ranks[xroot] == ranks[yroot]:
            ranks[xroot] += 1


results = [entire]
for a, b in reversed(ab[1:]):
    merge(a, b)
    results.append(entire)

for v in reversed(results):
    print(v)


Measured memory_bytes: 37904
#include <iostream>
#include <array>
#include <algorithm>

int main()
{
    int a, b, c; 
    std::cin >> a >> b >> c;
    std::array<int, 3> arr{{a, b, c}};
    std::sort(arr.begin(), arr.end());
    if (arr[0] == 5 && arr[1] == 5 && arr[2] == 7)
    {
        std::cout << "YES";
    }
    else
    {
        std::cout << "NO";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x - a) < abs(x - b)) {
    cout << "A" << endl;
  } else
    cout << "B" << endl;
  return 0;
}


Measured memory_bytes: 3620
N,A,B = map(int, input().split())

# 1.A,Bを1グループとして計上
n_group = N // (A+B)
ans = A * n_group

# 2.Aの追加できる分の計上
res = N - (A+B)*n_group
ans += min(A,res)

# 3.answer
print(ans)

Measured memory_bytes: 2940
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
s = input()
cnt = 0
ans = 0
ss = ''
for i in range(len(s)):
    if len(s[:-(i+1)]) % 2 == 0:
        ss = s[:-(i+1)]
        # print(ss)
        cnt = 0
        for j in range(int(len(ss)/2)):
            # print(ss[j])
            # print(ss[j+int(len(ss)/2)])
            if ss[j] == ss[j+int(len(ss)/2)]:
                cnt += 1
        if cnt == int(len(ss)/2):
            ans = max(ans, cnt)
print(ans*2)
# n = int(input())
# v = readints()
# print(set(v))
# if len(set(v)) == 1:
#    print(len(v)//2)
#    exit()


Measured memory_bytes: 39280
from Queue import Queue
mv=((-1,0),(1,0),(0,-1),(0,1))
while True:
    X,Y=map(int,raw_input().split())
    if X==Y==0:break
    tx,ty=map(int,raw_input().split())
    kx,ky=map(int,raw_input().split())
    tx,ty,kx,ky=tx-1,ty-1,kx-1,ky-1
    D=[map(int,raw_input().split()) for i in range(Y)]
    Q=Queue()
    Q.put((tx,ty,kx,ky,0))
    visited=set()
    visited.add((tx,ty,kx,ky))
    while not Q.empty():
        tx,ty,kx,ky,t=Q.get()
        if t>=100:
            print "NA"
            break
        if tx==kx and ty==ky:
            print t
            break
        for i in range(4):
            dtx,dty=tx+mv[i][0],ty+mv[i][1]
            dkx,dky=kx-mv[i][0],ky-mv[i][1]
            if dtx<0 or dtx>=X or dty<0 or dty>=Y:
                dtx,dty=tx,ty
            if dkx<0 or dkx>=X or dky<0 or dky>=Y:
                dkx,dky=kx,ky
            if D[dty][dtx]==1:
                dtx,dty=tx,ty
            if D[dky][dkx]==1:
                dkx,dky=kx,ky
            if (dtx,dty,dkx,dky) not in visited:
                visited.add((dtx,dty,dkx,dky))
                Q.put((dtx,dty,dkx,dky,t+1))
    else:
        print "NA"

Measured memory_bytes: 33312
N = int(input())
A = [int(i) for i in input().split()]

def flag(l,r):
    return 1 if [a for a in A if l <= a <= r] else 0

ans = 0
for l in range(0,2801, 400):
    ans += flag(l, l + 399)

ans1 = ans + len([a for a in A if a >= 3200])
if ans == 0:
    print(1,ans1)
else:
    print(ans,ans1)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

class myTree
{
public:
  enum
  {
    ROOT = 0,
    INT = 1,
    LEAF = 2
  };

  myTree() {}
  myTree(int n)
    : p(vs32(n, -1)), c(vector< vs32 >(n)), d(vs32(n, 0))
  {}
  ~myTree() {}

  vs32 p;
  vector< vs32 > c;
  vs32 d;

  void add(int r, int c)
  {
    this->c[r].push_back(c);
    this->p[c] = r;
    // this->d[c] = this->d[r] + 1;
  }

  int status(int x)
  {
    if (p[x] < 0) return ROOT;
    else if (!c[x].empty()) return INT;
    else return LEAF;
  }

  void depth()
  {
    int r = 0;
    while (p[r] > 0)
    {
      r = p[r];
    }

    queue<int> q;
    q.push(r);
    while (!q.empty())
    {
      int x = q.front();
      q.pop();
      if (p[x] >= 0)
      {
	d[x] = d[p[x]] + 1;
      }
      rep (i, c[x].size())
      {
	q.push(c[x][i]);
      }
    }
  }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    myTree mt(n);
    int p;
    int c;
    int nc;
    rep (i, n)
    {
      cin >> p >> nc;
      rep (j, nc)
      {
	cin >> c;
	mt.add(p, c);
      }
    }

    mt.depth();

    rep (i, n)
    {
      cout << "node " << i << ": ";
      cout << "parent = " << mt.p[i] << ", ";
      cout << "depth = " << mt.d[i] << ", ";
      cout << (mt.status(i) == myTree::ROOT ? "root, ":
	       mt.status(i) == myTree::INT ? "internal node, ":
	       mt.status(i) == myTree::LEAF ? "leaf, ": "BAD, ");
      cout << "[";
      rep (j, mt.c[i].size())
      {
	if (j > 0) cout << ", ";
	cout << mt.c[i][j];
      }
      cout << "]\n";
    }
    return 0;
}




Measured memory_bytes: 7196
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace AtCoder.ABC110 {
    class B {
        static void Main() => CustomMain();

        static void Solve() {
            var a = ReadIntArray();
            var x = ReadIntArray();
            var y = ReadIntArray();

            for (int i = a[2] + 1; i <= a[3]; i++) {
                if (x.All(v => v < i) && y.All(v => i <= v)) {
                    WriteAnswer("No War");
                    return;
                }
            }

            WriteAnswer("War");
        }

        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>

using namespace std;
typedef long long ll;
ll N;

int main(){

    string b;
    cin >> b;

    if(b == "A"){
        cout << "T" << endl;
    }else if(b == "T"){
        cout << "A" << endl;
    }else if(b == "C"){
        cout << "G" << endl;
    }else if(b == "G"){
        cout << "C" << endl;
    }
    






} 

Measured memory_bytes: 256
// Bismillah .Ya Allah...
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const ll mx = 1e18;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    ll x,y;
    sort(a,a+n);
    sort(b,b+n);
    if(n&1)
    {
        x = a[n/2];
        y = b[n/2];
    }
    else
    {
        x = a[n/2-1]+a[n/2];
        y = b[n/2-1]+b[n/2];
    }
    cout<<y-x+1<<endl;
    return 0;
}


Measured memory_bytes: 5228