akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N,i=1;
  cin>>N;
  for(;i<=N;i*=2){}
  cout<<i/2<<endl;
  return 0;
}

//   TimeTaken();



Measured memory_bytes: 256
N = int(input())
s = [int(input()) for _ in range(N)]
s.sort()
ans = sum(s)
if ans % 10 != 0:
    print(ans)
    exit()
for i in range(N):
    if s[i] % 10 != 0:
        print(ans-s[i])
        exit()
print(0)

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

int main() {
    auto pr = [](int s){
        cout << s << endl;
        exit(0);
    };
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b){
        pr(c);
    }else if(a==c){
        pr(b);
    }else if(b==c){
        pr(a);
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF = 2e9;
#define LINF = 1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << = << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO")
#define Yes(n) cout << ((n) ? "Yes" : "No")

void input(vector<int> x, auto n){
   rep(i,n)cin >> x[i];
}

int main(){

   double r;
   cin >> r;

   printf("%lf %lf\n", r*r*M_PI, r*2*M_PI);

}


Measured memory_bytes: 3120
#include <stdio.h>

int main(void)
{
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(c>=a&&c<=b){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

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

int n;
string S;
vector<int> maxes;

int main() {
    cin >> S;
    n = S.length();
    maxes.push_back(n);
    S = " " + S;

    for (int k = 1; k <= n - 1; ++k) {
        if (S[k] != S[k + 1]) {
            maxes.push_back(max(k, n - k));
        }
    }

    int T = *min_element(maxes.begin(), maxes.end());
    cout << T << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,ans=0;
  cin >> a >> b;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=a;j++){
      int k=b-i-j;
      if(i+j+k==b&&k>=0&&k<=a){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	int n, count = 0;
	string s;
	cin >> n >> s;

	FOR(0, n - 2)
	{
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') count++;
	}

	cout << count;
}

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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

lli n,m,r;
vll s;
vll idx;
lli a,b,c;
mat dist;
lli ans = LONG_MAX;

int main(){
  cin >> n >> m >> r;
  idx = vll(r);
  iota(idx.begin(),idx.end(),0);
  s = vll(r);
  for(lli i = 0;i < r;i++){
    cin >> s[i];
  }
  dist = mat(n+1,vll(n+1,INT_MAX));
  for(lli i = 0;i <= n;i++){
    dist[i][i] = 0;
  }
  for(lli i = 0;i < m;i++){
    cin >> a >> b >> c;
    dist[a][b] = c;
    dist[b][a] = c;
  }
  for(lli i = 0;i <= n;i++){
    for(lli j = 0;j <= n;j++){
      for(lli k = 0;k <= n;k++){
        dist[j][k] = min(dist[j][k],dist[j][i]+dist[i][k]);
      }
    }
  }
  do{
    lli res = 0;
    for(lli i = 1;i < r;i++){
      res += dist[s[idx[i-1]]][s[idx[i]]];
    }
    ans = min(ans,res);
  }while(next_permutation(idx.begin(),idx.end()));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
from time import time
from random import random

limit_secs = 2
start_time = time()

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

def calc_score():
    score = 0
    S = 0
    last = [-1] * 26
    for d in range(D):
        S += s[d][t[d]]
        last[t[d]] = d
        for i in range(26):
            S -= c[i] * (d - last[i])
        score += max(10 ** 6 + S, 0)
    return score

def solution():
    return [i % 26 for i in range(D)]

t = solution()
score = calc_score()
while time() - start_time + 0.14 < limit_secs:
    d = int(random() * D)
    q = int(random() * 26)
    old = t[d]
    t[d] = q
    new_score = calc_score()
    if new_score < score:
        t[d] = old
    else:
        score = new_score
print('\n'.join(str(e + 1) for e in t))


Measured memory_bytes: 85052
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
//#include "toollib.h"
//#include "puzzle.h"
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#pragma warning (disable:4018)
#pragma warning (disable:4244)
#pragma warning (disable:4996)

using namespace std;
typedef long long int lint;


//***** Main Program *****

int main() {
	int n, q;
	cin >> n;
	vector<int> S(n);
	Loop(i, n) cin >> S[i];
	cin >> q;
	vector<int> T(q);
	Loop(i, q) cin >> T[i];
	int ret = 0;
	Loop(i, q) {
		Loop(j, n) {
			if (S[j] == T[i]) {
				ret++;
				break;
			}
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3136
fun main(args: Array<String>) = p11()

fun p11() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val ksList = (1..m).map { readLine()!!.split(' ').map { it.toInt() - 1 }.drop(1) }
    val pList = readLine()!!.split(' ').map { it.toInt() }

    var answer = 0

    for (i in 0L until (1L shl n)) {
        ksList.mapIndexed { index, sList -> sList.count { (i shr it) % 2 == 0L } % 2 == pList[index] }
            .all { it }.let { if (it) answer++ }
    }

    println(answer)
}


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

int main()
{
    string a,b;
    int l,i,d=1;
    cin>>a>>b;
    l=a.length();
    for(i=0;i<l;i++)
    {
        if(a[i]==b[i])
        {
            d=1;
            //continue;
        }
        else
        {
            d=0;
            break;
        }
    }
    if(d==1)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 3592
G = [1]
cnt = 0


def insert_sort_general(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j -= g
            cnt += 1
        A[j + g] = v


def shell_sort(A, n):
    global G
    g = 4
    while g < n:
        G.append(g)
        g = 3 * g + 1
    G.reverse()
    for g in G:
        insert_sort_general(A, n, g)
    return G


if __name__ == '__main__':
    n = int(raw_input())
    A = []
    for i in range(n):
        x = int(raw_input())
        A.append(x)
    shell_sort(A, n)
    print len(G)
    for x in G:
        print x,
    print
    print cnt
    for i in range(n):
        print A[i]


Measured memory_bytes: 68056
#include<stdio.h>
#include<string.h>
int main(void){
    int i;
    char a[3][3];

    scanf("%s%s%s",a[0],a[1],a[2]);

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

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1e9+7;

bool start[200020],goal[200020];
int main(){
    int n,m;
    cin>>n>>m;
    
    rep(i,0,m){
        int x,y;
        cin>>x>>y;
        if(x==1)start[y]=true;
        if(y==n)goal[x]=true;
    }
    
    bool can=false;
    rep(i,0,n+1)if(start[i] && goal[i])can=true;
    if(can)cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#define  MAXN 10010
using namespace std;
struct Edge
{
	int point1;
	int point2;
	int weight;
};
bool cmp(Edge &x, Edge &y)
{
	return x.weight < y.weight;
}
int pre[MAXN];
vector <Edge> vec;
int find(int x)
{//并查集
	int root = x;

	while (pre[root] != root)
		root = pre[root];//找根
	int t = x;
	while (pre[t] != root)
	{//路径压缩
		int temp = pre[t];
		pre[t] = root;
		t = temp;
	}

	return root;
}
int main()
{
	int n, m;
	int min_sum = 0;

	scanf("%d%d", &n, &m);//n是点数，m是边数
	for (int i = 0; i < n; i++)
		pre[i] = i;//初始化并查集
	for (int i = 0; i < m; i++)
	{//输入每条边的两个顶点及其权重
		Edge temp;

		scanf("%d%d%d", &temp.point1, &temp.point2, &temp.weight);
		vec.push_back(temp);
	}
	sort(vec.begin(), vec.end(), cmp);//按权重对边进行排序
	int coun = 0;
	for (int i = 0; i < m; i++)
	{//最多只有m条边
		int fx = find(vec[i].point1);
		int fy = find(vec[i].point2);

		if (fx != fy)
		{//如果这条边的两个顶点所在集合不相同就合并
			coun++;//成功合并后就多了一条边
			min_sum += vec[i].weight;
			pre[fx] = fy;//合并
			if (coun == n - 1)
				break;//krusal有n-1条边
		}
	}
	printf("%d\n", min_sum);
	return 0;
}


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

string s[3];
int main(void){
	cin >> s[0] >> s[1] >> s[2];
	int now = 0;
	while(1){
		if(s[now].size() == 0){
			if(now == 0) printf("A\n");
			else if(now == 1) printf("B\n");
			else if(now == 2) printf("C\n");
			return 0;
		}
		int tmp = now;
		if(s[now][0] == 'a'){
			now = 0;
		}else if(s[now][0] == 'b'){
			now = 1;
		}else if(s[now][0] == 'c'){
			now = 2;
		}
		s[tmp].erase(s[tmp].begin());
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using GraphI = vector<vector<int>>;
using GraphC = vector<vector<char>>;

int main() {
  int h, w;
  cin >> h >> w;
  GraphC g(h, vector<char>(w, '#'));
  int white = 0;
  rep(y, h) {
    rep(x, w) {
      cin >> g[y][x];
      if (g[y][x] == '.') white++;
    }
  }

  GraphI d(h, vector<int>(w, -1));
  d[0][0] = 0;
  queue<pair<int, int>> q;
  q.push(make_pair(0, 0));

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

  while (!q.empty()) {
    pair<int, int> now = q.front();
    q.pop();

    rep(i, 4) {
      int ny, nx;
      ny = now.first + dy[i];
      nx = now.second + dx[i];
      if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
      if (g[ny][nx] == '#') continue;
      if (d[ny][nx] != -1) continue;
      d[ny][nx] = d[now.first][now.second] + 1;
      q.push(make_pair(ny, nx));
    }
  }

  int goal = d[h - 1][w - 1];
  if (goal == -1)
    cout << -1 << endl;
  else
    cout << white - (d[h - 1][w - 1] + 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <vector>
#include <map>
#include <cstring>
#include <set>
using namespace std;

typedef long long ll;

ll n, a[100005], x, rj, s[55], s2[55];

ll f(ll p, ll pr)
{
    if (pr == 0)
        return 1;

    if (p == 0)
        return 0;

    if (p == s[pr] - 1)
        return s2[pr];

    if (p == s[pr] / 2)
        return 1 + s2[pr - 1];

    if (p < s[pr] / 2)
        return f(p - 1, pr - 1);
    else
        return f(p - s[pr - 1] - 2, pr - 1) + s2[pr - 1] + 1;
}

int main()
{
    cin >> n >> x;
    --x;
    s[0] = 1;
    s2[0] = 1;
    for (int i = 1; i <= 50; ++i)
    {
        s[i] = s[i - 1] * 2 + 3;
        s2[i] = s2[i - 1] * 2 + 1;
    }
    cout << f(x, n) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int i,t,n;
	for(i=0;i<4;i++){
		scanf("%d %d",&t,&n);
		switch(t){
		case 1:
			printf("%d\n",n*6000);
			break;
		case 2:
			printf("%d\n",n*4000);
			break;
		case 3:
			printf("%d\n",n*3000);
			break;
		case 4:
			printf("%d\n",n*2000);
			break;
		}
	}
	return 0;
}

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

int main()
{
    string s;
    cin >> s;
    int N = s.size();
    int r=0,b=0;
    for(int i=0;i<N;i++)
    {
        if(s.at(i)=='0') r++;
        if(s.at(i)=='1') b++;
    }
    cout << min(r,b) * 2 << endl;

    return 0;
}

Measured memory_bytes: 512
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, L, R, H, W;



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> N;
	map<int, int>m;
	for (int i = 0; i < N; i++) {
		cin >> M;
		m[M]++;
	}
	M = 0;
	for (auto i : m) {
		if (i.second % 2) {
			M++;
		}
	}
	cout << M << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<string.h>
#include<stdbool.h>

int a[200001];
int rocker[200001];
int rocker_no[200001];
bool rocker_judge[200001];

int main()
{
    int n, d, c, j, r_num;
    long long k;
    
    scanf("%d %lld", &n, &k);

    for (int i = 1; i<=n; i++)
    {
        scanf("%d", &a[i]);
        rocker_judge[i] = true;
    }

    c = 1;
    j = 1;

    for (;rocker_judge[c] == true; j++)
    {
        rocker_judge[c] = false;
        rocker_no[c] = j;
        rocker[j] = c;
        c = a[c];
    }

    r_num = j - rocker_no[c]; 

    if ((k+1) <= rocker_no[c]){
        d = rocker[k+1];
    } else {
        d = rocker[((k - (rocker_no[c] - 1))%r_num) + rocker_no[c]];
    }

    printf("%d", d);

    return 0;
}

Measured memory_bytes: 4180
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int h = sc.nextInt();
			int w = sc.nextInt();
			int k = sc.nextInt();
			
			int[][] table = new int[h][w];
			
			for(int i = 0 ; i < h ; i++ ) {
				String s = sc.next();
				
				for(int j = 0 ; j < s.length(); j++ ) {
					table[i][j] = s.charAt(j) == '.' ? 0 : 1;
				}
			}
			
//			for(int i = 0 ; i < h ;i++ ) {
//				for(int j = 0 ; j < w ; j++ ) {
//					System.out.print(table[i][j]);
//				}
//				System.out.println();
//			}
			
			//consider all case
			int maxRows = (int)Math.pow(2, h);
			int maxCols = (int)Math.pow(2, w);
			
			int ans = 0;
			
			for(int i = 0 ; i < maxRows ; i++ ) {
				
				List<Integer> restRows = new ArrayList<>();
				for(int l = 0 ; l < h ; l++ ) {
//					System.out.println((i >> l) & 1);
					if ( ((i >> l) & 1) == 1 ) {
						restRows.add(l);
					}
				}
//				System.out.println(i & 1);
//				System.out.println((i >> 1) & 1);
//				System.out.println((i >> 2) & 1);
//				System.out.println(i >> 3 & 1);
//				System.out.println(i >> 4 & 1);
//				System.out.println(i >> 5 & 1);				
//				System.out.println("----");
				
				for(int j = 0 ; j < maxCols ; j++ ) {
					List<Integer> restCols = new ArrayList<>();

					for(int l = 0 ; l < w ; l++ ) {
//						System.out.println((j >> l) & 1);
						if ( ((j >> l) & 1) == 1 ) {
							restCols.add(l);
						}
					}
//					System.out.println("----");
					//check blacks
					int count = 0;
					for(int y = 0 ; y < h ; y++ ) {
						if ( !restRows.contains(y) ) continue;
						for(int x = 0 ; x < w ; x++ ) {
							if ( restCols.contains(x)) {
								if ( table[y][x] == 1) {
									count++;
								}
							}
						}
					}
					
					if ( count == k ) {
//						System.out.println(i + " x " + j);
						ans++;
					}
				}
			}
			
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 38248
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

    lint res = 0;

    lint i = 1;
    while (i * i <= n) {
        lint m = (n - i);
        if (m % i != 0) { i++; continue; }
        m /= i;
        if (i >= m) { i++; continue; }
        res += m;
        i++;
    }

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


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

int main(){
  int n, m, i, j, k;
  string s, ans="No";
  cin >> n >> m;
  
  vector<string> a, b;
  
  for (k=0; k<n; k++) {
    cin >> s;
    a.push_back(s);
  }
  for (k=0; k<m; k++) {
    cin >> s;
    b.push_back(s);
  }
  
  for (i=0; i<=n-m; i++) {
    for (j=0; j<=n-m; j++) {
      for (k=0; k<m; k++) {
        s = a[i+k].substr(j, m);
        if (b[k] != s) break;
        if (k == (m-1)) ans ="Yes"; 
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;  
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	x := nextInt()
	if x == 3 || x == 5 || x == 7 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 998244353
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, S; cin >> N >> S;
	VI A(N);
	REP(i, N)cin >> A[i];
	int dp[3010][3010][3] = { 0 };

	dp[0][0][0] = 1;

	eFOR(i, 1, N) {

		eFOR(j, 0, S) {

			dp[i][j][0] += dp[i - 1][j][0];
			dp[i][j][1] += dp[i - 1][j][0] + dp[i - 1][j][1];
			dp[i][j][2] += dp[i - 1][j][0] + dp[i - 1][j][1] + dp[i - 1][j][2];
			
			dp[i][j][0] %= mod;
			dp[i][j][1] %= mod;
			dp[i][j][2] %= mod;

			if (j - A[i - 1] < 0)continue;

			dp[i][j][1] += dp[i - 1][j - A[i - 1]][0] + dp[i - 1][j - A[i - 1]][1];
			dp[i][j][2] += dp[i - 1][j - A[i - 1]][0] + dp[i - 1][j - A[i - 1]][1];

			dp[i][j][0] %= mod;
			dp[i][j][1] %= mod;
			dp[i][j][2] %= mod;


			//cout << i << " " << j << " " << dp[i][j][0] << " " << dp[i][j][1] << " " << dp[i][j][2] << endl;
		}
	}

	cout << dp[N][S][2] << endl;

	return 0;
}



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

int main () {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;

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

  vector < int > b(a);
  sort(b.begin(), b.end());

  int swaps = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) swaps++;
    if (swaps > 2) {
      cout << "NO\n";
      return 0;
    }
  }

  cout << "YES\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long
int store[100001];
int main() {
    ios_base::sync_with_stdio(false);
 cin.tie(NULL);
	int n;
	cin>>n;
	int arr[n+1];
	ll sum=0;
	for(int i=1;i<=n;i++)
	{
	    cin>>arr[i];
	    sum+=arr[i];
	    store[arr[i]]++;
	}
	int q;
	cin>>q;
	while(q--)
	{
	    int a,b;
	    cin>>a>>b;
	    if(store[a]==0)
	    cout<<sum<<"\n";
	    else
	    {
	        int x=store[a];
	        store[a]=0;
	        store[b]+=x;
	        sum+=x*(b-a);
	        cout<<sum<<"\n";
	    }
	}
	return 0;
}


Measured memory_bytes: 4424
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define sz(v) (int)v.size()
#define pb push_back

using namespace std;
int n;
int main(){
    cin >> n;
    cout<< ((n%2)? 2*n : n) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back
#define INF 1e9
using namespace std;

int main()
{
    int r;
    cin>>r;
    cout<<r*r<<endl;
    return 0;
}

Measured memory_bytes: 256
open Batteries
open Printf
let () =
  let s = Scanf.scanf "%s " (fun a -> a) in
  let s1 = String.slice ~last:1 s in
  let s2 = String.slice ~first:2 ~last:(String.length s - 1) s in

  Printf.printf "%s\n" @@
  if s1 = "A" && (
      let l = List.of_enum (
          String.find_all s2 "C"
        )
      in
      List.length l = 1
    ) && (
       String.length (String.filter Char.is_lowercase s) = (String.length s) - 2
    )
  then "AC" else "WA"


Measured memory_bytes: 1152
/**
 * File    : F.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-2-27 18:27:15
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

const long long MOD = 1000000007;

long long power(long long x, long long n) {
  if (n == 0) {
    return 1;
  } else if (n%2 == 1) {
    return (x * power(x, n-1)) % MOD;
  } else {
    long long half = power(x, n/2);
    return (half * half) % MOD;
  }
}

int f[30000010];

int main()
{
  int S;
  cin >> S;
  vector<int> Y;
  int SQ = sqrt(S) + 10;
  for (int i = 1; i < SQ; i++)
  {
    if (S%i == 0)
    {
      int j = S / i;
      if (i < j)
      {
        Y.push_back(i);
        Y.push_back(j);
      }
      else if (i == j)
      {
        Y.push_back(i);
      }
    }
  }
  ll ans = 0;
  for (auto i = 0; i < 8; i++)
  {
    int lb = power(10, i);
    int ub = min((int)power(10, i + 1), 30000010);
    for (auto j = lb; j < ub; j++)
    {
      f[j] = i+1;
    }
  }
  int lb = 1;
  int ub = 1;
  int sum = 0;
  while (lb < 10000000)
  {
    if (sum == S)
      ans++;
    if (sum <= S)
    {
      sum += f[ub++];
    }
    else
    {
      sum -= f[lb++];
    }
  }
  ans += S / 8;
  for (auto k : Y)
  {
    if (k <= S/8)
    {
      int d = S / k;
      ans += (power(10, d) + MOD - power(10, d - 1) + MOD - S / d) % MOD;
      ans %= MOD;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 117504
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    i = 0
    ans = 0
    while i<n:
        if A[i] % 2 == 0:
            A[i] //= 2
            ans += 1
        else:
            i += 1
    print(ans)
resolve()

Measured memory_bytes: 10112
/*
Author: Snickeen 
Email : ff@snickeen.com
If you find any bug, please tell me.
*/

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

typedef long long LL;

const LL INF = 1e18+7;
const LL MOD = 1e9+7;
const LL MAXN = 1e6+7;

/////**********************************************/////



signed main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	LL n=0;
	char a[5];
	while(n++<3)cin>>a,cout<<a[n-1];
	return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		a.push_back(tmp - i - 1);
	}
	sort(a.begin(), a.end());
	long long ans = 0, d = (n % 2 == 0 ? (a[n / 2 - 1] + a[n / 2]) / 2 : a[n / 2]);
	for (int i = 0; i < n; i++)
		ans += abs(a[i] - d);
	cout << ans << endl;

	return 0;
}


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

using namespace std;

int n,m;

void process()
{
    for (int x=0;x<=n;++x)
    {
        int y=n-x;
        if (2*x+4*y==m)
        {
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
}

int main()
{
    cin>>n>>m;
    process();
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll x,ans=0,n=100;
  cin>>x;
  
  while(n<x)
  {
    n+=n/100;
    ans++;
  }
  
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 3612
line=[]

for i in range(5):
    line.append( int(input()))

k = int(input())

out = "Yay!"

for i in range(5):
    for j in range(4-i):
        tmp = line[i] - line[j+1]

        if abs(tmp) > k:
            out = ":("

    if out == ":(":
        break

print(out)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    vector<int> x, y;
    int n, m, X, Y, k;
    cin >> n >> m >> X >>  Y;
    for(int i = 0; i < n; i++){
        cin >> k;
        x.push_back(k);
    }
    for(int i = 0; i < m; i++){
        cin >> k;
        y.push_back(k);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    if(max(x[n-1], X) < min(y[0], Y)) cout << "No War" << endl;
    else cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    long int hight[10];
    long int i,j,temp;
    for(i=0;i<10;i++){
        scanf("%ld",&hight[i]);
    }
    for(i=0;i<10;i++){
        for(j=i+1;j<10;j++){
            if(hight[i]<hight[j]){
                temp=hight[i];
                hight[i]=hight[j];
                hight[j]=temp;
            }
        }
    }
    for(i=0;i<3;i++)
    printf("%ld\n",hight[i]);
    return 0;
}

Measured memory_bytes: 600
import Data.List (unfoldr)
import Data.Tuple (swap)

toDigits :: Int -> [Int]
toDigits = unfoldr phi
  where
    phi n = if n /= 0 then Just (swap (n `divMod` 10)) else Nothing

calc :: [Int] -> Int
calc [n,a,b] = sum $ filter p [1..n]
  where
    p m = a <= s && s <= b where s = sum (toDigits m)

main :: IO ()
main = print . calc =<< fmap read . words <$> getLine


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

int main() {
  int A, B;
  cin >> A >> B;

  cout << max({A + B, 2 * A - 1, 2 * B - 1}) << endl;
  return 0;
}

Measured memory_bytes: 3592
n,c = map(int,input().split())
xv = [ tuple(map(int, input().split())) for _ in range(n)]

go = [[0] * (n+1) for _ in range(2)]
turn = [[0] * (n+1) for _ in range(2)]

tmp = 0
g_max = 0
t_max = 0
for i in range(1,n+1):
    tmp += xv[i-1][1]
    go[0][i] = g_max = max(tmp - xv[i-1][0], g_max)
    turn[0][i] = t_max = max(tmp - xv[i-1][0] * 2, t_max)
    
tmp = 0
g_max = 0
t_max = 0
for i in range(n, 0, -1):
    tmp += xv[i-1][1]
    go[1][i] = g_max = max(tmp - (c - xv[i-1][0]), g_max)
    turn[1][i] = t_max = max(tmp - (c - xv[i-1][0]) * 2, t_max)

ans = 0
for i in range(1, n+1):
    ans = max(go[0][i] + turn[1][(i+1)%(n+1)], ans)
    ans = max(go[1][i] + turn[0][i-1], ans)
    
print(ans)

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

int main()
{
  int N,M;
  cin >> N >> M;
  
  int H[N]; // Height
  for (int n=0;n<N;n++)
    cin >> H[n];
  
  vector<vector<int>> graph(N);
  
   for (int m=0;m<M;m++) {
     int a,b;
     cin >> a >> b;
     graph.at(a-1).push_back(b-1);
     graph.at(b-1).push_back(a-1);
   }
  
  int best_point = 0;
  
  for (int n=0;n<N;n++) {
    bool is_best = true;
    for (int i=0; i < (int)(graph.at(n).size()); i++) {
      if (H[n] <= H[graph.at(n).at(i)]) {
        is_best=false;
        break;
      }
    }
    
    if (is_best) best_point++;
  }

  cout << best_point << endl;
}

Measured memory_bytes: 8812
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

string S[26][26];

int main()
{
	int H, W;

	cin >> H >> W;
	rep(i, H) rep(j, W) cin >> S[i][j];

	rep(i, H) rep(j, W) {
		if (S[i][j] == "snuke") {
			char c = 'A' + (char)j;

			cout << c << i + 1 << endl;

			return 0;
		}
	}

	return 0;
}

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

int main(){
    int N, K;
    std::cin >> N >> K;
    std::vector< int > A(N);
    int max_cnt = 0;
    for(int i=0; i<N; i++){
        std::cin >> A[i];
        if(A[i] == N){
            max_cnt++;
        }
    }
    for(int i=0; i<K; i++){
        std::vector< int > p(N, 0);
        std::vector< int > m(N, 0);
        int cnt = 0;
        for(int j=0; j<N; j++){
            int p_index = j - A[j];
            if(p_index < 0){
                cnt++;
            }else{
                p[p_index]++;
            }

            int m_index = j + A[j];
            if(m_index < N){
                m[m_index]++;
            }
        }
        for(int j=0; j<N; j++){
            cnt += p[j];
            A[j] = cnt;
            cnt -= m[j];
        }
        bool end = true;
        for(int j=0; j<N; j++){
            if(A[j] != N){
                end = false;
                break;
            }
        }
        if(end){
            break;
        }
        //if(max_cnt == N){
        //    //std::cout << i << "i" << max_cnt << std::endl;
        //    break;
        //}
    }

    for(int i=0; i<N; i++){
        std::cout << A[i] << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 5632
a = input().split()
b = input()
c = int(0)

for i in range(int(a[0])):
  if b[i] == "-":
    c = 1
  else:
    pass

if b[int(a[0])] != "-":
  c = 1

for i in range(int(a[0]) + 1, int(a[0]) + int(a[1]) + 1):
  if b[i] == "-":
    c = 1
  else:
    pass

if c == 1:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
 
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

bool ispali(string string1){
    ll length = string1.length();
    
    int flag=0;
    for(int i=0;i < length ;i++){
        if(string1[i] != string1[length-i-1]){
            flag = 1;
            break;
	   }
	}
	if(flag){
		return false;
	}
	return true;
}

int main() {

	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	string s;
	cin>>s;
	string s1="";
	string s2="";

	ll n = s.length();
	for (int i = 0; i < n/2; ++i)
	{
		s1+=s[i];
	}

	for (int i = (n/2)+1; i < n; ++i)
	{
		s2+=s[i];
	}

	if(ispali(s) && ispali(s1) && ispali(s2)){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}

	return 0;
}

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

int main(void){
    string s;
    cin >> s;
    for(int i=0; i<4; i++){
        cout << s[i];
    }
    cout << " ";
    for(int i=4; i<12; i++){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

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

void fail(){
    cout << -1 << endl;
    exit(0);
}

typedef vector<pair<int, int>> PT;

int main(){
    int N, K, A[50];
    cin >> N >> K;
    PT P;
    for(int i=0; i<N; i++){
        cin >> A[i];
        P.push_back({A[i], i});
    }
    sort(P.rbegin(), P.rend());

    vector<int> ans;
    while(true){
        for(int i=0; i<N-1; i++){
            if(P[i].first == 0) fail();
            P[i].first--;
            ans.push_back(P[i].second);
        }
        if(K == 0 && P[N-1].first > 0){
            ans.push_back(P[N-1].second);
            int Q = ans.size();
            cout << Q << endl;
            for(int i=0; i<Q; i++) cout << ans[i]+1 << " \n"[i==Q-1];
            return 0;
        }else{
            K--;
            PT P2 = {P[N-1]};
            P.pop_back();
            sort(P.rbegin(), P.rend());
            for(auto& p : P) P2.push_back(p);
            P = P2;
        }
    }
    return 0;
}

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

using namespace std;

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

	vector<int> nodes(N);

	for (int i = 0; i < N; i++)
		nodes[i] = 0;

	for (int i = 0; i < M * 2; i++)
	{
		int a;
		cin >> a;
		a--;
		nodes[a]++;
	}

	for (int i = 0; i < N; i++)
		cout << nodes[i] << endl;	

	return 0;
}

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

#define ll long long
#define endl "\n";
#define mod 1000000007
#define pii pair<int,int>
#define vii vector<pii>
#define mp make_pair
#define all(a) a.begin(), a.end()
#define mk(arr,n,type) type *arr=new type[n];

void fastio() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int main() {
	fastio();
	long double a, b;
	cin >> a >> b;
	long long int x = a * b;
	cout << x;

	return 0;
}


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x ,int y){return (x%mod + y%mod)%mod;}
inline int submod(int x ,int y){return (x%mod - y%mod + mod)%mod;}
inline int mulmod(int x ,int y){return (x%mod *1LL* y%mod)%mod;}
inline int nextSubMask(int i , int mask) {return (i-1)&mask;} /// returns next smallest submask

void we_r_done(){cout<<"NO"; exit(0);}

void debug(bool ok , string mssg)
{
    if(ok)return;
    cout<<mssg;
    exit(0);
}

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    FastIO;

    int n;
    cin>>n;

    multiset<int>st;
    int x;
    cin>>x;
    st.insert(x);
    for(int i=2; i<=n; i++){
        cin>>x;

        auto it  = st.lower_bound(x);

        if(it == st.begin()){
            st.insert(x);
        }
        else{
            it--;
            //cout<<"  "<<*it<<endl;
            if(*it != x) st.erase(it);
            st.insert(x);
        }
    }

    cout<<st.size();


    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 4992
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())

    if N % 10 in (2, 4, 5, 7, 9):
        print("hon")
    elif N % 10 == 3:
        print("bon")
    else:
        print("pon")


if __name__ == '__main__':
    main()



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

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

	int ans;

	if (a * c <= b) {
		ans = c;
	}
	else {		
		ans = b / a;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] a){
		Scanner s=new Scanner(System.in);
		int i,sum=0,d;
		while(s.hasNext()){
			d=s.nextInt();
			for(i=1;d*i<600;i++){
				sum+=(int)Math.pow(d*i, 2)*d;
			}
			System.out.println(sum);
			sum=0;
		}
	}
}

Measured memory_bytes: 11000
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        var hash = new HashSet<char>() {
            'A', 'C', 'G', 'T'
        };

        var max = 0;
        var c = 0;

        for (int i = 0; i < s.Length; i++) {
            c = hash.Contains(s[i]) ? c + 1 : 0;
            max = Math.Max(max,c);
        }

        return max;
    }
}


Measured memory_bytes: 11360
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k, j;
  cin >> j;
  string s;
  k=0;
  for(int i=0;i<j;i++){
    cin >> s;
    if(s=="Y"){
      cout << "Four" << endl;
      break;
    }
    k++;
  }
  if(k==j){
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
vector<int> v[200001];
int f[200001],vis[200001],js, tot, res;
void dfs(int x, bool f) {
	vis[x]=1;
	if(f) ++js;
	else ++tot;
	for(int i=0; i<v[x].size(); i++) {
		int y=v[x][i];
		++res;
		if (!vis[y])
			dfs(y,f^1);
	}
}
main() {
	int n=read(),x,y,cnt=0,ans=0;
	for(int i=1; i<=n; i++) {
		x=read(),y=read()+100000;
		if(!f[x]) f[x]=++cnt;
		if(!f[y]) f[y]=++cnt;
		x=f[x], y=f[y],v[x].push_back(y),v[y].push_back(x);
	}
	for(int i=1; i<=cnt; i++)
		if(!vis[i])
			js=0,tot=0,res=0,dfs(i,0),ans+=js*tot-(res>>1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14976
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> A, B, C;
  rep(i,N){
    int a;
    cin >> a;
    A.push_back(a);
  } 
  rep(i,N){
    int b;
    cin >> b;
    B.push_back(b);
  }
  rep(i,N-1){
    int c;
    cin >> c;
    C.push_back(c);
  }

  int ret = 0;
  rep(i,N){
    ret += B[A[i]-1];
    if(i>0){
      if(A[i] == A[i-1]+1){
        ret += C[A[i-1]-1];
      }
    }
  }
  
  cout << ret << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	char c;
	cin >> c;

	vector<char>abc = { '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' };

	char ans;
	for (int i = 0; i < 26; i++) {
		if (c == abc[i]) {
			ans = abc[i + 1];
			break;
		}
	}

	cout << ans << endl;



	return 0;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Stack;

public class Main {

	static class Node {
		int id, parentId, left, right;
		boolean visited;
		public Node(int id) {
			this.id = id;
			parentId = left = right = -1;
			visited = false;
		}
	}

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		Node[] nodes = new Node[n];
		for (int i = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(reader.readLine());
			int id = Integer.parseInt(st.nextToken());
			int left = Integer.parseInt(st.nextToken());
			int right = Integer.parseInt(st.nextToken());
			if (nodes[id] == null) {
				nodes[id] = new Node(id);
			}
			nodes[id].left = left;
			nodes[id].right = right;
			if (left != -1) {
				if (nodes[left] == null) nodes[left] = new Node(left);
				nodes[left].parentId = id;
			}
			if (right != -1) {
				if (nodes[right] == null) nodes[right] = new Node(right);
				nodes[right].parentId = id;
			}
		}

		int rootId = -1;
		for (int i = 0; i < nodes.length; i++) {
			if (nodes[i].parentId == -1) {
				rootId = nodes[i].id;
				break;
			}
		}
		System.out.println("Preorder");
		preOrder(nodes, rootId);
		resetVisited(nodes);
		System.out.println("Inorder");
		inOrder(nodes, rootId);
		resetVisited(nodes);
		System.out.println("Postorder");
		postOrder(nodes, rootId);
	}

	private static void resetVisited(Node[] nodes) {
		for (int i = 0; i < nodes.length; i++) nodes[i].visited = false;
	}

	private static void visit(Node node) {
		System.out.print(" " + node.id);
		node.visited = true;		
	}
	
	private static void preOrder(Node[] nodes, int rootId) {
		Stack<Integer> stack = new Stack<Integer>();
		stack.push(rootId);
		while (!stack.isEmpty()) {
			Node node = nodes[stack.pop()];
			visit(node);
			if (node.right != -1) stack.push(node.right);
			if (node.left != -1) stack.push(node.left);
		}
		System.out.println("");
	}

	private static void inOrder(Node[] nodes, int rootId) {
		Stack<Integer> stack = new Stack<Integer>();
		stack.push(rootId);
		while (!stack.isEmpty()) {
			Node node = nodes[stack.pop()];
			if (node.right != -1 && !nodes[node.right].visited) stack.push(node.right);
			if (node.left == -1 || nodes[node.left].visited) {
				if (!node.visited) visit(node);
			} else {
				stack.push(node.id);
			}
			if (node.left != -1 && !nodes[node.left].visited) stack.push(node.left);
		}
		System.out.println("");
	}

	private static void postOrder(Node[] nodes, int rootId) {
		Stack<Integer> stack = new Stack<Integer>();
		stack.push(rootId);
		while (!stack.isEmpty()) {
			Node node = nodes[stack.pop()];
			if ((node.left == -1 || nodes[node.left].visited) && (node.right == -1 || nodes[node.right].visited)) {
				visit(node);
			} else {
				stack.push(node.id);
			}
			if (node.right != -1 && !nodes[node.right].visited) stack.push(node.right);
			if (node.left != -1 && !nodes[node.left].visited) stack.push(node.left);
		}
		System.out.println("");
	}
}


Measured memory_bytes: 24476
def main():
    k = int(input())
    hp = list(range(1, 10))
    for i in range(k-1):
        n = hp.pop(0)
        nm = n % 10
        val = n * 10 + nm
        
        if nm != 0:
            hp.append(val - 1)
        hp.append(val)
        if nm != 9:
            hp.append(val + 1)
    print(hp[0])

main()


Measured memory_bytes: 18480
import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from math import *

N = int(input())
s, t = input(), input()
mod = 10**9+7
ans = 1
pre = -1
for a, b in zip(s, t):
    if pre == 0:
        ans *= 2
        if a == b:
            pre = 0
        else:
            pre = 1
    elif pre == 1:
        pre = 2
    elif pre == 2:
        if a == b:
            pre = 0
        else:
            ans *= 3
            pre = 1
    else:
        if a == b:
            ans *= 3
            pre = 0
        else:
            ans *= 6
            pre = 1
    ans %= mod
print(ans)



Measured memory_bytes: 3564
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#define rr register
using namespace std;
int a,b;
int main(){
    cin>>a>>b;
    if(a>0)cout<<"Positive";
    else if(a==0||(a<0&&b>0))cout<<"Zero";
    else if((abs(b)-abs(a))%2!=0)cout<<"Positive";
    else cout<<"Negative";
    return 0;
}

Measured memory_bytes: 256