akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{

    ArrayList<char[]> color,list;
    ArrayList<String> clist,alist;

    void solve(){
        Scanner sc = new Scanner(System.in);

        clist = new ArrayList<String>();
        clist.add("Red");
        clist.add("Yellow");
        clist.add("Blue");
        clist.add("Magenta");
        clist.add("Green");
        clist.add("Cyan");

        while(true){
            int n = sc.nextInt();
            if(n==0) break;

            color = new ArrayList<char[]>();
            int cnt = 0;
            for(int i=0; i<n; i++){
                char[] c = new char[6];
                for(int j=0; j<6; j++) c[j] = (char)clist.indexOf(sc.next());
                if(same(c)) cnt++;
                else color.add(c);
            }

            System.out.println(cnt);
        }
    }

    int[][] rotate = {{1,2,4,3},{0,4,5,1},{0,2,5,3}};

    boolean same(char[] dice){
        list = new ArrayList<char[]>();
        alist = new ArrayList<String>();
        for(int i=0; i<4; i++){
            dice = rotate(dice,0);
            for(int j=0; j<4; j++){
                dice = rotate(dice,1);
                for(int l=0; l<4; l++){
                    dice = rotate(dice,2);
                    String ns = String.valueOf(dice);
                    if(!alist.contains(ns)){
                        list.add(dice);
                        alist.add(ns);
                    }
                }
            }
        }

        for(int i=0; i<list.size(); i++){
            char[] s1 = list.get(i);
            for(int j=0; j<color.size(); j++){
                boolean boo = false;
                char[] s2 = color.get(j);
                for(int k=0; k<6; k++){
                    if(s1[k]!=s2[k]){
                        boo = false;
                        break;
                    }
                    boo = true;
                }
                if(boo) return true;
            }
        }
        return false;
    }

    char[] rotate(char[] dice, int idx){
        char[] res = new char[6];
        for(int i=0; i<6; i++) res[i] = dice[i];

        char tmp = res[rotate[idx][3]];
        for(int i=3; i>0; i--) res[rotate[idx][i]] = res[rotate[idx][i-1]];
        res[rotate[idx][0]] = tmp;
        return res;
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 12000
def solve(string):
    s, t = string.split()
    s, t = s[::-1], t[::-1]
    for i in range(len(s)):
        for j in range(min(len(t), len(s) - i)):
            if s[i + j] != t[j] and s[i + j] != "?":
                break
            if j == len(t) - 1:
                return (s[:i] + t + s[i + len(t):])[::-1].replace("?", "a")
    return "UNRESTORABLE"


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
map<string,int> s;
    long long ans=0;
 cin>>N;
    for(long long i=0;i<N;i++)
    {
         string str;
        cin>>str;
        sort(str.begin(),str.end());
        s[str]++;
        ans=ans+s[str]-1;
        
    }
   
    
    cout<<ans<<endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,k,n) for(int i = k; i < n; i++)  
#define repp(i,k,n) for(int i = k; i <= n; i++) 
#define per(i,k,n) for(int i = k; i >= n; i--)

#define int long long
#define all(a) a.begin(),a.end()       

#define pb push_back
typedef long long ll; 
typedef pair<int, int> ii;
typedef pair<int,ii > iii; 
typedef vector<ii> vii;
typedef vector<char> vchar;
typedef vector<int> vi;
#define ff first
#define ss second

#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));

#define INF 1000000000
//#define mod 998244353
#define mod 1000000007
#define endl "\n"


   //=\/=\/=\/=\/=\/=\/=\/=\/=\/=\        Jai Hind Dosto        /=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\
  //=\/=\/=\/=\                    ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿                             /=\/=\/=\/=\\
 //=\/=\/=\/=\                                                                               /=\/=\/=\/=\\
//=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\



int modPow(int a, int b);           

                
void solve(){
    int n ;
    cin >> n ;
    int a[n];
    int sum =0;
    map<int, int> xx;
    rep(i,0,n)cin >> a[i], sum+=a[i],xx[a[i]]++;
    int q; cin >> q;
    rep(i,0,q){
        int a1,b1; cin >> a1 >> b1;
        int temp = xx[a1];
        xx[a1]=0;
        xx[b1] += temp;
        sum -= temp*a1;
        sum += temp*b1;
        cout << sum <<endl;
    }
}






signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed;
    //cout <<setprecision(6);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
 //   int test=1; cin >> test; while(test--)
    solve();
}

int modPow(int a, int b){
    if(b==0)return 1;
    if(b%2==0){
        int x = a*a;
        x%=mod;
        return modPow(x,b/2);
    }
    return (a*modPow(a,b-1))%mod;
}




Measured memory_bytes: 10288
// failed to generate code

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

long long f(long long N,long long X){
	if( N < X ) swap(N,X);
	if( X == 0 ) return -N;
	// cout << N << " " << X << "|" << 2 * X * (N/X)  << endl;
	return 2 * X * (N/X) + f(X,N%X);
}

int main(){	
	ios::sync_with_stdio(false);
	long long N,X;
	cin >> N >> X;
	cout << N + f(N-X,X) << endl;
	
	
	
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size() 配列名.length()
using namespace std;
typedef unsigned long long ll;

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

	int ans = -MOD;
	int min_memo[n];
	min_memo[0] = a[0];

	for(int i = 1; i < n; i++){
		ans = max(ans, a[i] - min_memo[i - 1]);
		min_memo[i] = min(min_memo[i - 1], a[i]);
	}

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



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

const int mod = 1e9+7;

int main() {
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll ans = 0;
  ll p = 1;
  rep(i,60){
    ll res = 0;
    rep(j,n){
      if((a[j]>>i)&1) res++;
    }
    ans += ((res*(n - res))%mod*p)%mod;
    ans %= mod;
    p = (p*2)%mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <utility>

#define INF 1000000005


using namespace std;

long long n, size;
pair <long long, long long> tab[100000];
long long dp[1000000];
long long minimum = INF;
long long score = 0;

int main(){
    
    cin >> n >> size;
    
    
	for(int i = 0; i < n; i++){
        cin >> tab[i].first >> tab[i].second;
        // first - weight
        // second - value
        minimum = min(minimum, tab[i].first);//do kiedy mam sprawdzac od dp[pojemnosc] do do[pojemnosc - minimum]
	}
    
    
    for(int element = 0; element < n; element++){
        for(int i = size; i >= 0; i--){
            dp[i + tab[element].first] = max(dp[i + tab[element].first], dp[i] + tab[element].second);
            
        }
        
    }
    
    
    for(int i = 0; i < minimum; i++){
        score = max(score, dp[size - i]);
    }
    cout << score;
}


Measured memory_bytes: 3840
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#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 mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

int a[105];
int b[105];
void solve(){  
	int n;
	cin>>n;
	rep(i,0,n-1) cin>>b[i];
	a[0]=b[0];
	a[n-1]=b[n-2];
	int ans=0;
	rep(i,0,n-2){
		a[i+1]=min(b[i],b[i+1]);
	}  
	rep(i,0,n) ans+=a[i];
	cout<<ans<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

int main() {

	int N, A, B;
	cin >> N >> A >> B;

	int S = 0;

	for (int i = 1; i <= N; i++) {

		int sum = 0;
		int t = i;

		while (t/10 != 0) {
			sum += t % 10;
			t = t/10;
		}

		sum += t;


		if (sum >= A && sum <= B) {
			S += i;
		}
	}

	cout << S << endl;

	return 0;
	
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Satoshi
{
	class Program
	{
		public static void Main(string[] args)
		{
			string[] s = Console.ReadLine().Split(' ');
			int H = int.Parse(s[0]);
			int W = int.Parse(s[1]);
			char[,] c = new char[2*H, W];
			for (int i = 0; i < H; i++)
			{
				string tmp = Console.ReadLine();
				for (int j = 0; j < W; j++)
				{
					c[2*i, j] = tmp[j];
					c[2 * i + 1, j] = tmp[j];
				}
			}
			for (int i = 0; i < 2*H; i++)
			{
				for (int j = 0; j < W; j++)
				{
					Console.Write(c[i, j]);
					if (j == W - 1)
						Console.Write("\n");
				}
			}
		}
	}
}

Measured memory_bytes: 2776
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
  ll ans=0;
  ll prev=-100;
  REP(N){
    --A[i];
    if(A[i]==prev+1){
      ans+=B[A[i]]+C[prev];
    }else{
      ans+=B[A[i]];
    }
    prev=A[i];
  }
  cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    std::vector<long long> C(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&C[i]);
    }
    solve(N, std::move(A), std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 256
import Foundation

let input_line = readLine()!

var split = input_line.componentsSeparatedByString(" ")
let S = split[0]
let T = split[1]
 
//標準入力二行
let input_line2 = readLine()!
split = input_line2.componentsSeparatedByString(" ")
var A = Int(split[0])!
var B = Int(split[1])!

//標準入力二行
let U = readLine()!
 
if U == S {
  A -= 1
} else {
  B -= 1
}
print(A, B)

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

int main(){
  string s;
  cin >> s;
  int cnt0=0;
  for(int i=0; i<s.length(); i++){
    if(s[i]=='0')cnt0++;
  }
  cout << 2*min(cnt0, int(s.length()-cnt0));
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long LL;

const int MAX = 1000;

int main()
{
    char a[100];
    cin>>a;
    int len = strlen(a);
    for(int i = 0;i<len;i++)
    {
        if(a[i]=='A'&&a[i+1]=='C')
        {
              cout<<"Yes"<<endl;
              return 0;
        }

    }

    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
q = int(input())
for i in range(q):
    n = int(input())
    
    cnt = 0
    li = list()
    while n >= 10:
        cnt += 1
        di = 10
        ma = 0
        while di < n:
            l = n % di
            u = n // di
            ma = max(ma, l * u)
            di *= 10
        n = ma
        if ma in li:
            cnt = -1
            break
        li.append(ma)
    print(cnt)


Measured memory_bytes: 5592
from math import*
def factrization_prime(number):
    factor = {}
    div = 2
    s = sqrt(number)
    while div < s:
        div_cnt = 0
        while number % div == 0:
            div_cnt += 1
            number //= div
        if div_cnt != 0:
            factor[div] = div_cnt
        div += 1
    if number > 1:
        factor[number] = 1
    return factor
A, B = map(int, input().split())
f = factrization_prime(gcd(A,B))
print(len(f)+1)


Measured memory_bytes: 63356
N = int(input())
a = map(int, input().split())
d = {}
for an in a:
    if an not in d:
        d[an] = 0
    if an + 1 not in d:
        d[an + 1] = 0
    if an - 1 not in d:
        d[an - 1] = 0
    d[an] = d[an] + 1
    d[an + 1] = d[an + 1] + 1
    d[an - 1] = d[an - 1] + 1
print(max(d[x] for x in d))

Measured memory_bytes: 22192
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    ll n; cin >> n;
    vector<int> vec;
    rep(i,n){
        ll d;
        cin >> d;
        vec.push_back(d);
    }
    sort(all(vec));
    int f,s;
    f = n/2-1;
    s = n/2;
    cout << vec[s] - vec[f] << endl;
}

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

int main(){
  long long int sum = 0, p, n;
  int q;
  char c;
  cin >> q;
  while(q--){
    cin >> p >> c >> n;
    if(c == '(')
      sum += n;
    else
      sum -= n;
    if(sum==0)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 1128
def main():
    n, m = map(int, input().split())
    Students = [list(map(int,input().split())) for _ in range(n)]
    Check = [list(map(int,input().split())) for _ in range(m)]
    for s in Students:
        ans = 1
        for i, c in enumerate(Check, 1):
            dist = abs(c[0]-s[0]) + abs(c[1]-s[1])
            if i<2:
                min_dist = dist
            elif dist < min_dist:
                min_dist = dist
                ans = i
        print(ans)
main()

Measured memory_bytes: 3064
import java.io.*;
import java.math.BigInteger;
import java.util.*;

class Main{
    public static void main(String[] args){
        try {
            PrintWriter out=new PrintWriter(System.out,true);
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            int t=Integer.parseInt(br.readLine());
            Map<String,Integer> map=new HashMap<>();
            map.put("AC",0);
            map.put("RE",0);
            map.put("TLE",0);
            map.put("WA",0);
            for(int i=0;i<t;i++){
                String str=br.readLine();
                map.put(str,map.get(str)+1);
            }
            out.println("AC x "+map.get("AC"));
            out.println("WA x "+map.get("WA"));
            out.println("TLE x "+map.get("TLE"));
            out.println("RE x "+map.get("RE"));
            out.close();
        } catch (Exception e) {
            System.out.println("kkkk "+ e.getMessage());
        }
    }
    static boolean isPal(String s){
        StringBuilder str=new StringBuilder(s);
        str=str.reverse();
        String ss=String.valueOf(str);
        if (ss.equals(s)) {
            return true;
        }
        return false;
    }
    static int mod(int a,int b){
        if (a>b){
            return a-b;
        }
        return b-a;
    }
    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
    static int lcm(int a,int b){
        long c=a*b;
        return (int)(c/hcf(a,b));
    }
    static int hcf(int a,int b){
        if(a==0){
            return b;
        }
        if(b==0){
            return a;
        }
        if(a>b)
            return hcf(a%b,b);

        return hcf(a,b%a);
    }
    static void dfs(ArrayList<HashSet<Integer>> list,boolean[] vis,int i){
        vis[i]=true;
        Iterator<Integer> it=list.get(i).iterator();
        while(it.hasNext()){
            int u=it.next();
            if(!vis[u]){
                dfs(list,vis,u);
            }
        }
    }
    static int modInverse(int x,int m){
        return power(x,m-2,m);
    }
    static int power(int x, int y, int m)
    {
        if (y == 0)
            return 1;

        long p = power(x, y / 2, m) % m;
        p = (p * p) % m;

        return (int)((y%2==0)? p : (x*p)%m);
    }
    static class pair{
        int a,b;
        public pair(int a,int b){
            this.a=a;
            this.b=b;
        }
    }
}

Measured memory_bytes: 45024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    vector<int> dp(n+1);

    rep(i, n) {
        dp[p[i]] = dp[p[i] - 1] + 1;
    }
    int mx = *max_element(dp.begin(), dp.end());
    int ans = n - mx;
    cout << ans << endl;
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define int long long int
const int mod = 1000000007;
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;


signed main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin>>n;
    vector<int>arr(n);
    int sum = 0;
    for(int i=0; i<n; i++){
        cin>>arr[i];
        sum += arr[i];
        sum = sum%mod;
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        sum -= arr[i];
        if(sum < 0)
            sum += mod;
        ans += arr[i]*sum;
        ans = ans%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4764
//***Bismillahir Rahmanir Rahim***//

//*********************************//
//******Ashraful Haque Toni********//
//********Dept. of CSE,JnU*********//
//email:ashrafulhaquetoni@gmail.com//
//*******contact:01640690531*******//
//*********************************//


#include<bits/stdc++.h>

using namespace std;

#define         ash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define         pb push_back
#define         sc(n) scanf("%d",&n);
#define         scl(n) scanf("%I64d",&n);
#define         sc2(m,n) scanf("%d %d ",&m,&n);
#define         sc2l(m,n) scanf("%I64d %I64d ",&m,&n);
#define         pf printf
#define         Big(x,y) max(x,y);
#define         Small(x,y) min(x,y);
#define         input(array,size) for(int i=0;i<size;i++)cin>>array[i];
#define         newline pf("\n");
#define         f(s,l,in) for(ll i=s;i<l;i+=in)
#define         Max INT_MAX
#define         Min INT_MIN
#define         pi acos(-1.0)
#define         Memset(a,val) memset(a,val,sizeof(a));

typedef long long ll;


int main()
{
    ash;
    string s;
    cin>>s;
    int cnt=0,cnt1=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0')cnt++;
           if(s[i]=='1')cnt1++;

    }
     int r=min(cnt,cnt1)*2;
    pf("%d\n",r);


    return 0;
}




Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            int[] a = in.Int(N);
            int ans = 0;
            for (int i = 0; i < N; i++) {
                if ((i + 1) % 2 == 1 && a[i] % 2 == 1) ans++;
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

        public int[] Int(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Int();
            }
            return a;
        }

    }
}



Measured memory_bytes: 32656
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

#include <deque>

#include <cassert>

#include <memory>

using namespace std;

typedef long long LL;

int main() {
    
    string s;
    cin >> s;
    if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi") cout << "Yes"; else cout << "No";
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	double a, b, t;
	std::cin >> a >> b >> t;
	int count = a;
	int result = 0;
	while (count <= t + 0.5)
	{
		result += b;
		count += a;
	}
	std::cout << result;
	return 0;
}


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

// ???????????????
int bubbleSort(int A[], int n) {
	int cnt = 0;
	// ?????°??????????????§?????????
	int flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			// ?????¢???????????????????´?
			if (A[j] < A[j - 1]) {
				swap(A[j], A[j - 1]);
				flag = 1;
				cnt++;
			}
		}
	}
	return cnt;
}
int main() {
	int n, A[110];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &A[i]);
	
	int cnt = bubbleSort(A, n);
	for (int i = 0; i < n; i++)
		printf("%d%c", A[i], i == n - 1 ? '\n' : ' ');
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 3228
#include"stdio.h"
#include<cstring>
using namespace std;
const int N=2000020;
int n,i,j,k,a,b,root;
int h[N],t[N],v[N];
int sz[N],fa[N],f[N],ans=1<<30;
char ch;
void read(int &a){
	a=0;
	while((ch=getchar())<48);
	while(ch>47)
		a=a*10+ch-48,ch=getchar();
}
void add(int a,int b){
	t[++k]=h[a];
	h[a]=k;
	v[k]=b;
}
void init(){
	read(n);
	memset(fa,-1,sizeof(fa));
	for(i=1;i<n;i++){
		read(a);read(b);
		add(a,b);
		add(b,a);
	}
}
void dfs1(int i){
	f[i]=0;
	int deg=0;
	for(int j=h[i];j;j=t[j])
		if(v[j]!=fa[i]){
			fa[v[j]]=i;
			dfs1(v[j]);
			f[i]+=f[v[j]];
			if(f[v[j]]==0)
				deg++;
		}
	if(deg>1)
		f[i]+=deg-1;

}
int min(int x,int y){
	return x<y?x:y;
}
void dfs2(int i){	
	f[i]=0;
	int deg=0;
	for(int j=h[i];j;j=t[j]){
		f[i]+=f[v[j]];
		if(f[v[j]]==0)
			deg++;
	}
	if(deg>1)
		f[i]+=deg-1;
	ans=min(ans,f[i]+1);
	int x=f[i];
	for(int j=h[i];j;j=t[j])
		if(v[j]!=fa[i]){
			f[i]=x-f[v[j]]-(deg>1?deg-1:0);
			if(f[v[j]]==0)
				deg--;
			f[i]+=deg>1?deg-1:0;
			dfs2(v[j]);
			if(f[v[j]]==0)
				deg++;
		}
}
void work(){
	if(n==1){
		printf("0");
		return;
	}
	dfs1(0);
	dfs2(0);
	printf("%d",ans);
}
int main(){
	init();
	work();
	return 0;	
}


Measured memory_bytes: 21632
N = int(input())
n_ac = 0
n_wa = 0
n_tle = 0
n_re = 0
for i in range(N):
    s = input()
    if s == 'AC':
        n_ac += 1
    elif s == 'WA':
        n_wa += 1
    elif s == 'TLE':
        n_tle += 1
    elif s == 'RE':
        n_re += 1
print('AC x {}'.format(n_ac))
print('WA x {}'.format(n_wa))
print('TLE x {}'.format(n_tle))
print('RE x {}'.format(n_re))


Measured memory_bytes: 9180
#include<stdio.h>

int main(void){
	double a,b,c,d,e,f,g,x,y;

	while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF){
		y=(f-c*d/a)/(e-b*d/a);
		x=(f-c*e/b)/(d-a*e/b);

		if(-0.0004<x&&x<=0)x=0;
		if(-0.0004<y&&y<=0)y=0;

		printf("%.3f %.3f\n",x,y);
	
	}

	return 0;

}

Measured memory_bytes: 652
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        
        
        
        while(true){
            var nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int vertical = nums[0];
            int side = nums[1];
            var flag = true;
            
            if(vertical==0 && side==0){
                break;
            }
            
            for(int i = 0; i < vertical; i++){
                
                if(i % 2 == 1){
                    flag = false;
                }else{
                    flag = true;
                }
                
                for(int l = 0; l < side; l++){
                    
                    if(flag){
                        Console.Write("#");
                        flag = false;
                    }else{
                        Console.Write(".");
                        flag = true;
                    }
                    
                }
                
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}



Measured memory_bytes: 16364
package main

import (
	"fmt"
)

func main() {
	var x int
	_, _ = fmt.Scan(&x)
	fmt.Println(Solve(x))
}

func Solve(x int) int {
	if x == 2 {
		return 2
	}
	
	primes := make([]int, 0)
	primes = append(primes, 2)
	
	for i := 3; ; i += 2 {
		isPrime := true
		for _, t := range primes {
			if i%t == 0 {
				isPrime = false
				break
			}
		}
		if isPrime {
			if x <= i {
				return i
			} else {
				primes = append(primes, i)
			}
		}
	}
}


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

int main()
{
	string s;
	cin >> s;
	if(s[2]==s[3]&&s[4]==s[5])
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;
stack<char> S;
char s[222222];
int n;
int main(void)
{
	int i, j;
	scanf("%s",&s[1]);
	n=strlen(&s[1]);
	for(i=1 ; i<=n ; i++)
	{
		if(s[i]=='S')
		{
			S.push('S');	
		}	
		if(s[i]=='T')
		{
			if(!S.empty() && S.top()=='S')
			{
				S.pop();
			}
			else
			{
				S.push('T');
			}
		}
	}	
	cout<<S.size();
	return 0;
}

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

int main(){
  double a, b, x;
  cin >> a >> b >> x;
  double vol = a*a*b;
  double ans = 0;
  if (vol/2 < x){
    ans = atan((2*a*a*b-2*x)/(a*a*a));
  }
  else {
    ans = M_PI/2 - atan(2*x/(a*b*b));
  }
  cout << setprecision(10);
  cout << ans*180/M_PI << endl;
}


Measured memory_bytes: 512
s = input()
q = int(input())

reverse_flag = 0
head = ""
back = ""
for _ in range(q):
    query = input()
    if query[0] == "1":
        reverse_flag ^= 1
    else:
        t,f,c = query.split()
        f = int(f) + reverse_flag
        if f%2 == 1:
            head = c + head
        else:
            back = back + c
s = head + s + back
print(s if reverse_flag%2 == 0 else s[::-1])

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


int main(){
    int n;
    cin >>n;
    vector<double>all(n);
    rep(i,n){
        cin >> all.at(i);
    }
    priority_queue<double,vector<double>,greater<double>> kk;
    rep(i,n){
        kk.push(all.at(i));
    }
    for (int i = 0; i < n-1; i++)
    {
        double mini = kk.top();
        kk.pop();
        double second = kk.top();
        kk.pop();
        double now = (mini+second)/2;
        kk.push(now);
    }
    cout<<kk.top()<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define loop(i,n) for(ll i=0;i<n;i++)
#define cloop(i,m,n) for(ll i=m;i<n;i++)
#define Matrix vector<vector<ll>>
#define Point pair<ll,ll>
#define Coordinates vector<Point>
ll global =0;
using namespace std;

ll gcd(ll a, ll b){
    /*
    return gcd of a,b
    */
    if(b>a)return gcd(b,a);
    if(a%b)return gcd(b,a%b);
    return b;
}
void init_matrix( Matrix& graph, ll num){
    /*
    Initialize Matrix elements with num rows 
    */
    loop(i,num) graph.push_back(vector<ll>(1,LLONG_MAX));
}
auto max_mp(map<ll,ll>&mp){
    /*
    return max element of map in form pair<key,val>
    */
    auto max_e = mp.begin();
    auto it = mp.begin();
    while(it!=mp.end()){
        if(it->second > max_e->second){
            max_e = it;
        }
        it++;
    }
    return *max_e;
}

auto min_mp(map<ll,ll>&mp){
    /*
    return min element of map in form pair<key,val>
    */
    auto min_e = mp.begin();
    auto it = mp.begin();
    while(it!=mp.end()){
        if(it->second < min_e->second){
            min_e = it;
        }
        it++;
    }
    return *min_e;
}
vector<ll> generate_prime(ll n) { 
    /*
    generate all primes number less than equal to n
    */
    vector<bool> prime(n+1,true);
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    vector<ll> pr;
    for (ll p=2; p<=n; p++) 
       if (prime[p]) 
          pr.push_back(p);
    return pr;
}



int main(){
    ll k,n;
    cin >> k >> n;
    ll num[n];
    ll md = LLONG_MIN;
    cin >> num[0];
    cloop(i,1,n){
        cin >> num[i];
        md = max(md,num[i]-num[i-1]);
    }
    md = max(md,k-num[n-1] + num[0]);
    cout << k- md << endl;
}
	
/*
input:

*/

/*
output:

*/	

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;
int main(){

	int a, b;
	cin >> a >> b;

	cout << a / b <<" "<< a%b <<" ";
	printf("%.5f\n", double(a) / double(b));

	return 0;
}


Measured memory_bytes: 3248
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n], sum=0;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    cout << sum - n << endl;
}


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

using namespace std;

typedef long long ll;

ll a, b;

int n;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	while (n--)
	{
		cin >> a >> b;
		if (a == b)
			cout << 2 * (a - 1) << endl;
		else if (a + 1 == b)
			cout << 2 * (a - 1) << endl;
		else
		{
			ll c = sqrt(a * b);
			if (c * c == a * b)
				--c;
			if (c * (c + 1) < a * b)
				cout << 2 * c - 1 << endl;
			else
				cout << 2 * c - 2 << endl;
		}
	}
	return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  double x = (a + b) / 2.0;
  int y = x;
  int z = x;
  y = y * 10;
  double total = x * 10;
  y = total - y;
  if(y > 4){
  	z++;
  };
  
  cout << z << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int SortingAlgorithm(int* A, int N) {
	int swapCount = 0;
	bool flag = 1;
	for (int i = 0; flag ; i++)
	{
		flag = 0;

		for ( int j = N - 1; j > i ; j--)
		{
			if (A[j] < A[j - 1]) {
				swap(A[j], A[j - 1]);
				flag = 1;
				swapCount++;

			}
		}
	}

	return swapCount;
}

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

	swapCount = SortingAlgorithm(A, N);

	for (int i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << A[i];
	}

	cout << endl;
	cout << swapCount << endl;

	return 0;
}


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

void Main() {
    // input
    u_int64_t X;
    cin >> X;

    // translate
    u_int64_t account = 100;
    u_int64_t year = 0;

    while (true) {
        if (account >= X) {
            cout << year << endl;
            return;
        }

        year++;
        /* 
        account *= 101;
        account /= 100;
        */ 
        // として, オーバーフロー
        // 64bit ではギリギリアウト

        account += account / 100;


    }


    // output

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size() 配列名.Length()
using namespace std;
typedef unsigned long long ll;


int main(void){
	string s;
	cin >> s;

	bool jud = true;

	for(int i = s.size() - 1; i >= 0; i--){
		if(s[i] == 'm'){
			if(i >= 4 && s[i-1] == 'a' && s[i-2] == 'e' && s[i-3] == 'r'
				&& s[i-4] == 'd'){
				i -= 4;
				continue;
			}
			else {
				jud = false;
				break;
			}
		}
		else if(s[i] == 'e'){
			if(i >= 4 && s[i-1] == 's' && s[i-2] == 'a' && s[i-3] == 'r'
				&& s[i-4] == 'e'){
				i -= 4;
				continue;
			}
			else {
				jud = false;
				break;
			}
		}
		else if(s[i] == 'r'){
			if(i >= 6 && s[i-1] == 'e' && s[i-2] == 'm' && s[i-3] == 'a'
			  && s[i-4] == 'e' && s[i-5] == 'r' && s[i-6] == 'd'){
				i -= 	6;
				continue;
			}
			else if(i >= 5 && s[i-1] == 'e' && s[i-2] == 's' && s[i-3] == 'a'
				&& s[i-4] == 'r' && s[i-5] == 'e'){
				i -= 5;
				continue;
			}
			else {
				jud = false;
				break;
			}
		}
		else {
			jud = false;
			break;
		}
	}
	cout << (jud ? "YES" : "NO") << endl;
}


Measured memory_bytes: 512
A=[[int(i) for i in input().split()]for j in range(3)]
N=int(input())
b=[int(input()) for i in range(N)]
C=[[0 for i in range(3)] for j in range(3)]
for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i]==A[j][k]:
                C[j][k]=1
for i in range(3):
    if C[i][0]*C[i][1]*C[i][2]==1:
        print("Yes")
        exit()
    if C[0][i]*C[1][i]*C[2][i]==1:
        print("Yes")
        exit()
if C[0][0]*C[1][1]*C[2][2]==1:
    print("Yes")
    exit()
if C[2][0]*C[1][1]*C[0][2]==1:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = [0] + A
B = [0] + B
C = [0] + C

ans = 0
for i, a in enumerate(A[1:-1]):
    i = i+1 
#    print(i, A[i], A[i+1])
#    print(B[a])
    ans += B[a]
    if A[i+1] - A[i] == 1:
#        print('C', C[a])
        ans += C[a]
ans += B[A[-1]]
print(ans)

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

int main()
{
  int	n;
  char	str[100000];
  char	tmp[100000];

  while(1){
    scanf("%d",&n);
    if (n == 0){ break; }
    scanf("%s",str);
 	
    while( n>0 ){
      int	i,j,len;

      len = strlen(str);
      memset(tmp, '\0', sizeof(tmp));
      char	c = '\0';
      char	countbuf[10],valuebuf[10];
      int	count;

      for(i = 0;i < len;i++){
	if (c != str[i]){
	  count = 0;
	  for (j = i; j < len; j++){
	    if( str[i]==str[j]){
	      count++;
	    }else{
	      break;
	    }    
	  }
	  memset(valuebuf,'\0',sizeof(valuebuf));
	  valuebuf[0] = str[i];
	  sprintf(countbuf,"%d", count);
	  strcat(tmp,countbuf);
	  strcat(tmp,valuebuf);
	  memset(countbuf, '\0', sizeof(countbuf));
	  c = str[i];
	}
      }
      memcpy(str,tmp,sizeof(tmp));   
      n--;
    }
  
    printf("%s\n", tmp);	
  }
  return 0;
}

Measured memory_bytes: 2812
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

class UnionFind {
public:
	vector<int> r, p;

	UnionFind() {}
	UnionFind(int size) {
		r.resize(size, 0);
		p.resize(size, 0);
		rep(i, 0, size)makeSet(i);
	}

	void makeSet(int x) {
		p[x] = x;
		r[x] = 0;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (r[x] > r[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (x == y) {
				r[y]++;
			}
		}
	}


	int findSet(int x) {
		if (x == p[x]) {
			return x;
		}
		else {
			return p[x] = findSet(p[x]);
		}
	}
};

void err() {
	puts("No");
	exit(0);
}

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

	int N;
	cin >> N;
	vector<pair<int, int>>A(N), B(N);

	for (int i = 0; i < N; i++) { cin >> A[i].first; A[i].second = i; }
	for (int i = 0; i < N; i++) { cin >> B[i].first; B[i].second = i; }
	sort(all(A));
	sort(all(B));

	UnionFind un = UnionFind(N);
	for (int i = 0; i < N; i++) {
		if (A[i].first > B[i].first)err();
		un.unite(A[i].second,B[i].second);
	}

	set<int>st;
	for (int i = 0; i < N; i++)st.insert(un.findSet(i));
	if (st.size() >= 2) { puts("Yes"); return 0; }
	int ok = 0;
	for (int i = 0; i < N - 1; i++)if(B[i].first >= A[i+1].first)ok = 1;

	if (ok)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()

template<typename T>
struct Bellman_ford{
  struct edge{
    int to;
    T cost;
  };
  int V;
  std::vector<std::vector<edge>>Edges;
  Bellman_ford(int V):V(V),Edges(V){}
  const T Inf = 1e9;
  void add_edge(int from,int to,T cost){
    Edges[from].push_back({to,cost});
  }
  std::pair<std::vector<T>,bool> execution(int s){
    std::queue<int>que;
    std::vector<T>dist(V,Inf);
    que.push(s);
    dist[s] = 0;
    for(int i = 0;i < V;i++){
      int loop = que.size();
      for(int j = 0;j < loop;j++){
	int now = que.front();
	que.pop();
	for(auto e:Edges[now]){
	  if(dist[e.to] > dist[now] + e.cost){
	    dist[e.to] = dist[now] + e.cost;
	    que.push(e.to);
	  }
	}
      }
      if(i == V-1 && !que.empty())return std::make_pair(dist, false);
    }
    return std::make_pair(dist, true);
  }
};


int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  ll v,e,r;std::cin>>v>>e>>r;
  Bellman_ford<int>bf(v);
  for(int i=0;i<e;i++){
    ll a,b,c;std::cin>>a>>b>>c;
    bf.add_edge(a,b,c);
  }
  std::pair<std::vector<int>,bool> ans = bf.execution(r);
  if(ans.second == false){
    std::cout<<"NEGATIVE CYCLE"<<std::endl;
    return 0;
  }
  for(auto e:ans.first){
    if(e == INF){
      std::cout<<"INF"<<std::endl;
    }else{
      std::cout<<e<<std::endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3276
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main() {
  string line;
  while (getline(cin, line)) {
    stringstream stream;
    stream << line;
    int a, b;
    stream >> a >> b;
    cout << a + b << endl;
  }
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <math.h>
int judge(int);
int main(){
  int A[10000],i,n,cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    }
  for(i=0;i<n;i++){
    if (judge(A[i])==1)cnt++;
    }
  printf("%d\n",cnt);
  return 0;
}

int judge(int x){
  int i;
  if(x==2)return 1;
  if(x<2)return 0;
  if(x%2==0)return 0;
  
  for(i=3;i<=sqrt((double)x);i+=2){
    if(x%i==0)return 0;
  }
  return 1;
}



Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };



int now;
const int _root[6][2] =
{
	{ 1, 2 },
	{ 1, 3 },
	{ 1, 2 },
	{ 4, 5 },
	{ 5, 2 },
	{ 2, 1 },
};
string str;

int main() {
	while ( cin >> str && str != "#" ) {
		now = 0;
		for ( int i = 0; i < str.size(); i++ ) {
			if ( now == _root[ now ][ str[ i ] - '0' ] ) {
				break;
			}
			now = _root[ now ][ str[ i ] - '0' ];
		}
		printf( "%s\n", now == 5 ? "Yes" : "No" );
	}
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  int length = S.size();
  int cnt = 0;
  for (int i = 0; i < length; i++){
    if (S.at(i) == '0' + (i % 2)){
      cnt++;
    }
  }
  if (cnt < length - cnt)
    cout << cnt << endl;
  else
    cout << length - cnt << endl;
}


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

#define DEBUG_MSG_off

int n;
vector<int> v_list;

int main() {
  cin >> n;
  v_list.resize(n);
  for(int i=0;i<n;i++) cin >> v_list[i];

  int ans = 0;
  for(int i=0;i<n;i++) {
    if (i==0) {
      continue;
    } 
    if (i==(n-1)) {
      continue;
    }
    priority_queue<int> pque;
    pque.push(v_list[i-1]);
    pque.push(v_list[i]);
    pque.push(v_list[i+1]);

    //printf("%d\n",pque.top());
    pque.pop();
    int tmp = pque.top();
    if (tmp==v_list[i]) {
      ans++;
    }
  }
  cout << ans << "\n";

#ifdef DEBUG_MSG
  cerr << n << "\n";
  for(auto s: v_list) cerr << s << "\n"; 
#endif
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int u, v, cost; };
int mod = 1000000007;

signed main() {
	int n, k; cin >> n >> k;
	if (n%k)cout << 1 << endl;
	else cout << 0 << endl;
}


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

int N, M;
typedef pair<int,int> pint;

vector<pint> A;
bool cmp(pint a, pint b) { return a.second < b.second; }

int main() {
    cin >> N >> M;
    A.resize(M);
    for (int i = 0; i < M; ++i) cin >> A[i].first >> A[i].second;
    sort(A.begin(), A.end(), cmp);
    int res = 0;
    int endtime = 0;
    for (int i = 0; i < M; ++i) {
        if (A[i].first >= endtime) {
            endtime = A[i].second;
            ++res;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int n,N;
int main() {
  cin >> N;
  n = N;
  int sum = 0;
  while(N > 0) {
    sum += N%10;
    N /= 10;
  }
  if(n%sum == 0) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int A = sc.nextInt();
    if(H % A == 0) {
      System.out.println(H / A);
    }else {
      System.out.println(H / A + 1);
    }
  }
}

Measured memory_bytes: 21716
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

intmax_t solve(std::string const& s, size_t k) {
  size_t n = s.length();

  std::vector<size_t> acc(n);
  for (size_t i = 0; i < n; ++i)
    if (s[i] == 'M') acc[i] = 1;
  acc.insert(acc.begin(), 0);
  for (size_t i = 1; i <= n; ++i) acc[i] += acc[i-1];

  intmax_t d = 0;
  intmax_t m = 0;
  intmax_t c = 0;
  for (size_t i = 0; i < n; ++i) {
    if (s[i] == 'D') {
      ++d;
    } else if (s[i] == 'M') {
      m += d;
    } else if (s[i] == 'C') {
      c += m;
    }
    if (i+1 < k) continue;

    if (s[i+1-k] == 'D') {
      --d;
      m -= acc[i+1] - acc[i+1-k];
    }
  }
  return c;
}

int main() {
  size_t n;
  scanf("%zu", &n);
  char buf[1048576];
  scanf("%s", buf);
  std::string s = buf;

  size_t q;
  scanf("%zu", &q);

  for (size_t i = 0; i < q; ++i) {
    size_t k;
    scanf("%zu", &k);
    printf("%jd\n", solve(s, k));
  }
}


Measured memory_bytes: 21568
# 16:07
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
# def LIST(): return list(map(str, input().split()))
# def LIST(): return list(input())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A = LIST()
per = list(permutations(A))
ans_l = []
for p in per:
    ans = 0
    for i in range(len(p)-1):
        ans += abs(p[i+1] - p[i])
    ans_l.append(ans)
print(min(ans_l))



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

int main(){

	int A,B,X;
	char op;
	
	cin >> A >> op >> B;
	
	if (op == '+'){
		X = A+B;
	}else{
		X = A-B;
	}
	
	cout << X << endl;

	return 0;

}

Measured memory_bytes: 256