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

int main() {
    string s;
    cin>>s;
    s.erase(s.size()-1, 1);
    int mx = 0;
    for (int i = 1; i < s.size(); ++i) {
        string t1, t2;
        for (int j = 0; j < i; ++j) {
            t1+=s[j];
        }
        for (int j = i; j < i + i; ++j) {
            t2+=s[j];
        }
        if (t1==t2) mx = max(mx, int(t1.size() + t2.size()));
    }
    cout<<mx<<endl;
}




Measured memory_bytes: 256
using System;

public class AOJ1
{
    static void Main()
    {
        double r = 6378.1;
        double[] val=new double[4];
        double[] x = new double[2];
        double[] y = new double[2];
        double[] z = new double[2];
        while (true)
        {
            string[] str = Console.ReadLine().Split(' ');
            for (int i = 0; i < str.Length; i++) val[i] = double.Parse(str[i]);
            if (val[0] == -1 && val[1] == -1 && val[2] == -1 && val[3] == -1) break;
            for (int i = 0; i < str.Length; i++) val[i] = val[i] * Math.PI / 180.0;
            for (int i = 0; i < 2; i++)
            {
                x[i] = r * Math.Cos(val[2*i]) * Math.Cos(val[2*i+1]);
                y[i] = r * Math.Cos(val[2*i]) * Math.Sin(val[2*i+1]);
                z[i] = r * Math.Sin(val[2*i]);
            }
            double dist = Math.Sqrt((x[0] - x[1]) * (x[0] - x[1]) + (y[0] - y[1]) * (y[0] - y[1]) + (z[0] - z[1]) * (z[0] - z[1]));
            double theta = 2 * Math.Asin(dist / (2 * r));
            Console.WriteLine("{0:f0}",r * theta);
        }
    }
}

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


void solve(long long A, long long B, long long C, long long D){
  cout << max(A*B, C*D) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def main():
    #s = map(ord, list(readline().strip()))
    #print(s)
    s = readline().strip()
    Q = int(readline())

    queue = deque(s)
    r = 0

    for _ in range(Q):
        t, *x = map(str, readline().split())
        if t == "1":
            r += 1
        else:
            f, c = x[0], x[1]
            if f == "1":
                if r % 2 == 0:
                    queue.appendleft(c)
                else:
                    queue.append(c)
            else:
                if r % 2 == 0:
                    queue.append(c)
                else:
                    queue.appendleft(c)

    ans = "".join(queue)
    if r % 2 == 0:
        print(ans)
    else:
        print(ans[::-1])


if __name__ == "__main__":
    main()


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

ans = 0
tmp = A[0]
for i in range(1, N):
    if tmp > A[i]:
        ans += tmp - A[i]
        tmp = max(A[i - 1], tmp)
    else:
        tmp = max(A[i], tmp)

print(ans) 

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

int main()
{
	string S;
	cin >> S;
	rep(i,S.size())
	{
		cout << "x";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int p[210000];
int main(){
	long long a,b,n;
	scanf("%lld%lld%lld",&a,&b,&n);
	long long ret=0;
	ret=max(ret,(a*n)/b-a*(n/b));
	if(n>=b-1)ret=max(ret,(a*(b-1))/b);
	
	printf("%lld\n",ret);
}

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


int main() {
int n,count=0;
cin>>n;
string s;
cin>>s;
for(int i=0;i<n-1;i++){
    if(s[i]!=s[i+1]){
        count++;
    }
}


cout<<count+1<<endl;

return 0;
}

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

int main (void) {
    int n;
    scanf("%d", &n);

    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        string s = to_string(i);
        if (s.size() % 2 == 1) cnt++;
    }

    printf("%d", cnt);
    
    return 0;
}

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

int main() {
    double pi=3.14159265358979;
double A,B,H,M;
cin>>A>>B>>H>>M;
double t=H*60;
double minit=t+M;
double radM=M/60;
double radH=minit/720;
double rad=abs(radM-radH);
double s=A*A+B*B-(2*A*B*(cos(2*pi*rad)));
double u=sqrt(s);
cout<<fixed<<setprecision(20)<<u<<endl;

}

Measured memory_bytes: 4228
// AOJ 1275 "And Then There Was One" (ICPCアジア地区予選 2007 東京大会 Problem A)
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            int m = sc.nextInt();
            if (n == 0) {
                break;
            }
            
            ArrayList<Integer> stone = new ArrayList<Integer>();
            for (int i = 1; i <= n; i++) {
                stone.add(i);
            }
            
            stone.remove(m - 1);
            int tmp = m - 1;
            while (stone.size() > 1) {
                tmp = (tmp + k - 1) % stone.size();
                stone.remove(tmp);
            }
            System.out.println(stone.get(0));
        }
    }
}

Measured memory_bytes: 38040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    ll ans = INF;
    for(ll i = 1; i*i <= n; i++){
        if(n%i == 0){
            chmin(ans, i+n/i-2);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin

def linearSearch(target:list, value):
    target_copy = target.copy()
    target_copy.append(value)
    i = 0
    while target_copy[i] != value:
        i += 1
    if i == len(target_copy) - 1:
        return False
    return True

def main():
    n = stdin.readline()
    s = list(map(int, stdin.readline().split()))
    q = stdin.readline()
    t = list(map(int, stdin.readline().split()))
    print(sum([1 for v in t if linearSearch(s, v)]))
        
main()


Measured memory_bytes: 6512
import java.util.Scanner;

public class Main{

	public static int gcd(int x, int y) {

		int z = x % y;

		if (z == 0) {
			return y;
		} else {
			return(gcd(y,z));
		}
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();

		System.out.println(gcd(x,y));

	}

}



Measured memory_bytes: 26284
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
typedef pair<int, int> pii;

int main(){
	while(true){
		int n, w, d;
		cin >> n >> w >> d;
		if(n == 0 && w == 0 && d == 0){ break; }
		vector<pii> pieces(1, pii(w, d));
		while(n--){
			int p, s;
			cin >> p >> s;
			pii piece = pieces[p - 1];
			pieces.erase(pieces.begin() + p - 1);
			s = s % (piece.first + piece.second);
			if(s < piece.first){
				int w1 = s, w2 = piece.first - s;
				pieces.push_back(pii(min(w1, w2), piece.second));
				pieces.push_back(pii(max(w1, w2), piece.second));
			}else{
				s -= piece.first;
				int h1 = s, h2 = piece.second - s;
				pieces.push_back(pii(piece.first, min(h1, h2)));
				pieces.push_back(pii(piece.first, max(h1, h2)));
			}
		}
		vector<int> answers;
		for(int i = 0; i < pieces.size(); ++i){
			answers.push_back(pieces[i].first * pieces[i].second);
		}
		sort(answers.begin(), answers.end());
		for(int i = 0; i < answers.size(); ++i){
			cout << answers[i] << (i == answers.size() - 1 ? "\n" : " ");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>                          
using namespace std;
int n,a,b,ans,c,x;
int main(){
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++)
    {
    	c=i;
    	x=0;
    	while(c>0) x+=c%10,c/=10;
    	if(x>=a&&x<=b) ans+=i;
	}
	cout<<ans;
	return 0;
}
//68871358
//76140264
//25446011
//200841159
//914174775

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int n;
    cin>>n;
    int a[n];
    int i,j;
    int ans=0;
    rep(i,n){
    cin>>a[i];
    }
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            ans+=a[i]*a[j];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000000
#define mod 1000000007

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	ll N,ans=1;
	cin>>N;
	ll f[11000];
	FOR(i,2,N+1){
		int num=i;
		for(int j=2;j*j<=num;j++){
			while(num%j==0){
				f[j]++;
				num/=j;
			}
		}
		if(num>1)f[num]++;
	}
	FOR(i,2,N+1)
		(ans*=f[i]+1)%=mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
#define LL long long
#define For(i,n) for(int i=1;i<=n;i++)

using namespace std;
int n,m,t;
LL X;
int main()
{
	cin>>X;
	LL p=0;
	int i;
	for(i=1;i;i++)
	{
		p+=i;
		if(p>=X)break;
	}
	
	cout<<i<<endl;
	
	return 0;
}


Measured memory_bytes: 256
const main = input => {
  const [A, B, C] = input.trim().split(' ').map(x => parseInt(x))
  if (A === B) {
    console.log(C)
  } else {
    if (A === C) {
      console.log(B)
    } else {
      console.log(A)
    }
  }
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 30416
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

x = ni()

if x < 1200:
    print("ABC")
else:
    print("ARC")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const in maxn = 1e5+9;
const in mod = 1e9+7;

in fat[maxn],inv[maxn];

in fastexp(in base,in e){
    if(e == 0) return 1;
    in ans = fastexp(base,e/2);
    ans = (ans*ans)%mod;
    if(e%2==1) ans = (ans*base)%mod;
    return ans;
}

void precalc(){
    fat[0] = fat[1] = 1;
    rep(i,2,maxn){
        fat[i] = (fat[i-1]*i)%mod;
    }
    inv[0] = inv[1] = 1;
    rep(i,2,maxn){
        inv[i] = fastexp(fat[i],mod-2);
    }
}

in comb(in a,in b){
    return (((fat[a]*inv[b])%mod)*inv[a-b])%mod;
}

int main(){
    IOS;
    precalc();
    in n,k,ans=0;
    cin >> n >> k;
    vector<in> a(n);
    rep(i,0,n){
        cin >> a[i];
    }
    sort(all(a));
    reverse(all(a));
    rep(i,0,n-k+1){
        ans = (ans + (a[i]*comb(n-1-i,k-1))%mod)%mod;
    }
    reverse(all(a));
    rep(i,0,n-k+1){
        ans = (ans - (a[i]*comb(n-1-i,k-1))%mod)%mod;
        while(ans<0) ans+=mod;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 2560
def to_ruby_form(e)
    0 while e.gsub!(/([\w)])\s+([\w(])/, '\1*\2')
    e.gsub!(/\s+/, '')
    0 while e.gsub!(/([\w)])([a-z(])/, '\1*\2')
    0 while e.gsub!(/([a-z)])([\w(])/, '\1*\2')
    e.gsub!(?^, '**')
end

def sample(e, input)
    eval(e.tr('a-z', input))
end

N = 10
loop do
    e = gets.chomp
    break if e == ?.
    to_ruby_form(e)
    a = (0..9).to_a * 2 + (0..5).to_a
    inputs = (0..N-1).map { a.shuffle.join }
    outputs = inputs.map {|input| sample(e, input)}

    until (e = gets.chomp) == ?.
        to_ruby_form(e)
        if (0..N-1).all? {|i| sample(e, inputs[i]) == outputs[i]}
            puts 'yes'
        else
            puts 'no'
        end
    end
    puts ?.
end

Measured memory_bytes: 9600
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
# mod = 998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"
INF = 1<<32-1
# INF = 10**18

def main():
    n = int(ipt())
    print((pow(10,n,mod)+pow(8,n,mod)-2*pow(9,n,mod))%mod)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 74956
X = int(input())

if X >= 1800:
    print(1)
elif X >= 1600:
    print(2)
elif X >= 1400:
    print(3)
elif X >= 1200:
    print(4)
elif X >= 1000:
    print(5)
elif X >= 800:
    print(6)
elif X >= 600:
    print(7)
elif X >= 400:
    print(8)


Measured memory_bytes: 9196
#include <iostream>
#include <cmath>
#include <algorithm>

const int N = 100;
const int W = 10000;
int table[N+1][W+1] = {}; // total "value"

struct item {
    int value;
    int weight;
} items[N+1];

const int NONE = -1;

int main() {
    using namespace std;

    int n, w;
    cin >> n >> w;
    for( int i=0; i<n; ++i ) {
        cin >> items[i+1].value >> items[i+1].weight;
    }

    // init
    for( int nn=0; nn<n; ++nn ) {
        for( int ww=0; ww<w; ++ww ) {
            table[nn][ww] = NONE;
        }
    }
    table[0][0] = 0;

    for( int i=1; i<=n; ++i ) {
        for ( int j=0; j<=w; ++j ) {
            if ( table[i-1][j] != NONE ) {
                const int prev_v = table[i-1][j];

                // if not take
                table[i][j] = max(prev_v, table[i][j]);

                // if take
                if ( j + items[i].weight <= W ) {
                    table[i][j + items[i].weight] = max(prev_v + items[i].value, table[i][j + items[i].weight]);
                }
            }
        }
    }

    cout << *max_element( table[n], table[n] + w + 1 ) << endl;
}

Measured memory_bytes: 5104
function main(input) {
  input=input.trim();
  const a = parseInt(input.split(" ")[0], 10);
  const b = parseInt(input.split(" ")[1], 10);
  console.log(((b-a)*(b-a+1)/2)-b);
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21320
s = input()

ss = s.replace('BC', '0').replace('A','1')

cnt = 0
ans = 0

for i in range(len(ss)-1, -1, -1):
    if ss[i] == 'B' or ss[i] == 'C':
        cnt = 0
    elif ss[i] == '1': ans += cnt
    else : cnt += 1
        
print(ans)


Measured memory_bytes: 3560
#include <stdio.h>
int main(void){
    long n,i,min=10001,cnt=0;
    long a[200];
    scanf("%ld",&n);
    for(i=0;i<n;i++) scanf("%ld",&a[i]);
    for(i=0;i<n;i++){
        cnt=0;
        while(a[i]%2!=1) {
            a[i]/=2;
            cnt++;
        }
        if(min>cnt) min=cnt;
    }
    printf("%ld",min);
}
    


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

signed main() {
    string s;

    for (int i = 0; i < 4; i++) {
        char c;
        cin >> c;
        s += c;
    }

    sort(s.begin(), s.end());

    cout << (s == "1479" ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int main() {
	ll N=0;
	set<ll> S;
	vector<ll> vec(4000);
	for (ll i = 0; i <2000; i++) {
		vec.at(i+2000) = i * i * i * i * i;
		vec.at(i) = -ll(2000-i) *ll(2000 - i) * ll(2000 - i)* ll(2000 - i)* ll(2000 - i);
	}
	
	ll A, B,X;
	cin >> X;
	int k, l,fr=1;
	rep(i, 4000) {
		A = vec.at(i);
		rep(j, 4000) {
			B = vec.at(j);
			if (A - B == X) {
				k = i;
				
				l = j;
				fr = 0;
			}
			if (fr == 0) {
				break;
			}
		}
		if (fr == 0) {
			break;
		}
	}
	cout<< k-2000<<" "<<l-2000<<endl;
}


Measured memory_bytes: 3660
import java.util.*;
public class Main {

	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
      	
      	if(s.equals("Sunny")) {
          System.out.println("Cloudy");
        }else if(s.equals("Cloudy")){
          System.out.println("Rainy");
        }else if(s.equals("Rainy")){
          System.out.println("Sunny");
        }
      
      
	}

}


Measured memory_bytes: 22996
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define debug(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

int main(int const argc, char const** argv){
  ll N, H, W;
  cin >> N >> H >> W;

  cout << (N - H +  1) * (N - W + 1);
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

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

    int ans = max(0, a - 2 * b);
    cout << ans << endl;

    return 0;
}

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

#define ALL(c) std::begin(c), std::end(c)

using namespace std;
using ll = long long;

void solve() {
  int a, b;
  cin >> a >> b;
  for (int i = 0; i < 1300; i++) {
    if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.14159265358979323846;
double pi2=pi/2.0;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,0,-1,0};
int dw[4]={0,1,0,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}


int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string n;cin>>n;
    int sum=0;
    rep(i,0,n.size()){
        int u=n[i]-'0';
        sum+=u;
    }
    if(sum%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3760
def all_water(h_list):
  if len(h_list) == 0:
    return 0
  min_h = min(h_list)
  new_list = [x - min_h for x in h_list]
  i = new_list.index(0)
  return min_h + all_water(new_list[:i]) + all_water(new_list[i+1:])

n = input()

height = list(map(int,input().split(" ")))

print(all_water(height))

Measured memory_bytes: 3060
/*
HI I'm JiKuai.
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll a, b;
	cin >> a >> b;
	ll n = __gcd(a, b);
	
	int ans = 1;
	for(ll i = 2; i*i <=n; i++) {
		if(n%i==0) {
			ans++;
			while(n%i==0) {
				n/=i;
			}
		}
	}
	if(n!=1) ans++;
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LL long long int 
const LL MOD=2019;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//            When something is important enough, you do it even if the odds are not in your favor.
LL l,r;
bool check(LL i){
  LL x=l/2019;
  x*=2019;
  if((l<=x+i&&x+i<=r)||(l<=x+i+2019&&x+i+2019<=r)) return 1;
  return 0;
}
bool check1(LL i){
  LL x=l/2019;
  x*=2019;
  LL a=0;
  if((l<=x+i&&x+i<=r)) a++;
  if((l<=x+i+2019&&x+i+2019<=r)) a++;
  if((l<=x+i+2*2019&&x+i+2*2019<=r)) a++;
  if(a>=2) return 1;
  else return 0;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LL i,j,ans=1e18;cin>>l>>r;
      fo(i,0,2019){
        fo(j,0,2019){
          if(i!=j){
            if(check(i)&&check(j)){
              ans=min(ans,i*j%MOD);
            }
          }
          else{
            if(check1(i)){
              ans=min(ans,i*i%MOD);
            }
          }
        }
      }
      cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

void dfs(ll v,ll color[],vector<pair<ll,ll>> g[],bool visited[])
{
    visited[v]=true;
    
    for(auto it:g[v])
    {
        if(visited[it.first]==false)
        {
            visited[it.first]=true;
            
            if((it.second)%2==0)
            color[it.first]=color[v];
            else
            {
                if(color[v]==1)
                {
                    color[it.first]=0;
                }
                else
                color[it.first]=1;
            }
            dfs(it.first,color,g,visited);
        }
    }
}

int main() 
{
    ll n;
    cin>>n;
    vector<pair<ll,ll>> g[n+1];
    for(ll i=1;i<=n-1;i++)
    {
        ll u,v,w;
        cin>>u>>v>>w;
        g[u].push_back({v,w});
        g[v].push_back({u,w});
    }
    
    bool visited[n+1];
    for(ll i=0;i<=n;i++)
    visited[i]=false;
    
    ll color[n+1];
    for(ll i=0;i<=n;i++)
    color[i]=-1;
    
    color[1]=1;
    
    dfs(1,color,g,visited);
    
    for(ll i=1;i<=n;i++)
    cout<<color[i]<<'\n';
}

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

int main() {
    int n;
    cin >> n;
    int a[2][n];
    rep(i, n) cin >> a[0][i];
    rep(i, n) cin >> a[1][i];

    int ans = 0;
    rep(i, n) {
        int cnt = 0;
        for (int j = 0; j <= i; j++) cnt += a[0][j];
        for (int j = i; j < n; j++) cnt += a[1][j];
        ans = max(ans, cnt);
    }

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


Measured memory_bytes: 256
// frog1
// bottom-up approach
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<iomanip>
#define ll long long
using namespace std;
int main()
{
	ll n,val,k;
	cin>>n>>k;
	vector<ll> height(n,0);
	vector<ll> dp(n,INT_MAX);
	for(ll i=0;i<n;i++)
	{
		cin>>height[i];
	}
	
	dp[0]=0;
	dp[1]=abs(height[1]-height[0]);
	for(ll i=1;i<n;i++)
	{
		for(ll j=i-1;j>=i-k&&j>=0;j--)
		{
		val=abs(height[i]-height[j])+dp[j];
		dp[i]=min(dp[i],val);
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char const* argv[])
{
	int x;
  	cin >> x;
	int max = 0;
	for(int i = 2; i < 10; i++){
			int j = 2;
			while(pow(j, i) <= x){
					j++;
			}
			if(max < pow(j - 1, i))max = pow(j - 1, i);
	}
	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256
use text_io::*;
// use std::collections::*;
// use std::process::exit;

fn main() {
    let mut n:usize = read!();
    let mut v:Vec<[usize;2]> = Vec::new();
    for i in 0..n {
        let mut a:isize = read!();
        let mut a:usize = (10000+a) as usize;
        let mut b:isize = read!();
        let mut b:usize = (10000+b) as usize;
        v.push([a,b]);
    }
    let mut sum:f64 = 0.0;
    for i in 0..n {
        for j in i+1..n {
            sum += (((v[i][0]as f64 -v[j][0]as f64)*(v[i][0]as f64 -v[j][0]as f64)+(v[i][1]as f64-v[j][1]as f64)*(v[i][1]as f64-v[j][1]as f64)) as f64).sqrt();
        }
    }
    println!("{}",sum*2.0/n as f64);
}

Measured memory_bytes: 2180
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int d[225816][26],memo[225816];
bool done[225816];

int solve(int i){
	int j;
	if(i==INF){
		return 0;
	}
	if(done[i]){
		return memo[i];
	}
	done[i] = true;
	memo[i] = INF;
	for(j=0; j<26; ++j){
		memo[i] = min(memo[i],solve(d[i][j])+1);
	}
	return memo[i];
}

int main(void){
	int n,i,j;
	string s;
	cin >> s;
	n = s.l_ength();
	for(j=0; j<26; ++j){
		d[n][j] = INF;
		for(i=n-1; i>=0; --i){
			d[i][j] = d[i+1][j];
			if(s[i] == 'a'+j){
				d[i][j] = i+1;
			}
		}
	}
	i = 0;
	while(i<INF){
		for(j=0; j<26; ++j){
			if(solve(i) == solve(d[i][j])+1){
				cout << ((char)('a'+j));
				i = d[i][j];
				break;
			}
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 23172
from bisect import bisect_left
N = int(input())
As = [int(input()) for _ in range(N)]

INF = 10**20
dp = [As[0]]

for i in range(1, N):
    a = As[i]
    if a>dp[-1]:
        dp.append(a)
    else:
        dp[bisect_left(dp, a)] = a
print(len(dp))


Measured memory_bytes: 10360
S = input()

start = len(S)

while 0<start:

    if start < 5:
        print("NO")
        exit()
    elif start == 7 and S[start-7:start] == "dreamer":
        print("YES")
        exit()
    elif start == 6 and S[start-6:start] == "eraser":
        print("YES")
        exit()
    elif start == 5 and S[start-5:start] == "erase":
        print("YES")
        exit()
    elif start == 5 and S[start-5:start] == "dream":
        print("YES")
        exit()
    elif S[start-6:start] == "eraser":
        start -=6
    elif S[start-5:start] == "erase":
        start -=5
    elif S[start-5:start] == "dream":
        start -=5
    elif S[start-7:start] == "dreamer":
        start -=7
    else:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)
ll dp[4020][2020][2];
ll mod=924844033;
int main(){
    int N,K;
    cin>>N>>K;
    vector<ll> m;
    ll c=0,s=0;
    bool t[2001];
    for(int i=1;i<N+1;i++){
        if(!t[i]){
            s+=(N-i)/K*2;
            rp(j,0,(N-i)/K) m.push_back(c);
            c++;
            rp(j,0,(N-i)/K) m.push_back(c);
            c++;
            for(int j=i;j<=N;j+=K){
                t[j]=true;
            }
        }
    }
    dp[0][0][0]=1;
    rp(i,0,s){
        rp(j,0,min(ll(2001),ll(i+1))){
            (dp[i+1][j+1][1]+=dp[i][j][0])%=mod;
            if(m[i]!=m[i-1]) (dp[i+1][j+1][1]+=dp[i][j][1])%=mod;
            (dp[i+1][j][0]+=(dp[i][j][0]+dp[i][j][1]))%=mod;
        }
    }
    ll per[2001];
    per[0]=1;
    rp(i,1,2001){
        per[i]=(per[i-1]*i)%mod;
    }
    ll sub=0;
    for(int i=1; i<=min(ll(s),ll(N)); ++i)
    {
        if(i%2==0) sub = (sub - ((dp[s][i][0]+dp[s][i][1])*per[N-i])%mod + mod)%mod;
        else sub = (sub + ((dp[s][i][0]+dp[s][i][1])*per[N-i])%mod)%mod;
    }
    
    ll ans=(per[N]-sub+mod)%mod;
    cout << ans << endl;
    return 0;
    
};

Measured memory_bytes: 105536
#include <stdio.h>
int main(){
    int n,now;
    char c;
    bool f;
    while(scanf("%d\n",&n)!=EOF){
        now=0;
        while(now<n){
            scanf("%c",&c);
            f=true;
            while(c=='H'){
                scanf("%c",&c);
                if(c=='o'){
                    scanf("%c",&c);
                    if(c=='s'){
                        scanf("%c",&c);
                        if(c=='h'){
                            scanf("%c",&c);
                            if(c=='i'){
                                scanf("%c",&c);
                                if(c=='n'){
                                    scanf("%c",&c);
                                    if(c=='o'){
                                        printf("Hoshina");
                                        f=false;
                                    }
                                    else printf("Hoshin");
                                }
                                else printf("Hoshi");
                            }
                            else printf("Hosh");
                        }
                        else printf("Hos");
                    }
                    else printf("Ho");
                }
                else printf("H");
            }
            if(f)printf("%c",c);
            if(c=='\n')now++;
        }
    }
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
 
//#define kk
//#define int long long
#define FOR(i, n) for(int i=1; i<=n; i++)
#define ff first
#define ss second
#define ll int
#define inf 1000000000
#define pb push_back
#define mod 1000000007
 
const long long INF=1e18+5;
 
typedef pair<int, int> pi;

int arr[1001][1001];
int dp[1001][1001]; 
 
void solve(){
	int n, m;
	cin>>n>>m;
	
	for(int i=1; i<=n; i++){
		string s;
		cin>>s;
		for(int j=1; j<=m; j++){
			arr[i][j]=s[j-1];
		}
	}
	
	dp[n][m]=1;
	
	for(int i=n-1; i>=1; i--){
		if(dp[i+1][m] && arr[i][m]!='#') dp[i][m]=1;
		else dp[i][m]=0;
	}
	
	for(int i=m-1; i>=1; i--){
		if(dp[n][i+1] && arr[n][i]!='#') dp[n][i]=1;
		else dp[n][i]=0;
	}
	
	for(int i=n-1; i>=1; i--){
		for(int j=m-1; j>=1; j--){
			if(arr[i][j]=='#') dp[i][j]=0;
			else dp[i][j]=(dp[i+1][j]+dp[i][j+1])%mod;
		}
	}
	cout<<dp[1][1]%mod<<endl;
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	#ifdef kk
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	int T=1;
	//cin>>T;
	
	while(T--){
		solve();
	}
}


Measured memory_bytes: 11516
# A, B = [int(i) for i in input().split(" ")]
# A = int(input())
# As = [int(i) for i in input().split(" ")]
# Ss = ["".join(sorted(input())) for _ in range(N)]
# from math import factorial
# def nCr(n, r): return factorial(n) // factorial(r) // factorial(n - r)

a = int(input())
s = (input())
if a >= 3200: print(s)
else: print("red")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
        cin >> a[i];
    vector<ll> s;
    vector<ll> ord(n + 1, -1);
    ll c = 1, l = 0;
    ll v = 1;
    while (ord[v] == -1)
    {
        ord[v] = s.size();
        s.emplace_back(v);
        v = a[v - 1];
    }
    c = s.size() - ord[v];
    l = ord[v];
    if (k < l)
        cout << s[k] << endl;
    else
    {
        k -= l;
        k %= c;
        cout << s[l + k] << endl;
    }
}

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

int main() {
  int K, X;
  cin >> K >> X;
  for (int i = X - K + 1; i < X + K; ++i) {
    cout << i;
    if (i < X + K - 1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

const string DIRS = "URDL", TANK = "^>v<";
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};

bool in_range(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }
int dir(char c) { return DIRS.find(c); }

int T, H, W, N, tx, ty;
string grid[22], operation;

void move(int d) {
	grid[ty][tx] = '.';
	
	int nx = tx + dx[d], ny = ty + dy[d];
	
	if (in_range(nx, ny, W, H) && grid[ny][nx] == '.') {
		grid[ny][nx] = TANK[d];
		ty = ny; tx = nx;
	} else {
		grid[ty][tx] = TANK[d];
	}
}

void shoot() {
	int d = TANK.find(grid[ty][tx]);
	int x = tx + dx[d], y = ty + dy[d];
	
	while (in_range(x, y, W, H) && grid[y][x] != '#' && grid[y][x] != '*') {
		x += dx[d];
		y += dy[d];
	}
	
	if (in_range(x, y, W, H) && grid[y][x] == '*') grid[y][x] = '.';
}

void simulate() {
	for_(i,0,N) {
		char c = operation[i];
		
		if (c == 'S') {
			shoot();
		} else {
			move(dir(c));
		}
	}
}

int main() {
	cin >> T;
	
	for_(case_num,0,T) {
		cin >> H >> W;
		
		for_(y,0,H) {
			cin >> grid[y];
			for_(x,0,W) if (TANK.find(grid[y][x]) != TANK.npos) tx = x, ty = y;
		}
		
		cin >> N;
		cin >> operation;
		
		simulate();
		
		for_(y,0,H) cout << grid[y] << endl;
		if (case_num < T - 1) cout << endl;
	}
}

Measured memory_bytes: 1208
#include <cstdio>
#include <vector>
#include <unordered_map>

const int MN = 100005;

int N, A[MN];
std::vector<int> G[MN];

std::unordered_map<int, int> mp[MN];
int DFS(int u, int p) {
	if (mp[u].count(p)) return mp[u][p];
	for (int v : G[u]) if (v != p && A[v] < A[u] && !DFS(v, u)) return mp[u][p] = 1;
	return mp[u][p] = 0;
}

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
	for (int i = 1, x, y; i < N; ++i) {
		scanf("%d%d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	for (int i = 1; i <= N; ++i) if (DFS(i, 0)) printf("%d ", i);
	puts("");
	return 0;
}

Measured memory_bytes: 11412
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int main(){
  string ans="CODEFESTIVAL2016",s;
  cin>>s;
  int res=0;
  REP(i,16) if(s[i]!=ans[i]) ++res;
  cout<<res<<endl;


  return 0;
}





Measured memory_bytes: 256
odd = [ "R", "U", "D"]
add = ["L", "U", "D"] 
ans = 1
 
S = input()
for i,s in enumerate(S):
  if (i+1)%2 == 0:
    if (s in add) == False:
      ans = 0
  else:
    if (s in odd) == False:
      ans = 0
      
if ans == 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3060
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const ll mod=998244353;
inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}
const int N=3e3+10;
ll dp[N][N];
int a[N],n,s;
void add(ll &x,ll y)
{
    x=(x+y)%mod;
}
int main()
{
    n=read(),s=read();
    rep(i,1,n) a[i]=read();
    dp[0][0]=1;
    rep(i,1,n)
    {
        for(int j=0;j<=s;++j) dp[i][j]=dp[i-1][j]*2%mod;

        for(int j=s;j>=a[i];--j){
            add(dp[i][j],dp[i-1][j-a[i]]);
        }
    }
    printf("%lld\n",dp[n][s]);
}


Measured memory_bytes: 74212
#include "bits/stdc++.h"
using namespace std;
int k;
vector<int> data(3);
void solve(){
    cin >> data.at(0) >> data.at(1) >> data.at(2);
    cin >> k;
    sort(data.begin(), data.end());
    for(int i = 0; i < k; i++){
    data.at(2) *= 2;
    }
    cout << data.at(0) + data.at(1) + data.at(2) << endl;
}
int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k,n;
    cin >> k >> n;
    vll a(n);
    REP(i,n) cin >> a[i];
    ll ans = LLINF;
    if(n==2){
        ans = a[1]-a[0];
        ans = min(ans,k+a[0]-a[1]);
        cout << ans << endl;
        return 0;
    }
    REP(i,n-1){
        ans = min(ans,a[i]+k-a[i+1]);
    }
    ans = min(ans,a[n-1]-a[0]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

int A,B,C,D,E,F;
int sugar[3000+1],water[3000+1];

double ratio(int s,int w){
    if(s==0 && w==0)
        return 0;
    else
        return (double)s/(s+w);
}

int main(void){
    cin>>A>>B>>C>>D>>E>>F;
    water[0]=1;
    REP(i,3000+1){
        if(water[i]&&i+100*A<=3000)
            water[i+A*100]=1;
        if(water[i]&&i+100*B<=3000)
            water[i+B*100]=1;
    }
    sugar[0]=1;
    REP(i,3000+1){
        if(sugar[i]&&i+C<=3000)
            sugar[i+C]=1;
        if(sugar[i]&&i+D<=3000)
            sugar[i+D]=1;
    }
    int s=0,w=0;
    REP(i,3000+1)
        REP(j,3000+1)
            if(i+j<=F && ratio(i,j)<=ratio(E,100) && ratio(s,w)<=ratio(i,j) && sugar[i] && water[j]){
                s=i;
                w=j;
            }
    cout<<s+w<<" "<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin >> s;
    string a[16] = {
        "AKIHABARA",
        "AKIHABAR",
        "AKIHABRA",
        "AKIHABR",
        "AKIHBARA",
        "AKIHBAR",
        "AKIHBRA",
        "AKIHBR",
        "KIHABARA",
        "KIHABAR",
        "KIHABRA",
        "KIHABR",
        "KIHBARA",
        "KIHBAR",
        "KIHBRA",
        "KIHBR"
    };
    rep(i, 16){
        if(s == a[i]){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
 
using namespace std;
 
int main()
{
    stack<int> S1;
    stack<pair<int, int> > S2;
    char c;
    int sum=0;
    int i,j,a;
    for(i=0; cin >> c ;i++)
    {
        if(c=='\\') S1.push(i);
        else if(c=='/' && S1.size()>0)
        {
            j=S1.top();
            S1.pop();
            sum+=i-j;
            a=i-j;
            while(S2.size()>0 && S2.top().first>j)
            {
                a+=S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j,a));
        }
    }
     
    vector<int> ans;
    while(S2.size()>0)
    {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for(i=0;i<ans.size();i++)
    {
       cout << " ";
       cout << ans[i];
    }
    cout << endl;
     
    return 0;
}

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

int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int e = d-b,f = c-a;
    cout << c-e << " " << d+f << " " << a-e << " " << b+f << endl;
}

Measured memory_bytes: 256