akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  
  int N; cin >> N;
  
  int currentT = 0; int currentX = 0; int currentY = 0;
  
  vector<int> vecT(N), vecX(N), vecY(N);
  
  for (int i = 0; i < N; i++) {
    
    int t, x, y; cin >> t >> x >> y;
    
    vecT[i] = t; vecX[i] = x; vecY[i] = y;
    
  }
  
  for (int i = 0; i < N; i++) {
    
    int difT = vecT[i] - currentT;
    
    int difC = abs(vecX[i] - currentX) + abs(vecY[i] - currentY);
    
    if (difT < difC || difT % 2 != difC % 2) {
      cout << "No" << endl;
      return 0;
    }
    
    currentT = vecT[i]; currentX = vecX[i]; currentY = vecY[i];
    
  }
  
  cout << "Yes" << endl;
  
}

Measured memory_bytes: 4148
#include <stdio.h>

int main(void){
  int n,x,a = 0,i,j,k;
  while(1){
    scanf("%d %d",&n,&x);
    if(n == 0 && x == 0){
      break;
    }
    for(i = 1; i <= n; i++){
      for(j = 2; j <= n; j++){
        for(k = 3; k <= n; k++){
          if(i != j && j != k && k != i && i + j + k == x && i <  j && j < k){
            a += 1;
          }
        }
      }
    }
    printf("%d\n",a);
    a = 0;
  }
  return 0;
}


Measured memory_bytes: 2044
def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)

def factorize(n):
    result = []
    dev = 2
    while dev * dev <= n:
        if n % dev == 0:
            n //= dev
            result.append(dev)
        else:
            dev += 1
    if n > 1:
        result.append(n)
    return result

A, B = [int(x) for x in input().split()]
lst = factorize(gcd(A, B))
print(len(set(lst)) + 1)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s,t,temp;

	cin >>s >>t;
	for(int i=0;i<(int)s.size();i++){
		temp="";
		if(s==t){
			cout<<"Yes"<<endl;
			return 0;
		}
		for(int j=1;j<(int)s.size();j++)temp+=s[j];
		temp+=s[0];
		s=temp;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
a=int(input())
def f(i):
    if i%2==0:
        return i/2
    else: 
        return i*3+1
L=[a]
x=1
for i in range(1000000):
    if not f(L[i]) in L:
        L.append(f(L[i]))
        x+=1
    else:
        L.append(f(L[i]))
        x+=1
        break
print(x)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> Q;

ll n, ans;
vector<ll> vec;

int main()
{
	cin >> n;
	vec.push_back(n);
	for (int i = 2; ; i++)
	{
		if (vec.back() <= n / i + 1)
		{
			break;
		}
		vec.push_back(n / i);
	}
	ll j = vec.back() - 1;
	while (vec.back() != 1)
	{
		vec.push_back(j);
		j--;
	}
	for (int i = 0; i < (int)vec.size(); i++)
	{
		ll m = (n - vec[i]) / vec[i];
		if (m == 0) continue;
		if (n / m == n % m)
		{
			ans += m;
		}
	}
	cout << ans << endl;
	cin >> n;
}

Measured memory_bytes: 34788
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x, y;
    cin >> x >> y;
    bool tf = false;

    for(int i=0; i<=x; i++){
        if(i*2 + (x-i)*4 == y) tf = true;
    }

    if(tf) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
// 4:40
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <tuple>
#include <utility>
using namespace std;
typedef long long ll;
#define for1(i,n) for (ll i=0;i<(n);(i)++)
#define for2(i,m,n) for (ll (i)=(m);(i)<(n);(i)++)
#define for3(i,m,n,d) for (ll (i)=(m);(i)<(n);(i)+=(d))
#define INF (1LL << 60)

void solve()
{
  ll X;
  cin >> X;
  ll distance = 0;
  ll t = 0;
  while (distance < X) {
    ++t;
    distance += t;
  }
  cout << t << endl;
}

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


Measured memory_bytes: 256
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)

int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(6);

  map<char, bool> ball;
  ball['A'] = true;
  ball['B'] = false;
  ball['C'] = false;

  char from, to;
  char del;
  while(cin>>from>>del>>to){
    swap(ball[from], ball[to]);
  }

  for(map<char,bool>::iterator it=ball.begin(); it!=ball.end(); ++it){
    if( it->second == true ){
      cout << it->first << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1168
import java.util.*;

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

       Scanner scan = new Scanner(System.in);
       int n = scan.nextInt();
        Set s = new HashSet();
        for (int i = 0; i < n; i++) {
            s.add(scan.next());
        }
        System.out.println(s.size());
    }
}

Measured memory_bytes: 76492
/*
Author : N_o_o_B
Created : April 22 2020 16:07:33 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int f(int n){
    if(n%2==0) return n/2;
    return 3*n+1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int s;
    cin >> s;
    set<int> a;
    a.insert(s);
    while(1){
        if(a.count(f(s))){
            cout << sz(a) + 1 << endl;
            return 0;
        }
        a.insert(f(s));
        s = f(s);
    }



    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
constexpr long INF = 1L << 60;
constexpr int MOD = 998244353;

int N, ans[1001][1001];

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  cin >> N;
  // item: N * 2, 1 3 6 10
  // 1
  //
  // 1 2
  // 1 3
  // 2 3
  //
  // 1 2 3
  // 1 4 5
  // 2 4 6
  // 3 5 6
  //
  // 1 2 3 4
  // 1 5 6 7
  // 2 5 8 9
  // 3 6 8 10
  // 4 7 9 10

  // bn = n
  // an = a1 + (n)(1~n-1)
  // an = n*(n+1)/2
  for(int i = 1; i*(i+1)/2 <= N; ++i) {
    if(i*(i+1)/2 == N) {
      cout << "Yes" << '\n';
      cout << i+1 << '\n';
      int base = 1;
      for(int j = 0; j < i; ++j) {
        for(int k = j; k < i; ++k) ans[j][k] = k + base;
        for(int k = j+1; k <= i; ++k) ans[k][j] = k + base - 1;
        base += i - j - 1;
      }
      for(int j = 0; j <= i; ++j) {
        cout << i << ' ';
        for(int k = 0; k < i; ++k) cout << ans[j][k] << ' ';
        cout << '\n';
      }
      return 0;
    }
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define N 10004
#define llong long long
#define _pair  pair<int, int>
#define MP make_pair
#define fi first
#define se second
using namespace std;
int n;
int a[100];
bool check()
    {
        for (int i=1; i <= n; i++)
            if (a[i] != i)
                return 0;
        return 1;
    }
void YES()
    {
        cout<<"YES";
        exit(0);
    }
void NO()
    {
        cout<<"NO";
        exit(0);
    }
int main()
{
    ios::sync_with_stdio(0);
    cin>>n;
    for (int i=1; i <= n; i++)
        cin>>a[i];
    if (check()) YES();
    for (int i=1; i <= n; i++)
        for (int j=i+1; j <= n; j++){
            swap(a[i],a[j]);
            if (check()) YES();
            swap(a[i],a[j]);
        }
    NO();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
	        int a = sc.nextInt();
	        int b = sc.nextInt();
			int c = sc.nextInt();
			int max = 0;
			int min = 0;
			int k = sc.nextInt();
			int ans = 0;
			
	       if(a > b && a > c){
	        	max = a;
	        	min = b+c;
	        }else if(b > a && b > c){
	        	max = b;
	        	min = a+ c;
	        }else if(c >= a && c >= b) {
	        	max = c;
	        	min = a+b;
	        }
	        
	        for(int i=0; i< k; i++){
	        	max = max * 2;
	        }	        
	        ans = max + min;
	        System.out.println(ans);
	}
}

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

#define M 1000000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
	if ( ch == 'A'){
		return 1;
	}
	else if ( ch == 'C'){
		return 2;
	}
	else if ( ch == 'G'){
		return 3;
	}
	else if ( ch == 'T'){
		return 4;
	}
	else{
		return 5;
	}
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ 
	return key%M;
	/* your task */
}
int h2(int key){
	return 1+(key % (M-1));
	/* your task */
}

int find(char str[]){
	long long key, i, h;
	key=getKey(str);
	for(i=0;;i++){
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0){
			return 1;
		}
		else if(strlen(H[h])==0){
			return 0;
		}
	}
	return 0;
    /* your task */
}

int insert(char str[]){
	long long key, i, h;
	key=getKey(str);
	for(i=0;;i++){
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0){
			return 1;
		}
		else if(strlen(H[h])==0){
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
    /* your task */

}

int main(){
    int i, n;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}


Measured memory_bytes: 15460
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int a, b, c, d, e;
	scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
	printf("%d\n", c * 60 + d - a * 60 - b - e);
}

Measured memory_bytes: 3248
#include<stdio.h>
int ta[100010],nt[200010],to[200010],co[200010];
//無向グラフ
void mkls(int v,int e,int *a,int *b,int *c){
  int i;
  for(i=0;i<=v;i++)ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    co[ta[b[i]]=i+e]=co[ta[a[i]]=i]=c[i];
  }
}
int main(){
  int n,i,r,t,a[100010],b[100010],c[100010],q[100010],d[100010]={1,1};
  scanf("%d",&n);
  for(i=0;i<n-1;i++){
    scanf("%d %d %d",&a[i],&b[i],&c[i]);
    c[i]%=2;
  }
  mkls(n,n-1,a,b,c);
  q[t=0]=1;
  for(r=1;r-t;t++){
    for(i=ta[q[t]];i+1;i=nt[i]){
      if(d[to[i]])continue;
      d[q[r++]=to[i]]=(d[q[t]]+co[i])%2+2;
    }
  }
  //for(i=0;i<n;i++)printf("%d ",d[i+1]);printf("\n");
  for(i=0;i<n;i++)printf("%d\n",d[i+1]%2);
  return 0;
}


Measured memory_bytes: 4992
#include"bits/stdc++.h"
using namespace std;

typedef long long ll;

ll func(ll a, ll b) {
	ll cnta=1,cntb=1;
	while (1) {
		if ((a / 10) != 0) {
			a /= 10;
			cnta++;
		}
		else {
			break;
		}
	}
	while (1) {
		if ((b / 10) != 0) {
			b /= 10;
			cntb++;
		}
		else {
			break;
		}
	}

	return ((cnta>=cntb)?cnta:cntb);
}

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

	ll mi=(ll)1e13;
	//cout << sqrt(N) << endl;
	for (ll i = 1; i <= sqrt(N); i++) {
		//cout << i << endl;
		ll m;
		if ((N%i) == 0) {
			//cout << i <<" "<< N/i << endl;
			m = func(i, N / i);
			//cout <<" "<< m << endl;
			mi = min(mi, m);
		}
	}
	cout << mi << endl;
}

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

int main(){
    int a,b,k,count,ans;
    cin >> a >> b >> k;
    int divisor[110] = {};
    for(int i = 1;i < 101;i++){
        if(a % i == 0) divisor[i]++;
        if(b % i == 0) divisor[i]++;
    }
    for(int i = 110;i > 0;i--){
        if(divisor[i] == 2) count++;
        if(count == k) {
            ans = i;
            break;
            }
    }

    cout << ans << endl;

}

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

using namespace std;

int main(void) {
  int N; cin >> N;
  int A[N];
  int mnus[N];
  int plus[N];
  memset(mnus, 0, sizeof(mnus));
  memset(plus, 0, sizeof(plus));

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

  for (int i = 0; i < N; i++) {
    mnus[i] = i+1 - A[i];
    plus[i] = i+1 + A[i];
  }
  
  long long m_n[N];
  long long p_n[N];
  memset(m_n, 0, sizeof(m_n));
  memset(p_n, 0, sizeof(p_n));

  for (int i = 0; i < N; i++) {
    if (mnus[i] > 1) m_n[mnus[i]]++;
    if (plus[i] < N) p_n[plus[i]]++;
  }

  long long ans = 0;
  for (int i = 0; i < N; i++) ans += p_n[i] * m_n[i];

  cout << ans << endl;
  return 0;
}

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

using namespace std;


int main(){

	int n,x;
	cin>>n>>x;
	vector<int> l(n+5);
	for(int i =1;i<n+1;i++)
		cin>>l[i];
	vector<int> D(n+5);
	D[1]=0;
	int cnt;
	for(int i =2;i<=n+1;i++)
		{D[i]=D[i-1]+l[i-1];
			if(D[i]>x)
				{cnt=i-1;
					break;}}
	if(cnt==0)
		cnt=n+1;
	cout<<cnt<<endl;
	return 0;
}
			

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int num = 1;
    for(int i=1; i<=n; i++){
        if( num*2 < num + k ) num = num*2;
        else num = num + k;
    }
    cout << num << endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

template<typename T>
using vec2 = vector<vector<T>>;
template<typename T>
using vec3 = vec2<vector<T>>;
template<typename T>
using vec4 = vec3<vector<T>>;
template<typename T>
using vec5 = vec4<vector<T>>;
template<typename T>
using vec6 = vec5<vector<T>>;



int main(){
    ll N,X,M;
    cin>>N>>X>>M;
    vector<ll> route;
    vector<bool> visited(M, false);
    int loopstart = M+10;
    for(int i = 0;i < N;i++){
        if(visited[X]){
            loopstart = X;
            break;
        }
        visited[X]=true;
        route.push_back(X);
        X = (X*X)%M;
    }
    for(int i = 0;i < route.size();i++){
        if(route[i] == loopstart)loopstart = i;
    }
    // for(int i = 0;i < route.size();i++){
    //     cout<<route[i]<<" ";
    // }cout<<endl;
    // cout<<route.size()<<endl;
    // cout<<loopstart<<endl;
    ll res = 0;
    int K = route.size();
    N--;
    for(int i = 0;i < route.size();i++){
        if(i < loopstart){
            res += route[i];
            N--;
            continue;
        }
        int looplength = K - loopstart;
        int j = i - loopstart;
        res += route[i] * (N/looplength) + (j <= N % looplength ? route[i] : 0);
    // cout<<looplength<<" "<<j<<" "<<route[i] * (N/looplength) + (j <= N % looplength ? route[i] : 0)<<endl;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3924
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = read().rstrip().decode('utf-8')

weekday = "SUN,MON,TUE,WED,THU,FRI,SAT".split(',')

dic = {x:7 - i for i, x in enumerate(weekday)}
print(dic[S])

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		String s[] = str.split("");

		boolean isEasy = true;
		for (int i = 0 ; i < s.length ; i++) 
			if(i % 2 == 0){
				if(s[i].equals("L")) {
					isEasy = false;
					break;
				}
			}else{
				if(s[i].equals("R")) {
					isEasy = false;
					break;
				}

			}
		
		if (isEasy) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		
	}	
}

Measured memory_bytes: 21972
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
L = []
for i in range(M):
	b, c = map(int, input().split())
	L.append((c, b))
L = sorted(L, reverse = True)
L.append((0, N))
temp = 0
sum = 0
for i in range(M + 1):
	for j in range(L[i][1]):
		if A[temp] < L[i][0]:
			sum += L[i][0]
			temp += 1
		else:
			sum += A[temp]
			temp += 1
		if temp == N:
			break
	if temp == N:
		break
print(sum)

Measured memory_bytes: 21836
# coding: utf-8
# Your code here!

def CountingSort(A):
    MAX = 10000
    B = [0 for e in range(n)]
    C = [0 for e in range(MAX)]
    
    for j in range(n):
        C[A[j]] += 1
    
    for i in range(1,MAX):
        C[i] += C[i-1]

    for j in range(n-1,-1,-1):
        B[C[A[j]]-1] = A[j]
        C[A[j]]-=1
        
    return B
n = int(input())
A = [int(e) for e in input().split()]
print(*CountingSort(A))


Measured memory_bytes: 224248
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    vector<ll> A(n + 1);
    A[0] = 2;
    A[1] = 1;
    FOR(i, 2, n + 1){
        A[i] = A[i - 1] + A[i - 2];
    }
    cout << A[n] << endl;

}

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

const int nm = 4e3;

int n, cc[3][nm + 1];
const char cs[] = "RGB";
int color(char c) {
	return find(cs, cs + 3, c) - cs;
}

string s;

long long ans = 0;

int main() {
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cc[j][i + 1] = cc[j][i];
		}
		cc[color(s[i])][i + 1]++;
	}
	for (int i = 0; i < n - 3; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			if (s[i] == s[j])
				continue;
			int k = 2 * j - i;
			int a = 3 - color(s[i]) - color(s[j]);
			ans += cc[a][n] - cc[a][j + 1];
			if (color(s[k]) == a)
				ans--;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 2e6+6;
void solve(){
	int a[3];
	for(int i=0;i<3;i++)cin>>a[i];
	sort(a,a+3);
	if(a[0]+a[1]==a[2])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MP make_pair
#define endl '\n'
const int mod = 10007;
const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;

int main(int argc, char* argv[]) {
#ifdef local
    freopen("in.txt", "r", stdin);
#endif
    string a, b;
    int n;
    cin >> n;
    cin >> a >> b;
    for (int i = 0; i < n; i++) {
        cout << a[i] << b[i];
    }
    cout << endl;
    return 0;
}


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

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

	string s;
	cin >> s;
	map<char, int> app;
	ll ans = 0;
	ford(i, s.size() - 1, 0) {
		int total = s.size() - i - 1;
		total -= app[s[i]];
		ans += total;
		app[s[i]]++;
	}
	cout << ans + 1 << '\n';

	return 0;
}



Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int dp[1010][1010];

int main() {
  string s1,s2; cin >> s1 >> s2;

  FOR(i,0,s1.length()) dp[i][0] = i;
  FOR(i,0,s2.length()) dp[0][i] = i;

  FOR(i,1,s1.length()){
    FOR(j,1,s2.length()){
      int x = 1;
      if(s1[i-1]==s2[j-1]) x = 0;
      dp[i][j] = min({dp[i-1][j-1] + x, dp[i-1][j] + 1, dp[i][j-1] + 1});
    }
  }

  cout << dp[s1.length()][s2.length()] << endl;
}




Measured memory_bytes: 7120
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans=LINF,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll cop[ohara];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n)cop[i]=a[i];
    rep(i,cop[0]+1){
        cnt=i;
        rep(j,n)a[j]=cop[j];
        a[0]-=cnt;
        rep(j,n-1){
            if(a[j]<=0)continue;
            cnt+=a[j]*2;
            a[j+1]-=a[j];
            a[j]=0;
            if(a[j+1]<0)a[j+1]=0;
        }
        ans=min(ans,cnt+a[n-1]);
    }
    Cout(ans);
    return 0;
}



Measured memory_bytes: 3304
class Tree
	attr_accessor :parent, :root, :dep, :key, :left,:right, :sib
  
	def initialize(key)
		@parent = -1
		@left = -1
		@right = -1
		@dep = -1
		@key = key
		@sib = -1
	end

	def depth(answer,tree)
		if @left!=-1
			@left.depth(answer + 1,tree)
		end

		if @right != -1
			@right.depth(answer + 1,tree)
		end
		@dep = answer
	end

	def height(h)
		n1 = h
		n2 = h

		if @left!=-1
			n1 = left.height(h + 1)
		end
    
		if @right!=-1
			n2 = right.height(h + 1)
		end

		return n1 > n2 ? n1:n2
	end

	def showparent
		if @parent == -1
			return -1
		else
			return @parent.key
		end
	end

	def showsib
		if @sib == -1
			return -1
		else
			return @sib.key
		end
	end

	def degree
		answer = 0
		if @left != -1
			answer+=1
		end
		if @right != -1
			answer+=1
		end
		answer
	end
end

n = gets.to_i

tree = Hash.new
check = Array.new(n){true}
n.times do |i|
	tree[i] = Tree.new(i)
end

n.times do
	data = gets.split.map(&:to_i)
	num = data[0]
	tree[num].left = tree[data[1]] || -1
	tree[num].right = tree[data[2]] || -1
	if tree[data[1]]
		tree[data[1]].parent = tree[num]
		tree[data[1]].sib = tree[data[2]] || -1
		check[data[1]] = false
	end
	if tree[data[2]]
		tree[data[2]].parent = tree[num]
		tree[data[2]].sib = tree[data[1]] || -1
		check[data[2]] = false
	end
end
r = check.index(true)
tree[r].depth(0,tree)

n.times do |i|
	obj = tree[i]
	type = nil
	if obj.parent == -1
		type = "root"
	elsif obj.left == -1 && obj.right == -1
		type = "leaf"
	else
		type = "internal node"
	end

	puts "node #{i}: parent = #{obj.showparent}, sibling = #{obj.showsib}, degree = #{obj.degree}, depth = #{obj.dep}, height = #{obj.height(0)}, #{type}"


end

Measured memory_bytes: 8716
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 1000005;
const ll mm = 1e+18;
int p[N];
void sieve(){
    for(int i=1;i<N;i++) p[i]=i;
    for(int i=2;i<=sqrt(N);i++){
        if(p[i]==i){
            for(int j=i*i;j<N;j+=i) p[j]=i;
        }
    }
}
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
void solve()
{
    int n;
    cin>>n;
    sieve();
    set<int>s;
    bool pp=true;
    int gc=0;
    rep0(i,n){
        int x;
        cin>>x;
        gc=gcd(gc,x);
        while(x!=1){
            int y=p[x];
            if(s.find(y)!=s.end()){
                pp=false;
            }
            if(pp)s.insert(y);
            while(x%y==0){
                x/=y;
            }
        }
    }
    if(pp){
        cout<<"pairwise coprime";
    }
    else if(gc==1) cout<<"setwise coprime";
    else cout<<"not coprime";

}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 15144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NK[0], K = NK[1];
            double[] p = Console.ReadLine().Split().Select(x => double.Parse(x)/2+0.5).ToArray();

            
            
            int i = 0;
            double sum = 0;
            for (i = 0; i < K; i++) sum+=p[i];
            double ans = sum;
            for(; i < N; i++)
            {
                sum -= p[i - K];
                sum += p[i];
                ans = Math.Max(ans, sum);
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 35036
uses math;
var  heap,heap1:array[0..500000] of longint;
     res:int64;
     n,nheap:longint;
     f,g,a:array[0..500000] of int64;
procedure nhap;
var i:longint;
begin
 read(n);
 for i:=1 to 3*n do read(a[i]);
end;
procedure doicho(var x,y:longint);
var tg:longint;
begin
 tg:=x;
 x:=y;
 y:=tg;
end;
procedure upheap(i:longint);
var j:longint;
begin
 j:=i div 2;
 if (i=1) or (a[heap[i]]>a[heap[j]]) then exit;
 doicho(heap[i],heap[j]);
 upheap(j);
end;
procedure downheap(i:longint);
var j:longint;
begin
 j:=2*i;
 if j>nheap then exit;
 if (j<nheap) and (A[heap[j]]>a[heap[j+1]]) then inc(j);
 if a[heap[i]]>a[heap[j]] then
  begin
   doicho(heap[i],heap[j]);
   downheap(j);
  end;
end;
procedure push(x:longint);
begin
 inc(nheap);
 heap[nheap]:=x;
 upheap(nheap);
end;
function pop:longint;
begin
 pop:=heap[1];
 heap[1]:=heap[nheap];
 dec(nheap);
 downheap(1);
end;
procedure upheap1(i:longint);
var j:longint;
begin
 j:=i div 2;
 if (i=1) or (a[heap1[i]]<a[heap1[j]]) then exit;
 doicho(heap1[i],heap1[j]);
 upheap1(j);
end;
procedure downheap1(i:longint);
var j:longint;
begin
 j:=2*i;
 if j>nheap then exit;
 if (j<nheap) and (A[heap1[j]]<a[heap1[j+1]]) then inc(j);
 if a[heap1[i]]<a[heap1[j]] then
  begin
   doicho(heap1[i],heap1[j]);
   downheap1(j);
  end;
end;
procedure push1(x:longint);
begin
 inc(nheap);
 heap1[nheap]:=x;
 upheap1(nheap);
end;
function pop1:longint;
begin
 pop1:=heap1[1];
 heap1[1]:=heap1[nheap];
 dec(nheap);
 downheap1(1);
end;
procedure xuli;
var i,k:longint;
begin
 for i:=1 to n do
  begin
   push(i);
   f[i]:=f[i-1]+a[i];
  end;
 for i:=n+1 to 3*n do
  begin
   k:=pop;
   if a[i]>a[k] then
    begin
     f[i]:=f[i-1]-a[k]+a[i];
     push(i);
    end
   else
    begin
     f[i]:=f[i-1];
     push(k);
    end;
  end;
 nheap:=0;
 for i:=3*n downto 2*n+1 do
  begin
   push1(i);
   g[i]:=g[i+1]+a[i];
  end;
 for i:=2*n downto 1 do
  begin
   k:=pop1;
   if a[i]<a[k] then
    begin
     g[i]:=g[i+1]-a[k]+a[i];
     push1(i);
    end
   else
    begin
     g[i]:=g[i+1];
     push1(k);
    end;
  end;
 res:=-high(int64);
 for i:=n to 2*n do res:=max(Res,f[i]-g[i+1]);
 write(REs);
end;
begin
// assign(input,'b.inp');reset(input);
// assign(output,'b.out');rewrite(output);
 nhap;
 xuli;
// close(input); close(output);
end.


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

int main(){
   int a,b,tosi;
   cin>>a>>b;
   if(a == 0){
      if(b >= 1868&&b <= 1911){
         tosi = b - 1867;
         cout << "M" << tosi << endl;
      }else if(b >= 1912&&b <= 1925){
         tosi = b - 1911;
         cout << "T" << tosi << endl;
      }else if(b >= 1926&&b <= 1988){
         tosi = b - 1925;
         cout << "S" << tosi << endl;
      }else if(b >= 1989&&b <= 2016){
         tosi = b - 1988;
         cout << "H" << tosi << endl;
      }
   }else if(a == 1){
       tosi = b + 1867;
       cout << tosi << endl;
   }else if(a == 2){
       tosi = b + 1911;
       cout << tosi << endl;
   }else if(a == 3){
       tosi = b + 1925;
       cout << tosi << endl;
   }else if(a == 4){
       tosi = b + 1988;
       cout << tosi << endl;
   }
   return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

vector<int> ans;
int x,y,s;

int main(){
	while(1){
		cin >> x >> y >> s;
		if(x + y + s == 0) break;
		int mx = 0;
		for(int i = 1; i < s;i++){
			for(int j = s-1;j >= 1;j--){
				if((i*(100+x)/100 + j*(100+x)/100) == s){
					int sum = i*(100+y)/100 + j*(100+y)/100;
					mx = max(mx,sum);
					break;
				}
			}
		}
		ans.push_back(mx);
	}
	for(int i = 0;i < ans.size();i++) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3124
#include"bits/stdc++.h"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill( (T*)array, (T*)(array+N), val ); }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    ll n;
    cin >> n;
    ll M;
    ll s;
    vector<ll> f(10001,0);
    REPS(x, 100) {
        REPS(y, 100) {
            REPS(z, 100) {
                s = (x * x + y * y + z * z + x * y + y * z + z * x);
                if (s <= 10000)f[s]++;
            }
        }
    }
    REPS(i, n + 1) {
        cout << f[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    sort(all(a));
    cout << a[n-1] << " ";
    int mn = inf;
    int ind = -1;
    rep(i,n-1) {
        if(a[n-1]&1) {
            if(chmin(mn,min(abs(a[n-1]/2-a[i]),abs(a[n-1]/2+1-a[i])))) ind = i;
        } else {
            if(chmin(mn,abs(a[n-1]/2-a[i]))) ind = i;
        }
    }
    cout << a[ind] << endl;
}


Measured memory_bytes: 640
from itertools import groupby, chain
from operator import itemgetter


def sweep(l):
    result = []
    s = set(l)
    while s:
        a = max(s)
        b = 1 << (a.bit_length() - 1)
        s = {t ^ a if t >= b else t for t in s}
        s.discard(0)
        result.append([a, b])

    return result


t = int(input())
buf = []
for _ in range(t):
    n = int(input())
    aaa = list(map(int, input().split()))
    s = input()

    if s[-1] == '1':
        buf.append(1)
        continue

    grp = [list(map(itemgetter(1), itr)) for c, itr in groupby(zip(s, aaa), key=itemgetter(0))]
    if s[0] == '0':
        grp = grp[1:]
    grp1 = grp[0::2]
    grp0 = grp[1::2]
    erasable = [False] * sum(len(g) for g in grp1)
    for i in range(len(grp1)):
        l1 = list(chain(*grp1[:i + 1]))
        l0 = list(chain(*grp0[i:]))
        s0 = sweep(l0)

        for a, b in s0:
            for i in range(len(l1)):
                if l1[i] & b:
                    l1[i] ^= a

        for j, c in enumerate(l1):
            if c == 0:
                erasable[j] = True

    if all(erasable):
        buf.append(0)
    else:
        buf.append(1)


print('\n'.join(map(str, buf)))


Measured memory_bytes: 73452
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String[] s = new String[2];
        StringBuilder sba = new StringBuilder();
        for (int i = 0; i < b; i++) {
            sba.append(a);
        }
        s[0] = sba.toString();
        StringBuilder sbb = new StringBuilder();
        for (int i = 0; i < a; i++) {
            sbb.append(b);
        }
        s[1] = sbb.toString();
        Arrays.sort(s);
        System.out.println(s[0]);
    }

}


Measured memory_bytes: 22100
N=int(input())
A=list(map(int,input().split()))

X=1000
Y=0

for k in range(N-1):
    if Y:
        X+=Y*A[k]
        Y=0
        
    if A[k]<A[k+1]:
        Y=X//A[k]
        X-=A[k]*Y

X+=A[-1]*Y
print(X)


Measured memory_bytes: 61688
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int h[100010];
    rep(i, n) cin >> h[i];
    int maximam[100010];
    int minimam[100010];
    maximam[0] = 0;
    minimam[n] = INF;
    rep(i, n) maximam[i + 1] = max(maximam[i], h[i]);
    rep(i, n) minimam[n - i - 1] = min(minimam[n - i], h[n - i - 1]);
    // rep(i, n + 1) cout << maximam[i] << " ";
    // cout << endl;
    // rep(i, n + 1) cout << minimam[i] << " ";
    // cout << endl;
    rep(i, n + 1) {
        if(maximam[i] > minimam[i] + 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl; 

    return 0;
}


Measured memory_bytes: 5968
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,k=parseMap(split(readline()))
    s=chomp(readline())
    cnt=Vector{Int}()
    res=1
    for i in 2:n+1
        if i==n+1 || s[i]!=s[i-1]
            push!(cnt,res*ifelse(s[i-1]=='0',-1,1))
            res=1
        else
            res+=1
        end
    end
    l=length(cnt)
    ans=0
    ruiseki=[0 for i in 1:l+1]
    for i in 1:l
        ruiseki[i+1]=ruiseki[i]+abs(cnt[i])
    end
    for i in 1:l
        if cnt[i]>0
            m=min(i+2k,l)
        else
            m=min(i+2k-1,l)
        end
        ans=max(ans,ruiseki[m+1]-ruiseki[i])
    end
    println(ans)
end
main()

Measured memory_bytes: 119004
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    string a, b; cin >> b >> a;
    int cnt = 0;
    for(int i = 0; i < min(b.size(), a.size()); i++){
        if(a[i] == b[i])
            cnt++;
    }
    if((a.size() - b.size()) == 1 && cnt == b.size()){
        cout << "Yes\n";
    }else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>

#define ll long long

using namespace std;

int main(){
	int z;
	cin >> z;
	while(z){
		ll _z = (ll)z*z*z;
		ll mx = 0;
		for(int x = 1;x<z;x++){
			ll _x = (ll)x*x*x;
			for(int y = 1;; y++){
				ll _y = (ll)y*y*y;
				if(_z > _x+_y) mx=max(mx,_x+_y);
				else break;
			}
		}
		cout << _z-mx << endl;
		cin >> z;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    char x,y; cin >> x >> y;
    if (x > y)
    {
        cout << ">\n";
    } else if (x == y) {
        cout << "=\n";
    } else {
        cout << "<\n";
    }
    return 0;
}

Measured memory_bytes: 256
/*input
98765432109876543210
58
*/
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize ("unroll-loops")*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define input(str) freopen(str,"r",stdin);
#define output(str) freopen(str,"w",stdout);
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF  3e16+1
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld\n",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define modd 1000000007
#define len(x) x.size()
#define all(v) (v.begin(),v.end())
#define ll int
#define pi 3.1415926535897932384626
#define ld double
const int N =2e5+2;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
int n,d;
string k;
int dp[10005][100][2];
int recur(int pos,int sum,int flag)
{
	if(pos==n)
	{
		int some=(sum)%d;
		if((some)>0)
			return 0;
		else
		{
			return 1;
		}
	}
	else if(dp[pos][sum][flag]!=-1)
		return dp[pos][sum][flag];
	else
	{
		int tmp=0;
		int temp=k[pos]-'0';
		for(int i=0;i<temp;i++)
		{
			int some=(sum+i)%d;
			tmp+=recur(pos+1,some,0);
			tmp%=modd;
		}
		if(flag)
		{
			int some=(sum+temp)%d;
			tmp+=recur(pos+1,some,1);
			tmp%=modd;
		}
		else
		{
			for(int i=temp;i<10;i++)
			{
				int some=(sum+i)%d;
				tmp+=recur(pos+1,some,0);
				tmp%=modd;
			}	
		}
		dp[pos][sum][flag]=tmp;
		return dp[pos][sum][flag];
	}
}
signed main()
{
	speed
	cin>>k;
	cin>>d;
	n=len(k);
	//cout<<n<<endl;
	rep(i,10005)
	{
		rep(j,100)
		{
			rep(h,2)
			{
				dp[i][j][h]=-1;
			}
		}
	}
	int ans=-1;
	int val=k[0]-'0';
	for(int i=0;i<val;i++)
	{
		ans+=recur(1,i,0);
		ans%=modd;
	}	
	ans+=recur(1,val,1);
	ans%=modd;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 16896
import java.util.*;
import java.math.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long d = sc.nextLong();
		double ans = (double)((m-1)*(n-d))/(double)(n*n);
		if(d!=0) ans *= 2;
		BigDecimal x = new BigDecimal(ans);
		System.out.printf("%.20f",x);
		return;
	}
}

Measured memory_bytes: 22996
#include<iostream>
using namespace std;
int main()
{
	int k;
	cin >> k;
	int a = k % 2 , b = k / 2 , c = 0;
	if (a == 0){
		c = b * b; 
	} else {
		c = b * (b + 1);
	}
	cout << c << endl;
}

Measured memory_bytes: 256
import math

def main():
    a,b,h,m = map(int,input().split())
    fun = h*60 + m
    angleM = (fun * 6) % 360
    angleH = (fun * 0.5) % 360

    print(math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(angleH - angleM))))



if __name__ == "__main__":
    main()


Measured memory_bytes: 9436
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr<<#x<<'='<<x<<' '
#define f first
#define s second
typedef long long ll;
typedef pair<int,int> pi;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    char ch; cin >> ch;
    cout << (char)((int)ch+1);
    return 0;
}


Measured memory_bytes: 256
def stones(k, moves):
    winnable = [False] * (k + 1)
    for i in range(1, k+1):
        winnable[i] = not all(winnable[i - j] for j in moves if j <= i)
    return ["Second", "First"][winnable[k]]

def main():
    n, k = [int(x) for x in input().split()]
    moves = [int(x) for x in input().split()]
    return stones(k, moves)

print(main())

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

const int N = 80, M = 80, MAX = 26000;

bitset<MAX> dp[N][M];

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    int n, m;
    cin >> n >> m;
    vector<vector<int> > a(n, vector<int> (m)), b(n, vector<int> (m));
    cin >> a >> b;

    //bool dp[n][m][MAX];

    for (int i = 0;i < n;i++) {
        for (int j = 0;j < m;j++) {
            for (int k = 0;k < MAX;k++) {
                dp[i][j][k] = 0;
            }
        }
    }

    dp[0][0][a[0][0] - b[0][0] + MAX/2] = 1;
    dp[0][0][b[0][0] - a[0][0] + MAX/2] = 1;

    for (int i = 0;i < n;i++) {
        for (int j = 0;j < m;j++) {
            for (int k = 0;k < MAX;k++) {
                if (dp[i][j][k]) {
                    if (i + 1 < n) {
                        dp[i + 1][j][k + a[i + 1][j] - b[i + 1][j]] = 1;
                        dp[i + 1][j][k + b[i + 1][j] - a[i + 1][j]] = 1;
                    }

                    if (j + 1 < m) {
                        dp[i][j + 1][k + a[i][j + 1] - b[i][j + 1]] = 1;
                        dp[i][j + 1][k + b[i][j + 1] - a[i][j + 1]] = 1;
                    }

                }
            }
        }
    }

    int ans = 1e9;

    for (int i = 0;i < MAX;i++) {
        if (dp[n - 1][m - 1][i]) {
            chkmin(ans, abs(i - MAX/2));
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 20736
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
#include<math.h>

using namespace std;

int N;
int a[10010] = {};
int cnt = 0;
int flag = 0;

int clc(int a) 
{
	int count = 0;

	while (a % 2 == 0) 
	{
		a = a / 2;

		count++;
	}

	return count;
}

int main(void)
{



	cin >> N;

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

		cnt += clc(a[i]);
	}
	
	cout << cnt << endl;


	return 0;
}

Measured memory_bytes: 256
<?php
  fscanf(STDIN,"%d",$a);
  $num = $a;
  $sum_num = 0;
  $div_num = 10;
  $keta_num = 0;

  while($num != 0)
  {
    $keta_num = ($num % $div_num);
    $sum_num += $keta_num;
    $num -= $keta_num;
    $num /= 10;
  }
  if($a % $sum_num == 0)
  {
    echo "Yes";
  }
  else
  {
    echo "No";
  }

Measured memory_bytes: 3828