akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  int alice = 0, bob = 0;
  rep(i,n) {
    if (i%2==0) alice += a[i];
    else bob += a[i];
  }
  cout << alice - bob << endl;
  return 0;
}

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){
	ll A,B,C,D;
	cin>>A>>B>>C>>D;

	cout<<max(A*B,C*D)<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   int a,b,c,d;
   scanf("%d %d %d",&a,&b,&c);
    d=c;
    c=b;
    b=a;
    a=d;
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		String s = fs.next();
		int len = s.length();
		char c[] = s.toCharArray();
		int a[] = new int[len];
		for(int i=0;i<len;i++) {
			a[i] = c[i] - '0';
		}
		
		
		long dp[][] = new long[len+1][2];
		dp[0][0] = 1;
		for(int i=0;i<len;i++) {
			if(a[i]==0) {
				dp[i+1][0] = plus(dp[i+1][0],dp[i][0]);
				dp[i+1][1] = plus(dp[i+1][1],mul(dp[i][1],3));
			}
			else {
				dp[i+1][0] = plus(dp[i+1][0], mul(dp[i][0],2));
				dp[i+1][1] = plus(dp[i+1][1], mul(dp[i][1],3));
				dp[i+1][1] = plus(dp[i+1][1], dp[i][0]);
			}
		}
		System.out.println(plus(dp[len][0],dp[len][1]));
	}
	
	//MOD culculations
	static long plus(long x, long y) {
		return (x + y) % mod;
	}

	static long sub(long x, long y) {
		return (x - y + mod) % mod;
	}

	static long mul(long x, long y) {
		return (x * y) % mod;
	}

	static long div(long x, long y) {
		return x * modpow(y, mod - 2) % mod;
	}

	static long modpow(long x, long y) {
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * modpow(x, y - 1)) % mod;
		long root = modpow(x, y / 2);
		return root * root % mod;
	}
	
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 27584
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>

using namespace std;

int main(){
	int n;
	long long int l[87];
	scanf("%d",&n);
	if(n==0)    printf("2\n");
	if(n==1)	printf("1\n");
	if(n>=2){
		for(int i=0;i<=n;i++){
			l[0]=2;
			l[1]=1;
			if(i>=2)
			l[i]=l[i-1]+l[i-2];
		}
		printf("%lld\n",l[n]);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int day = 0;
  if (S.at(0) == 'R'){
    day += 1;
  }
  if (S.at(1) == 'R'){
    if (day == 1){
      day += 1;
    }
    else{
      day = 1;
    }
  }
  if (S.at(2) == 'R'){
    if (day == 2){
      day = 3;
    }
    else if(S.at(1) == 'R'){
      day = 2;
    }
    else{
      day = 1;
    }
  }
  cout << day << endl;
}

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

int main() {
  int n, m;
  int ans = 0;
  cin >> n >> m;
  rep(i, n) {
    ans += i;
  }
  rep(i, m) {
    ans += i;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if( s.at(i) == ',' ){
      cout << ' ';
      continue;
    }
    cout << s.at(i);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    static int mod = 1000000007;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int dp[][] = new int[n+1][m+1];
        dp[1][1] = 1;
        for(int i=1;i<=n;i++){
            char cur[] = sc.next().toCharArray();
            for(int j=1;j<=m;j++){
                if(cur[j-1] == '.'){
                    dp[i][j] = (dp[i][j]+dp[i-1][j] + dp[i][j-1])%mod;
                }else{
                    dp[i][j] = 0;
                }
            }
        }
//        for(int i[]:dp){
//            for(int j:i)
//                System.out.print(j+" ");
//            System.out.println();
//        }
        System.out.println(dp[n][m]);
    }

}



Measured memory_bytes: 47820
N = int(input())
if N == 0:
    print(0)
    exit()

L = []
M = []

for length in range(1,41):
    if length % 2 == 0:
        l = -2 * pow(4,length//2) // 3
        m = (pow(4,length//2) - 1) // 3
    elif length % 2 == 1:
        l = -2 * (pow(4,(length-1)//2) - 1) // 3
        m = (pow(4,(length+1)//2) - 1) // 3
    L.append(l)
    M.append(m)

identify = []
for i in range(40):
    if i == 0:
        ap_list = [L[0],M[0]]
    elif i % 2 == 1:
        ap_list = [L[i],L[i-1]]
    elif i % 2 == 0:
        ap_list = [M[i-1],M[i]]
    identify.append(ap_list)

bit = [0]*40
for i in range(39,-1,-1):
    left = identify[i][0]
    right = identify[i][1]
    if i % 2 == 0 and left < N <= right:
        bit[39-i] = 1
        N -= pow(-2,i)
    elif i % 2 == 1 and left <= N < right:
        bit[39-i] = 1
        N -= pow(-2,i)

ans = "".join(str(e) for e in bit).lstrip("0")
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int del(int x) { return x>=P?x-P:x; }
void add(int &x,int y) { x=del(x+y); }
int ksm (int a,int b)
{
	int ans=1;
	while (b)
	{
		if (b&1) ans=(LL)ans*a%P;
		a=(LL)a*a%P,b>>=1;
	}
	return ans;
}
int jc[N],inv[N];
void init (int n)
{
	jc[0]=1;
	for (int i=1; i<=n; i++)
		jc[i]=(LL)i*jc[i-1]%P;
	inv[n]=ksm (jc[n],P-2);
	for (int i=n-1; i>=0; i--)
		inv[i]=(LL)(i+1)*inv[i+1]%P;
}
int C(int n,int m) { return (m< 0||m> n)?0:(LL)jc[n]*inv[m]%P*inv[n-m]%P; }
int n,m,a[N],f[18][1<<17|1];

int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	sc(n),sc(m); init (1<<n);
	for (int i=1; i<=m; i++)
		sc(a[i]);
	sort (a+1,a+m+1,greater <int> ());
	f[0][0]=1;
	int S=1<<n;
	for (int i=0; i< m; i++)
		for (int s=0; s< S; s++) if (f[i][s])
		{
			int g=f[i][s]; add(f[i+1][s],g);
			int las=S-s-a[i+1];
			for (int x=0; x< n; x++) if (!(s>>x&1))
				if (las>=(1<<x)-1) add(f[i+1][s|(1<<x)],(LL)g*C(las,(1<<x)-1)%P*jc[1<<x]%P);
		}
	int ans=0;
	for (int s=0; s< S; s++)
	{
		int g=(LL)f[m][s]*jc[S-s-1]%P;
		add(ans,__builtin_popcount (s)&1?(P-g):g);
	}
	pr((LL)ans*S%P);

    return 0;
}


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

int main() {
 
  string S;
  cin >> S;
  if(S.at(0)==S.at(1)||S.at(1)==S.at(2)||S.at(2)==S.at(3)){
    cout<<"Bad"<<endl;
  }else {
    cout<<"Good"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long d = sc.nextLong();

		int ans=0;
		for (int i=0; i<n; i++){
			long x = sc.nextLong();
			long y = sc.nextLong();

			if ((x*x + y*y) <= d * d){
				ans++;
			}
		}
		System.out.println(ans);
	}


}

Measured memory_bytes: 59104
#include<bits/stdc++.h>
#define M 1000000007
#define pb push_back
#define ll long long int
using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	int i,j;
	for(i=0;i<n;i++)
		cin>>a[i];
	ll dp[n][k+1];
	ll prefsum[k+1];
	for(i=0;i<n;i++)
	{
		for(j=0;j<=k;j++)
		{
			if(i==0)
			{
				dp[i][j] = (j<=a[i]);
			}
			else
			{
				dp[i][j] = prefsum[j]-((j-a[i]-1>=0)?prefsum[j-a[i]-1]:0);
				dp[i][j] = (dp[i][j]+M)%M;
			}
		//	cout<<dp[i][j]<<" ";
		}
		//cout<<"\n";
		prefsum[0] = dp[i][0];
		for(int k1 = 1;k1<=k;k1++)
			prefsum[k1] = (prefsum[k1-1]+dp[i][k1])%M;
	}

	cout<<dp[n-1][k];
	return 0;

}


Measured memory_bytes: 82340
#include<bits/stdc++.h>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n, m;
	
	vector<int> a(100001);
	
	cin>>n;
	while(n--){
		int l,r;
		cin>>l>>r;
		for(int i=l;i<=r;++i) ++a[i];
	}
	
	cout<<accumulate(ALL(a), 0LL)<<endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

struct union_find{
  vector<int> par,r;

  union_find(int n){
  	par.resize(n);
  	r.resize(n);
  	init(n);
  }

  void init(int n){
    for(int i = 0; i < n; i++) par[i] = i;
    for(int i = 0; i < n; i++) r[i] = 0;
  }

  int find(int x){
    if(par[x] == x) return x;
    else return find(par[x]);
  }

  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(r[x] < r[y]){
      par[x] = y;
    }else{
      par[y] = x;
      if(r[x] == r[y]) r[x]++;
    }
  }

  bool same(int x,int y){
  	return find(x) == find(y);
  }
};

int main()
{
	int n,m;
	cin >> n >> m;

	vector<pair<int,int> > e(m);

	for(int i = 0; i < m; i++){
		cin >> e[i].first >> e[i].second;
		e[i].first--;
		e[i].second--;
	}

	int ans = 0;
	for(int i = 0; i < m; i++){
		union_find uf(n);

		for(int j = 0; j < m; j++){
			if(i!=j && !uf.same(e[j].first,e[j].second)){
				uf.unite(e[j].first,e[j].second);
			}
		}
		set<int> s;
		for(int j = 0; j < n; j++){
			if(uf.par[j]==j) s.insert(uf.par[j]);
		}
		if(s.size()>1) ans++;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

typedef vector<int> Vec;

void solve(Vec &s){
  int ans = 20;
  const int dx[8] = {-1,-1,-1,0,0,1,1,1};
  const int dy[8] = {-1,0,1,-1,1,-1,0,1};
  queue<Vec> Q;
  Q.push(s);
  set<Vec> visited;
  visited.insert(s);
  while(!Q.empty()){
    Vec v = Q.front(); Q.pop();
    int size = v.size();
    ans = min(ans,size);
    if(size == 0) continue;
    for(int i = 0 ; i < size ; i++){
      for(int j = 0 ; j < 8 ; j++){
        Vec next;
        int nx = i%4 + dx[j];
        int ny = i/4 + dy[j];
        if(nx < 0 || ny < 0 || nx >= min(4,size) || ny >= min(5,size)) continue;
        if(nx+ny*4 < 0 || nx+ny*4 >= size) continue;
        if(v[i] == v[nx+ny*4]){
          for(int k = 0 ; k < size ; k++){
            if(i == k || nx+ny*4 == k) continue;
            next.push_back(v[k]);
          }
          if(!visited.count(next)){
            visited.insert(next);
            Q.push(next);
          }
        }
      }
    }
  }
  cout << ans << endl;
}

int main(){
  int Tc;
  cin >> Tc;
  while(Tc--){
    Vec vec(20);
    for(int i = 0 ; i < 20 ; i++){
      cin >> vec[i];
    }
    solve(vec);
  }
  return 0;
}

Measured memory_bytes: 1324
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[]) {
  long long int i,x,k;
  char s[120],t[3];
  scanf("%s",s);
  scanf("%lld",&k);
  for(i=0;i<100;i++){
    if(s[i]!='1'){
    x=i;
    t[0]=s[i];
    if (x>=k)
    printf("1\n");
    else
    printf("%c\n",t[0]);
    return 0;
  }
}
printf("1\n" );
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec a(N); cin >> a;
    vec ans(N + 1, 0);

    int sz = 0;
    IFOR(i, 1, N + 1){
        int a0 = a[i - 1];
        int tmp = 0;
        for(int j = 2 * i; j <= N; j += i) tmp += ans[j];
        if(tmp % 2 != a0){
            ans[i] = 1;
            sz++;
        }
    }
    Out(sz);
    FOR(i, 1, N + 1) if(ans[i]) cout << i << " ";
    cout << endl; 

    return 0;
}


Measured memory_bytes: 3968
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll N;
    cin >> N;
    ll ans = 1, num = 0;
    for(int i=2; i<=N; i+=2){
        int tmp = i;
        int cnt = 0;
        while(tmp%2==0){
            tmp/=2;
            cnt++;
        }
        if(cnt > num){
            num = cnt;
            ans = i;
        }
    }
    cout << ans << el;
}



Measured memory_bytes: 256
N = int(input())

# print("")
# 証言者ごとに整理する
testimony_list = []
for i in range(N):
    array = [-1] * N
    testimony_list.append(array)
for i in range(N):
    A = int(input())
    for j in range(A):
        # iさんの、xさんへの証言
        x, y = map(int, input().split())
        # print("test:{} {}".format(x, y))
        # iさんの、xさんへの証言
        # print("test:{} {} {}".format(x - 1, i, y))
        # print(testimony_list)
        testimony_list[i][x - 1] = y

# print(testimony_list)
max_count = 0
failed = False
for i in range(2 ** N):
    results = [-1] * N
    shoujiki = 0
    for j in range(len(testimony_list)):
        # check = (i >> j & 1)
        # print("チェック: {} {}".format(i, j))
        # print(i >> j & 1)
        if i >> j & 1:
            shoujiki += 1
            # print("{}:{}".format(bin(i), j))
            array = testimony_list[j]
            for k in range(len(array)):
                # print(
                #     "k={} result[k]:array[k] {}:{}".format(
                #         k, results[k], array[k]))
                # print(i >> k & 1)
                if not (i >> k & 1) and array[k] == 1:
                    # print("矛盾2")
                    failed = True
                    break
                elif (i >> k & 1) and array[k] == 0:
                    # print("矛盾3")
                    failed = True
                    break
                if array[k] == -1:
                    continue
                if results[k] == -1:
                    results[k] = array[k]
                elif results[k] != array[k]:
                    # print("矛盾1")
                    failed = True
                    break
        if failed is True:
            # print("failed")
            # results = [-1] * N
            break
    if failed is True:
        failed = False
        continue
    # print("計算: {}".format(i))
    # print(results)
    # count = 0
    # for result in results:
    #     if result != -1:
    #         count += 1
    # print(count)
    if max_count < shoujiki:
        max_count = shoujiki
print(max_count)


Measured memory_bytes: 3064
#coding:utf-8
import bisect
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True



def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    x, y = LMIIS()

    if (x+y)%3!=0:
      print(0)
      exit()
    n = (x+y)//3
    if 0 > x-n or 0 > y-n:
      print(0)
      exit()

    m = min(x-n,y-n)
    mod = 10**9 + 7

    a = 1
    b = 1
    for i in range(n - m + 1, n+1):
        a = a * i % mod
    for i in range(1, m + 1):
        b = b * i % mod
    print(a * pow(b, mod - 2, mod) % mod)




if __name__ == '__main__':
    main()


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

int main() {
    int a, b;
    cin >> a >> b;

    int cnt = 1, ans = 0;

    while (true) {
        if (cnt >= b) {
            cout << ans << endl;
            return 0;
        } else cnt += a-1, ans++;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int a, b;
  while(1){
    scanf("%d %d", &a, &b);
    if(a==0||b==0) break;
    for(int i = 0; i<a; i++){
      for(int j = 0; j<b; j++){
        if(i%2==0) {
          if(j%2==0)  printf("#");
          else  printf(".");
        }
        else{
           if(j%2==0)  printf(".");
          else  printf("#");
        }
      }
       printf("\n");
    }
    printf("\n");
  } 
  return 0;
}


Measured memory_bytes: 2684
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    
    rep(i,n+1){
        rep(j,m+1){
            int tmp = i*m+j*n -2*(i*j);
            //cout <<i << " " << j << " " << i*m << "-" << j*n << " "  << tmp << endl;

            if(tmp == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>

using namespace std;

typedef long long ll;

int main() {
  int n;
  cin >> n;

  int k = 0;
  int sum = 0;

  for (int i = 1; i <= n; i++) {
    sum += i;
    k++;
    if (sum >= n) { break; }
  }

  for (int i = k; i > 0; i--) {
    if (i <= n)  {
      cout << i << endl;
      n -= i;
    }
    if (n == 0) { break; }
  }

  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int>table(n);

  for (int i = 0; i < n; i++) {
    cin >> table.at(i);
  }
  for (int i = 0; i < n-1; i++) {
    for (int j = i+1; j <n; j++) {
      if (abs(table.at(i)-table.at(j)) % (n-1) == 0) {
        cout << table.at(i) << " " << table.at(j);
        return 0;
      }
    }
  }
}





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

typedef pair<int,int> pint;
typedef pair<pint,pint> ppint;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int> > a(H, vector<int>(W, 0));
    int odd = 0;
    for (int i = 0; i < H; ++i) for (int j = 0; j < W; ++j) {
        cin >> a[i][j];
        if (a[i][j] & 1) ++odd;
    }
    
    vector<ppint> res;
    int num = 0;
    int x = 0, y = 0;
    for (int iter = 0; iter < W*H; ++iter) {
        if (a[x][y] & 1) ++num;
            
        int nx = x, ny = y;
        if (x % 2 == 0) {
            if (ny == W-1) ++nx;
            else ++ny;
        }
        else {
            if (ny == 0) ++nx;
            else --ny;
        }
        if (num & 1) if (num < odd) res.push_back(ppint(pint(x, y), pint(nx, ny)));
        x = nx, y = ny;
    }
        
    cout << res.size() << endl;
    for (auto p : res) {
        cout << p.first.first+1 << " " << p.first.second+1 << " " << p.second.first+1 << " " << p.second.second+1 << endl;
    }
}

Measured memory_bytes: 6276
#include <bits/stdc++.h>
using namespace std ;
int main() {
	int r, c, n;
	cin >> r >> c >> n;
	vector<pair<int, int>> up, down, left, right;
	int now = 0;
	for(int i = 0; i < n; i++) {
		int a, b, x, y;
		cin >> a >> b >> x >> y;
		if((a<r&&a>0 && b<c&&b>0) ||(x<r && x>0 && y<c && y>0)) {}
		else {
			now++;
			if(a==0) up.push_back({b, now});
			else if(a==r) down.push_back({b, now});
			else if(b==0) left.push_back({a, now});
			else if(b==c) right.push_back({a, now});
			if(x==0) up.push_back({y, now});
			else if(x==r) down.push_back({y, now});
			else if(y==0) left.push_back({x, now});
			else if(y==c) right.push_back({x, now});
		}
	}
	sort(up.begin(), up.end());
	sort(down.begin(), down.end());
	sort(left.begin(), left.end());
	sort(right.begin(), right.end());
	stack<int> st;
	for(auto s: up) {
		if(st.empty())st.push(s.second);
		else {
			if(s.second != st.top()) st.push(s.second);
			else st.pop(); 
		}
	}
	for(auto s: right) {
		if(st.empty())st.push(s.second);
		else {
			if(s.second != st.top()) st.push(s.second);
			else st.pop(); 
		}
	}
	for(int s = down.size()-1; s >= 0; s--) {
		if(st.empty())st.push(down[s].second);
		else {
			if(down[s].second != st.top()) st.push(down[s].second);
			else st.pop(); 
		}
	}
	for(int s = left.size()-1; s >= 0; s--) {
		if(st.empty())st.push(left[s].second);
		else {
			if(left[s].second != st.top()) st.push(left[s].second);
			else st.pop(); 
		}
	}
	if(st.empty()) cout << "YES";
	else cout << "NO";
	return 0; 
}

Measured memory_bytes: 2520
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


struct b{int w,s,v;};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  vector<b>bs(n);
  rep(i,n)
  {
    cin>>bs[i].w>>bs[i].s>>bs[i].v;
  }
  sort(all(bs),[](b p,b q){if(p.s+p.w!=q.s+q.w)return p.s+p.w<q.s+q.w;return p.s<q.s;});
  vector<ll>dp(20001,-1);
  dp[0]=0;
  rep(i,n)
  {
    for(int j=bs[i].s;j>=0;j--)
    {
      if(dp[j]==-1||j+bs[i].w>20000)continue;
      chmax(dp[j+bs[i].w],dp[j]+bs[i].v);
    }
  }
  auto res=(*max_element(all(dp)));
  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <time.h>
#include <algorithm>
using namespace std;
#define INF 2147483647 

int main() {
	ios_base::sync_with_stdio(false);

	string s, t; cin >> s >> t;
	int len = s.size();
	int cnt = 0;
	for (int i = 0; i < len; i++) {
		if (s[i] == t[i]) {
			cnt += 1;
		}
	}
	cout << cnt << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

ll N ;
vector<ll> A;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N ;
    
    rep(i, N){
        ll inp;
        cin >> inp;
        A.pb(inp);
    }
    
    ll even = 0;
    ll odd = 0;
    rep(i, N){
        if(i % 2 == 0) even += A[i];
        else odd += A[i];
    }
    
    ll m = even - odd ;
    vector<ll> ans ;
    ans.pb(m);
    
    rep(i, N){
        ans.pb((A[i]-ans[i]/2)*2);
    }
    rep(i, N){
        cout << ans[i] << " " ;
    }

    cout << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;
const LL m = 1e9+7;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

vector<LL> pr;
LL phi[MAXN];

LL po(LL a, LL n){
	if(n==0) return 1;
	LL an = po(a,n/2);
	an = (an*an)%m;
	if(n&1) an = (an*a)%m;
	return an;
}

int main(){
  fio();
  LL n,k; cin>>n>>k;
  LL an = po(k,n);
  for(LL i=2; i<=k; i++){
  	if(phi[i]==0){
  		pr.pb(i);
  		phi[i] = i-1;
  	}
  	an = (an + po(k/i,n)*phi[i]%m)%m;
  	for(auto p:pr){
  		if(i*p>k) break;
  		if(i%p==0){
  			phi[i*p] = p*phi[i];
  		}
  		else{
  			phi[i*p] = phi[i]*phi[p];
  		}
  	}
  }
  cout<<an<<endl;
  return 0;
}

Measured memory_bytes: 4476
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	int city[5], k;
	for (int i = 0; i < 5; i++) {
		scanf("%d", &city[i]);

	}
	scanf("%d", &k);

	bool can = true;

	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			if (city[j] - city[i] > k) {
				can = false;
			}

		}
	}


	if (can) {
		printf("Yay!");
	}
	else {
		printf(":(");
	}

}

Measured memory_bytes: 128
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

bool IsSquaredValue(int32_t n) {
  const int32_t a = static_cast<int32_t>(sqrt(n));
  return (a * a == n);
}

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

  int32_t N, T, A;
  cin >> N >> T >> A;
  int32_t min = INT32_MAX;
  int32_t result = -1;
  for (int32_t i = 0; i < N; ++i) {
    int32_t H;
    cin >> H;
    const int32_t evaluate = abs(1000 * (T - A) - 6 * H);
    if (evaluate < min) {
      result = i + 1;
      min = evaluate;
    }
  }
  cout << result << endl;
  return 0;
}


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

// N, Mの制約がとても強いので，考えられる数列Aの候補が十分少ない -> 全探索

int N, M, Q;
vector<int> a, b, c, d;
int ans;

void DFS(vector<int> A)
{
    if (A.size() == N + 1)
    {
        int now = 0;
        for (int i = 0; i < Q; i++)
        {
            if (A[b[i]] - A[a[i]] == c[i])
            {
                now += d[i];
            }
        }
        ans = max(ans, now);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= M)
    {
        DFS(A);
        A.back()++;
    }
}

int main()
{
    cin >> N >> M >> Q;
    a = b = c = d = vector<int>(Q);
    for (int i = 0; i < Q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    DFS(vector<int>(1, 1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
int b[110000];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",b+i);
	std::sort(b,b+a);
	long long now=0;
	for(int i=0;i<a;i++)now+=b[i];
	int ret=0;
	for(int i=a-1;i>=0;i--){
		if(b[i+1]>now*2)break;
		ret++;
		now-=b[i];
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];

    ll back = a[0];
    ll ans = 1000;
    ll kabu = 0;
    rep(i, n){
        if(a[i] > back){
            kabu += (ans / back);
            ans = ans % back;
            ans += a[i] * kabu;
            kabu = 0;
        }
        back = a[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3556
import * as fs from 'fs';

namespace AtCoder.abc092 {

    export class Program {

        constructor(private readonly args: string) {
            this.args = args;
        }

        /**
         * in
         *
         * out
         *
         */
        main(this: Program): void {
            const [a, b, c, d]: number[] = this.args.split('\n').map(Number);

            console.log(Math.min(a, b) + Math.min(c, d));
        }
    }
}

const args = fs.readFileSync('/dev/stdin', 'utf8').trim();
const prg = new AtCoder.abc092.Program(args);
prg.main();


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

char S[20], T[20];
ll i, j, k;
int main(){
    scanf("%s%s", S,T);
    for (i = 0; S[i];++i){
        if(S[i]!=T[i])
            break;
    }
    if(S[i]){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
        return 0;
}

Measured memory_bytes: 3656
n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))

# Liner Search
def LinerSearch(A, key):
    for i in range(len(A)):
        if A[i] == key:
            return True

    return False

#Liner Search2
def LinerSearch2(A, key):
    i = 0
    A.append(key)
    while A[i] != key:
        i += 1
    if i == n:
        A.pop()
        return False
    else:
        A.pop()
        return True



cnt = 0
for i in range(len(T)):
    if LinerSearch2(S, T[i]):
        cnt = cnt+1

print(cnt)


Measured memory_bytes: 6552
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()

struct katana
{
    ll wield, thrw;
};
vector<katana> swords;

void sort2vectors_custom(vector<katana> &swords, string method)
{
    ll n = swords.size();
    vector<ll> p(n);
    vector<katana> swords2(n);
    iota(all(p), 0);

    sort(all(p), [&](ll a, ll b) {
        if (method == "wield")
        {
            return swords[a].wield < swords[b].wield;
        }
        else
        {
            return swords[a].thrw < swords[b].thrw;
        }
    });

    rep(i, n)
    {
        swords2[i] = swords[p[i]];
    }
    swords = swords2;
}

int main()
{
    ll n, h, cnt = 0;
    cin >> n >> h;
    swords.resize(n);
    rep(i, swords.size())
    {
        cin >> swords[i].wield >> swords[i].thrw;
    }
    sort2vectors_custom(swords, "thrw");
    reverse(all(swords));
    sort2vectors_custom(swords, "wield");
    katana main_sword = swords.back();
    swords.pop_back();
    sort2vectors_custom(swords, "thrw");

    while (h > 0)
    {
        ++cnt;
        if (main_sword.thrw >= h)
        {
            h -= main_sword.thrw;
        }
        else if (swords.size() > 0 && main_sword.wield < swords.back().thrw)
        {
            h -= swords.back().thrw;
            swords.pop_back();
        }
        else
        {
            h -= main_sword.thrw;
            cnt += 1 + (h - 1) / main_sword.wield;
            break;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int main() {
  int n, y;
  cin >> n >> y;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n - i; j++) {
      if (10000 * i + 5000 * j + 1000 * (n - j - i) == y) {
        cout << i << ' ' << j << ' ' << n - j - i << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod=1e9+7;

/*
Codeforces 766A
Codeforces 766B
ATCODER A
Codeforces 766C
HDU 3001
HDU 3007
*/


/*
Codeforces 766A 题意：
题意好坑，介绍了一堆子串的性质，长的一定不是短的的子串。
思路：
那么如果两个串相同-1
不相同取max(len1,len2)...

Codeforces 766B 题意：
给你n条线段，问能否取三个线段得一个三角形。
两边之和大于第三边。
枚举最大边，看能不能产生比他大的组合。
那其实sort完以后a<b<c只要看a+b是不是>c就好了

AtCoder Beginner Contest 052 A题意：
输出大的面积？
思路：
max(A*B,C*D);
AtCoder Beginner Contest 052 B题意：
好像只要比较I和D的个数差，然后和0比大小就好了？

HDU 3001 题意：
每个城市最多只玩一次，起点任意，求花费最少。
思路：

*/
char s[110];
int n;
int main()
{
    scanf("%d",&n);
    scanf("%s",s);
    int num=0;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='I') num++;
        else num--;
        ans=max(ans,num);
    }
    printf("%d\n",ans);
    return 0;
}







Measured memory_bytes: 256
n,k = map(int, input().split())
a = list(map(int, input().split()))
bita = [sum(1 for x in a if x&2**i) for i in range(41)]
bita2 = [max(x,n-x) for x in bita]
ans = 0
for i in range(41):
  if k&2**i:
    ans += bita2[i]*2**i
  else:
    ans += bita[i]*2**i
for bit in range(41):
  if not k&2**bit:
    continue
  x = ((k>>bit)<<bit) - 1
  c = 0
  for i in range(41):
    if x&2**i:
      c += bita2[i]*2**i
    else:
      c += bita[i]*2**i
  if c > ans:
    ans = c
print(ans)


Measured memory_bytes: 14620
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
const int maxn = 102, rt = 1<<10;
int a, b;
char mat[maxn][maxn];
void solve() {
	cin >> a >> b;
	for(int i = 0; i < 100; i++)
		for(int j = 0; j < 100; j++)
			mat[i][j] = j < 50 ? '.' : '#';
	a--, b--;
	for(int i = 1; i < 99; i+=2)
		for(int j = 1; j < 99; j+=2) {
			if(mat[i][j] == mat[i][j+1] && mat[i][j] == mat[i][j-1] && mat[i][j] == mat[i-1][j] && mat[i][j] == mat[i+1][j]) {
				if(mat[i][j] == '#' && a) a--, mat[i][j] = '.';
				else if(mat[i][j] == '.' && b) b--, mat[i][j] = '#';
			}
		}
	cout << "100 100\n";
	for(int i = 0; i < 100; i++, cout << '\n')
		for(int j = 0; j < 100; j++) 
			cout << mat[i][j];
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	solve();
}


Measured memory_bytes: 256
// -------- START : snippet -------- //

#include <bits/stdc++.h>
using namespace std;

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

// -------- START : macro -------- //

#define ll long long
#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 len(c) (ll)c.size()
#define all(v) (v).begin(),(v).end()
#define lb(v,x) (lower_bound(all(v),x)-v.begin())
#define ub(v,x) (upper_bound(all(v),x)-v.begin())
#define has(c,x) (c.find(x) != c.end())
#define uniq(v) v.erase(unique(all(v)),v.end())
#define bit(k) (1LL<<(k))
#define INF int(1e9)

template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

// -------- END : macro -------- //

// -------- START : debug macro -------- //

template<class T,class U> ostream& operator<<(ostream& ost, const pair<T,U> &p) { ost << "(" << p.first << ", " << p.second << ")"; return ost; }
#define ostream_container { ost << "{"; for(const auto &t : v) { if (&t != &*v.begin()) ost << ", "; ost << t; } ost << "}"; return ost; }
template<class T> ostream& operator<<(ostream &ost, const vector<T> &v) ostream_container
template<class T> ostream& operator<<(ostream &ost, const set<T> &v) ostream_container
template<class T,class U> ostream& operator<<(ostream &ost, const map<T,U> &v) ostream_container

template<class H> void recursive_debug(string s, H h) {
    cerr << "\033[33m" << s << " = " << h << endl << "\033[m";
}
template<class H,class... T> void recursive_debug(string s, H h, T... t) {
    int comma = s.find(',');
    cerr << "\033[33m" << s.substr(0,comma) << " = " << h << ", ";
    recursive_debug(s.substr(comma+1), t...);
}
#define debug(...) recursive_debug(#__VA_ARGS__, __VA_ARGS__)

// -------- END : debug macro -------- //

// -------- END : snippet -------- //

int main(void) {
    ll k;
    cin >> k;
    if (k % 2 == 0) {
        cout << -1 << endl;
        return 0;
    }
    ll x = 0;
    rep1(i,k){
        x = (x*10 + 7) % k;
        if (x == 0) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  ll ans;
  cin >> n;
  ans = 3*n*n;
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

vector<ll> a;
int n;

void solution(){
	cin >> n;
	a = vector<ll>(n); for(auto& x : a) cin >> x;
	// state -- only depends on the portion of the array which is remaining
	// dp[i][j] -- minimum cost to combine array from a[i]....a[j]

	vector<ll> pre(n,0);
	pre[0] = a[0];
	for(int i = 1; i < n; i++) pre[i] = pre[i-1]+a[i];
	vector<vector<ll>> dp(n,vector<ll>(n,1e18));
	for(int x = 0; x < n; x++){
		for(int y = 0; y+x < n; y++){
			int i = y, j = y+x;
			if(i == j) dp[i][j] = 0;
			else if(i+1 == j) dp[i][j] = a[i]+a[j];
			else{
				for(int k = i; k < j; k++){
					ll left = pre[k] - (i == 0? 0 : pre[i-1]);
					ll right = pre[j] - pre[k];
					dp[i][j] = min(dp[i][j], left + right + dp[i][k] + dp[k+1][j]);
				}
			}
		}
	}
	cout << dp[0][n-1] << endl;
	
}	


int main(){ 

	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}


Measured memory_bytes: 4488
#include<bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))

int main(){
    int N;
    cin >> N;
    long double ans = 1;
    long double sum = 0;
    rep(i,N){
        int A;
        cin >> A;
        sum += 1.0/A;
    }
    ans /= sum;

    cout << setprecision(10) << ans << endl;


}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

void addMapKey(map<long long, int> &m, long long k){
	if(m.count(k) == 0){
		m[k] = 1;
	}
	else{
		m[k]++;
	}
}

long long N;
vector<long long> A;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	long long minus = 0;
	long long min = INF;
	long long ans = 0;
	for(int i=0; i<N; i++){
		long long a;
		cin >> a;
		A.push_back(a);
		ans += abs(a);
		if(a < 0){
			minus++;
		}
		if(min > abs(a)){
			min = abs(a);
		}
	}
	
	if((minus % 2) != 0){
		ans -= 2*min;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4264
q1=list(map(int,input().split(" ")))
a1=list(map(int,input().split(" ")))


sum1=sum(a1[:q1[1]])
sumsum=sum1
for i in range(q1[0]-q1[1]):
    sum1=sum1+a1[i+q1[1]]-a1[i]
    if(sumsum<sum1):
        sumsum=sum1
sumsum+=q1[1]
print(sumsum/2)

Measured memory_bytes: 25060