akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;	//Scannerクラス：Java標準入力を取得する

class Main{		//クラス宣言
	public static void main(String[] args){		//メソッド宣言
		int a;				//
		int b;
		int d;
		int r;
		double f;


		try(Scanner sc = new Scanner(System.in)){
			a = sc.nextInt();
			b = sc.nextInt();

			d = a / b;
			r = a % b;
			f = (double)a / b;

			System.out.println(String.format("%d %d %.8f",d,r,f));
		}
	}
}







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

int main() {
	int a,n;
	int max, min;
	long long sum =0;
	cin >> n;
	cin >> a;
	min = max = sum = a;
	for (int i = 0;i < n-1;i++) {
		cin >> a;
		if (a > max)max = a;
		if (a < min)min = a;
		sum += a;
	}
	cout << min << ' ' << max << ' ' << sum << endl;
}


Measured memory_bytes: 3096
n = int(input())
s = sorted(list(int(input()) for i in range(n)))
c = 0

if sum(s) % 10 != 0:
    c = sum(s)
else:
    for i in range(n):
        if s[i] % 10 != 0:
            c = sum(s) - s[i]
            break
print(c)

Measured memory_bytes: 2940
word_dic = {}
N = int(input())
for i in range(N):
    word = input()
    if word in word_dic.keys():
        word_dic[word] += 1
    else:
        word_dic[word] = 1
        
M = int(input())
for i in range(M):
    word = input()
    if word in word_dic.keys():
        word_dic[word] -= 1
        
score = max(word_dic.values())
if score < 0:
    score = 0
print(score)

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
  int s,a[100001],ans;
  scanf("%d",&s);

  a[0]=s;

  if(s!=1 && s!=2 &&s!=4){
  for(int i=0;i<1000001;i++){
    if(a[i]%2==0){
      a[i+1]=a[i]/2;
    }else{
      a[i+1]=3*a[i]+1;
    }
      if(a[i+1]==4){
        ans=i+5;
        break;
      }
  }
  }else{
	ans=4;
  }

  printf("%d",ans);
}


Measured memory_bytes: 128
import sys
from itertools import accumulate

input = sys.stdin.readline


def solve(H, W, D, A, Q, LR):
    position = [None] * (H * W + 1)
    for h in range(H):
        for w in range(W):
            position[A[h][w]] = (h, w)

    mp = [0] * (H * W + 1)

    for i in range(1, H * W + 1 - D):
        h, w = position[i]
        y, x = position[i + D]
        mp[i + D] = abs(x - w) + abs(y - h)

    for d in range(1, D + 1):
        mp[d::D] = list(accumulate(mp[d::D]))

    ans = [str(mp[r] - mp[l]) for l, r in LR]
    ans = "\n".join(ans)
    return ans


def main():
    H, W, D = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    Q = int(input())
    LR = [list(map(int, input().split())) for _ in range(Q)]

    ans = solve(H, W, D, A, Q, LR)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 49004
#include <stdio.h>
long long lucas(int i) {
	if(i==0) return 2LL; if(i==1) return 1LL;
	long long a = 2, b = 1, c = 3;
	for(int j = 2; j < i; j++) {
		c = c + b;
		b = a + b;
		a = c - b;
	}
	return c;
}
int main()
{
	int N;
	scanf("%d", &N);
	printf("%lld\n", lucas(N));
	return 0;
}


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

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;


using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	cstr(str);
	
	rep(i, str.length() / 2) {
		if (str[i] != str[(str.length() -1)/ 2  - i-1]) {
			cout << "No" << endl;
			return 0;
		}
		if (str[i + (str.length() + 3) / 2 -1] != str[str.length() - 1 - i]) {
			cout << "No" << endl;
			return 0;
		}
		if (str[i] != str[str.length() - i - 1]) {
			cout << "No" << endl;
			return 0;
		}
			
	}
	cout << "Yes" << endl;
	
	

	return 0;
}


Measured memory_bytes: 3568
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct pos{
	double x;
	double y;
};
int main() {
	vector<pos> point(4);
	while (cin >> point[0].x >> point[0].y >> point[1].x >> point[1].y >> point[2].x >> point[2].y >> point[3].x >> point[3].y){
		double cross[3];
		REP(j, 3){
			cross[j] = (point[(j + 1) % 3].x - point[(j) % 3].x)*(point[3].y - point[(j) % 3].y) - (point[(j + 1) % 3].y - point[(j) % 3].y)*(point[3].x - point[(j) % 3].x);
			
		}
		if ((cross[0]>0 && cross[1]>0 && cross[2]>0) || (cross[0]<0 && cross[1]<0 && cross[2]<0))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

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


#define li          long long int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

#define UF_NUM 505050
li parent[UF_NUM];
li cnt[UF_NUM];

inline void init_uf() {
    rep(i, UF_NUM) {
        parent[i] = i;
        cnt[i] = 1;
    }
}

inline li find(li x) {
    if (parent[x] == x)return x;
    else return (parent[x] = find(parent[x]));
}

inline void union_(li x, li y) {
    li parent_x = find(x);
    li parent_y = find(y);
    if (parent_y != parent_x && cnt[parent_y] > 0) {
        cnt[parent_y] += cnt[parent_x];
        cnt[parent_x] = 0;
    }
    parent[parent_x] = parent_y;

}


int main() {
    init_uf();
    li n, m;
    cin >> n >> m;
    rep(i, m) {
        li a, b;
        cin >> a >> b;
        a--;
        b--;
        union_(a, b);
        //dump(cnt, n);
    }
    li res = 0;
    rin{
        if (find(i) == i) {
            res = max(res, cnt[i]);
        }
    }
    cout << res << endl;


    return 0;
}


Measured memory_bytes: 17660
import java.util.ArrayList;
        import java.util.Arrays;
        import java.util.Collections;
        import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int counter = 0;
        int prev = 0;
        int max = 0;

        if (n == 1) {
            System.out.println(0);
            System.exit(0);
        }
        for (int i = 0; i < n; i++) {
            int current = sc.nextInt();
            if (current > prev) {
                if (counter > max) {
                    max = counter;
                }

                counter = 0;
            } else {
                counter++;
            }
            
            prev = current;
        }
      
      	if (counter > max) {
         	max = counter; 
        }

        System.out.println(max);


    }
}

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

using namespace std;

int main(void)
{
    int n ,r;
    cin >> n >> r;
    if (n >= 10) {
        cout << r << endl;
        return 0;
    } else {
        cout << r + 100 * (10 - n) << endl;
        return 0;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int,int> pii;
typedef priority_queue<int,vector<int>,greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 1010;
vector<int>tree[N];
int v[N],dp[5*N],f[N],n;
void dfs(int x){
    for(auto vv:tree[x])
        dfs(vv);
    memset(dp,0x3f,sizeof(dp));
    dp[0]=0;
    for(auto vv:tree[x]){
        for(int i=v[x];i>=0;i--)
        {
            int tmp=0x3f3f3f3f;
            if(i>=v[vv])tmp=min(tmp,dp[i-v[vv]]+f[vv]);
            if(i>=f[vv])tmp=min(tmp,dp[i-f[vv]]+v[vv]);
            dp[i]=tmp;
        }
    }
    for(int i=v[x];i>=0;i--)f[x]=min(f[x],dp[i]);
}
int main()
{
    memset(f,0x3f, sizeof(f));
    scanf("%d",&n);
    for(int i=2;i<=n;i++){
        int x;scanf("%d",&x);
        tree[x].push_back(i);
    }
    for(int i=1;i<=n;i++){
        scanf("%d",&v[i]);
    }
    dfs(1);
    if (f[1]<0x3f3f3f3f) {
        printf("POSSIBLE\n");
    } else {
        printf("IMPOSSIBLE\n");
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M,K;
int A[100010],B[100010];
int C[100010],D[100010];

struct UnionFind {
	vector<int> data;
 	UnionFind(int size):data(size, -1) {}
	bool unite(int x,int y){
		x=root(x);
		y=root(y);
 	   if(x!=y){
			if (data[y]<data[x]){
				swap(x, y);
			}
			data[x]+=data[y];
			data[y]=x;
		}
		return x!=y;
	}
	bool same(int x, int y){
		return root(x)==root(y);
	}
	int root(int x){
		return data[x]<0? x:data[x]=root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int E[100010];
int F[100010];

signed main(){
	cin>>N>>M>>K;
	REP(i,M){
		cin>>A[i]>>B[i];
		A[i]--,B[i]--;
	}
	REP(i,K){
		cin>>C[i]>>D[i];
		C[i]--,D[i]--;
	}
	UnionFind UN(N+10);
	REP(i,M){
		UN.unite(A[i],B[i]);
		E[A[i]]++;
		E[B[i]]++;
	}
	REP(i,N){
		F[i]=UN.size(i)-E[i]-1;
		DEB(F[i])END
	}
	REP(i,K){
		if(UN.same(C[i],D[i])){
			F[C[i]]--,F[D[i]]--;
		}
	}
	REP(i,N){
		cout<<F[i];
		if(i<N-1){
			cout<<" ";
		}
	}
	cout<<endl;
	return 0;
}


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

const ll mod = 1e9+7;

ll mpow(ll x,ll n){
    ll res = 1;
    while(n != 0){
        if(n&1) res = res*x % mod;
        x = x*x % mod;
        n = n >> 1; 
    }
    return res;
}
ll fac(ll i){
    static ll fatorial[300000+1]={0};

    if(fatorial[i]) return fatorial[i];
    else if(i==0) return fatorial[0] = 1;
    else return fatorial[i] = fac(i-1)*i % mod;
}
ll ifac(ll i){
    static ll ifactorial[300000+1]={0};

    if(ifactorial[i]) return ifactorial[i];
    else if(i==0) return ifactorial[0] = 1;
    else return ifactorial[i] = ifac(i-1)*mpow(i,mod-2) % mod;
}
ll comb(ll a,ll b){
    if(a==0 && b==0) return 1;
    if(a<b || a<0) return 0;
    ll tmp = ifac(a-b)*ifac(b) % mod;
    return tmp*fac(a) % mod;
}

ll calc(ll x){
    if(x==0) return 1;
    ll res = 0;
    for(int i = 0;i <= x/2;i ++){
        res += comb(x-i,i);
        res %= mod;
    }
    return res;
}

int main(){
    ll n,m,ans = 1,from = 0,to;
    cin >> n >> m;
    for(int i = 0;i < m;i ++){
        ll a;
        cin >> a;
        if(from-1==a){
            continue;
        }else if(from==a){
            cout << 0 << endl;
            return 0;
        }

        to = a-1;
        ans *= calc(to-from);
        //cout << from << " " << to << endl;
        ans %= mod;
        from = a+1;
    }
    //cout << from << " " << to << endl;
    ans *= calc(n-from);
    ans %= mod;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4608
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <math.h>
const int N = 1e5+10;
long long z;
int main() {
	scanf("%lld", &z);
	for (long long x=-1000; x<=1000; x++) {
		for (long long y=-1000; y<=1000; y++) {
			long long n = x*x*x*x*x, m = y*y*y*y*y;
			if (n - m == z) {
				printf("%lld %lld\n", x, y);
				return 0;
			}
		}
	}
}

Measured memory_bytes: 1728
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n,m;
  cin >> n >> m;
  map<int,int> mp;
  rep(i,m) {
    mp[i] = 0;
  }

  
  for (int i = 0; i < n; ++i) {
    ll k; 
    cin >> k;
    vector<ll> a(k);
    rep(i,k) {
      cin >> a[i];
      mp[a[i]] += 1;
    }
  }
  ll ans = 0;
  for (auto itr : mp) {
    if (itr.second == n) {
      ans += 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define mor > muu & operator << (
#define R22(r) sim > typename \
  enable_if<1 r sizeof dud<c>(0), muu&>::type operator<<(c g) {
sim > struct rge { c b, e; };
sim > rge<c> range(c h, c n) { return {h, n}; }
sim > auto dud(c* r) -> decltype(cerr << *r);
sim > char dud(...);
struct muu {
#ifdef LOCAL
stringstream a;
~muu() { cerr << a.str() << endl; }
R22(<) a << boolalpha << g; ris; }
R22(==) ris << range(begin(g), end(g)); }
sim, class b mor pair < b, c > r) { ris << "(" << r.first << ", " << r.second << ")"; }
sim mor rge<c> u) {
  a << "[";
  for (c i = u.b; i != u.e; ++i)
    *this << ", " + 2 * (i == u.b) << *i;
  ris << "]";
}
#else
sim mor const c&) { ris; }
#endif
muu & operator()() { ris; }
};
#define imie(r...) "[" #r ": " << (r) << "] "
#define imask(r...) "[" #r ": " << bitset<8 * sizeof(r)>(r) << "] "
#define arr(a, i) "[" #a imie(i) ": " << a[i] << "] "
#define arr2(a, i, j) "[" #a imie(i) imie(j) ": " << a[i][j] << "] "
#define debug (muu() << __FUNCTION__ << "#" << __LINE__ << ": ")

const int N = 2e5 + 7;
char s[N];

int main() {
    scanf("%s", s);
    int ile = 0;
    long long wynik = 0;
    for (int i = 0; s[i]; ++i) {
        if (s[i] == 'B') ile++;
        else wynik += ile;
    }
    printf("%lld\n", wynik);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <set>
#include <cmath>

using namespace std;
 
int main(){
    int n;
 
    while(cin >> n ,n){
	int num;
	set<int> s[2];
 
	for(int i = 0 ; i < n ; i++){
	    cin >> num;
	    s[0].insert(num);
	}
 
	for(int i = 1 ; i <= 2*n ; i++){
	    if(s[0].find(i) == s[0].end()){
		s[1].insert(i);
	    }
	}
 
	bool turn = false;
	int field = 0;
 
	while(true){
	    if(s[0].size() == 0 || s[1].size() == 0){
		break;
	    }
 
	    set<int>::iterator it;
	    for(it = s[turn].begin() ; it != s[turn].end() ; it++){
		if(field < *it){
		    s[turn].erase(it);
		    field = *it;
		    turn = abs(1-turn);
		    break;
		}
	    }     
 
	    if(it == s[turn].end()){
		field = 0;
		turn = abs(1-turn);
	    } 
	}
	cout << s[1].size() << endl;
	cout << s[0].size() << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    ll n, m;
    cin >> n >> m;

    if (n == 1 && m == 1) {
        put(1);
        return 0;
    }

    if (n == 1) {
        put(max(0LL, m - 2));
        return 0;
    }

    if (m == 1) {
        put(max(0LL, n - 2));
        return 0;
    }

    put((m - 2) * (n - 2));

    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(){
  int L,i,j,k,st,sw;
  int an[10000];
  char a[7];
  int ma,mi;
  int ju;
  while(1){
    //syoki
    for(i=0;i<10000;i++){
      an[i]=0;
    }
    k=1;
    sw=0;
    for(i=0;i<7;i++){
      a[i]='0';
    }
    scanf("%s%d",a,&L);
    for(i=0;i<7;i++){
      if(a[i]=='\0')a[i]='0';
    }
    if(a[0]=='0'&&L==0)break;
      ju=1;
      for(i=0;i<L;i++){
	if(i!=0)ju*=10;
	an[0]+=(a[L-i-1]-'0')*ju;
      }
    while(1){

      //ma
      for(i=0;i<L;i++){
	for(j=1;j<L;j++){
	  if(a[j-1]<a[j]){
	    st=a[j];
	    a[j]=a[j-1];
	    a[j-1]=st;
	  }
	}
      }
      ju=1;
      ma=0;
      for(i=0;i<L;i++){
	if(i!=0)ju*=10;
	ma+=(a[L-i-1]-'0')*ju;
      }
      //mi
      for(i=0;i<L;i++){
	for(j=1;j<L;j++){
	  if(a[j-1]>a[j]){
	    st=a[j];
	    a[j]=a[j-1];
	    a[j-1]=st;
	  }
	}
      }
      ju=1;
      mi=0;
      for(i=0;i<L;i++){
	if(i!=0)ju*=10;
	mi+=(a[L-i-1]-'0')*ju;
      }
      //
      an[k]=ma-mi;
      k++;
      for(i=0;i<k-1;i++){
	if(an[k-1]==an[i]){
	  printf("%d %d %d\n",i,an[i],k-1-i);
	  sw=1;
	}
      }
      if(sw==1)break;
      st=an[k-1];
      for(i=0;i<L;i++){
	a[i]=st/ju+'0';
	st%=ju;
	ju/=10;
      }
    }
  }
  return 0;
}
    
      

Measured memory_bytes: 1068
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;
 
typedef int ll;
 
#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define endl '\n'
 
typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;
 
const int mod=1e9+7;
 
int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}
 
void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}
 
int gcd(int a, int b) {
   if (b == 0)
   return a;
   return gcd(b, a % b);
}


vector<string>v;
int comp[1005][1005];
int currComp=1;
int n, m, cx, cy, dx, dy;
vector<int>graph[1000005];
map<pii, int>mpp;
int dist[1000005];

void dfs(int currx, int curry) {
	if(currx<=0 || currx>n || curry<=0 || curry>m)	return;
	if(comp[currx][curry] || v[currx][curry]=='#')	return;
	comp[currx][curry]=currComp;
	dfs(currx+1, curry);
	dfs(currx, curry+1);
	dfs(currx, curry-1);
	dfs(currx-1, curry);
}

 
ll main() {
	// freopen("Task.in", "r", stdin);freopen("Task.out", "w", stdout);

	cin>>n>>m>>cx>>cy>>dx>>dy;

	v.pb("");
	for (int i=0; i<n; i++) {
		string s;
		cin>>s;
		string t=" "+s;
		v.pb(t);
	}

	if(v[cx][cy]=='#' || v[dx][dy]=='#') {
		cout<<"-1\n";
		return 0;
	}

	for (int i=1; i<=n; i++) {
		for (int j=1; j<=m; j++) {
			if(comp[i][j] || v[i][j]=='#')	continue;
			dfs(i, j);
			currComp++;
		}
	}

	// for (int i=1; i<=n; i++) {
	// 	for (int j=1; j<=m; j++) {
	// 		cout<<comp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	for (int i=1; i<=n; i++) {
		for (int j=1; j<=m; j++) {
			if(v[i][j]=='#')	continue;
			for (int k=-2; k<=2; k++) {
				for (int p=-2; p<=2; p++) {
					int x=i+k, y=j+p;
					if(x<=0 || x>n || y<=0 || y>m)	continue;

					if(v[x][y]=='#')	continue;
					int firs=comp[i][j], sec=comp[x][y];
					if(firs>sec)	swap(firs, sec);
					if(firs==sec)	continue;
					// cout<<firs<<" "<<sec<<endl;
					if(mpp.find(mp(firs, sec))==mpp.end()) {
						mpp[mp(firs, sec)]=1;
						// cout<<firs<<" "<<sec<<endl;
						graph[firs].pb(sec);
						graph[sec].pb(firs);
					}
				}
			}
		}
	}


	int src=comp[cx][cy];
	int dest=comp[dx][dy];

	queue<int>bfs;
	bfs.push(src);
	dist[src]=1;
	while (!bfs.empty()) {
		int top=bfs.front();
		// cout<<top<<endl;
		bfs.pop();
		// cout<<graph[top].size()<<endl;
		for (int i=0; i<graph[top].size(); i++) {
			int curr=graph[top][i];
			// cout<<curr<<" "<<dist[curr]<<endl;
			if(dist[curr]==0) {
				bfs.push(curr);
				dist[curr]=dist[top]+1;
			}
		}
	}

	cout<<dist[dest]-1<<endl;
}

Measured memory_bytes: 54888
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 2e5 + 10;
int64 a[N];
int64 sum[N], B[N], C[N];
int64 L[N], R[N];

void solve(int64 a[], int n, int64 A[]) {
  for (int i = 0; i < n; ++i) {
    sum[i + 1] = sum[i] + a[i];
  }
  for (int i = 0; i < n; ++i) {
    C[i] = sum[n] - sum[i];
  }
  B[n] = 0;
  for (int i = n - 1; i >= 0; --i) {
    int x = 0;
    if (a[i] == 0) {
      x = 2;
    } else {
      x = a[i] % 2;
    }
    B[i] = min(C[i], B[i + 1] + x);
  }
  A[n] = 0;
  for (int i = n - 1; i >= 0; --i) {
    int x = 1 - a[i] % 2;
    A[i] = min(B[i], A[i + 1] + x);
  }
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  solve(a, n, R);
  reverse(a, a + n);
  solve(a, n, L);
  int64 ret = 1LL << 60;
  ret = min(ret, R[0]);
  ret = min(ret, L[0]);
  for (int i = 1; i < n; ++i) {
    ret = min(ret, R[i] + L[n - i]);
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 9600
program rally
  implicit none
  integer :: n, x(100) = 0, i, p
  read(*,*) n
  read(*,*) x(1:n)
  p = sum(x(1:n))/n
  write(*,'(i0)') min(sum((x(1:n)-p)*(x(1:n)-p)),sum((x(1:n)-p-1)*(x(1:n)-p-1)))
end program rally

Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(n-1):
    if p[i]==i+1:
        p[i],p[i+1]=p[i+1],p[i]
        ans+=1
if p[n-1]==n:
    p[n-1],p[n-2]=p[n-2],p[n-1]
    ans+=1
print(ans)

Measured memory_bytes: 13880
s = list(str(input()))
alpha = [chr(i) for i in range(97, 97+26)]
temp = [[] for _ in range(26)]
k = 0
for i in range(26):
  for j in range(len(s)):
    if alpha[i] == s[j]:
      temp[i].append(j)
M = []      
for i in range(26):
  m = 0
  l = len(temp[i])
  if l != 0:
    m = max([len(s) - temp[i][l - 1] - 1,temp[i][0]])
    for j in range(l-1):
      m = max([m,temp[i][j+1] - temp[i][j]-1])
    M.append(m)
print(min(M))    

Measured memory_bytes: 9156
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i,n) for(int i=0;i<n;i++)
char ca;
ll  c, d = 0, e,n, i, j, k, h, w, a[100005] = {}, b[55][55] = {}, o, p;
queue<ll> q;
string s;
vector<vector<ll>> v(100005);
map<ll,ll> m;

int main() {
	cin >> n;
	for (i = 1; i < n;i++) {
		cin >> o >> p >> e;
		v[o].push_back(p);
		v[p].push_back(o);
		m[o*n+p] = e;
		m[p * n + o] = e;
	}
	a[1] = 1;
	q.push(1);
	while (q.size() > 0) {
		w = q.front();
		rep(i, v[w].size()) {
			c = v[w][i];
			if (a[c] == 0) {
				k = m[w * n + c];
				a[c] = 1 + ((k + a[w] + 1) % 2);
				q.push(c);
			}
		}
			q.pop();
	}
	
		rep(i, n)
			cout << a[i + 1] - 1<<"\n";



	return 0;
}

Measured memory_bytes: 19840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>

using namespace std;

#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
const int MOD = 1e9 + 7;



int main() {
    int n;
    cin >> n;
    vs S(n);
    vector<char> alp = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
    map<char, int> ans;
    for (char x : alp) {
        ans[x] = 100;
    }
    rep(i, n) cin >> S[i];
    rep(i, n) {
        vi anss(26,0);
        rep(k, 26) {
                rep(j, S[i].size()) {
                if (S[i].at(j) == alp[k]) {
                    anss[k]++;
                }
            }
            if (anss[k] < ans[alp[k]]) ans[alp[k]] = anss[k];
        }
    }
    string answer = "";
    for (int i = 0; i < 26; i++) {
        rep(j, ans[alp[i]]) answer = answer + alp[i];
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{	
	int n,q,a;
	cin>>n;
	vector<int>v(n);
	map<int,int>m;
	for(int i=0;i<n;i++)cin>>v[i];
	for(int bit=0;bit<(1<<n);bit++)
	{	
		int sum=0;
		for(int i=0;i<n;i++)
		{
			if(bit&(1<<i))sum+=v[i];
		}
		m[sum]++;
	}
	cin>>q;
	for(int i=0;i<q;i++)
	{
		cin>>a;
		if(m[a]>0)cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	return 0;	
}


Measured memory_bytes: 3124
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
D = lr()

l = {i: 0 for i in range(13)}

for d in D:
    l[d] += 1

possible_lists = [[]]

for k, v in l.items():
    if v > 2:
        possible_lists = [[0]]
        break
    elif v > 1:
        new = [[0]] + [pl + [k, 24-k] for pl in possible_lists]
        # new = [pl + [k, k] for pl in possible_lists] + [pl + [24-k, 24-k] for pl in possible_lists] + [pl + [k, 24-k] for pl in possible_lists]
        possible_lists = new
    elif v > 0:
        new = [pl + [k] for pl in possible_lists] + [pl + [24-k] for pl in possible_lists]
        possible_lists = new

Max = -1
for pl in possible_lists:
    Min = 13
    pl.sort()
    for i in range(len(pl)):
        if i == 0:
            cand = pl[i]-0
            Min = min(Min, min(cand, 24-cand))
        elif i == len(pl)-1:
            cand = pl[i]-pl[i-1]
            Min = min(Min, min(cand, 24-cand))
            cand = pl[i]-0
            Min = min(Min, min(cand, 24-cand))
        else:
            cand = pl[i]-pl[i-1]
            Min = min(Min, min(cand, 24-cand))
    Max = max(Min, Max)

print(Max)


Measured memory_bytes: 3188
N=int(input())
Ni=[]
Mi=[]
Payoff=0
for i in range(N):
    Ni.append(input())
for i in range(int(input())):
    Mi.append(input())
for i in set(Ni+Mi):
    Payoff=max(Payoff, Ni.count(i)-Mi.count(i))
print(Payoff)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<ll> cnt(k, 0);
	for(int i = 1; i <= n; i++){
		cnt[i%k]++;
	}
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		int id = (k-(i%k))%k;
		if(id != i%k) continue;
		ans += (cnt[id])*(cnt[id]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

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

        // Input
        Scanner sc = new Scanner(System.in);

        String input = sc.next();
        String result = "";

        if ( input.trim().equals("Sunny") ) {
           result="Cloudy";
        } else if ( input.trim().equals("Cloudy") ) {
           result="Rainy";
        } else if ( input.trim().equals("Rainy") ) {
           result="Sunny";
        } else {
           result="Input Error";
        }

        // Output
        System.out.println(result);

        sc.close();
    }
}

Measured memory_bytes: 35616
#include <cstdlib>
#include <iostream>
#include <math.h>



void Eratosthenes(int N){

}

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

    int n;
    while (std::cin >> n) {
        if (n==0){
            return EXIT_SUCCESS;
        }
        int Nw = 4000;
        int ar[Nw];
        for( int i=0; i < Nw; i++){
            ar[i] = -1;
        }
        int br[Nw];
        for( int i=0; i < Nw; i++){
            br[i] = 0;
        }
        int e,p,q;
        for(int i = 0; i < n; i++){
            std::cin >> e >> p >> q;
            int b = -1;
            for(int k=0; k<Nw; k++){
                if (ar[k] == e) {
                    br[k] += p*q;
                    b = 1;
                    break;
                }
            }
            if (b==-1){
                for(int k=0; k<Nw; k++){
                    if (ar[k] == -1) {
                        ar[k] = e;
                        br[k] = p*q;
                        break;
                    }
                }
            }
        }
        int f = 0;
        for(int i =0; i < Nw; i++){
            if (br[i] >= 1000000){
                std::cout << ar[i] << std::endl;
                f = 1;
            }
        }
        if ( f == 0 ){
            std::cout << "NA" << std::endl;
        }
        // for(int i = 0; i< 5; i++){
        //     fprintf(stderr,"i=%2d, ar[i]=%5d, br[i]=%9d\n",i,ar[i],br[i]);
        // }
        // return EXIT_SUCCESS;
    }
    return EXIT_SUCCESS;
}


Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;
template<typename T> T factorial(T n){
    if(n==1) return 1;
    else return n*factorial(n-1);
}
template<typename T> T combination(T n, T k){
    vector<vector<T>> v(n+1, vector<T>(n+1, 0)); //dpテーブル
    rep(i, v.size()){
        v[i][0] = 1; v[i][i] = 1;
    }
    for(int j=1; j<v.size(); j++){
        for(int k=1; k<j; k++){
            v[j][k] = v[j-1][k-1] + v[j-1][k];
        }
    }
    return v[n][k];
}
struct edge{
    int to; // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using graph = vector<vector<edge>>;
using Graph = vector<vector<int>>;

int main(){
    str s; cin >> s;
    ll k; cin >> k;
    int ones = 0;
    rep(i, s.size()){
        if(s[i] == '1') ones++;
        else break;
    }
    if(ones >= k){
        cout << 1 << endl;
        return 0;
    }else{
        rep(i, s.size()){
            if(s[i] != '1'){
                cout << s[i] << endl;
                return 0;
            }else{
                continue;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
int main() {
    string S;
    cin >> S;
    int N = S.length() - 1;
    //連続しているRとLを探す周期は2であることは確か
    vector<int> C;
    for(int i = 0; i < S.length() - 1; i++) {
        if(S[i] != S[i + 1]) {
            C.push_back(i);
        }
    }
    // Rが始まる座標と偶数回目でのRとLの数
    vector<tuple<int, int, int>> res;
    for(int i = 0; i < C.size(); i++) {
        if(i == 0 and i == C.size() - 1) {
            int left = C[i];
            int right = N - C[i] - 1;
            int lc = 1 + left / 2 + (right - right / 2);
            int rc = 1 + (left - left / 2) + right / 2;
            res.emplace_back(C[i], rc, lc);

        } else if(i == 0) {
            int left = C[i];
            int right = C[i + 1] - C[i] - 1;
            int lc = 1 + left / 2 + (right - right / 2);
            int rc = 1 + (left - left / 2) + right / 2;
            res.emplace_back(C[i], rc, lc);

        } else if(i % 2 == 0 and i == C.size() - 1) {
            int left = C[i] - C[i - 1] - 1;
            int right = N - C[i] - 1;
            int lc = 1 + left / 2 + (right - right / 2);
            int rc = 1 + (left - left / 2) + right / 2;
            res.emplace_back(C[i], rc, lc);

        } else if(i % 2 == 0) {
            int left = C[i] - C[i - 1] - 1;
            int right = C[i + 1] - C[i] - 1;
            int lc = 1 + left / 2 + (right - right / 2);
            int rc = 1 + (left - left / 2) + right / 2;
            res.emplace_back(C[i], rc, lc);
        }
    }
    vector<long long> ans(N + 1, 0);
    for(int i = 0; i < res.size(); i++) {
        ans[get<0>(res[i])] = get<2>(res[i]);
        ans[get<0>(res[i]) + 1] = get<1>(res[i]);
    }
    REP(i, N + 1) { cout << ans[i] << " "; }
    cout << endl;
}

Measured memory_bytes: 2676
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll Rec(ll l,ll r);

const ll Inf = 1e18;

ll n;
ll a[440];
ll Prefix[440];

ll Dp[440][440];

int main()
{
    cin>>n;

    for(ll i=1;i<=n;i++) scanf("%I64d",a+i) , Prefix[i] = a[i] + Prefix[i-1];

    for(ll l=0;l<440;l++)
        for(ll r=0;r<440;r++)
            Dp[l][r] = ( l==r ? 0 : Inf );

    for(ll L=2;L<=n;L++)
        for(ll l=1,r=l+L-1;r<=n;l++,r++)
            for(ll i=l;i<r;i++)
                Dp[l][r] = min( Dp[l][r] , Dp[l][i] + Dp[i+1][r] + Prefix[r] - Prefix[l-1] );

    cout<<Dp[1][n];
}

Measured memory_bytes: 1792
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n, k;
    int[] card;
    boolean Joker;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    k = sc.nextInt();
	    if(n==0 && k==0) break;

	    card = new int[k];
	    
	    for(int i=0; i<k; i++)
		card[i] = sc.nextInt();
	    Arrays.sort(card);
	    Joker = card[0]==0;
	    //show();
	    
	    int R = k+1;
	    int L = Joker ? 2:1; 
	    int m = (R+L)/2;
	    while(L+1 != R){
		//System.out.println("*"+L+" "+R+" "+m);
		//System.out.println(m+" "+step(m));
		if(step(m)) L = m;
		else R = m;
		m = (R+L)/2;
	    }

	    System.out.println(L);
	}
    }

    boolean step(int m){
	int s = Joker ? 1:0;
	for(int i=s; i<k; i++){
	    //System.out.println("++"+card[i]);
	    int endN = i+m-1; // テヲツ慊?・ツセツ古」ツ?ョテ」ツつォテ」ツδシテ」ツδ嘉」ツ?ョテゥツ?催・ツ按療ァツ閉ェテ・ツ渉キ
	    int endC = card[i]+m-1; //テヲツ慊?・ツセツ古」ツ?ョテ」ツつォテ」ツδシテ」ツδ嘉」ツ?ォテ」ツ?づ」ツつ凝」ツ?ケテ」ツ?催・ツ?、
	    if(endC>n || endN>k) continue;
	    
	    if(endN==k)
		if(card[k-1]==endC && Joker) return true;
		else return false;
		
	    if(card[endN]==endC ||
	       (card[endN-1]==endC && Joker))
		return true;
	}
	return false;
    }

    void show(){
	for(int i=0; i<k; i++)
	    System.out.print(card[i]+" ");
	System.out.println();
    }
}

Measured memory_bytes: 62852
#include<stdio.h>

int main(){
  int n,c,s[100000],t[100000],cc[100000],f[30][200002]={},i,j,sum=0,max=0;
  scanf("%d %d",&n,&c);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&s[i],&t[i],&cc[i]);
    for(j=2*s[i]-1;j<=2*t[i];j++) f[cc[i]-1][j]=1;
  }
  for(i=1;i<=200001;i++){
    sum=0;
    for(j=0;j<c;j++){
      sum+=f[j][i];
    }
    if(max<sum)max=sum;
  }
  printf("%d\n",max);
}

Measured memory_bytes: 24832
import sys

def main():
  input = sys.stdin.readline
  b = str(input().strip())
  if b == 'A':
    print('T')
  elif b == 'T':
    print('A')
  elif b == 'G':
    print('C')
  else:
    print('G')

if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
#include <stdio.h>
int main(void){
    // Your code here!
    int X, flag = 0;
    scanf("%d",&X);
    for(int i = 1; i <= 9 && flag == 0; i++)
    {
        if(X%i == 0 && X/i <= 9 && X/i >= i)
            flag = 1;
    }
    printf("%s\n", (flag == 1)? "Yes":"No");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int n;
ll a[101];
ll dfs(int x,vector<int> &vec){
    if(x==n+1) return 0;
    bool isDiv=false;
    for(int i=0;i<vec.size();i++){
        isDiv|=(x%vec[i]==0);
    }
    if(isDiv) return dfs(x+1,vec);
    if(a[x]<0){
        if(x>50){
            return dfs(x+1,vec);
        }
        if(x>33){
            bool isDiv2=false;
            for(int i=0;i<vec.size();i++){
                isDiv2|=((2*x)%vec[i]==0);
            }
            if(isDiv2){
                return dfs(x+1,vec);
            }
            vec.push_back(x);
            ll res=dfs(x+1,vec)+max(0LL,a[x]+a[2*x]);
            vec.pop_back();
            return res;
        }
        vec.push_back(x);
        ll res2=dfs(x+1,vec);
        vec.pop_back();
        ll res1=dfs(x+1,vec)+a[x];
        return max(res1,res2);
    }
    else{
        ll res1=dfs(x+1,vec)+a[x];
        return res1;
    }
}

int main(){
    cin>>n;
    for(int i=0;i<101;i++) a[i]=0;
    for(int i=0;i<n;i++) cin>>a[i+1];
    vector<int> vec;
    cout<<dfs(1,vec)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vp vector<pair<int,int>>
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define ull unsigned long long
#define ld long double
#define all(x) x.begin(),x.end()
#define cmp(t,x) [](const t& _a,const t& _b) {return _a.x<_b.x;}
#define pq priority_queue
const long long p = (long long)1e9+7;
ll fmp(ll a,ll n,ll p){
	if (a==0) return 0;
	if (n==0) return 1;
	if (a==1) return a%p;
	ll ans = (fmp(a,n/2,p));ans=(ans*ans)%p;
	if (n%2) ans=(ans*a)%p;
	return ans;
}
ll dp[2002];
int main(){
    ios::sync_with_stdio(true);
    cin.tie(NULL);
    ll n;cin>>n;
	dp[3]=1;
	for (int i=4;i<=n;i++){
		dp[i]=1;
		for (int j=3;j<=i-3;j++) dp[i]=((dp[i]+dp[j])%p+p)%p;
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include "iostream"
using namespace std;
int main()
{
    int t;
    cin>>t;
    
    int l= t%10;
    
    if(l==2 || l==4 || l==5||l==7 || l==9)
        cout<<"hon"<<endl;
    
     if(l==0 || l==1 || l==6||l==8 )
        cout<<"pon"<<endl;
     if(l==3)
        cout<<"bon"<<endl;

}


Measured memory_bytes: 3132
#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;

int n;
long long a[100011];
long long s[100011];
int ans;
int main()
{
    int i,j,k;
    int xx;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&xx);
        a[i]=xx;
    }
    
    sort(a+1,a+n+1);
    s[0]=0;
    for(i=1;i<=n;i++)
    {
        s[i]=s[i-1]+a[i];
    }
    
    ans=1;
    for(i=n-1;i>=1;i--)
    {
        if(s[i]*2>=a[i+1])
        {
            ans++;
        }
        else
        {
            break;
        }
    }
    
    cout<<ans<<endl;
    
    
    return 0;
} 


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


int main() {
    int N;
    cin >> N;
    int p[N];
    rep(i, N) cin >> p[i];
    sort(p, p + N, greater<int>());

    int payment=0;
    rep(i, N){
        if(payment == 0){
            payment += p[i] / 2;
            continue;
        }
        payment += p[i];
    }
    cout << payment << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    string s,t;
    cin >> s;
    for(intl i = 0;i < s.length(); i += 2)cout << s[i];
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int a[100005]={0},b[100005]={0},c[100005]={0},copyA[100005],copyB[100005],copyC[100005],n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d %d %d",&copyA[i],&copyB[i],&copyC[i]);
	for(int i=1;i<=n;i++){//i天 
		a[i]=max(b[i-1]+copyA[i],c[i-1]+copyA[i]);
		b[i]=max(a[i-1]+copyB[i],c[i-1]+copyB[i]);
		c[i]=max(a[i-1]+copyC[i],b[i-1]+copyC[i]);
	}
	cout<<max(max(a[n],b[n]),c[n]);
	return 0;
}

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

//Euclid's algorithm
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}


int main(){
    ll n,k;
    cin>>n>>k;
    ll curr=0;
    ll p = 1e9 + 7; 
    ll ans=0;
    for(ll i=k;i<=n+1;i++){
        curr = (((i)*(2*n-i+1))/2) - (((i-1)*(i))/2) + 1;
        ans+=curr;
        ans=ans%p;
    }
    cout<<ans;
}

    


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

int main(){
  int a,b;
  cin >> a >> b;
  
  int suma=0;
  int sumb=0;
  
  for(int i=0;i<b;i++){
    suma=suma+a*pow(10,i);
  }
  for(int i=0;i<a;i++){
    sumb=sumb+b*pow(10,i);
  }
  
  if(a>b){
    cout << sumb << endl;
  }
  else{
    cout << suma << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
main(){
  int n,i,j,A[N],mini,b,c=0;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  for(i = 0; i < n; i++){
    mini = i;
    for(j = i; j < n; j++){
      if(A[j] < A[mini]){
	mini = j;
      }
    }
    if(mini != i){
	b = A[i];
	A[i] = A[mini];
	A[mini] = b;
	c++;
    }
  }


  for(i = 0; i < n-1; i++){
    printf("%d ",A[i]);
  }                                /* 表示 */
  printf("%d\n",A[n-1]);
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define pb push_back
    #define hell 1000000007

 using namespace std;
                                                                                                                                                                                                vector < int > v[100005];
vector < pair < ll , ll > > ok;
      void solve()
        {
           ll int i,j,k,n,e=0,m,n1,n2,c=0,x;
     cin>>n>>m>>x;
     rep(i,0,10)
      {
          k=n*x-m;
          cout<<k<<endl;
          x=k;

      }
        }




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

     int t=1;
    //cin>>t;
     while(t--)
      solve();
    }


Measured memory_bytes: 2560