akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int a[3][6];
  FOR(i,0,3) FOR(j,0,6) cin >> a[i][j];
  FOR(i,0,3) a[i][3]--;
  FOR(i,0,3) a[i][4]+=59;
  FOR(i,0,3) a[i][5]+=60;
  FOR(i,0,3) FOR(j,0,3) a[i][j+3] -= a[i][j];
  FOR(i,0,3) {
    for(int j = 5; j >= 4; j--) {
      if(a[i][j] >= 60) {
        a[i][j-1]++;
        a[i][j] -= 60;
      }
    }
  }
  FOR(i,0,3) FOR(j,3,6) {
    printf("%d%c",a[i][j],j==5?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 3156
//
//  main.cpp
//  ABC173A
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    int ans=0;
    if(n%1000>0){
        ans=1000-n%1000;
    }else{
        ans=0;
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 3160
yyyy, mm, dd = input().split('/')

#print(yyyy)
#print(mm)
#print(dd)

if int(yyyy) >= 2020:
    print('TED')
elif int(yyyy) <= 2018:
    print('Heisei')
else:
    if int(mm) >= 5:
        print('TBD')
    else:
        print('Heisei')

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


const int MAXN = 1005;
vector<vector<int>> to(2505);
vector<vector<int>>ot(2505);
vector<int>d(2505,INF);

bool re[2505];
bool er[2505];
bool use[2505];

bool dfs(int v){
  if (re[v]) return re[v];
  else{
    re[v]=true;
    for(auto T:to[v]){
      dfs(T);
    }
  }
}

bool rdfs(int v){
  if (er[v]) return er[v];
  else{
    er[v]=true;
  //  cout<<er[v]<<v<<'v'<<endl;
    for(auto T:ot[v]){
    //  cout<<T<<'T'<<endl;
      rdfs(T);
    }
  }
}




int main() {
  int n,m,p;
  cin>>n>>m>>p;
  vector<tuple<int,int,int>> t;
  rep(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    c-=p;
    c=-c;
    t.emplace_back(a,b,c);
    to[a].push_back(b);
    ot[b].push_back(a);
  }

  dfs(0);
  rdfs(n-1);
//  cout<<er[0]<<' '<<er[1]<<' '<<er[2]<<'e'<<endl;
  rep(i,n){
    use[i]=re[i]&er[i];
  //  cout<<re[i]<<endl;
  //  cout<<er[i]<<endl;
  }
  int cnt=0;
  bool update=true;
  d[0]=0;
  while (update){
    update=false;
  rep(i,m){
    int a1,b1,c1;
    tie(a1,b1,c1)=t[i];
  //  cout<<'c'<<endl;
    if (!use[a1])continue;
    if (!use[b1])continue;
    int newD=d[a1]+c1;
    if (d[b1]>newD){
      update=true;
      d[b1]=newD;
//      cout<<newD<<endl;
       }
    }
    cnt++;
    if (cnt>n){
      cout<<-1;
      return 0;
    }
  }


    cout<<max(-d[n-1],0);


}


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

int main()
{
    ll N;
    string S;
    cin >> N >> S;
    ll r=0;ll g=0;ll b=0;
    for (ll i = 0; i < N ; i++)
    {
        if(S[i]=='R')r++;
        else if(S[i]=='G')g++;
        else b++;
    }
    ll res=r*g*b;
    ll d=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            int k=j*2-i;
            if(k>=N||S[k]==S[j]||S[i]==S[j]||S[i]==S[k])continue;
            d++;
        }
    }
    cout << res - d;
}

Measured memory_bytes: 3612
from itertools import accumulate


def solve(string):
    _, *a = map(int, string.split())
    ac = list(accumulate(a))
    ans = 0
    for _a, _c in zip(a, ac):
        ans = (ans + _a * (ac[-1] - _c)) % (10**9 + 7)
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;


int N;
vi a;


int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	cin >> N;

	a.assign(N, 0);

	int need = 1;

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

	if (need == 1)
		cout << "-1\n";
	else
		cout << N - (need - 1) << '\n';



	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


Measured memory_bytes: 1024
S = input()

list1 = ["SUN","MON","TUE","WED","THU","FRI","SAT" ]
if S == list1[0]:
    print(7)
elif S == list1[1]:
    print(6)
elif S == list1[2]:
    print(5)
elif S == list1[3]:
    print(4)
elif S == list1[4]:
    print(3)
elif S == list1[5]:
    print(2)
elif S == list1[6]:
    print(1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define MAX 3e5+7
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	char c;
	cin >> c;
	if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u')
	{
		cout << "vowel";
	}
	else
	{
		cout << "consonant";
	}
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())

alphabets = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]

scripts = [[] for i in range(N)]
scripts[0] = ["a"]

for i in range(N-1) :
  for ii in range(N-1) :
    if(len(scripts[N-ii-1]) > 0) :
      scripts[N-ii-1] = [str1+str2 for str1 in scripts[N-ii-1] for str2 in alphabets[0:N-ii]]
    scripts[N-ii-1].extend([str1+alphabets[N-ii-1] for str1 in scripts[N-ii-2]])
  scripts[0] = [scripts[0][0]+alphabets[0]]
  
scripts_flatten = []
for i in range(N) :
  scripts_flatten.extend(scripts[i])
scripts_flatten.sort()
for string in scripts_flatten :
  print(string)

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

long long n,a[100005],r1,r2;

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

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

    sort(a,a+n);
    r2=a[n-1];

    long long q1=lower_bound(a,a+n,a[n-1]/2+(a[n-1]%2==1))-a;
    long long q2=q1-1;
    if(q1==0)
    {
        r1=a[q1];
        cout<<r2<<" "<<r1<<endl;
    }
    else if(q1==n-1)
    {
        r1=a[q2];
        cout<<r2<<" "<<r1<<endl;
    }
    else
    {
        if(a[n-1]%2==0)
        {
            long long d=a[n-1]/2;
            long long d1=llabs(d-a[q1]),d2=llabs(d-a[q2]);
            if(d1<d2)
                r1=a[q1];
            else
                r1=a[q2];
        }
        else
        {
            float d=a[n-1]/2+0.5;
            float d1=fabs(d-a[q1]),d2=fabs(d-a[q2]);
            if(d1<d2)
                r1=a[q1];
            else
                r1=a[q2];
        }
        cout<<r2<<" "<<r1<<endl;
    }


    return 0;
}


Measured memory_bytes: 4408
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
int main() {
	string s;
	string t;
	cin >> s;
	cin >> t;

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

	if (s < t)cout << "Yes";
	else cout << "No";

	
}

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

using namespace std;

bool isN(double x) {
  return x == (int) x;
}

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

  if (isN((a + b) / 2.0)) {
    cout << (a + b) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005
ll ans[N];
ll expo(ll base, ll exponent, ll mod) {								//return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%mod;
        }
        base = base*base;
        base %= mod;
        exponent>>= 1;
    }
    return ans%mod;
}
int main()
{
	ios
	ll n,k,i,j;
	cin>>n>>k;
	ll tot=0;
	for(i=k;i>0;i--){
		ll minus=0;
		for(j=2*i;j<=k;j+=i){
			minus+=ans[j];
			minus%=hell;
		}
		ans[i]+=expo(k/i,n,hell)%hell;
		ans[i]-=minus;
		// cout<<minus<<' '<<tot<<"\n";
		ans[i]+=(2*hell);
		ans[i]%=hell;
	}
	for(i=1;i<=k;i++)tot+=(ans[i]*i)%hell,tot%=hell;
	cout<<tot;
	return 0;
}

Measured memory_bytes: 4348
#include <stdio.h>

int main(){
  	int P, Q, R, max, res;
  	scanf("%d %d %d\n",&P,&Q,&R);
	max = P;
  	if(Q >= max){
      max = Q;
    }
  
  	if(R >= max){
    	max = R;
    }
  	
  	res = P+Q+R-max;
  
  	printf("%d\n",res);
  
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main() {
  int n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d;
  cin >> s;

  bool yes = true;

  for (auto i = a-1; i < d-1; ++i) {
    if (s[i] == '#' && s[i+1] == '#') {
      cout << "No" << endl;
      return 0;
    }
  }

  if (d < c) {
    bool no = true;
    for (auto i = b-2; i <= d-2; ++i) {
      if (s[i] == '.' && s[i+1] == '.' && s[i+2] == '.') {
        cout << "Yes" << endl;
        no = false;
        return 0;
      }
    }
    if (no) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
map<long long ,long long>dp;
long long Dp(long long x)
{
    return dp[x]? dp[x]:dp[x]=((Dp(x/2)+Dp((x-1)/2)+Dp((x-2)/2)))%MOD;
}
int main()
{
    dp[0]=1,dp[1]=2;
    long long n;
    cin>>n;
    cout<<Dp(n);
    return 0;
} 

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int[] base = {1,11,111,1111,11111,111111,1111111,11111111,111111111};
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        String x = Integer.toString(a*base[b-1]);
        String y = Integer.toString(b*base[a-1]);
        
        System.out.println(x.compareTo(y)>0?y:x);
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n,m;
    cin>>n>>m;
    if(n>=3 && m>=3)
        cout<<(n-2)*(m-2)<<endl;
    else if(n==2 || m==2)
        cout<<0<<endl;
    else if(n==1 && m==1)
        cout<<1<<endl;
    else if(n==1)
        cout<<m-2<<endl;
    else if(m==1)
        cout<<n-2<<endl;
    return 0;
}


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

int main(){
    string s;
    int k;
    cin>>s;
    cin>>k;
    set<string> sub;
    for(int i=0;i<s.size();i++){
        for(int j=1;i+j-1<s.size()&&j<=k;j++){
            sub.insert(s.substr(i,j));
        }
    }
    
    auto itr=sub.begin();
    for(int i=0;i<k-1;i++){
        itr++;
    }
    cout<<*itr<<endl;
    
    return 0;
}


Measured memory_bytes: 1664
from collections import deque
n=int(input())
X=[[] for _ in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    X[u-1].append([v-1,w])
    X[v-1].append([u-1,w])
C=[0]*n
q=deque([])
for v,w in X[0]:
    q.append([v,w])
visited=[0]*n

while q:
    v,w=q.popleft()

    if visited[v]==1:
        continue
    visited[v]=1
    if w%2==0:
        C[v]=0
    else:
        C[v]=1
    for pv,pw in X[v]:
        q.append([pv,pw+w])

for c in C:
    print(c)

Measured memory_bytes: 46492
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    n, x, t  = map(int, input().split())

    #output
    a, b = divmod(n, x)

    # %%
    if b == 0:
        print(n//x * t)
    else:
        print((n//x+1)*t)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int main(){
	int a,b;
	cin>>a>>b;
	if(a==b) puts("Draw");
	else if(a==1||(a>b&&b>1)) puts("Alice");
	else puts("Bob");
	return 0;
}

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

typedef long long ll;

int main(){
  ll n,sum=0;
  cin >> n;
  vector<string> s(n);
  for(int i=0;i<n;i++) cin >> s[i];
  sort(s.begin(),s.end());
  for(int i=1;i<n;i++){
    if(s[i]!=s[i-1]) sum++;
  }
   cout << sum+1 << endl;
  return 0;
}


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

int main(){
    int n, m, i;
    long long int c;
    cin >> n >> m;
    pair<int, int> a[n];
    for(i=0; i<n; i++){
        cin >> a[i].first >> a[i].second;
    }
    sort(a, a+n);
    i = 0;
    while(m>0){
        if(m>=a[i].second){
            c += (long long int)a[i].first*a[i].second;
            m -= a[i].second;
        }else{
            c += (long long int)a[i].first*m;
            m = 0;
        }
        i++;
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
 ll  a,b; cin>>a>>b;
 cout<<6-a-b<<endl;
  
}


Measured memory_bytes: 764
N=int(input())
A1=list(int(i) for i in input().split())
A2=list(int(i) for i in input().split())

maxd=0

for i in range(N):
	tmp=sum(A1[0:i+1])+sum(A2[i:N])
	if tmp>maxd:
		maxd=tmp	

print(maxd)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string a;
    cin >> a;
    if(a<="z"&& a>="a"){
        cout << "a" << endl;
    }else if(a<="Z"&& a>="A"){
        cout << "A" << endl;
    }
}


Measured memory_bytes: 3584
S = input()

if S[0] == S[1] == S[2] == S[3]:
    print("No")
elif S[0] == S[1] and S[2] == S[3] or S[0] == S[2] and S[1] == S[3] or S[0] == S[3] and S[1] == S[2]:
    print("Yes")
else:
    print("No")


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

void display(const std::vector<std::vector<int>>& vec);

int main(void) {
    u_int a, b, n;
    const int NOT_ASSIGNED = -1;

    std::cin >> a >> b;
    for (; a != 0 && b != 0; std::cin >> a >> b) {
        /*
         * 初期化
         */
        std::vector<std::vector<int>> matrix(a);
        for (u_int x = 0; x < a; ++x) {
            if (x == 0) {
                // x = 0 上はそれぞれ1通り
                matrix[x].resize(b, 1);
            } else {
                matrix[x].resize(b, NOT_ASSIGNED);
            }
            matrix[x][0] = 1;  // y = 0 上はそれぞれ1通り
        }
        // 原点
        matrix[0][0] = 0;

        /*
         * 行き止まりを反映する
         */
        std::cin >> n;
        for (u_int i = 0, x, y; i < n; ++i) {
            std::cin >> x >> y;
            matrix[--x][--y] = 0;  // 行き止まり

            // x = 0 上に行き止まりがあるとき、y 以降は通ることができない
            if (x == 0) {
                auto it = matrix[0].begin();
                for (std::advance(it, y + 1); it != matrix[0].end(); ++it) {
                    *it = 0;
                }
            }
            // y = 0 上に行き止まりがあるとき、x 以降は通ることができない
            if (y == 0) {
                for (u_int j = x + 1; j < a; ++j) {
                    matrix[j][0] = 0;
                }
            }
        }

        /*
         * 経路の計算
         */
        for (u_int x = 1; x < a; ++x) {
            for (u_int y = 1; y < b; ++y) {
                if (matrix[x][y] == NOT_ASSIGNED) {
                    matrix[x][y] = matrix[x][y-1] + matrix[x-1][y];
                }
            }
        }

        std::cout << matrix[a-1][b-1] << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
using namespace std;

#define PB push_back

bool dp[2001];


int main(int argc,char* argv[]){
  int n,q,x,i,j,MAX,tmp_MAX;
  queue<int> m;
  memset(dp,0,sizeof(dp));
  dp[0]=true;
  MAX=0;
  
  cin>>n;
  for(i=0;i<n;i++){
    cin>>x;
    tmp_MAX=0;

    for(j=MAX;j>=0;j--){
      if(dp[j]){
	if(tmp_MAX<j+x) tmp_MAX=j+x;

	dp[j+x]=true;
      }
    }
    MAX=tmp_MAX;
  }

  cin>>q;
  for(i=0;i<q;i++){
    cin>>x;
    if(dp[x])
      cout<<"yes"<<endl;
    else
      cout<<"no"<<endl;
  }

  return 0;
}

Measured memory_bytes: 1196
import java.util.*;
import java.math.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();

		List<Integer> list = new ArrayList<>();

		int sum = 0;
		for(int i=0;i<n;i++){
			int thi = sc.nextInt();
			list.add(thi);
			sum += thi;
		}
		
		Collections.sort(list);

		sum -= list.get(n-1)/2;
		// System.out.println(list.get(n-1));
		System.out.println(sum);

	}
}

Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    for(int i=(n-1)/2; ; --i){
        if(s.substr(0, i) == s.substr(i, i)){
            cout << (i*2) << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<queue>
int n, m;
std::vector<std::vector<bool>> graph;

bool bfs(){
    std::vector<bool> state(n, false);
    std::queue<int> que;

    int now = 0;
    que.push(now);

    while(!que.empty()){
        now = que.front(); que.pop();
        state[now] = true;

        for(int i = 0; i < n; i++){
            if(graph[now][i] && !state[i]){
                que.push(i);
            }
        }
    }

    // check
    for(int i = 0; i < n; i++){
        if(state[i] == false) return true; // 橋です
    }

    return false; // 橋でない
}

int main(){
    std::cin >> n >> m;
    graph.resize(n, std::vector<bool>(n, false));
    std::vector<int> edge1(m);
    std::vector<int> edge2(m);
    for(int i = 0; i < m; i++){
        int a, b;
        std::cin >> a >> b;
        a--; b--;
        edge1[i] = a;
        edge2[i] = b;
        graph[a][b] = true;
        graph[b][a] = true;
    }

    int cnt = 0;
    for(int i = 0; i < m; i++){
        int a = edge1[i], b = edge2[i];
        graph[a][b] = false;
        graph[b][a] = false;
        if(bfs()) cnt++;
        graph[a][b] = true;
        graph[b][a] = true;
    }

    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void)
{	
	int n;
	cin >> n;
	
	int *a_price;
	a_price = new int[n];
	
	for (int i = 0; i < n; i++) {
		cin >> a_price[i];
	}
	
	int min = 1000000000;
	int maxd = -999999999;
	for (int j = 1; j < n; j++) {
		if (a_price[j-1] < min) min = a_price[j-1];
		int d = a_price[j] - min;
		if (maxd < d) maxd = d;
	}
	
	cout << maxd << endl;
	
	delete[] a_price;
	return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

	static private int[] dice = new int[6];

	/**
	 * 上面を確認
	 */
	static public int checkUpper() {
		return dice[0];
	}

	/**
	 * 入力された方向に移動
	 * @param order
	 */
	static public void move(String order) {

		for(Character s : order.toCharArray()) {
			int buf;
	        switch(s){
	            case 'N':{
	                buf = dice[0];
	                dice[0] = dice[1];
	                dice[1] = dice[5];
	                dice[5] = dice[4];
	                dice[4] = buf;
	                break;
	            }
	            case 'E':{
	                buf = dice[0];
	                dice[0] = dice[3];
	                dice[3] = dice[5];
	                dice[5] = dice[2];
	                dice[2] = buf;
	                break;
	            }
	            case 'W':{
	                buf = dice[0];
	                dice[0] = dice[2];
	                dice[2] = dice[5];
	                dice[5] = dice[3];
	                dice[3] = buf;
	                break;
	            }
	            case 'S':{
	                buf = dice[0];
	                dice[0] = dice[4];
	                dice[4] = dice[5];
	                dice[5] = dice[1];
	                dice[1] = buf;
	                break;
	            }
	        }
		}
	}


	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int[] nums = new int[6];
		for(int i=0; i<6; i++) {
			nums[i] = sc.nextInt();
		}

		String order = sc.next();

		sc.close();

		dice = nums;
		move(order);

		System.out.println(checkUpper());
	}

}


Measured memory_bytes: 26288
##Just for prctice
n=int(input())

A=[int(i) for i in input().split()]
ans=-1
for i in range(0,n-1):
    for k in range(i+1,n):
        ans=max(ans,abs(A[i]-A[k]))

print(ans)


"""
4
1 4 6 3

5

2
1000000000 1

999999999

5
1 1 1 1 1

0
"""


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e[11],dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[210011];
int l[580121];
int j[600021];

long long x,y,z,mod=1000000007;
//string r;
char r[2010][2111];

P u[1];
priority_queue<int> q;
//stack<P> s;

vector<int> v;

bool as(P a,P b)
{
  return a.x<b.x;
}


int main()
{
  scanf("%d",&a);
  for(int t=1;t<=a;t++)
  {
    scanf("%d",&n);
    q.push(n);
  }
  n=0;
  for(;q.size();)
  {
    c=q.top();
    q.pop();
    if(q.size()&&q.top()==c)
    {
      if(n==0) n=q.top();
      else if(m==0) m=q.top();
      q.pop();
    }
  }
  printf("%lld",(long long)n*m);
}
//3




Measured memory_bytes: 892
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <limits>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

constexpr int MAX_R = 8, MAX_N = 200, INF = std::numeric_limits<int>::max()>>2;

int N, M, R;
int r[MAX_R];
int d[MAX_N][MAX_N];

int main()
{
    scanf( "%d%d%d", &N, &M, &R );
    rep( i, R )
        scanf( "%d", r+i ), --r[i];

    std::fill( (int*)d, (int*)(d+N), INF );
    rep( i, N )
        d[i][i] = 0;

    rep( i, M )
    {
        int A, B, C;
        scanf( "%d%d%d", &A, &B, &C );
        --A; --B;
        d[A][B] = d[B][A] = C;
    }

    rep( k, N ) rep( i, N ) rep( j, N )
        d[i][j] = std::min( d[i][j], d[i][k]+d[k][j] );

    std::vector<int> v(R);
    std::iota( v.begin(), v.end(), 0 );

    int ans = INF;

    do
    { 
      int sum = 0;

      rep( i, R-1 )
        sum += d[r[v[i]]][r[v[i+1]]];

      ans = std::min( ans, sum );
    } while( std::next_permutation( v.begin(), v.end() ) );

    printf( "%d\n", ans );

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
class SegTree {
    int n;// 葉の数
    vector<T> data;// データを格納するvector
    T def; // 初期値かつ単位元
    function<T(T, T)> operation; // 区間クエリで使う処理
    function<T(T, T)> update;// 点更新で使う処理

    // 区間[a,b)の総和。ノードk=[l,r)に着目している。
    T _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return def; // 交差しない
        if (a <= l && r <= b)
            return data[k]; // a,l,r,bの順で完全に含まれる
        else {
            T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
            T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
            return operation(c1, c2);
        }
    }

    public:
    // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
    // _update:更新関数
    SegTree(size_t _n, T _def, function<T(T, T)> _operation,
        function<T(T, T)> _update)
        : def(_def), operation(_operation), update(_update) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        data = vector<T>(2 * n - 1, def);
    }

    // 場所i(0-indexed)の値をxで更新
    void change(int i, T x) {
        i += n - 1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    // [a, b)の区間クエリを実行
    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    // 添字でアクセス
    T operator[](int i) {
        return data[i + n - 1];
    }
};
int main(){
    ll n,m;cin >> n >>m;
    vector<pair<pl,ll>> e(m);
    rep(i,m){
        cin >> e[i].fi.fi >> e[i].fi.se >> e[i].se;
        e[i].fi.fi--;e[i].fi.se--;
    }
    sort(all(e));
    SegTree<ll> st(n,INF/10,[](ll a,ll b){return min(a,b);},[](ll a,ll b){return min(a,b);});
    st.change(0,0);
    rep(i,m){
        ll cost=st.query(e[i].fi.fi,e[i].fi.se+1);
        st.change(e[i].fi.se,cost+e[i].se);
        /*rep(i,n)cout << st[i] <<" ";
        cout << endl;*/
    }
    //rep(i,n)cout << st[i] <<endl;
    if(st[n-1]==INF/10)cout << -1 <<endl;
    else cout << st[n-1] <<endl;
}

Measured memory_bytes: 4608
import java.util.Scanner;

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

        long total = 0;
        long a[] = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            total += a[i];
        }

        long former = 0;
        long min = Long.MAX_VALUE;
        for (int i = 0; i < n - 1; i++) {
            former += a[i];
            min = Math.min(min, Math.abs(total - 2 * former));
        }

        System.out.println(min);
    }
}


Measured memory_bytes: 65324
// D - Flat Subsequence
#include <bits/stdc++.h>
using namespace std;

#include <atcoder/segtree>
// モノイドの構成
using S = int; // 型
S op(S a, S b){ return max(a,b); } // ２項演算
S e(){ return 0; } // 単位元
// (1) segtree<S, op, e> seg(int n)
using SegT = atcoder::segtree<S, op, e>;
#define AMAX 300001 // データ最大値 + α

int main(){
	int n, k; cin>>n>>k;
	SegT sg(AMAX); // init
	for(int i=0; i<n; ++i){
		int a; cin>>a;
		int l = max(0, a - k);
		int r = min(a + k + 1, AMAX);
		int longest = sg.prod(l, r); // op を [l,r) の範囲で実行（区間最大）
		sg.set(a, longest + 1); // a の位置を longest+1 に更新（１点更新）
	}
	cout<< sg.all_prod() <<endl; // op を [0,AMAX) で実行（全体の最大）
}


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

int N, M;
vector<vector<int>> adj;
vector<int> dp;

int solve(int u) {
    if (dp[u] != -1) return dp[u];
    int res = 0;
    for (int v : adj[u]) {
        res = max(res, 1 + solve(v));
    }
    return dp[u] = res;
}

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

    cin >> N >> M;
    adj = vector<vector<int>>(N);
    dp = vector<int>(N, -1);
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        adj[u].push_back(v);
    }

    int res = 0;
    for (int i = 0; i < N; i++) res = max(res, solve(i));
    cout << res << "\n";
}



Measured memory_bytes: 8192
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    long A=gl();
	    long B=gl();
	    long K=gl();
	    boolean t=true;
	    for (int i=0; i<K;i++) {
	    	if (t) {
	    		if(A%2==1)A--;
	    		A=A/2;
	    		B+=A;
	    	} else {
	    		if(B%2==1)B--;
	    		B=B/2;
	    		A+=B;
	    	}
          t=!t;
	    }
	    System.out.println(A+" "+B);
	}

	public static double f(double r, double n, double m, double i) {
		double a = 0;
		double b=0;
		if(0<i&&i<n) {
			a=Math.abs(r-((2*r/n)*i));
			a= Math.sqrt(Math.pow(r, 2) - Math.pow(a, 2));
		}
		if(0<i-m&&i-m<n) {
			b=Math.abs(r-(2*r*(i-m)/n));
			b=Math.sqrt(Math.pow(r, 2) - Math.pow(b, 2));
		}
		return 2* Math.max(a, b);
	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 38696
#include <iostream>

int main()
{
  std::string n;
  std::cin >> n;
  for(int i = 0; i < 3; i++){
    if(n.at(i) == '1'){
      n.at(i) = '9';
    }else{
      n.at(i) = '1';
    }
  }
  std::cout << n;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
	int n,m,a[100]={0},b[100]={0},score[100]={0},i,j;
	cin>>n;//friends
	cin>>m;//Times
	for(i=0;i<m;i++){
		cin>>a[i];
	}
	for(j=0;j<m;j++){
		for(i=0;i<n;i++){
			cin>>b[i];
			if(a[j]==b[i]){
				score[i]++;
			}
			else{
				score[a[j]-1]++;
			}
		}
	}
	for(i=0;i<n;i++){
		cout<<score[i]<<endl;
	}
	return 0;
}


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

class Main {
  public static void main(String[] args){
    int[] m = new int[10];
    input(m, 10);
    Arrays.sort(m);
    reverse(m);
    output(m, 3);
  }

  private static final void reverse(int[] m){
    int n = m.length;
    for (int i = 0; i < n / 2; i++){
      int tmp = m[i];
      m[i] = m[n - i - 1];
      m[n - i - 1] = tmp;
    }
  }

  private static final void output(int[] m, int n){
    for (int i = 0; i < n; i++){
      System.out.println(m[i]);
    }
  }

  private static final void input(int[] m, int n){
    Scanner cin = new Scanner(System.in);
    for (int i = 0; i < n; i++){
      m[i] = cin.nextInt();
    }
  }
}

Measured memory_bytes: 26104
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define NIL -(long long)(1e9)
long long n,w;

long long weigths[102];
long long values[102];

 long long dp[107][100005];

long long dpa(long long tn,long long tw){
 //cout<<tn<<" ";
if (tw<0){
	return NIL;
}if(tn<0){
	return 0;
}
// dp[tn][tw]=tv;
if (dp[tn][tw]!=-1){
	return dp[tn][tw];
}
dp[tn][tw]=max(dpa(tn-1,tw-weigths[tn])+values[tn],dpa(tn-1,tw));
return dp[tn][tw];

}


int main () {
memset(dp,-1,sizeof(dp));
// freopen("a.in","r",stdin);
// freopen("a.out","w",stdout);
cin>>n>>w;

for (long long i = 0; i < n; ++i)
{
	cin>>weigths[i]>>values[i];
}
cout<<dpa(n-1,w);

	return 0;
}



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

int main() {
  string S, T;
  cin >> S >> T;
  string T2;
  T2 = T.substr(0, S.size());
  if (S == T2){
    cout << "Yes" << endl;
    return 0;
  }
    cout << "No" << endl;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
int n;
int a[111111],b[111111],c[111111];
int ans=0;
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n)cin>>c[i];
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	rep(i,n){
		int cnt=1;
		cnt*=lower_bound(a,a+n,b[i])-a;
		cnt*=n-(upper_bound(c,c+n,b[i])-c);
		ans+=cnt;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        long n = stdIn.nextLong();
        // long sum = 0;
        
        
        // for(int i = 1; i < n; i++){
        //     sum += i %( i + 1);
        // }
        
        // num[0] = 1;
        // w[0] = 2;
        // w[n - 1] = 1;
        
        // for(int i = 0; i < n; i++){
        //     //sum += num[i] % w[i];
        //     System.out.println(num[i] + " " + w[i]);
        // }
        
        System.out.println((n * n - n) / 2);
    }
}


Measured memory_bytes: 21844
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	var (
		n int
	)
	fmt.Scan(&n)

	var (
		// tmp int
		max int
		min int
	)
	max = math.MinInt64
	min = math.MaxInt64

	for i := 0; i < n; i++ {
		s := nextLine()
		tmp, _ := strconv.Atoi(s)
		if tmp-min > max {
			max = tmp - min
		}
		if min > tmp {
			min = tmp
		}
	}

	fmt.Println(max)
}



Measured memory_bytes: 4180
slist = raw_input().split(" ")

new_str_list=[]
for s in slist:
    new_str = ""
    for c in s:
        if c.isupper():
            new_str += c.lower()
        else:
            new_str += c.upper()
    new_str_list.append(new_str)

print " ".join(new_str_list)

Measured memory_bytes: 4200
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a,b,c) push(make_pair(make_pair((a) , (b)) , (c)))
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 810;
int H,W,K;
bool r[MC][MC];
int d[MC][MC];
int e[5] = {1,0,-1,0,1};
int ans = 1e9 + 7;
priority_queue<P3,vector<P3>,greater<P3> > Q;

int main(){
	scanf("%d%d%d" , &H , &W , &K);
	repp(i,1,H+1){
		repp(j,1,W+1){
			char c;
			d[i][j] = 1e9 + 7;
			scanf(" %c" , &c);
			if(c == 'S'){
				r[i][j] = 1;
				d[i][j] = 0;
				Q.PB(0,i,j);
			} else if(c == '#'){
				r[i][j] = 0;
			} else {
				r[i][j] = 1;
			}
		}
	}
	while(!Q.empty()){
		int x = Q.top().first.second;
		int y = Q.top().second;
		Q.pop();
		if(x == 1 || x == H || y == 1 || y == W){
			ans = min(ans , d[x][y]);
		} else {
			repp(i,0,4){
				int u = x + e[i];
				int v = y + e[i+1];
				int z;
				if(r[u][v]){
					z = d[x][y] + 1;
				} else if(d[x][y] <= K){
					z = K + 1;
				} else {
					z = d[x][y] + 1;
				}
				if(d[u][v] > z){
					d[u][v] = z;
					Q.PB(z,u,v);
				}
			}
		}
	}
	printf("%d\n" , (ans+K-1)/K);
	return 0;
}


Measured memory_bytes: 6644
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

t = inp
puts (sum(t)>21)? "bust" : "win"

Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(int argc, char const *argv[])
{
    string a, b;
    cin >> a >> b;
    string c = a + b;
    float n, m;
    n = stod(c);
    m = sqrt(n);
    if (ceil(m) == floor(m))
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
 
using namespace std;
 
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x) % hell;
        x=(x*x) % hell;
        n=n/2;
    }
    return result % hell;
}
 
class dsu{
    vi p,rank;
    vi set_count;
  
  public:
    dsu(int n){
        p.assign(n,0); 
        rank.assign(n,0);
        set_count.assign(n,1);
        for(int i=0;i<n;i++) p[i] = i;
    }
    int findSet(int x){
        return (p[x] == x) ? x:(p[x] = findSet(p[x]));
    }
    bool isSame(int i, int j){
        return (findSet(i) == findSet(j));
    }
    void unionSet(int i, int j){
        if(!isSame(i,j)){
            int x = findSet(i), y = findSet(j);
            if(rank[x] > rank[y]) {p[y] = x; set_count[x]+=set_count[y];}
            else{
                p[x] = y;
                set_count[y]+=set_count[x];
                if(rank[x] == rank[y]) rank[y]++;
            }
        }
    }
    int count(int x){
        return set_count[findSet(x)];
    }
};

int S[105][105];
int T[105][105];

// code copied from god_arham
int mod_inv(int a,int m){
    a=a%m;
    return power(a,m-2)%hell;
}
int fact[200005];
void count_fact(){
    int i,x=1;
    fact[0]=1;
    for(int i=1;i<200002;i++){
        
        x=(x*i)%hell;
      //  cout<<x<<" ";
        fact[i]=x;
        
    }
}
 
int ncr(int n,int r){
    int a=fact[n],b=fact[r],c=fact[n-r];
    
    return (a*mod_inv(b*c,hell))%hell;
} 
//copied code ends here
 
signed main()
{
    tezz
 
    int a,b;
    cin>>a>>b;
    cout<<6 - a - b;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a = [int(input()) for _ in range(5)]
    k = int(input())
    if a[-1]-a[0] > k:
        print(':(')
    else:
        print('Yay!')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
n,m,k=map(int,input().split())
ans=0
for i in range(0,n+1):
  for j in range(0,m+1):
    if m*i+(n-i*2)*j==k:
      ans=1
      break
  if ans==1:
    print("Yes")
    break
else:
  print("No")

Measured memory_bytes: 9212
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
   
int main(){
    string s;
    cin >> s;
    string ss="CODEFESTIVAL2016";
    int n=s.size();
    int ans=0;
    rep(i,n){
        if(s.at(i)!=ss.at(i))ans++;
    }
    cout << ans << endl;
} 

    

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split("");

		int blue = 0;
		int red = 0;

		for (int i = 0; i < str.length; i++) {
			if (str[i].equals("0"))
				red++;
			else
				blue++;
		}

		if (blue == 0 || red == 0) {
			System.out.println("0");
		} else {
			int min = Math.min(blue, red);
			System.out.println(min * 2);
		}
	}
}


Measured memory_bytes: 29396
#include <cstdio>
#include <string>
#include <stack>
#include <sstream>
#include <iostream>

using namespace std;

int a[4],aa[4];
bool used[4];
int cal[4],calk[4];
char kind[3]={'+','-','*'};
string str;

int func(){
	stack<int> s;
	int j=0;
	for(int i=0;i<4;i++){
		s.push(aa[i]);
		while(cal[j]==i && j<3){
			if(s.size()<2)return -1;
			int a=s.top();
			s.pop();
			int b=s.top();
			s.pop();
			if(calk[j]==0)s.push(a+b);
			if(calk[j]==1)s.push(a-b);
			if(calk[j]==2)s.push(a*b);
			j++;
		}
	}
	if(s.size()!=1)return -1;
	return s.top();
}

string func2(){
	stack<string> s;
	int j=0;
	for(int i=0;i<4;i++){
		ostringstream os;
		os << aa[i];
		s.push(os.str());
		while(cal[j]==i && j<3){
			string a=s.top();
			s.pop();
			string b=s.top();
			s.pop();
			if(calk[j]==0)s.push("("+a+" " + "+" + " "+ b+")");
			if(calk[j]==1)s.push("("+a+" " + "-" + " "+ b+")");
			if(calk[j]==2)s.push("("+a+" " + "*" + " "+ b+")");
			j++;
		}
	}
	return s.top();
}

void dfs(int v,int v2){
	if(v==4 && v2==3){
		int res=func();
		if(res==10)str=func2();
		return;
	}
	if(v<4){
		for(int i=0;i<4;i++){
			if(!used[i]){
				aa[v]=a[i];
				used[i]=true;
				dfs(v+1,v2);
				used[i]=false;
			}
		}
	}
	if(v==4){
		for(int i=0;i<=2;i++){
			for(int j=0;j<4;j++){
				if(v2>0 && cal[v2-1]>j)continue;
				calk[v2]=i;
				cal[v2]=j;
				dfs(v,v2+1);
			}
		}	
	}
}

int main(void){
	while(1){
		for(int i=0;i<4;i++){
			scanf("%d",&a[i]);
		}
		if(a[0]==0)break;
		str="0";
		dfs(0,0);
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 1252
import math
a, b, h, m = map(int, input().split()) 


min_sum = 60 * h + m
h_d = math.radians(90 - 360*min_sum/720)
m_d = math.radians(90 - 360*m/60)

h_x = a*math.cos(h_d)
h_y = a*math.sin(h_d)

m_x = b*math.cos(m_d)
m_y = b*math.sin(m_d)

d2 = (h_x-m_x)**2 + (h_y-m_y)**2
ans = d2**0.5
print(ans)

Measured memory_bytes: 9580
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 	first
#define s 	second
#define ll 	int
#define int 	long long
#define ld 	long double
#define pb 	push_back
#define eb 	emplace_back
#define mk 	make_pair
#define vi 	vector<int>
#define pii 	pair<int,int>
#define vpi 	vector<pii>
#define fori(a,b,c) for(register int i=a;i<b;i+=c)
#define ford(a,b,c) for(register int i=a;i>=b;i-=c)
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl()
{
	cout<<"Control\n";
}
signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n,l;
    cin>>n>>l;

    if(n%l)
    cout<<(n/l)+1;
    else
    cout<<n/l;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main() {
    ll n,x=0;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> ans(n);
    for (ll i=0;i<n;++i){
        if (s[i]=='I'){
            ++x;
        }else{
            --x;
        }
        ans[i]=x;
    }
    sort(ans.begin(),ans.end());
    ll z=0;
    cout << max(ans[n-1],z) << endl;
    return 0;
}


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

using namespace std;
using ll=long long;

#define rep(i, a, n) for (int i = (a); i < (n); ++i)

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  int a,b;
  cin>>a;
  cin>>b;
  a==1 && b==2 ? cout<<"3"<<endl : a==1 && b==3 ? cout<<"2"<<endl : a==2 && b==1 ? cout<<"3"<<endl : a==2 && b==3 ? cout<<"1"<<endl : a==3 && b==1 ? cout<<"2"<<endl : cout<<"1"<<endl;
}

Measured memory_bytes: 256