akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
int H,W;
vector<string> s;
string ans;
string ddr="URDL";
int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};	//URDL
bool on(int x,int y){
	return 0<=x&&x<H&&0<=y&&y<W;
}
bool dfs(int x,int y,int di,int cnt,vector<string> s){
/*	rep(i,H) cout<<s[i]<<endl;
	show(cnt);
	puts("");*/
	if(cnt==0) return true;
	for(int nd=(di+3)%4;nd!=(di+2)%4;nd=(nd+1)%4){
		int nx=x,ny=y;
		while(on(nx,ny)){
			if(s[nx][ny]=='o'){
				s[nx][ny]='.';
				if(dfs(nx,ny,nd,cnt-1,s)){
					ans=ddr[nd]+ans;
					return true;
				}
				s[nx][ny]='o';
				break;
			}
			nx+=dx[nd],ny+=dy[nd];
		}
	}
	return false;
}
int main(){
	cin>>H>>W;
	rep(i,H){
		string st;
		cin>>st;
		s.pb(st);
	}
	int sx,sy,di,cnt=0;
	rep(i,H) rep(j,W){
		if(s[i][j]=='o') cnt++;
		if(s[i][j]=='U') sx=i,sy=j,di=0,s[i][j]='.';
		if(s[i][j]=='R') sx=i,sy=j,di=1,s[i][j]='.';
		if(s[i][j]=='D') sx=i,sy=j,di=2,s[i][j]='.';
		if(s[i][j]=='L') sx=i,sy=j,di=3,s[i][j]='.';
	}
	dfs(sx,sy,di,cnt,s);
	cout<<ans<<endl;
}

Measured memory_bytes: 1228
#include <iostream>
#include <list>
#define ROOP(N) for(int i=0; i<N; i++)
using namespace std;

list<char> allStack;

void debug()
{
	int len = allStack.size();
	//cout << "=>";
	for (auto itr = allStack.begin(); itr != allStack.end(); ++itr) {
		std::cout << *itr;
	}
	//cout << "\n";
}

int min(int* arr, int len)
{
	int min = 1000;
	ROOP(len) {
		if (arr[i] < min) min = arr[i];
	}
	return min;
}

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

	int* prefixLength;
	prefixLength = (int*)malloc(sizeof(int)*N);
	int leftBracket = 0;
	char input;
	ROOP(N) {
		cin >> input;
		if (input == '(') {
			leftBracket++;
		}
		else{
			if (leftBracket > 0)
				leftBracket--;
			else
				allStack.push_front('(');
		}
		allStack.push_back(input);
	}

	ROOP(leftBracket) {
		allStack.push_back(')');
	}
	debug();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
const int64_t INF=9999999999999999;
int main() {
 int N;
 string S;
 cin>>N>>S;
 string x=S.substr(0,S.size()/2);
 x+=x;
 if(S==x){cout<<"Yes"<<endl;}
 else{cout<<"No"<<endl;}
 return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5+1;
const long inf=1e14;
int main(){
	int N;cin>>N;
	int a;int id[N+1];
	rep(i,1,N+1){ cin>>a; id[a] = i; }
	long ans = 0; long x,y;
	set<long> st;
	st.insert(0); st.insert(N+1);
	rep(i,1,N+1){
		st.insert(id[i]);
		auto it = st.find(id[i]);
		it--; x = *it;
		it++; it++; y = *it;
		ans += (id[i] - x) * (y - id[i]) * i;
	}cout<<ans<<endl;
}

Measured memory_bytes: 10368
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<tuple>
#include<sstream>
#include<functional>
#include<list>
#include<queue>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> p;
typedef pair<int, pair<int, pair<int, int>>> PP;
typedef vector<int> vec;
using Graph = vector<vector<int>>;
using graph = vector<vector<ll>>;

const long long INF = 1LL << 60;
const int inf = 1e9;
const long long MOD = 1e9+7;

ll dp[2001] = {};

int main() {
	ll s;
	cin >> s;
	dp[4] = 1; dp[5] = 1; dp[3] = 1;
	repd(i, 6, s + 1) {
		repd(j,3, i - 2) {
			dp[i] = (dp[i] + dp[j]) % MOD;
		}
		dp[i]++;
	}
	cout << dp[s]%MOD << endl;
	return 0;
}

Measured memory_bytes: 3148
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    const int MAX_N = 100000;
    int N, K, A[MAX_N];
    cin >> N >> K;
    REP(i, N) {
        cin >> A[i];
    }
    N -= K;
    int res = 1;
    while (N > 0) {
        res++;
        N -= (K - 1);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

long long pow(long long a, int n) {
  long long ret = 1;
  for (int i = 0; i < n; i++) {
    ret *= a;
  }
  return ret;
}

void solve(long long N, long long K){
    long long n_mod0 = 0;
    long long n_mod_half = 0;
    n_mod0 = N / K;
    if (K%2==0) {
      n_mod_half = n_mod0;
      if (N%K >= K/2) {
        n_mod_half++;
      }
    }
    long long ret;
    ret = pow(n_mod0, 3);
    ret += pow(n_mod_half, 3);
    std::cout << ret << std::endl;
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long N;
    long long K;
    scanf("%lld",&N);
    scanf("%lld",&K);
    solve(N, K);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 632
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] w = {"Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
				"Friday"};
		while(sc.hasNext()) {
			int m = sc.nextInt();
			int d = sc.nextInt();
			int k;
			if(m == 1 || m == 2) {
				m = 12 + m;
				k = -1;
			}else {
				k = 0;
			}
			if(m == 0)break;
			System.out.println(w[zeller(2004 + k, m, d)]);
		}
		sc.close();
	}
	static int zeller(int y, int m, int d) {
		int Y = y % 100;
		int C = y / 100;
		int t1 = d;
		int t2 = (26 * (m + 1)) / 10;
		int t3 = Y + Y / 4;
		int t4 = 5 * C + C / 4;
		return (t1 + t2 + t3 + t4) % 7;
	}
}


Measured memory_bytes: 26116
#include<iostream>

using namespace std;

int main() {

	int K, S, res = 0;

	cin >> K >> S;

	for (int i = 0; i <= K; i++) {
		if (i + K + K < S)continue;
		else if (i + K + K == S) {
			res++;
			continue;
		}
		else if (i + 0 + 0 > S)break;

		for (int j = 0; j <= K; j++) {
			if (i + j + K < S)continue;
			else if (i + j + K == S) {
				res++;
				continue;
			}
			else if (i + j + 0 > S)break;

			int q = S - i - j;
			if (q <= K && q >= 0)res++;
		}
	}

	cout << res << endl;
	return 0;
}

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


int main(){
    int D, G;
    cin >> D >> G;
    int p[10], c[10];
    for(int i = 0; i < D; i++){
        cin >> p[i] >> c[i];
    }
    //cout << "debug";
    int ans = 100000;
    for(int i = 0; i < (1 << D); i++){
        int tmpCnt = 0, tmpScore = 0;
        for(int j = 0; j < D; j++){
            if((1 << j) & i){
                tmpCnt += p[j];
                tmpScore += p[j] * (j+1) * 100 + c[j];
            }
        }
        for(int j = D-1; tmpScore < G && j >= 0; j--){
            if((1 << j) & i){
                continue;
            }else{
                int problemScore = (j+1) * 100;
                int plusCnt = min(p[j], (G - tmpScore + problemScore - 1) / problemScore);
                tmpScore += plusCnt * problemScore;
                tmpCnt += plusCnt;
            }
        }
        ans = min(ans, tmpCnt);
    }
    cout << ans << endl;
}


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

int main() {
  int N, A, X;
  cin >> N >> A;
  vector<long> DP(5001);
  DP.at(2500) = 1;
  while (cin >> X) {
    X -= A;
    if (X > 0) for (int i = 5000; i >= X; i--) DP.at(i) += DP.at(i - X);
    else for (int i = 0; i - X <= 5000; i++) DP.at(i) += DP.at(i - X);
  }
  cout << DP.at(2500) - 1 << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  while(cin >>s){
    int sum = 0, x = 1000, r;
    for(int i=0; i<s.size(); i++){
      if(s[i] == 'I'){r = 1;}
      if(s[i] == 'V'){r = 5;}
      if(s[i] == 'X'){r = 10;}
      if(s[i] == 'L'){r = 50;}
      if(s[i] == 'C'){r = 100;}
      if(s[i] == 'D'){r = 500;}
      if(s[i] == 'M'){r = 1000;}
      if(x>=r){sum+=r;x = r;}
      else{sum+=r-2*x;}
    }
    cout <<sum<<endl;
  }
  return 0;
}

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

using namespace std;

bool snuke_has_snack[105];

int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int snuke;
			cin >> snuke;
			snuke_has_snack[snuke] = true;
		}
	}
	int snukes_with_snacks = 0;
	for (int i = 1; i <= n; i++) {
		if (snuke_has_snack[i])
			snukes_with_snacks += 1;
	}
	cout << n - snukes_with_snacks << "\n";
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
struct edge {int u, v, color;};
void dfs(int u, int prev_color, auto& ans, const auto& g) {
  int color = 1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (color == prev_color) color++;
    ans[{u,v}] = color;
    dfs(v, color, ans, g);
    color ++;
  }
}
int main() {
  int N;
  cin >> N;
  vector<vector<int>> g(N);
  vector<pair<int, int>> edges(N - 1);
  vector<int> in(N);
  for (int i = 0; i < N - 1; i++) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    edges[i] = {u, v};
    in[v] ++;
  }

  int root = -1;
  for (int i = 0; i < N; i++) {
    if (!in[i]) root = i;
  }

  map<pair<int, int>, int> ans;
  dfs(root, 0, ans, g);

  int k = 0;
  for (auto& x : ans) {
    k = max(k, x.second);
  }

  cout << k << endl;
  for (auto& p : edges) {
    cout << ans[p] << endl;
  }
}


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

struct Mystruct
{
    long long atack;
    long long mp;
    double cost;

    Mystruct(long long input_a, long long input_b)
    {
        atack = input_a;
        mp = input_b;
        cost = input_a * 1.0 / input_b;
    }
    bool operator<(const Mystruct &another) const
    {
        if (cost == another.cost)
        {
            return mp < another.mp;
        }
        return cost < another.cost; //年齢を比較
    };
};

int main()
{
    string s;
    cin>>s;
    int n = s.length();

    string ans;
    REP(i,n){
        ans+='x';
    }

    ANS(ans)
    return 0;
}


Measured memory_bytes: 256
let n, k = Scanf.scanf " %d %d" @@ fun a b -> a, b
let ps = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let s, ms = ref 0, ref 0
let _ = Array.iteri (fun i p -> s := !s + p - if i >= k then ps.(i - k) else 0; ms := max !ms !s) ps; Printf.printf "%.12f\n" @@ float (!ms + k) /. 2.

Measured memory_bytes: 6016
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    auto tx = aryread!double();
    writeln(tx[0] / tx[1]);
}


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

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

	int n;

	cin >> n;

	if(n%2==0)
	{
		cout << n/2-1 << '\n';
	}
	else
	{
		cout << n/2 << '\n';
	}
	
	return 0;
}


Measured memory_bytes: 256
from collections import deque
n = int(input())
a = input().split()
b = deque()


for i in range(0,n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
if n % 2 != 0:
    b.reverse()

print(*b)


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

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define fo(i, a, b, k) for(int i = a; i <= b; i += k)
#define _fo(i, a, b, k) for(int i = a; i >= b; i -= k)
#define foa(i, a) for (auto &i : a)
#define fod(i, a) for(int i = 1; i*i <= a; i++)
#define sz(a) ((int) a.size())
#define all(a) begin(a), end(a)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mk(x, y) make_pair(x, y)  
#define log2i(x) (31-__builtin_clz(x))
#define log2ll(x) (63-__builtin_clzll(x)) 
#define msz(x) __builtin_popcount(x) 
#define mszll(x) __builtin_popcountll(x) 
#define fom(i, a, b) for(int i = a; i < (1<<b); i++)
#define ifon(i, mask) if(mask&(1<<i))
#define ss(i, mask) while(i=(i-mask)&mask)
#define ifss(i, mask) if(i > (mask^i)) 

typedef int64_t ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MAX = 1e5+1;
const int MOD = 1e9+7;
const ll INF = INT_MAX;
const ll _INF = INT_MIN;

int k, x;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> k >> x;
	int l = max(-1000000, x-k+1), r = min(1000000, x+k-1);
	
	fo(i, l, r, 1) cout << i << " ";
}

Measured memory_bytes: 256
def func():
    h,w = map(int, input().split())
    S = ['.' + input() + '.' for _ in range(h)]
    S.insert(0,'.'*(w+2))
    S.append('.'*(w+2))
    
    for r in range(1, h+1):
        for c in range(1, w+1):
            if S[r][c] == '.':
                count = 0
                count += S[r-1][c-1:c+2].count('#')
                count += S[r][c-1:c+2].count('#')
                count += S[r+1][c-1:c+2].count('#')
                print(count, end='')
            else:
                print('#', end='')
        print()

if __name__ == '__main__':
    func()


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

const int combination_max=1000000+1000000+2;
const int combination_modulo=1000000007;
vector<int64_t> factorials(combination_max);
vector<int64_t> factorials_inv(combination_max);
vector<int64_t> inverse(combination_max);
int combination_mod(int n, int k);
int prepare_combination_mod();

int main()
{
	int x,y;
	cin >> x >> y;

	if ( ((2*x-y)%3!=0) && ((2*y-x)%3!=0) )
	{
		cout << 0 << endl;
		return 0;
	}

	int n1,n2;
	n2=(2*x-y)/3;
	n1=(2*y-x)/3;

	if ((n1<0)||(n2<0))
	{
		cout << 0 << endl;
		return 0;
	}

	prepare_combination_mod();
	cout << combination_mod(n1+n2,n1) << endl;
}

int prepare_combination_mod()
{
	factorials[0]=1;
	factorials[1]=1;
	factorials_inv[0]=1;
	factorials_inv[1]=1;
	inverse[1]=1;
	for (int i=2;i<combination_max;++i)
	{
		factorials[i]=factorials[i-1]*i%combination_modulo;
		inverse[i]=combination_modulo - inverse[combination_modulo%i]*(combination_modulo/i)%combination_modulo;
		factorials_inv[i]=factorials_inv[i-1]*inverse[i]%combination_modulo;
	}
	return 0;
}

int combination_mod(int n, int k)
{
	return factorials[n]*(factorials_inv[k]*factorials_inv[n-k]%combination_modulo)%combination_modulo;
}







Measured memory_bytes: 47104
N , L = map(int , input().split())

apple_taste = []

for i in range(N):
    taste = L + i + 1 - 1
    apple_taste.append(taste)
    
import numpy as np

abs_apple_taste = np.abs(apple_taste)
m = min(abs_apple_taste)

for j in range(N):
    if m == abs_apple_taste[j]:
        apple_taste.remove(apple_taste[j])

pie_taste = 0       

for k in range(N-1):
    pie_taste += apple_taste[k]
    
print(pie_taste)

Measured memory_bytes: 13596
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int desc(const void *a,const void *b){
    return *(int*)b-*(int*)a;
}
int main(void){
    int n,m,i,sum=0;
    scanf("%d%d",&n,&m);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    qsort(a,n,sizeof(int),desc);
    double v = ceil(sum/(4.0*m));
    if(a[m-1]>=v) printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 128
W, H, x, y = map(int, input().split())

if (W==0)or(H==0):
    print(float(0))
    print(1)
else:
    if (W/2==float(x))&(H/2==float(y)):
        print(H*W/2)
        print(1)
    else:
        print(H*W/2)
        print(0)

Measured memory_bytes: 38456
N = int(input())
V = list(map(int,input().split()))

V.sort()
ans = 0.

if N == 2:
  ans = sum(V) / 2.
  print(ans)
  exit()
  
for i in range(N):
  if i == 0:
    ans += V[i] / pow(2,N-1)
  else:
    ans += V[i] / pow(2,N-i)
    
print(ans)
         


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline

N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
ans = 0
for i in range(N):
    A[-1-i] += ans
    ans += B[-1-i]*(-(-A[-1-i]//B[-1-i]))-A[-1-i]
print(ans)

Measured memory_bytes: 15016
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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; }

using namespace std;

using ll = long long;

const ll mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll r1, c1, r2, c2;
combination comb( 3000010 );

int main()
{
  scanf( "%lld%lld%lld%lld", &r1, &c1, &r2, &c2 );

  mint ans = 0;
  repi( c, c1, c2+1 )
  {
    ans += comb(r2+c+1,c+1)-comb(r1+c,c+1);
    //printf( "+%lld\n", comb(r2+1,c+1)-comb(r1,c+1) );
  }

  printf( "%lld\n", ans.x );

  return 0;
}

Measured memory_bytes: 47104
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define Fast_IO ios::sync_with_stdio(false);
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
#define N 2005
#define INF 3005
struct Edge
{
	int to,nxt;
};
Edge edge[N];
int fir[N];
int ss;
void add(int u,int v)
{
	ss++;
	edge[ss].to=v;
	edge[ss].nxt=fir[u];
	fir[u]=ss; 
}
bool vis[N];
int mp[N][N];
int ans[N],cnt=INF;
int dis[N];
int from[N];
struct node
{
    int dis;
    int num;
    bool operator < (const node &xx) const
    {
        return dis>xx.dis;
    }
};
int n,m;
priority_queue<node> q;
void dijk(int s)
{
	for(int i=1;i<=n;i++)
    {
        dis[i]=INF;
    }
    for(int i=fir[s];i!=0;i=edge[i].nxt)
    {
    	dis[edge[i].to]=1;
    	from[edge[i].to]=s;
    	q.push((node){1,edge[i].to});
	}
    while(!q.empty())
    {
        node tt=q.top();
        q.pop();
        int t=tt.num;
        int d=tt.dis;
        if(d!=dis[t])
        {
            continue;
        }
        for(int now=fir[t];now!=0;now=edge[now].nxt)
        {
            int to=edge[now].to;
            if(dis[t]+1<dis[to])
            {
                dis[to]=dis[t]+1;
                from[to]=t;
                q.push((node){dis[to],to});
            }
        }
    }
    if(dis[s]<cnt)
    {
    	cnt=dis[s];
    	ans[1]=s;
    	for(int i=2;i<=cnt;i++)
    	{
    		ans[i]=from[ans[i-1]];
		}
	}
}
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	cin>>n>>m;
	int u,v;
	for(int i=1;i<=m;i++)
	{
		u=read(),v=read();
		add(u,v);
	}
	for(int i=1;i<=n;i++)
	{
		dijk(i);
	}
	if(cnt==INF)
	{
		cout<<"-1\n";
		return 0;
	}
	cout<<cnt<<endl;
	for(int i=1;i<=cnt;i++)
	{
		printf("%d\n",ans[i]);
	}
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://abc064.contest.atcoder.jp/tasks/abc064_b

"""
import sys
from sys import stdin

input = stdin.readline


def main(args):
    N = int(input())
    positions = [int(x) for x in input().split()]
    print(max(positions) - min(positions))


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
vector<int> a[200005];
int d[200005];
bool vis[200005]={false};
int go(int x){
    if(vis[x]!=0)
        return d[x];
    vis[x]=1;
    for(int i=0;i<a[x].size();i++){
        d[x]=max(d[x],go(a[x][i])+1);
    }
    return d[x];
}
int main()
{
    int x,y,i,j,k,n,m;
    cin>>n>>m;
    for(i=0;i<m;i++){
        cin>>x>>y;
        a[x].push_back(y);
    }
    int ans=0;
    for(i=1;i<=n;i++){
        if(!vis[i])
            ans=max(ans,go(i));
    }
    cout<<ans;
}


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

#define MAX(a,b) (a > b) ? a : b
#define MIN(a,b) (a < b) ? a : b
const int inf = 1000000000; // 10^9

int main (){
   int a,b;scanf("%d %d",&a,&b);
   if(a < b){for(int i = 0;i < b;i++)
      printf("%d",a);
   }else if(b < a){for(int i = 0;i < a;i++)
      printf("%d",b);
   }else {
      for(int i = 0;i < a;i++)
         printf("%d",b);
   }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
        using namespace std;
         
        int main()
        {
    int a,b,d,ans;
        while(cin>>a>>b)
        {
    d=b-a;
     
    ans=d*(d-1)/2-a;
     
    cout<<ans<<endl;
        }
        return 0;
        }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n, i, j;
int main() {
	cin >> n;
	for(i=11; n; i+=10) {
		for(j=2; j*j<=i && i%j>0; j++);
		if(j*j>i) cout << i << ' ', n--;
	}
	return 0;
}

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

int main()
{
	string S, T;
	cin >> S >> T;
	
	for(int i = 0; i < (int)(S.length()); i++)
	{
		if(S[i] == T[i])
			continue;
			
		printf("No");
		return 0;
	}
	
	if(T.length() == S.length() + 1)
		printf("Yes");
		
	else
		printf("No");
}


Measured memory_bytes: 3692
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 28 22:56:10 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

N = int(input())
#X, Y = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N-1)]

fact = [1, 1] # 元テーブル
fact_inv = [1, 1] # 逆元テーブル
tmp_inv = [0, 1] # 逆元テーブル計算用テーブル
for i in range(2, N+1):
    fact.append((fact[-1] * i) % mod)
    tmp_inv.append((-tmp_inv[mod % i] * (mod//i)) % mod)
    fact_inv.append((fact_inv[-1] * tmp_inv[-1]) % mod)
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return fact[n] * fact_inv[r] * fact_inv[n-r] % mod
#逆元作成
def inv(a,mod):
    return pow(a,mod-2,mod)

graph = [[] for _ in range(N+1)]
for a, b in ab:
    graph[a].append(b)
    graph[b].append(a)
    
root = 1
parent = [0] * (N + 1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if parent[x] == y:
            continue
        parent[y] = x
        stack.append(y)

size_d = [0] * (N + 1)
dp_d = [1] * (N + 1)
for v in order[::-1]:
    dp_d[v] *= fact[size_d[v]]
    dp_d[v] %= mod
    p = parent[v]
    s = size_d[v] + 1
    size_d[p] += s
    dp_d[p] *= fact_inv[s] * dp_d[v]
    dp_d[p] %= mod

size_u = [N - x - 1 for x in size_d]
dp_u = [1] * (N + 1)
for v in order[1:]:
    p = parent[v]
    x = dp_d[p] * inv(dp_d[v],mod)
    x *= fact_inv[size_d[p]] * fact[size_d[v] + 1]
    x *= fact[size_u[v] - 1] * fact_inv[size_u[p]]
    x *= dp_u[p]
    dp_u[v] = x % mod

for xd, xu, sd, su in zip(dp_d[1:], dp_u[1:], size_d[1:], size_u[1:]):
    x = xd * xu * fact[sd + su] * fact_inv[sd] * fact_inv[su] % mod
    print(x)



Measured memory_bytes: 124988
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cstdio>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef vector<pair<int, int> > vp;
typedef vector<string> vs;

typedef pair<double, string > ds;
typedef vector<pair<double, string> > vpds;

typedef long long ll;

vector<string> StringSplit(const string &str, char sep){
    vs v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}

bool cmpr(ds a, ds b){
  if(a.fi != b.fi) return a.fi > b.fi;
  if(a.se < b.se) return true;
  else return false;
}

int main(){
  while(1){
    int n; cin>>n;
    if(n==0) break;
    vs namae(n);
    vpds data;
    rep(i,n){
      int p,a,b,c,d,e,f,s,m;
      string namae;
      cin>>namae>>p>>a>>b>>c>>d>>e>>f>>s>>m;
      double eff = (double)(f*s*m-p)/( (a+b+c) + (d+e)*m );
      ds item = mp(eff,namae);
      data.pb(item);
    }
    sort(data.begin(), data.end(), cmpr);
    rep(i,n){
      cout<<data[i].se<<endl;
    }
    cout<<"#"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3172
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
a, b = [0], [0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
 
ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 127144
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;



int main() {
    int a,b;
    char oper;
    while(true) {
        cin >> a >> oper >> b;
        switch(oper) {
            case '+':
                cout << a+b << endl;
                break;
            case '-':
                cout << a-b << endl;
                break;
            case '*':
                cout << a*b << endl;
                break;
            case '/':
                cout << a/b << endl;
                break;
            default:
                return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3080
#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;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  vector<int> b(m);
  rep(i, n){
    rep(j, m){
      cin >> a.at(i).at(j);
    }
  }
  rep(i,m){
    cin >> b.at(i);
  }
 vector<int> c(n, 0);
 rep(i,n){
   rep(j,m){
     c.at(i) += a.at(i).at(j)*b.at(j);
   }
   cout << c.at(i) << endl;
 }
 
  return 0;
}



Measured memory_bytes: 3184
while 1:
    try:
        a, b, c, d, e, f = map(float, raw_input().split())
        x = (c * e - b * f) / (a * e - b * d)
        y = (f * a - c * d) / (a * e - d * b)
        if x == -0.000:
            x = 0.000
        if y == -0.000:
            y = 0.000
        print str('%.3f' % x) + " " + str('%.3f' % y)
    except:
        break

Measured memory_bytes: 4240
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>

using namespace std;

int main(){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  int x=max({A,B,C});
  for(int i=0;i<K;i++){
    x*=2;
  }
  cout << A+B+C+x-max({A,B,C}) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int D = scanner.nextInt();
        int N = scanner.nextInt();
        if (N == 100) {
            System.out.println(
                    (long) Math.pow(100, D) * (long) N + (int) Math.pow(100, D)
            );

        } else {
            System.out.println(
                    (long) Math.pow(100, D) * (long) N
            );
        }
    }
}


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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll x;
    cin>>x;
    ll ans = 0;
    ll level = 0;
    while(x)
    {
        x/=2;
        ans+= pow(2,level++);
    }
    cout<<ans;
}


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

using namespace std;
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
#define pint(x) printf("%d",x)
#define ps printf(" "); 
#define plint(x) printf("%lld",x)
//#define sort(a,n) qsort(a,n,sizeof(int),cmpfunc)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define bg begin()
#define ed end()
#define Set(a, s) memset(a, s, sizeof (a))
#define mod 1000000007
#define tmod(k) if ((k) >= mod) k %= mod;
#define endl '\n'
#define nl printf("\n");
#define fors(i,n) for(int i=0; i<n; i++)
#define fore(i,n) for(int i=n-1; i>=0; i--)
#define forv(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
const int INF = 0x3f3f3f3f;
int cmpfunc (const void * a, const void * b)
{
   return ( *(int*)a - *(int*)b );
}

class node{
public:
	int id;
	int prio;
	int prd;
};

class compare{
public:
	bool operator()(node &n1, node &n2){
		if(n1.prio>n2.prio)//ascending
			return true;
		else if(n1.prio==n2.prio){
			return n1.id>n2.id;
		}
		return false;
	}
};
//priority_queue<node, vector<node>, compare> pq;

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*#ifdef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #else
    // online submission
    #endif*/
    int x,a,b;
    int3(x,a,b);
    if(abs(x-a)>abs(x-b)){
        printf("B");
    }
    else{
        printf("A");
    }
    
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;

public class Main
{
	public static void main(String[] arg) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int v = Integer.valueOf(br.readLine());
		ArrayList<Integer> amida = new ArrayList<Integer>(v);
		for(int i=0; i<v; i++)
			amida.add(i+1);

		int h = Integer.valueOf(br.readLine());
		
		for(int i=0; i<h; i++){
			String swapInd = br.readLine();
			int swap1 = Integer.valueOf(swapInd.split(",")[0]);
			int swap2 = Integer.valueOf(swapInd.split(",")[1]);
			Collections.swap(amida,swap1-1,swap2-1);
		}

		for(int i=0; i<v; i++)
			System.out.println(amida.get(i));
	}
}

Measured memory_bytes: 9752
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <numeric>
#define rep(i,n) for(int i=0;i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;


int main(){
        string s;
        string t;
        cin >> s;
        int a[26] = {};
        int n = (int)s.size();
        rep(i,n){
                a[s[i]-'a']++;
                if(s[i] !='x'){
                        t += s[i];
                }
        }
        string tt = t;
        reverse(tt.begin(),tt.end());
        int x = (int)'x'-'a';
        int kisuu = 0;
        int kisuuichi = 0;
        rep(i,26){
                if(a[i]%2==1){
                        kisuu++;
                        kisuuichi = i;
                }
        }
        if(tt!=t){
                cout << -1 << endl;
                return 0;
        }
        string ss = s;
        reverse(ss.begin(),ss.end());
        int ans = 0;
        int i = 0;
        int j = 0;
        string hoge;
        rep(i,n){
                hoge += '/';
        }
        s += hoge;
        ss += hoge;
        while(1){
                if(s[i]==ss[j]){
                        i++;
                        j++;
                }else{
                        if(s[i] =='x'){
                                ans++;
                                i++;
                        }
                        if(ss[j] =='x'){
                                ans++;
                                j++;
                        }
                }
                if(i>=n && j >=n)break;
        }
        cout <<ans/2 << endl;
        
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	string s;int n;
  cin>>n>>s;
  int count=0;
  for(int i=0;i<=n-3;i++)
  {
    if(s.substr(i,3)=="ABC")
     count++;
  }
  cout<<count;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <set>
#include <vector>
#include <list>
struct data{
    int r , c;
    bool operator < (const data &a){
        if (a.r == r)
            return c < a.c;
        return r < a.r;
    }
};
using namespace std;
int main(){
    int R , C , M;
    cin >> R >> C >> M;
    int row[R] = {0} , col[C] = {0};
    list<int> adjlist[R];
    vector<int> daftar;
    int maks = 0 , cnt , ans = 0;
    for (int i = 0 , r , c ; i < M ; i++){
        cin >> r >> c;
        --r , --c;
        adjlist[r].push_back(c);
        ++row[r] , ++col[c];
        if (col[c] > maks)
            cnt = 1 , maks = col[c] , daftar.clear() , daftar.push_back(c);
        else if (col[c] == maks)
            ++cnt , daftar.push_back(c);
    }
    bool is_maks[C] = {0};
    for (int it : daftar)
        is_maks[it] = 1;
    for (int i = 0 ; i < R ; i++){
        int hit = 0;
        for (int it : adjlist[i])
            if (is_maks[it])
                ++hit;
        if (hit == cnt)
            ans = max(ans , row[i] + maks - 1);
        else
            ans = max(ans , row[i] + maks);
    }
    cout << ans << endl;
}


Measured memory_bytes: 23556
#include <bits/stdc++.h>
using namespace std;
int f(int n)
  {int r{};
  for (int x = 1; x * x <= n; ++x) for (int y = 1; x * x + y * y + x * y <= n; ++y)
    for (int z = 1; x * x + y * y + z * z + x * y + y * z + z * x <= n; ++z) r += x * x + y * y + z * z + x * y + y * z + z * x == n;
return r;}
int main()
  {int N; cin >> N;
  for (int n = 1; n <= N; ++n) cout << f(n) << "\n";}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, m; std::cin >> n >> m;
  int l = 2 * m + 1;
  std::cout << (n + l - 1) / l << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#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;
long long dp[1100][1100];
long long inv[3333];
long long fact[3333];
long long finv[3333];
long long C(int a,int b){
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
int main(){
	int n,a,b,c,d;
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	inv[1]=fact[0]=finv[0]=1;
	for(int i=2;i<3333;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<3333;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
	dp[1][0]=1;
	for(int i=1;i<=b;i++){
		for(int j=0;j<=n;j++){
			if(!dp[i][j])continue;
			dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
		//	printf("%d %d: %lld\n",i,j,dp[i][j]);
			if(i>=a){
				int rem=n-j;
				long long ks=1;
				for(int k=1;k<=d;k++){
					if(j+k*i>n)break;
					ks=ks*C(rem,i)%mod;
					rem-=i;
					if(k>=c)dp[i+1][j+k*i]=(dp[i+1][j+k*i]+dp[i][j]*ks%mod*finv[k])%mod;
				}
			}
		}
	}
	printf("%lld\n",dp[b+1][n]);
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
typedef list<int>L;
int main(void){
	int q;
	int n,d,x;
	L li;
	int p;
	int i,j;
	cin>>q;
	auto itr=li.end();
	for(i=0;i<q;i++){
		cin>>n;
		if(n==0){
			cin>>x;
			li.insert(itr,x);
			itr--;
		}
		else if(n==1){
			cin>>d;
			if(d>=0){
				for(j=1;j<=d;j++)	itr++;
			}
			else{
				for(j=1;j<=abs(d);j++)	itr--;
			}
		}
		else{
			itr=li.erase(itr);
		}
		/*for(auto it=li.begin();it!=li.end();it++){
			cout<<*it<<endl;
		}*/
	}
	for(auto it=li.begin();it!=li.end();it++){
		cout<<*it<<endl;
	}
	return 0;
}


Measured memory_bytes: 18628
S = input()
n = len(S)
ATGC = set(['A', 'T', 'G', 'C'])
ans = 0
for i in range(n):
    for j in range(i+1, n+1):
        tmp_s = S[i:j]
        if len(set(tmp_s) - ATGC) == 0:
            ans = max(ans, j-i)
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
    int A, B, K;
    scanf("%ld %ld %ld", &A, &B, &K);
    int ans, i, counter = 0;
    i = A + 1;
    while(counter < K)
    {
        i --;
        //printf("%d, %d, %d\n", i, A % i, B % i);
        if(A % i == 0 && B % i == 0){
            counter ++;
        }
    }
    ans = i;
    printf("%ld", ans);
    return 0;
}

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

int main()
{
    int l;

    int i = 0;
    while (cin >> l) {

        if (l == 0) {
            break;
        }
        cout << "Case " << i + 1 << ": " << l << endl;

        i++;
    
    }
    
    return 0;
}


Measured memory_bytes: 3000
#include <stdio.h>

int main()
{
	int a, b, c, d, l, r;
  	scanf("%d%d%d%d", &a, &b, &c, &d);
  	l = a + b; r = c + d;
  	if (l > r){
    	printf("Left");
    }else if (l == r){
    	printf("Balanced");
    }else{
    	printf("Right");
    }
}

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

using namespace std;

int main(){
    int n,t,c=0,d=0,p,q,ans=0;
    scanf("%d %d",&n,&t);
    vector<int> a(n);
    for (auto&e:a) scanf("%d",&e);
    p=a[0];
    for (int i=1;i<n;i++) {
        p=min(p,a[i]);
        if (a[i]-p==d) {
            c++;
        } else if (a[i]-p>d) {
            c=1;
            d=a[i]-p;
        }
    }
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 640
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

A,B,M = miinps()
a = lmiinps()
b = lmiinps()
x = lmiinpsf(M)

mi = 10 ** 10

for i in range(M):
  mi = min(mi,a[x[i][0]-1]+b[x[i][1]-1]-x[i][2])

mi = min(mi,min(a)+min(b))

print(mi)

Measured memory_bytes: 38572
N=int(input())
cnt=[[0]*10 for i in range(10)]
for i in range(1,N+1):
    cnt[int(str(i)[0])][int(str(i)[-1])]+=1
ans=0
for i in range(1,10):
    for j in range(1,10):
        ans+=cnt[i][j]*cnt[j][i]
print(ans)

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

typedef long long ll;
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;}

int main() {
    int n;
    cin >> n;
    int init_n = n;
    vector<pair<int,int>>prime;
    for(int i = 2; i*i<=init_n;i++) {
        int tmp = 0;
        while(n%i == 0) {
            tmp++;
            n /= i;
        }
        prime.push_back(make_pair(i,tmp));
    }
    if(n != 1) prime.push_back(make_pair(n,1));
    
    cout << init_n << ":";
    rep(i,prime.size()) {
        if(prime[i].second == 0) continue;
        int cnt = prime[i].second;
        cout << " ";
        while(cnt) {
            cout << prime[i].first;
            if(cnt != 1)cout << " ";
            cnt--;
        }
    }
    cout << endl;
}


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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int n,a,b;
	cin >> n>>a>>b;
    cout<<((n*a>b)?b:n*a);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    int A, B, C, K, ans;
    cin >> A >> B >> C >> K;
    ans = 0;

    if(A > K){
        ans = K;
    } else if(A + B >= K) {
        ans = A;
    } else {
        ans = A - (K - A - B);
    }

    cout << ans << endl;

    return 0;
            
}

Measured memory_bytes: 3552
#include <iostream>
#include <cstdio>
#include <algorithm>
#define MAXN 100001
#define INF 200000000
using namespace std;

struct Card{
	char suit;
	int num;
};

Card L[MAXN/2 + 2], R[MAXN/2 + 2];

void merge(Card A[], int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}
	L[n1].num = INF;
	R[n2].num = INF;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		if (L[i].num <= R[j].num) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
		}
	}
}

void mergeSort(Card A[], int left, int right)
{
	int mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int partition(Card A[], int left, int right){
	int i = left - 1;
	Card x = A[right];
	for (int j = left; j < right; j++) {
		if (A[j].num <= x.num) {
			i++;
			Card temp = A[i];
			A[i] = A[j];
			A[j] = temp;
		}
	}
	Card t = A[i+1];
	A[i+1] = A[right];
	A[right] = t;
	return i+1;
}

void quickSort(Card A[], int p, int r){
	if (p < r) {
		int q = partition(A, p, r);
		quickSort(A, p, q-1);
		quickSort(A, q+1, r);
	}
}


int main(int argc, char *argv[]) {
	int n;
	scanf("%d", &n);
	Card c1[MAXN], c2[MAXN];
//	for (int i = 0; i < n; i++) {
//		scanf("%c %d", &c1[i].suit, &c1[i].num);
//		c2[i].suit = c1[i].suit;
//		c2[i].num = c1[i].num;
//	}
	char S[10];
	int v;
	for (int i = 0; i < n; i++) {
		scanf("%s %d", S, &v);
		c2[i].suit = c1[i].suit = S[0];
		c2[i].num = c1[i].num = v;
	}
	
	mergeSort(c1, 0, n);
	quickSort(c2, 0, n-1);
	
	int stable = 1;
	for (int i = 0; i < n;i++) {
		if (c1[i].suit != c2[i].suit) {
			stable = 0;
		}
	}
	
	if (stable == 1) {
		printf("Stable\n");
	}else {
		printf("Not stable\n");
	}
	for (int i = 0; i < n; i++) {
		printf("%c %d\n", c2[i].suit, c2[i].num);
	}
	return 0;
}


Measured memory_bytes: 5480
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int k, t;
    int a[105];
    int maxv = -1;
    int ans = 0;

    cin >> k >> t;
    for (int i = 0; i < t; i++) {
        cin >> a[i];

        maxv = max(a[i], maxv);
    }

    cout << max(maxv - 1 - (k - maxv), 0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

/*---?§????????????????S???h:m:s?????¢????????????????????¨?????????---*/
void time(int S)
{
	int h, m, s;

	s = S % 60;
	h = S / 3600;
	m = (S % 3600) / 60;

	printf("%d:%d:%d\n", h, m, s);
}

int main(void)
{
	int num;

	scanf("%d", &num);

	time(num);

	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    //方針
    //毎日満足度は低下し続ける
    //満足度上昇の方法はコンテスト開催のみ
    //開催されてないコンテストを放置すると低下が著しくなる
    //実際にコンテストを開いた時の満足度上昇が最大のものを採用してみる→もしかして根本的にダメだから全部0点になってる？
    //低下をなくせる分を上昇と捉えると、c_i(d-last(d,i)) + s_{d,i} だけペイすると考えられる？→あんまり適当じゃない
    //c_iが大きい順に順番に消化していくとか
    int D;cin>>D;
    int c[26],last[26]={},s[365][26];
    REP(i,26) cin>>c[i];
    REP(i,D) REP(j,26) cin>>s[i][j];
    int ord[26];
    iota(ord,ord+26,0);
    sort(ord,ord+26,[&](int x,int y){return c[x]>c[y];});
    REP(i,D){
        static int gomi = 0;
        gomi %= 26;
        cout<<ord[gomi]+1<<endl;
        gomi++;
    }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
typedef vector<bool> vb;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.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;}
ll llpow(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;}return res;}
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353



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

    // solution comes here

    ll N;
    cin >> N;
    vl C(N+5), S(N+5), F(N+5);
    rep(i, N-1) cin >> C[i+1] >> S[i+1] >> F[i+1];//1-indexed

    vl ans(N+5);

    for(int i=1; i<N; i++) {
        for(int j=i; j<N; j++) {
            if(ans[i]<=S[j]) ans[i] = S[j];
            else if(ans[i]%F[j]) ans[i] += F[j] - (ans[i]%F[j]);
            ans[i] += C[j];
        }
    }

    rep(i, N) cout << ans[1+i] << nl;
}

Measured memory_bytes: 256