akhauriyash/Code-Regression huggingface dataset:
// Always check for base cases
                // Check for overflows and out of index
                // Do something instead of sitting idle
                #include<bits/stdc++.h>
                #define ll long long
                #define f   first
                #define s   second
                #define pb          push_back
                #define mod        1000000007
                #define mod1       1000000009
                #define hell        998244353
                #define inf         1000000000000000000LL
                #define pi          3.14159265358979323
                //#define N           100005 
                const int N=200005;
                using namespace std;
                ll n,k,sum,q,res,m,val,ans;
                ll x,y;
                double p;
                ll xx[]={1,0,-1,0};
                ll yy[]={0,1,0,-1};
                void solve()    
                {   
                    ll h,w,m;
                    cin>>h>>w>>m;
                    map<ll,ll> c,r;
                    map<pair<ll,ll>,bool> hm;
                    for(int i=0;i<m;i++)
                    {
                        cin>>x>>y;
                        r[x]++;
                        c[y]++;
                        hm[{x,y}]=1;
                    }
                    vector<pair<ll,ll>> v,v1;
                    for(auto z:r) v.pb({z.s,z.f});
                    for(auto z:c) v1.pb({z.s,z.f});
                    sort(v.begin(),v.end());
                    sort(v1.begin(),v1.end());
                    n=v.size();
                    ll ans=1;
                    for(auto z:c)
                    {   ll res1=z.s;
                        ll res2=z.s;
                        if(n-1>=0) {res1+=(v[n-1].f-hm.count({v[n-1].s,z.f}));}
                        if(n-2>=0) {res2+=(v[n-2].f-hm.count({v[n-2].s,z.f}));}
                        ans=max({ans,res1,res2});
                    }
                    n=v1.size();
                    for(auto z:r)
                    {   ll res1=z.s;
                        ll res2=z.s;
                        if(n-1>=0) {res1+=(v1[n-1].f-hm.count({z.f,v1[n-1].s}));}
                        if(n-2>=0) {res2+=(v1[n-2].f-hm.count({z.f,v1[n-2].s}));}
                        ans=max({ans,res1,res2});
                    }
                    cout<<ans;


                }
                int main()  
                {   ios_base::sync_with_stdio(false);
                    cin.tie(0);cout.tie(0);
                    ll t=1;  
                    //cin>>t;
                     for(ll i=1;i<=t;i++)
                        solve();
                    

                }            


Measured memory_bytes: 76480
/**
* 氏名: 阿部寛之
* 学籍番号: 170441004
***/


#include<stdio.h>

int main(void)
{
	int value[3];
	int buff;
	scanf("%d %d %d", &value[0], &value[1], &value[2]);

	for (int i = 0; i < 3; i++)
	{
		for (int j = i; j < 3; j++)
		{
			if (value[i] > value[j])
			{
				buff = value[i];
				value[i] = value[j];
				value[j] = buff;
			}
		}
	}

	printf("%d %d %d\n", value[0], value[1], value[2]);
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	int v[n];
	REP(i,n) cin >> v[i];
	int c[n];
	REP(i,n) cin >> c[i];
	int res = 0;
	REP(i,n){
		if(v[i] - c[i] > 0)res += v[i] - c[i];
	}
	cout << res << endl;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=1005;
int n,m;
int x[maxn],y[maxn];
char ans[maxn];

int main(){
	m=31;
	scanf("%d",&n);
	REP(i,n){
		scanf("%d%d",&x[i],&y[i]);
		if(((x[i]+y[i])&1)!=((x[1]+y[1])&1)){
			puts("-1");
			return 0;
		}
	}
	bool eve=((x[1]+y[1])&1)==0;
	printf("%d\n",m+eve);
	REP(i,m)printf("%d ",1<<(31-i));
	if(eve)puts("1");
	else puts("");
	REP(i,n){
		if(eve)x[i]--;
		int sx=0,sy=0;
		REP(j,m){
			int dx=x[i]-sx,dy=y[i]-sy;
			if(dx-dy>0&&dx+dy>0)putchar('R'),sx+=(1<<(31-j));
			else if(dx-dy<0&&dx+dy>0)putchar('U'),sy+=(1<<(31-j));
			else if(dx-dy<0&&dx+dy<0)putchar('L'),sx-=(1<<(31-j));
			else putchar('D'),sy-=(1<<(31-j));
		}
		assert(sx==x[i]&&sy==y[i]);
		if(eve)putchar('R');
		puts("");
	}
	return 0;
}

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

typedef long long ll;

int N;
vector<int> G[100010],ele;
int A[100010];
bool vis[100010];
bool loop[100010];
int len[100010];
int par[100010];
int num[100010];
int nxt[100010];
int cnt;
ll ans = 1;
ll dp[100010];
ll mod = 1000000007;

void DFS(int v)
{
    if(vis[v])return;
    vis[v] = true;
    ele.push_back(v);
    for(int i = 0; i < G[v].size(); i++)DFS(G[v][i]);
    DFS(par[v]);
    return;
}

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        int a;
        scanf("%d",&a);
        G[a].push_back(i + 1);
        par[i + 1] = a;
    }

    for(int i = 1; i <= N; i++)if(!vis[i])
    {
        cnt = 0;
        ele.clear();
        DFS(i);
        int now = i;
        for(int j = 0; j < ele.size(); j++)now = par[now];
        for(int j = 0; j < ele.size(); j++)
        {
            if(!loop[now])cnt++;
            loop[now] = true;
            now = par[now];
        }
        if(cnt == ele.size())
        {
            num[cnt]++;
            continue;
        }
        int sum = 1;
        for(int j = 0; j < ele.size() * 2; j++)
        {
            nxt[now] = sum;
            sum++;
            if(G[now].size() == 2)sum = 1;
            now = par[now];
        }
        for(int j = 0; j < ele.size(); j++)
        {
            if(G[ele[j]].size() >= 3)ans = 0;
            if(!loop[ele[j]] && G[ele[j]].size() >= 2)ans = 0;
            if(G[ele[j]].size() == 0)
            {
                int l = 0;
                int tmp = ele[j];
                while(!loop[tmp])
                {
                    l++;
                    tmp = par[tmp];
                }
                len[tmp] = l;
            }
        }
        for(int j = 0; j < ele.size(); j++)
        {
            int tmp = ele[j];
            if(!loop[tmp] || G[tmp].size() == 1)continue;
            if(nxt[tmp] < len[tmp])ans = 0;
            if(nxt[tmp] > len[tmp])ans *= 2;
            ans %= mod;
        }
    }

    for(int i = 1; i <= N; i++)
    {
        for(int j = 0; j <= num[i]; j++)dp[j] = 0;
        dp[num[i]] = 1;
        for(int j = num[i]; j > 0; j--)
        {
            dp[j - 1] += dp[j];
            dp[j - 1] %= mod;
            if(j - 2 >= 0)dp[j - 2] += dp[j] * (ll)(j - 1) % mod * (ll)i % mod;
            dp[j - 2] %= mod;
            if(i % 2 && i > 1)dp[j - 1] += dp[j];
            dp[j - 1] %= mod;
        }
        ans *= dp[0];
        ans %= mod;
    }

    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 11124
#include <bits/stdc++.h>
using namespace std;
int main(){
	string a,b,c1;
	cin>>a>>b;
	int c2=0,i;
	c1=a+b;
	for(i=0;i<c1.length();i++) c2*=10,c2+=c1[i]-48;
	for(i=0;i*i<=c2;i++)
		if(i*i==c2){
			cout<<"Yes";
			return 0;
		}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
cal p q r = 4*p + 9*q + r*4

chk [pp,qq,rr,cc] [s,p,q,r] =
  let c = cal p q r
  in
    (p <= pp) && (q <= qq) && (r <= rr) && (c <= cc)

ans ([0]:_) = []
ans ([n]:x) =
  let d = take n x
      t = head $ drop n x
      r = drop (n+1) x
      a = filter (chk t) d
      a'= if a == []
          then ["NA"]
          else map (\ (s:_) -> show(s) ) a
  in
    a' ++ ans r

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  mapM_ putStrLn o

Measured memory_bytes: 5792
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_N 1000000

bool f[MAX_N + 1];

void
preparation()
{
	for (int i = 0; i <= MAX_N; ++i)
		f[i] = false;

	for (int i = 1; i <= MAX_N; i *= 2)
	{
		for (int j = 1; j <= MAX_N / i; j *= 3)
		{
			for (int k = 1; k <= MAX_N / (i * j); k *= 5)
				f[i * j * k] = true;
		}
	}
}

int
main(int argc, char **argv)
{
	preparation();

	while (true)
	{
		int m, n;
		scanf("%d", &m);
		if (m == 0)
			break;

		scanf("%d", &n);
		int count = 0;
		for (int i = m; i <= n; ++i)
		{
			if (f[i])
				count++;
		}

		printf("%d\n", count);
	}

	return 0;
}


Measured memory_bytes: 2672
#include <iostream>

using namespace std;

int main()
{
	int a, b, c, x, y;
	int ans = 0;
	
	cin >> a >> b >> c >> x >> y;
	
	while (x > 0 && y > 0) {
		if ((a + b) >= (c * 2)) {
			ans += (c * 2);
			x--;
			y--;
		}
		else {
			ans += (a + b);
			x--;
			y--;
		}
	}
	while (x > 0) {
		if (a > (c * 2)) {
			ans += (c * 2);
			x--;
		}
		else {
			ans += a;
			x--;
		}
	}
	
	while (y > 0) {
		if (b > (c * 2)) {
			ans += (c * 2);
			y--;
		}
		else {
			ans += b;
			y--;
		}
	}
	
	cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll h,w;
  while(cin>>h>>w){
    if(h==0&&w==0)break;

    rep(i,0,h){
      rep(j,0,w){
        if((i+j)%2==0)cout<<'#';
        else cout<<'.';
      }
      cout<<endl;
    }
    cout<<endl;
  }


  return 0;
}



Measured memory_bytes: 3096
def f(n, m, k):
    return (n + 1) // m * (m - k) + max(0, (n + 1) - (n + 1) // m * m - k) - (1 if k == 0 else 0)

n, k = [int(x) for x in input().split()]
print(sum(f(n, m, k) for m in range(k + 1, n + 1)))

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;  ///1e9+7

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,m;
    cin>>n>>m;
    if(m%n==0) cout<<n+m<<endl;
    else cout<<m-n<<endl;


}

main()
{
//    fastio();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  ll ans = 0;
  map<pair<char, char>, int> m;
  for(int i = 1; i <= N; ++i) {
    string A = to_string(i);
    m[make_pair(A[A.size() - 1], A[0])]++;
  }
  for(int i = 1; i <= N; ++i) {
    string B = to_string(i);
    ans += m[make_pair(B[0], B[B.size() - 1])];
  }
  cout << ans << endl;
}


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

int main(void){
	int a[4];
	int b[4];
	int h,br;
	
	while(cin >> a[0] >> a[1] >> a[2] >> a[3]>> b[0] >> b[1] >> b[2] >> b[3]){
		
		h=0;
		br=0;
		
		for(int k=0;k<4;k++){
			for(int l=0;l<4;l++){
				if(a[k]==b[l]){
					if(k==l) h++;
					else br++;
				}
			}
		}
		
		cout << h << ' '<< br << endl;
	}
}

Measured memory_bytes: 1156
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    
    VL c(n - 1), s(n - 1), f(n - 1);
    REP(i, n - 1) cin >> c[i] >> s[i] >> f[i];

    REP(i, n) {
        ll ans = 0;
        FOR(j, i, n - 2) {
            if(ans <= s[j]) ans = s[j];
            else ans = (ans + f[j] - 1) / f[j] * f[j];
            ans += c[j];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] num = new int[6];
		String[] line = sc.nextLine().split(" ");
		for(int i=0;i<6;i++){
			num[i]=Integer.parseInt(line[i]);
		}
		Dice dice=new Dice(num);
		line=sc.nextLine().split(" ");
		for(int i=0;i<6;i++){
			num[i]=Integer.parseInt(line[i]);
		}
		Dice dice2 = new Dice(num);

		int upper = dice2.getUpper();
		int s = dice2.getS();
             
		if(dice.getLower()==s){
			dice.moveN();
		}else if(dice.getN()==s){
			dice.moveN();
			dice.moveN();
		}else if(dice.getE()==s){
			dice.moveE();
			dice.moveN();
		}else if(dice.getW()==s){
			dice.moveW();
			dice.moveN();
		}else if(dice.getUpper()==s){
			dice.moveS();
		}
             
		if(dice.getLower()==upper){
			dice.moveW();
			dice.moveW();
		}else if(dice.getW()==upper){
			dice.moveE();
		}else if(dice.getE()==upper){
			dice.moveW();
		}
		
		if(dice.getLower()==dice2.getLower() && dice.getUpper()==dice2.getUpper()&&
			dice.getN()==dice2.getN() && dice.getE()==dice2.getE()&&
			dice.getS()==dice2.getS() && dice.getW()==dice2.getW()){
				System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}
class Dice{
//
	private final int lavel1,lavel2,lavel3,lavel4,lavel5,lavel6;
	private int w,s,e,n;
	private int upper,lower;
//	
	Dice(int[] i){
		lavel1=i[0];
		lavel2=i[1];
		lavel3=i[2];
		lavel4=i[3];
		lavel5=i[4];
		lavel6=i[5];
		
		w=lavel4;
		s=lavel2;
		e=lavel3;
		n=lavel5;
		
		upper=lavel1;
		lower=lavel6;
	}
	
	public int getUpper(){
		return upper;
	}
	public int getW(){
		return w;
	}
	public int getS(){
		return s;
	}
	public int getE(){
		return e;
	}
	public int getN(){
		return n;
	}
	public int getLower(){
		return lower;
	}
	
	public void moveW(){
		int i=lower;
		lower=w;
		w=upper;
		upper=e;
		e=i;
	}
	public void moveS(){
		int i=lower;
		lower=s;
		s=upper;
		upper=n;
		n=i;
	}
	public void moveE(){
		int i=lower;
		lower=e;
		e=upper;
		upper=w;
		w=i;
	}
	public void moveN(){
		int i=lower;
		lower=n;
		n=upper;
		upper=s;
		s=i;
	}
}

Measured memory_bytes: 26328
#include <iostream>
using namespace std;
using ll = long long;
int main(int argc, char const *argv[]) {
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k%2==1){
    if(b-a>1000000000000000000){
      cout<<"Unfair"<<endl;
    }else{
      cout<<b-a<<endl;
    }
  }else{
    if(b-a>1000000000000000000){
      cout<<"Unfair"<<endl;
    }else{
      cout<<a-b<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

struct Edge {
  int s,t,w;
  Edge(int s, int t, int w) : s(s),t(t),w(w) {}
};
struct P {
  int s, num, w;
  P(int s, int num, int w) : s(s),num(num),w(w) {}
};
const bool operator<(const P &a, const P &b) {
  return a.w>b.w;
}
int dist[100][100];

int main() {
  int n, m, c;
  while(cin>>n>>m>>c,n||m||c) {
    vector<Edge> g[n];
    REP(i,m) {
      int a,b,d;
      cin>>a>>b>>d;
      a--;b--;
      g[a].push_back(Edge(a,b,d));
    }
    REP(i, n) {
      REP(j, n) {
        dist[i][j] = INF;
      }
    }
    priority_queue<P> Q;
    Q.push(P(0,0,0));
    int ans = INF;
    while(!Q.empty()) {
      P e = Q.top(); Q.pop();
      //cout << e.s << " " << e.num << " " << e.w << endl;
      if (e.s == n-1 && e.w < c) {
        ans = min(ans, e.num);
      }
      if (dist[e.s][e.num] < e.w) continue;
      FOR(f, g[e.s]) {
        if (e.num+1 < n && dist[f->t][e.num+1] > e.w) {
          dist[f->t][e.num+1] = e.w;
          Q.push(P(f->t, e.num+1, e.w));
        }
        if (e.w+f->w <= c) {
          if (dist[f->t][e.num] > e.w+f->w) {
            dist[f->t][e.num] = e.w+f->w;
            Q.push(P(f->t, e.num, e.w+f->w));
          }
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

int main() {
  int n;
  cin >> n;
  vector<int> a(n+1);
  rep(i,n) cin >> a[i+1];
  vector<int> b(n+1);
  for (int i = n; i >= 1; --i) {
    int sum = 0;
    for (int j = i+i; j <= n; j += i) {
      sum ^= b[j];
    }
    b[i] = sum^a[i];
  }
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (b[i]) ans.push_back(i);
  }
  cout << ans.size() << endl;
  rep(i,ans.size()) {
    printf("%d%c", ans[i], i+1==ans.size()?'\n':' ');
  }
  return 0;
}



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

int main() {
	int N; int K;
	cin >> N >> K;
	vector<char> text(N);
	for (int i = 0; i < N; i++) {
		cin >> text.at(i);
	}
	text.at(K - 1) = tolower(text.at(K - 1));
	for (int i = 0; i < N; i++) {
		cout << text.at(i);
	}
	cout << endl;
}

Measured memory_bytes: 256
import itertools
import math
n=int(input())
l=[list(map(float,input().split())) for _ in range(n)]

N=[x for x in range(n)]

p_list = itertools.permutations(N)
n_num=math.factorial(n)

ans = 0
for i in p_list:
    step = 0
    j_prev = 0
    len = 0
    for j in i:
        if step == 0:
            j_prev=j
            step = 1
            continue
        len += math.sqrt((l[j][0]-l[j_prev][0])**2+(l[j][1]-l[j_prev][1])**2)
        j_prev=j
    ans += len/n_num
print(ans)       

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;
#define PI 3.14159265358979
double a, b, x;

void solve() {
  double deg;
  if (x < b*a*a/2) {
    deg = atan((b * b * a / 2.0) / x) * 180 / PI; 
  } else {
    deg = atan(2.0 * (a * a * b - x) / (a * a * a)) * 180 / PI;
  }
  cout << setprecision(10) << deg << endl;
}

int main() {
  cin >> a >> b >> x;
  solve();
}


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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i = 0;i<N;i++){
    cin >> A[i];
  }
  cout << 1+ (N-2)/(K-1) << endl;
}

Measured memory_bytes: 640
from collections import deque


def main():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())
    S = [input() for _ in range(H)]

    Q = deque([[Ch - 1, Cw - 1, 0]])  # 座標とワープ回数

    cost = [[-1 for _ in range(W)] for _ in range(H)]  # ワープ回数を記録

    while Q:
        r, c, cnt = Q.popleft()

        if cost[r][c] != -1:  # 訪れたことがある
            continue

        cost[r][c] = cnt

        for dr in range(-2, 3):
            for dc in range(-2, 3):
                nr = r + dr
                nc = c + dc

                if 0 <= nr < H and 0 <= nc < W and S[nr][nc] == ".":
                    if abs(dr) + abs(dc) == 1:  # 上下左右
                        Q.appendleft([nr, nc, cnt])
                    elif abs(dr) + abs(dc) >= 2:  # ワープ
                        Q.append([nr, nc, cnt + 1])

    print(cost[Dh - 1][Dw - 1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 237384
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

const int N = 600;

class S{
public:
  int y, x, c;
  S() : y(0), x(0), c(0) {}
  S(int y, int x, int c) : y(y), x(x), c(c) {}
};

int t, n, sy, sx;
bool mapData[N][N];
bool visited[N][N];
int dy[] = {1, 0, -1, -1, 0, 1};
int dx[] = {1, 1, 0, -1, -1, 0};

void bfs(){
  fill(visited[0], visited[N], false);
  S u;
  queue<S> q;
  q.push(S(sy, sx, 0));
  visited[sy][sx] = true;
  while(!q.empty()){
    u = q.front(); q.pop();
    for(int i=0;i<6;i++){
      int ny = u.y + dy[i];
      int nx = u.x + dx[i];
      if(!mapData[ny][nx]) continue;
      if(visited[ny][nx]) continue;
      visited[ny][nx] = true;
      if(u.c+1 < t) q.push(S(ny, nx, u.c+1));
    }
  }
}


main(){
  while(cin >> t >> n && (t|n)){
    fill(mapData[0], mapData[N], true);
    for(int i=0;i<n;i++){
      int y, x;
      cin >> x >> y; 
      mapData[y+N/2][x+N/2] = false;
    }
    cin >> sx >> sy;
    sx += N/2;
    sy += N/2;
    bfs();
    int ans = 0;
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        if(visited[i][j]) ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def invmod(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

n, k = map(int, input().split())
c = 10**9 + 7
if k >= n-1:
    a = 2*n - 1
    ans = a
    temp = a
    for i in range(1, n-1):
        temp = temp*(a-i) % c
        temp = temp*invmod(i+1, c) % c
    print(temp)
else:
    temp1 = n
    temp2 = n-1
    ans = 1 + (temp1 * temp2) % c
    for i in range(1, k):
        temp1 = temp1*(n-i) % c
        temp2 = temp2*(n-i-1) % c
        inv = invmod(i+1, c)
        temp1 = temp1*inv % c
        temp2 = temp2*inv % c
        
        ans += (temp1 * temp2) % c
    print(ans%c)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        if(x < a){
            System.out.print(0);
        }else{
            System.out.print(10);
        }
        sc.close();
    }
}

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

int BubbleSort(int *A,int N)
{
	//ソートカウント
	int count = 0;

	for (int j = N - 1; j > 0; j--) {
		for (int i = 0; i < j; i++) {
			if (A[i] > A[i + 1]) {
				std::swap(A[i], A[i + 1]);
				count++;
			}
		}
	}
	
	return count;
}


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

	int count = BubbleSort(A,N);

	for (int i = 0; i < N; i++) {
		cout << A[i];
		if (i == N - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}
	cout << count << endl;
	return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int n;
int a[100010];

bool cand(int total){
	int uniq = 0, dupl = 0;
	rep(i,n){
		if(a[i]+1 == total)
			uniq++;
		else if(a[i]==total)
			dupl++;
		else
			return false;
	}

	if(dupl == 1) return false;

	const int lower = uniq + min(dupl,1);
	const int upper = uniq + dupl/2;
	return lower <= total and total <= upper;
}

int main(void){
	cin >> n;
	rep(i,n) cin >> a[i];

	if(cand(a[0]) or cand(a[0]+1))
		puts("Yes");
	else
		puts("No");

	return 0;
}

Measured memory_bytes: 640
from collections import deque
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
pos = []
neg = []
for a in A:
    if a >= 0:
        pos.append(a)
    else:
        neg.append(-a)
pos = deque(sorted(pos))
neg = deque(sorted(neg))
mod = 10**9 + 7
ans = 1
sign = 1
if K % 2 == 1:
    if len(pos) > 0:
        ans = ans * pos.pop() % mod
    else:
        ans = ans * neg.popleft() % mod
        sign *= -1
    K -= 1
while K > 0:
    if len(pos) == 1 and len(neg) == 1:
        ans = ans * -neg.pop() * pos.pop() % mod
    elif sign == 1:
        if len(pos) < 2 or (len(neg) >= 2 and pos[-2] * pos[-1] < neg[-2] * neg[-1]):
            ans = ans * neg.pop() * neg.pop() % mod
        else:
            ans = ans * pos.pop() * pos.pop() % mod
    else:
        if len(pos) < 2 or (len(neg) >= 2 and pos[-2] * pos[-1] < neg[-2] * neg[-1]):
            ans = ans * neg.popleft() * neg.popleft() % mod
        else:
            ans = ans * pos.popleft() * pos.popleft() % mod
    K -= 2
ans = ans * sign % mod
print(ans)

Measured memory_bytes: 107992
k, a, b = map(int, input().split())
if b <= a + 2:
    print(k + 1)
elif k <= a - 1:
    print(k + 1)
else:
    ans = 0
    nokori = k

    ans += (a - 1)
    nokori -= (a - 1)

    ans += (b - a) * ((k - (a - 1)) // 2)
    nokori -= 2 * ((k - (a - 1)) // 2)


    ans += nokori


    print(ans+1)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
unordered_map<int,int>p;
int ans;
int n,m;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		for(int i=1;i<=x;i++){
			int x;
			scanf("%d",&x);
			p[x]++;
			if(p[x]==n)ans++;
		}
	}
	printf("%d\n",ans);
}

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

int main() {
  int x1, y1, x2, y2;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  int dx = x2 - x1, dy = y2 - y1,
      x3 = - dy + x2, y3 = dx + y2,
      x4 = -dy + x1, y4 = dx + y1;

  printf("%d %d %d %d\n", x3, y3, x4, y4);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,x,ans=0,n,m;
int main()
{
    cin>>a>>b>>x;
    if(a%x==0) n=a/x;
    else n=a/x+1;
    m=b/x;
    cout<<m-n+1<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll cnt = 0;
  rep(i,n) {
    if (i%2 == 0 && a[i]%2 == 1) ++cnt; 
  }
  cout << cnt << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3656
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char[] s = sc.next().toCharArray();
		System.out.println(s[2]==s[3]&&s[4]==s[5] ? "Yes" : "No");
		
		sc.close();
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#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;

bool kp(vector<ll> a,ll p,ll k){
	ll n = a.size();
	vector<ll> x;
	for(ll i = 0; i < n; i++){
		if(i!= p) x.push_back(a[i]);
	}

	bool dp[5005] = {false};
	dp[0] = true;
	for(ll i = 0; i < x.size(); i++){
		for(ll j = k-1; j >= 0; j--){
			if(j-x[i]>= 0 && dp[j-x[i]] == true) dp[j] = true;
		}
	}
	for(ll j = max((ll)0,k-a[p]); j <= k-1 ; j++){
		if(dp[j]) return true;
	}

	return false;
}

int main()
{
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	for(ll i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(all(a));

	ll l = -1,u = n;
	while(u-l>1){
		ll mid = (u+l)/2;
		if(kp(a,mid,k)){
			//cout <<"yes" << endl;
			u = mid;
		}
		else l = mid;
		//cout << a[mid] << endl;
	}

	cout << u << endl;

	return 0;
}

Measured memory_bytes: 492
n = int(input())
#n = 417
x=n//100
y=n%100
#print(x)
#print(y)
seq = (1,2,3,4,5)
exists = False

for i in seq:
    sum = 0
    z = y%i
    #print( 'z = ' + str(z))
    if z == 0:
        sum = y//i
        #print(sum)
        #print('a')
    else:
        sum = (y//i) + 1
        #print(sum)
    if sum <= x:
        print('1')
        exists =True
        break

if not exists:
    print('0')

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

int main () {
    string S;
    cin >> S;

    if (S == "Sunny")
        cout << "Cloudy" << endl;
    else if (S == "Cloudy")
        cout << "Rainy" << endl;
    else
        cout << "Sunny" << endl;

    return 0;
}

Measured memory_bytes: 256
from itertools  import product, permutations

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

D = [list(map(int, input().split())) for _ in range(C)]

c = [list(map(lambda x: int(x)-1, input().split())) for _ in range(N)]

res = 1000*N*N

cnt = [[0]*C for _ in range(3)]


for i,j in product(range(N), range(N)):
    cnt[(i + j)%3][c[i][j]] += 1

for c1, c2, c3 in permutations(range(C), 3):
    score = 0
    for cc, cn in enumerate(cnt[0]):
        score += cn*D[cc][c1]
    for cc, cn in enumerate(cnt[1]):
        score += cn*D[cc][c2]
    for cc, cn in enumerate(cnt[2]):
        score += cn*D[cc][c3]
    if res > score:
        res = score

print(res)



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

int n,m,o;
int k;
int fd[39];
int a;
int sum;
int main() {
	scanf("%d %d",&n,&m);
	o=n;
	while(o--) {
		scanf("%d",&k);
		while(k--) {
			scanf("%d",&a);
			fd[a]++;
		}
	}
	for(int i=1; i<=m; i++) {
		if(fd[i]==n) {
			sum++;
		}
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 384
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  int N;
  cin >> N;
  vector<int> P(N+1);
  vector<pll> v;
  srep(i,1,N+1){
    cin >> P[i];
    v.push_back({P[i], i});
  }
  //注意！iは1~N

  sort(v.begin(), v.end(), greater<pll>());

  int l1, l2, r1, r2;
  long sum=0;
  multiset<int> st;
  st.insert(0);
  st.insert(0);
  st.insert(N+1);
  st.insert(N+1);
  st.insert(v[0].second);
  //st.insert(v[1].second);
  srep(i,1,N){
    auto itr=st.lower_bound(v[i].second);
    r1=*itr;
    itr++;
    r2=*itr;
    itr--;
    itr--;
    l1=*itr;
    itr--;
    l2=*itr;
    sum+=((l1-l2)*(r1-v[i].second)+(r2-r1)*(v[i].second-l1))*v[i].first;
    st.insert(v[i].second);
  }

  cout << sum << endl;


}


Measured memory_bytes: 7408
#include <stdio.h>
#include <string.h>
#include <limits.h>

#define MIN(A,B) \
  ( (A) < (B) ? (A) : (B) )

struct
{
  char name[ 128 ];
  int  value;
}   item[ 128 ];
int item_count;

struct
{
  char name[ 128 ];
  char need[ 128 ][ 128 ];
  int  need_count;
} recipe[ 128 ];
int recipe_count;

static int
solve (
  const char * name
  )
{
  int res = INT_MAX;
  int i, j;

  for ( i = 0; i < item_count; ++i )
  {
    if ( strcmp ( name, item[ i ].name ) )  continue;

    res = MIN( res, item[ i ].value );
  }

  for ( i = 0; i < recipe_count; ++i )
  {
    int tmp = 0;

    if ( strcmp ( name, recipe[ i ].name ) ) continue;

    for ( j = 0; j < recipe[ i ].need_count; ++j )
    {
      const int G__1 = solve ( recipe[ i ].need[ j ] );
      if ( tmp  == INT_MAX
        || G__1 == INT_MAX ) tmp = INT_MAX;
      else tmp += solve ( recipe[ i ].need[ j ] );
    }

    res = MIN ( res, tmp );
  }

  return ( res );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    char require[ 128 ];

    scanf ( " %d", &item_count );
    if ( !( item_count ) )  break ;

    for ( i = 0; i < item_count; ++i )
    {
      scanf ( " %s %d", item[ i ].name, &item[ i ].value );
    }
    scanf ( " %d", &recipe_count );
    for ( i = 0; i < recipe_count; ++i )
    {
      scanf ( " %s %d", recipe[ i ].name, &recipe[ i ].need_count );
      for ( j = 0; j < recipe[ i ].need_count; ++j )
      {
        scanf ( " %s", recipe[ i ].need[ j ] );
      }
    }
    scanf ( " %s", require );

    printf ( "%d\n", solve ( require ) );
  }

  return ( 0 );
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.TreeSet;
import java.util.Arrays;
public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
           String s;
           while(true){
          s=sc.next();
          if(s.equals("-"))break;
          int m=sc.nextInt();
          for(int i=0;i<m;i++){
            int h=sc.nextInt();
            String x=s.substring(0,h);
            String y=s.substring(h);
            s=y+x;
          }
          System.out.println(s);
           }
}
}



Measured memory_bytes: 26676
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}


signed main(){
	
	ll A[5] = {0},B[5] = {0},C[5] ={0};
	ll a,b,c,ans = 0,cnt = 0,memo = 0;
	string s,t;
	bool flag = false;
	
	cin >> s;
	
	rep(i,0,s.size()){
		if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C'){
			cnt++;
		}
		else{
			if(cnt > ans) ans = cnt;
			cnt = 0;
		}
	}
	
	if(cnt > ans) ans = cnt;
	
	cout << ans << endl;
	
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N, K;
const ll MAX_K = 10;
ll D[MAX_K];

bool check(int n) {
  while(n) {
    REP(i, K) {
      if(n % 10 == D[i]) {
        return false;
      }
    }
    n /= 10;
  }
  return true;
}

int main(){
  cin >> N >> K;
  REP(i, K) {
    cin >> D[i];
  }
  
  ll a = N;
  while(!check(a)) {
    a++;
  }

  cout << a << endl;

  return 0;
}


Measured memory_bytes: 256
// 解き直し.
// https://img.atcoder.jp/arc064/editorial.pdf
// テストケース(1_12.txt) などで, TLE版となったため, ロジック修正.
// AtCoder Beginner Contest 051 (D - Candidates of No Shortest Paths) で 実装した ダイクストラ法 を 一部流用.
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define a first
#define b second
// cost を 2次元配列 から 1次元配列 に 変更.
double cost[1010];                // 頂点 0 から 各頂点まで の 最小コスト を 保存.
double x[1010], y[1010], r[1010]; // バリア情報.
double b[1010][1010];             // バリア i, j の 中心を結ぶ辺のコスト.

struct edge {
    int u;    // 次の頂点.
    double d; // コスト.
    bool operator < (const edge &E) const { return d > E.d; }
};

vector<edge> G[1010];

// https://ja.wikipedia.org/wiki/ダイクストラ法
// グラフを最良優先探索する.
// ※dijkstraの動作確認用.
// @param s: 今回探索する頂点番号.
// @return: 特に無し.
void dijkstra(int s){
    
    // 1. 初期化.
    priority_queue<edge> pq;
    
    // 2. 始点設定.
    pq.push({s, 0.0});
    cost[s] = 0.0;
    
    // 3. キュー pq が 空になるまで, 探索.
    while(!pq.empty()){
        // 4. 探索を継続するために, 頂点を取得.
        int u = pq.top().u;    // 頂点番号.
        double d = pq.top().d; // コスト.
        pq.pop();
        
        // 5. より小さいコストが設定済みなら, Skip.
        if(cost[u] < d) continue;
        
        // 6. 各隣接する頂点について, コストを確認し, 最短コストを更新.
        rep(i, G[u].size()){
            int nu = G[u][i].u;
            double nd = d + G[u][i].d;
            // 最短コスト更新.
            if(cost[nu] > nd) cost[nu] = nd, pq.push({nu, nd});
        }
    }
}

int main(){
    
    // 1. 入力情報.
    double xs, ys, xt, yt;
    int N;
    scanf("%lf %lf %lf %lf %d", &xs, &ys, &xt, &yt, &N);
    rep(i, N) scanf("%lf %lf %lf", &x[i + 1], &y[i + 1], &r[i + 1]);
    x[0] = xs, y[0] = ys, x[N + 1] = xt, y[N + 1] = yt;
    
    // 2. 辺のコストを事前計算.
    rep(i, N + 1){
        repx(j, i + 1, N + 2){
            double w = max(0.0, hypot(x[i] - x[j], y[i] - y[j]) - (r[i] + r[j]));
            b[i][j] = w;
            b[j][i] = w;
        }
    }
    
    // 3. グラフ作成.
    // 頂点が, 0, 1, ... , N, N + 1 までの (N + 2)頂点あると見る.
    rep(i, N + 1){
        repx(j, i + 1, N + 2){
            G[i].pb({j, b[i][j]});
            G[j].pb({i, b[j][i]});
        }
    }
    
    // 4. ダイクストラ法.
    rep(i, 1010) cost[i] = 202020202020202020.0;
    dijkstra(0);
    
    // 5. 出力.
    printf("%.10f\n", cost[N + 1]);
    return 0;
    
}

Measured memory_bytes: 31828
def main():
    n = int(input())
    d = {}
    ans = 0
    
    for _ in range(n):
        ss = ''.join(sorted(input()))
        d[ss] = d.get(ss, 0) + 1
        
    for k, v in d.items():
        if v != 1:
            ans += (v*(v-1)) // 2
         
    print(ans)
       
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 17852
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;
    cin >> n;
    for(int i = 0; i < n ; i++) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3876
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<ll> a(N), x(Q);
  rep(i, N) cin >> a[i];
  rep(i, Q) {
    ll x;
    cin >> x;
    ll ans = 0;

    // 区間の左端 left で場合分け
    int right = 0;  // 毎回 right を使い回す
    ll tot = 0;     // tot も使い回す
    rep(left, N) {
      // tot に a[right] を加えても大丈夫なら right を動かす
      while (right < N && tot + a[right] <= x) {
        tot += a[right];
        right++;
      }

      ans += (right - left);

      // left を increment する準備
      if (right == left)
        // right が left に重なったら right も動かす
        right++;
      else
        // left のみが increment されるので sum から a[left] を引く
        tot -= a[left];
    }

    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3552
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<tuple>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1LL << 62);
ll n,k, m, t,q,h1,h2,m1,m2; string s;
const ld PI = acos(-1);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int main() {
    cin >> s;
    if (s[0] == '?') s[0] = 'D';
    req(i, s.size() - 1) {
        if (s[i] == '?') {
            if (s[i - 1] == 'D') s[i] = 'D';
            else s[i] = 'D';
        }
    }cout << s << endl;
}

Measured memory_bytes: 3724
#include <stdio.h>
#include <string.h>

typedef int		BOOL;
#define TRUE	1;
#define FALSE	0;

typedef struct Word{
	char	word[31];
	int		page;
}	WORD;

WORD wordArray[100];

void input();
	BOOL is_smaller(WORD, int);
void output();

int main()
{
    input();
    output();
	
	return 0;
}

void input()
{
	int 	cnt1, cnt2;
	WORD	tempWORD;
	
	while(scanf("%s %d", tempWORD.word, &tempWORD.page) != EOF){
		for(cnt1 = 0; cnt1 < 100; cnt1++){
			if(wordArray[cnt1].page == 0){
				strcpy(wordArray[cnt1].word, tempWORD.word);
				wordArray[cnt1].page = tempWORD.page;
				break;
			}
			else if(is_smaller(tempWORD, cnt1)){
				for(cnt2 = 98; cnt2 >= cnt1; cnt2--){
					strcpy(wordArray[cnt2 + 1].word, wordArray[cnt2].word);
					wordArray[cnt2 + 1].page = wordArray[cnt2].page;
				}
				strcpy(wordArray[cnt1].word, tempWORD.word);
				wordArray[cnt1].page = tempWORD.page;
				break;
			}
		}
	}
}

BOOL is_smaller(WORD tempWORD, int cnt)
{
	if(strcmp(tempWORD.word, wordArray[cnt].word) < 0)
	{
		return TRUE;
	}
	else if(strcmp(tempWORD.word, wordArray[cnt].word) == 0)
	{
		if(tempWORD.page < wordArray[cnt].page)
		{
			return TRUE;
		}
		else
		{
			return FALSE;
		}
	}
	else
	{
		return FALSE;
	}
}

void output()
{
	int		output_cnt = 0;
	char	last_print_word[31] = "";

	while(wordArray[output_cnt].page != 0)
	{
		if(strcmp(last_print_word, "") == 0)
		{
			printf("%s\n", wordArray[output_cnt].word);
			strcpy(last_print_word, wordArray[output_cnt].word);
		}
		else if(strcmp(wordArray[output_cnt].word, last_print_word) != 0)
		{
			printf("\n%s\n", wordArray[output_cnt].word);
			strcpy(last_print_word, wordArray[output_cnt].word);
		}
		else
		{
			printf(" ");
		}
		printf("%d", wordArray[output_cnt].page);
		output_cnt++;
	}
	printf("\n");
}

Measured memory_bytes: 640