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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N;
    cin >> N;

    bool good = true;

    vi t(N), x(N), y(N);
    for (int i = 0; i < N; i++) {
        cin >> t[i] >> x[i] >> y[i];

        good &= (t[i]&1) == ((x[i]&1) ^ (y[i]&1));
        if (i) good &= (abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])) <= t[i] - t[i-1];
    }

    good &= abs(x[0]) + abs(y[0]) <= t[0];

    cout << (good ? "Yes\n" : "No\n");

    return 0;
}



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

int main(){
    int n,m;
    cin >> n >> m;
    int k=1;
    rp(i,m){
        k *= 2;
    }
    cout << ((n-m)*100+m*1900)*k << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626 
 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;

int arr[2][2]={{0,1},{1,0}};
signed main() {

	fastio();
//	#define LOCAL_DEFINE	
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int H,W,A,B;
	cin>>H>>W>>A>>B;
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			if((i<B)^(j<A))
			{
				cout<<"1";
			}else{
				cout<<"0";
			}
		}
		
		cout<<endl;
	}
 	return 0;
}


Measured memory_bytes: 1280
mansions = [[[0 for x in range(10)] 
                for floor in range(3)] 
                    for i in range(4)]

num = int(input())
for cnt in range(num):
    b,f,r,v = map(int,input().split())
    mansions[b-1][f-1][r-1] += v

mn_cnt =0
for mansion in mansions:
    for floor in mansion:
        print(" "+" ".join(map(str,floor)))
    if mn_cnt != 3:
        print("####################")
    mn_cnt+=1


Measured memory_bytes: 5608
n,m,l = map(int,input().split())#n,m,lの入力
#n x m の行列を読み込む
A = [[int(i) for i in input().split()]for j in range(n)]

#m x l の行列を読み込む
B = [[int(i) for i in input().split()]for j in range(m)]

#n*lの行列の積をいれる行列Cを定義
C = [[0]*l for i in range(n)]

# C = np.dot(A,B) #行列の積を求める

for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k]*B[k][j]

for i in range(n):
    print(C[i][0],end="")
    for j in range(1,l):
        print("",C[i][j],end="")
    print()



Measured memory_bytes: 7132
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<algorithm>

using namespace std;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define reep(i, s, t) for(int i=s;i<(int)t;i++)
#define irep(i, n) for(int i=(int)n-1;i>=0;i--)
#define ireep(i, n, s) for(int i=(int)n-1;i>=s;i--)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;



int main(){
	int b, r, g, c, s, t;
	while(cin >> b >> r >> g >> c >> s >> t) {
		if(!b && !r && !g && !c && !s && !t) break;
		int ans = 100;
		t -=r+b+g+c+(2*s)+(b*5)+(r*3);
		ans += (15*(b+r))+(((b*5)+(r*3))*13)-(3*(b+r+g+c+s))+((g*7)+(c*2)+(-3*t));
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
n,x=map(int,input().split())
a=list(map(int,input().split()))

cnt=0
for i in range(1,n):
    v = a[i]+a[i-1]-x
    if v>0:
        cnt+=v
        if a[i]>=v:
            a[i]-=v
        else:
            v-=a[i]
            a[i]=0
            a[i-1]-=v
        
print(cnt)


Measured memory_bytes: 14540
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var A = int.Parse(input[0]);
        var B = int.Parse(input[1]);
        var C = int.Parse(input[2]);
        
        if (A == B && B == C && A == C) {
            Console.WriteLine("Yes");
        }
        else {
            Console.WriteLine("No");
        }
    }
}


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

int main(){
int k,b;
  string s;
  cin>>k>>s;
  b=s.size();
  if(b>k){
vector<string> a(k+3);
    for(int i=0;i<k;i++){
a.at(i)=s.at(i);
    }
    a.at(k)=".";
    a.at(k+1)=".";
    a.at(k+2)=".";
    for(int i=0;i<k+3;i++){
    cout<<a.at(i);
  }
    cout<<endl;
  }
else{
  cout<<s<<endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

int dp[200001];

void solve_abc_d() {
	string s;
    ll n;
	ll ans = 0;
	ll val = 1;

	cin >> s;
    n = s.size();

	dp[n] = 0;
	rrep(i, n - 1, 0) {
		dp[i] = dp[i + 1] + val * (s[i] - '0');
		dp[i] %= 2019;
		val *= 10;
		val %= 2019;
	}

	V m(2019, 0);
	rep(i, n+1) {
		m[dp[i] % 2019]++;
	}

	rep(i, 2019) {
		if (m[i] > 0) {
			ans += m[i] * (m[i] - 1) / 2;
		}
	}

	cout << ans << "\n";
}

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

	solve_abc_d();

	return 0;
}


Measured memory_bytes: 4520
N = int(input())
A = list(map(int, input().split()))
max_A = 10**6+1

dp = [0] * (max_A)
for i in range(N):
    dp[A[i]] += 1

pairwise = True

for i in range(2, max_A):
    cnt = 0
    # 素数の倍数がdp配列に存在するか。自分以外にあれば2以上になる
    for j in range(i, max_A, i):
        cnt += dp[j]
    if cnt > 1:
        pairwise = False

if pairwise:
    print("pairwise coprime")
    exit()

from math import gcd

g = 0
for i in range(N):
    g = gcd(g, A[i])
if g == 1:
    print("setwise coprime")
else:
    print("not coprime")



Measured memory_bytes: 189416
#include <stdio.h>

#define MOD_BY 1000000007

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

/* A:0 C:1 G:2 T:3 */

int memo[128][1 << 6];

int search(int left, int history) {
	int p = history & 3, pp = (history >> 2) & 3, ppp = (history >> 4) & 3;
	int answer = 0;
	if (left <= 0) return 1;
	if (memo[left][history]) return ~memo[left][history];

	/* A */
	answer = add(answer, search(left - 1, ((history << 2) | 0) & 0x3f));
	/* C */
	if (!(pp == 0 && p == 2) && !(ppp == 0 && p == 2) && !(pp == 2 && p == 0) && !(ppp == 0 && pp == 2)) {
		answer = add(answer, search(left - 1, ((history << 2) | 1) & 0x3f));
	}
	/* G */
	if (!(pp == 0 && p == 1)) {
		answer = add(answer, search(left - 1, ((history << 2) | 2) & 0x3f));
	}
	/* T */
	answer = add(answer, search(left - 1, ((history << 2) | 3) & 0x3f));

	return ~(memo[left][history] = ~answer);
}

int main(void) {
	int N;
	if (scanf("%d", &N) != 1) return 1;
	printf("%d\n", search(N, 0x3f));
	return 0;
}

/*

NG putterns

AGC
A*GC
GAC
ACG
AG*C

*/


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll x;
    cin>>x;
    unordered_map<ll,int> mp;
    ifr(i,1000){
        ll c{1};
        fr(j,5) c*=i;
        if(mp[c+x])
            return cout<<mp[c+x]<<" "<<i<<endl,0;
        if(mp[x-c])
            return cout<<mp[x-c]<<" "<<-i<<endl,0;
        mp[c]=i;
    }

}

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

int a[3];

int main() {
    for(int i = 0; i < 3; ++i)
        cin >> a[i];
    swap(a[0], a[1]);
    swap(a[0], a[2]);
    for(int i = 0; i < 3; ++i)
        cout << a[i] << ' ';
    return 0;
}

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

template <typename T>
struct SegmentTree {
    using F = function<T(T, T)>;

    int size;
    vector<T> node;
    const F f;
    const T I;

    SegmentTree(int n, const F f, const T& I) : f(f), I(I) {
        size = 1;
        while (size < n) size *= 2;
        node.resize(2 * size, I);
    }

    T& operator[](int k) {
        return node[k + size];
    }

    void build() {
        for (int k = size - 1; k > 0; k--) {
            node[k] = f(node[2 * k], node[2 * k + 1]);
        }
    }

    void update(int k, const T& x) {
        k += size;
        node[k] = x;
        while (k /= 2) {
            node[k] = f(node[2 * k], node[2 * k + 1]);
        }
    }

    T query(int a, int b) {
        T L = I, R = I;
        for (a += size, b += size; a < b; a /= 2, b /= 2) {
            if (a & 1) L = f(L, node[a++]);
            if (b & 1) R = f(node[--b], R);
        }
        return f(L, R);
    }
};

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

    int n, q;
    cin >> n >> q;
    auto f = [](ll a, ll b) {
        return min(a, b);
    };
    SegmentTree<ll> segtree(n, f, (1LL << 31) - 1);
    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            segtree.update(x, y);
        } else {
            cout << segtree.query(x, y + 1) << '\n';
        }
    }
}


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

using namespace std;

typedef long long ll;

const int N = 1e6 + 10;

#define LD (t << 1)
#define RD (t << 1 | 1)

ll sum[N << 2], tag[N << 2];

void pushup(int t) {
  sum[t] = sum[LD] + sum[RD];
}

void pushnow(int t, int l, int r, int vl) {
  sum[t] = 1ll * (r - l + 1) * vl;
  tag[t] = vl;
}

void pushdown(int t, int l, int r) {
  if (tag[t]) {
    int mid = (l + r) >> 1;
    pushnow(LD, l, mid, tag[t]);
    pushnow(RD, mid + 1, r, tag[t]);
    tag[t] = 0;
  }
}

void modify(int t, int l, int r, int ql, int qr, int vl) {
  if (ql > qr) return;
  if (ql <= l && r <= qr) {
    pushnow(t, l, r, vl);
    return;
  }
  int mid = (l + r) >> 1;
  if (ql <= mid) {
    modify(LD, l, mid, ql, qr, vl);
  }
  if (qr > mid) {
    modify(RD, mid + 1, r, ql, qr, vl);
  }
  pushup(t);
}

int n, a[N], st[N], tp;

int main() {
  scanf("%d", &n);
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    while (tp && a[st[tp]] >= a[i]) {
      tp--;
    }
    modify(1, 1, n, st[tp] + 1, i, a[i]);
    ans += sum[1];
    st[++tp] = i;
  }
  printf("%lld\n", ans);
  return 0;
}

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define MAX 1000000001





int main(){
    double l;
    cin>>l;

    cout<<fixed<<setprecision(7)<<(l/3)*(l/3)*(l/3)<<endl;
}

Measured memory_bytes: 256
/*
                                                                           __                _________
                                                                          /  \              /  ______/
                                                                         /    \            /  /
                                                                        /  __  \          /  /
                                                                       /  /  \  \         |  |
                                                                      /  /____\  \        \  \
                                                                     /  ________  \        \  \______
                                                                    /__/        \__\        \________\
	
	I_love_Hacked;
	I_hate_pretest past;
	
    coder:xxjAc(K) 
    date:2018/3/26 
	    
    I_love_Ac;
    I_hate_WA;
    I_hate_Tle;
    I_hate_RE;
    I_hate_CE;
    I_hate_Mle;
    
    I love Accepts very much;
    
    set
    map
    stack
    queue
    deque
    priority_queue
    vecotr
*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
const int inf=1000000007;
int n;
int x[100007];
int y[100007];
pair<int,int> tx[100007],ty[100007];
int fa[100007];
pair<int,pair<int,int> > b[200007];
int fnd(int x1){
	if (x1==fa[x1]){
		return x1;
	}
	else{
		fa[x1]=fnd(fa[x1]);
		return fa[x1];
	}
}
int zdl(int x1,int y1){
	int t=inf;
	t=min(t,max(x[x1]-x[y1],x[y1]-x[x1]));
	t=min(t,max(y[x1]-y[y1],y[y1]-y[x1]));
	return t;
}
int main(){
	scanf("%d",&n);
	for (int i=0;i<n;i++){
		scanf("%d%d",x+i,y+i);
		tx[i].first=x[i];
		tx[i].second=i;
		ty[i].first=y[i];
		ty[i].second=i;
		fa[i]=i;
	}
	sort(tx,tx+n);
	sort(ty,ty+n);
	for (int i=0;i<n-1;i++){
		b[i*2].first=tx[i+1].first-tx[i].first;
		b[i*2].second.first=tx[i].second;
		b[i*2].second.second=tx[i+1].second;
		b[i*2+1].first=ty[i+1].first-ty[i].first;
		b[i*2+1].second.first=ty[i].second;
		b[i*2+1].second.second=ty[i+1].second;
	}
	sort(b,b+2*n);
	long long ans=0;
	int c=0;
	int x1,y1;
	for (int i=0;i<2*n;i++){
		x1=b[i].second.first;
		y1=b[i].second.second; 
		if (fnd(fa[x1])==fnd(fa[y1])){
			continue;
		}
		else{
			fa[fnd(x1)]=fnd(y1);
			c++;
			ans+=zdl(x1,y1);
			if (c==n-1){
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int time = 0;
  time = 1900*m + 100*(n-m);
  int r=1;
  int ans;
  int i;
  for(i=0;i<m;i++){
    r*=2;
  }
  cout << time * r;
}

Measured memory_bytes: 256
# coding: utf-8

N = gets.to_i
hs = gets.split.map {|e| e.to_i}

INF = 10**5

# dpテーブル用意
dp = Array.new(N+2, 0)

hs.each_with_index do |e, i|
  if i == 0
    next
  elsif i == 1
    dp[1] = (hs[1] - hs[0]).abs
  else
    _a = (hs[i] - hs[i-1]).abs + dp[i-1]
    _b = (hs[i] - hs[i-2]).abs + dp[i-2]
    if _a < _b
      dp[i] = _a
    else
      dp[i] = _b
    end
  end
end


puts dp[N-1]


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

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		StringTokenizer tokenizer;
		String s;
		while ((s = reader.readLine()) != null) {
			int d = Integer.parseInt(s);
			int sum = 0;
			for (int i = d; i < 600; i += d) {
				sum += Math.pow(i, 2) * d;
			}
			System.out.println(sum);
		}
	}

}

Measured memory_bytes: 15032
#include <bits/stdc++.h>
#define MAXN 100005
using namespace std;

int n;
char s[MAXN];

bool isPalindrome() {
    for (int i = 1, j = n - 1; i < j; ++i, --j)
        if (s[i] != s[j])
            return false;

    return true;
}

int main() {
    ios::sync_with_stdio(0);

    cin >> (s + 1);
    n = strlen(s + 1);

    if (s[n] != '0' || !isPalindrome() || s[1] != '1') {
        cout << "-1\n";
        return 0;
    }

    int nxt1 = n;
    for (int i = n - 1; i >= 1; --i) {
        cout << i << " " << nxt1 << "\n";
        if (s[i] == '1')
            nxt1 = i;
    }

    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int main(){
  int money;
  cin >> money;
  bool flag=false;
  if(money>1999){
    flag++;
  }
  else{
    int i,j,k,l,m,n;
    for(i=0;i<=20;i++){
      for(j=0;j<=20;j++){
        for(k=0;k<=20;k++){
          for(l=0;l<=20;l++){
            for(m=0;m<=20;m++){
              for(n=0;n<=20;n++){
                if(money==100*i+101*j+102*k+103*l+104*m+105*n){
                  flag=true;
                }
              }
            }
          }
        }
      }
    }
  }
  if(flag){
    cout << "1";
  }
  else{
    cout << "0";
  }
  return(0);
}

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

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;

const int inf = 1e11 + 5;
const long double PI = 3.141592653589793;

void solve(){
  int n;;
  cin >> n;
  auto sum = [](int i){
    return (i * (i + 1)) / 2;
  };
  cout << sum(n) - 3 * sum(n / 3) - 5 * sum(n / 5) + 15 * sum(n / 15) << endl;
  return;
}  
signed main(){
  fast;
  int t;
  t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

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

int main(){
  int N;
  cin >> N;
  
  string s;
  cin >> s;
  
  int red = 0;
  for(int i=0; i<N; i++){
    if(s.at(i)=='R'){
      red++;
    }
  }
  
  
  
  if(2*red > N){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.io.*;
 
public class Main{
    public static void main(String[] args){
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        String s,t,u;
        int a,b,hako;
        hako=0;
        String[] abc=new String[2];
        int[] xyz=new int[2];
        try{
                s=reader.readLine();
                t=reader.readLine();
                a=Integer.parseInt(s);
                b=Integer.parseInt(t);
                int[] x=new int[a+1];
                x[0]=0;
                for(int j=1;j<(a+1);j++){
                    x[j]=j;
                }
                for(int i=0;i<b;i++){
                    u=reader.readLine();
                    abc=u.split(",");
                    for(int k=0;k<2;k++){
                        xyz[k]=Integer.parseInt(abc[k]);
                    }
                    hako=x[xyz[0]];;
                    x[xyz[0]]=x[xyz[1]];
                    x[xyz[1]]=hako;
                }
                for(int l=1;l<(a+1);l++){
                    System.out.println(x[l]);
                }
        }catch(IOException e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 16920
/*
 * atcoder/abc130_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

ll W, H, x, y;
void solve() {
  cin >> W >> H >> x >> y;
  cout << W * H * 0.5 << " " << (x * 2 == W and y * 2 == H) << endl;
}
int main() {
  cout.precision(15);
  cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(15);
	ll arr[5];
	for(int a=0;a<5;a++)
	{
		cin>>arr[a];
		if(arr[a]==0)
		cout<<a+1;
	}
	return 0;
}

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

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

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long K){
  ll sum=0;
  FOR(i,1,K+1){
    FOR(j,1,K+1){
      FOR(k,1,K+1){
        sum+=gcd(i,gcd(j,k));
      }
    }
  }
  cout<<sum<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}

Measured memory_bytes: 3764
#include<stdio.h>
#include<string.h>
#define LEN 100005
 
typedef struct pp{
  char name[100];
  int t;
}P;
 
P Q[LEN+1];
int head, tail, n;
 
void enqueue(P x){
  Q[tail] = x;
  tail = (tail+1)%LEN;
}
 
P dequeue(){
  P res = Q[head];
  head = (head+1)%LEN;
  return res;
}
 
int empty(){
  return (head==tail?1:0);
}
 
int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  head = 1;
  tail = n+1;
 
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
 
  while(empty()==0){
    u = dequeue();
    if(u.t > q){
      u.t -= q;
      enqueue(u);
      elaps += q;
    }else{
      elaps += u.t;
      printf("%s %d\n",u.name, elaps);
    }
  }
  return 0;
}


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

int main() {
    int a[6];
    rep(i, 6) cin >> a[i];
    string ans = "Yay!";
    rep(i, 5) rep(j, 5) if (abs(a[i] - a[j]) > a[5]) ans = ":(";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,b[]={1,5,3,3,3,3,3,4,3,4},m,i;
    string s;
    char tab[20][6]={" ",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
    cin>>n;
    while(cin>>s){
        for(i=m=0;i<s.size();i++)
            if(s[i]=='0'){
                if(m)
                    cout<<tab[s[i-1]-'0'][(m-1)%b[s[i-1]-'0']];
                m=0;
            }else
                m++;
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 0
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
// #define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
vector<ll> freq(1000005 , 0),ps(1000005,0);
void solve(){
	ll n ;
	cin>> n ;
	vector<ll>arr(n);
	for(ll i=0;i<n ;i++){
		cin>>arr[i];
		ps[arr[i]]++;
	}
	ll mx=*max_element(arr.begin(),arr.end());
	ll ans=0;
	for(ll i=0;i<n ;i++){
		for(ll j=2*arr[i] ; j<=mx+1;j+=arr[i]){
			freq[j]=1;
		}
	}
	for(ll i=0;i<n ;i++){
		if(freq[arr[i]]==0 && ps[arr[i]]==1)ans++;
	}
	cout<<ans<<endl;
}
 
int main(){
	// mahakal(),fast;
	ll t =1 ;
	// cin>> t ;
	while(t--)solve();
	return 0;
}

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

using ll = long long;

const int nax = 2e5 + 5;
int arr[nax];
int n;
vector<int> edges[nax];
int lis[nax];
vector<int> last;
stack<pair<int, int>> st;

int getIndex(vector<int>& last, int val) {
    int index = 0;
    int l = 0, r = n;
    while(l <= r) {
        int mid = l + (r-l)/2;
        if(last[mid] < val) {
            index = mid;
            l = mid+1;
        }
        else {
            r = mid-1;
        }
    }
    return index;
}

void dfs(int v, int parent, int ans) {
    int index = getIndex(last, arr[v]);
    int newans = ans;
    pair<int, int> temp = make_pair(index+1, last[index+1]);
    if(last[index+1] > arr[v]) {
        last[index+1] = arr[v];
        newans = max(ans, index+1);
    }
    lis[v] = newans;
    st.push(temp);

    for(int nei : edges[v]) {
        if(nei != parent) {
            dfs(nei, v, newans);
        }
    }
    pair<int, int> p = st.top();
    st.pop();
    last[p.first] = p.second;
}

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    last.resize(nax, INT_MAX);
    last[0] = INT_MIN;
    for(int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    dfs(1, -1, 0);

    for(int i = 1; i <= n; i++) {
        cout << lis[i] << " ";
    }
}


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

int main() {
  std::vector<bool> al(26, false);

  std::string s;
  std::cin >> s;

  for (int64_t i = 0; i < s.size(); i++) {
    al[s[i] - 'a'] = true;
  }

  for (int i = 0; i < 26; i++) {
    if (!al[i]) {
      std::cout << static_cast<char>('a' + i) << std::endl;
      return 0;
    }
  }

  std::cout << "None" << std::endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

void fail(){
  puts("-1");
  exit(0);
}

int n;
ll d[125252];
int par[125252];
vi children[125252];
pll po[125252];

int cnt[125252];

int sz[125252];
ll val[125252];
void dfs1(int p){
  sz[p] = 1;
  val[p] = 0;
  for(int to : children[p]){
    dfs1(to);
    sz[p] += sz[to];
    val[p] += val[to] + sz[to];
  }
}
void dfs2(int p){
  if(val[p] != d[p])fail();
  for(int to : children[p]){
    ll tmp = val[to];
    val[to] = val[p] - sz[to] + (n-sz[to]);
    dfs2(to);
    val[to] = tmp;
  }
}

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%lld",d+i);

  REP(i,n)po[i] = pll(d[i], i);
  sort(po,po+n); reverse(po,po+n);
  
  map<ll,int> rev;
  REP(i,n)rev[d[i]] = i;

  REP(i,n)par[i] = -1;
  REP(i,n-1){
    int id = po[i].second;
    ll x = d[id];
    cnt[id]++;
    int a = cnt[id];
    int b = n-a;
    int c = b-a;
    if(c<=0)fail();
    ll nxt = x-c;
    if(rev.count(nxt)==0)fail();
    par[id] = rev[nxt];
    children[par[id]].push_back(id);
    cnt[par[id]] += cnt[id];
  }

  int root = 0;
  REP(i,n)if(par[i]==-1)root=i;

  dfs1(root);
  dfs2(root);
  REP(i,n)for(int j:children[i]){
    printf("%d %d\n",i+1,j+1);
  }
  return 0;
}


Measured memory_bytes: 20864
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int min = N+1;
		int ans = 0;
		for(int i = 0;i < N;i++) {
			int a = scn.nextInt();
			if(min >= a) {
				min = a;
				ans++;
			}
		}
		System.out.println(ans);
	}

}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int cnt = 0;
		for(int i=0;i<N;i++){
			var k = ri();
			if(k<A || k>=B)cnt++;
		}
		Console.WriteLine(cnt);
		
		
	}
	int N,A,B;
	public Sol(){
		var d = ria();
		N = d[0];
		A = d[1];
		B = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 2776
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)



int cal(vector<int>& v){
    if(v.empty())return -2;
    int ind = -1;
    int lim = v.size();
    rep(i,lim){
        if(i+1 == v[i]){
            ind = i;
        }
    }
    if(ind == -1)return -1;

    v.erase(v.begin()+ind);
    return ind;
}

int main() {
    int N;cin >> N;
    vector<int> b(N);
    rep(i,N)cin >> b[i];


    bool ok = true;
    vector<int> ans;
    rep(i,N){
        int tmp = cal(b);
        if(tmp == -1)ok = false;
        else if(tmp == -2)break;
        else ans.push_back(tmp+1);
    }

    if(ok){
        if(!b.empty())cout << -1 << endl;
        else{
            for(int j = ans.size()-1;j >= 0;j--)cout << ans[j] << endl;
        }
    }
    else cout << -1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 200010
int a[N],vis[N],s[N];
int main()
{
    int i,j,k,n,s1,s2,x;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    memset(vis,0,sizeof(vis));
    memset(s,0,sizeof(s));
    vis[0]=1;
    s1=0;
    for(i=1;i<=n;i++)
    {
        j=a[i];
        if(vis[j-1])
            s[j]=s[j-1]+1;
        else
            s[j]=1;
        vis[j]=1;
        s1=max(s1,s[j]);
    }
    printf("%d\n",n-s1);
    return 0;
}


Measured memory_bytes: 2560
N,K=list(map(int,input().split()))
a=list(map(int,input().split()))
a.sort(key=lambda x:abs(x),reverse=True)

mod=10**9+7

p=[]
m=[]
zero=False
cntm=0
cntp=0

for aa in a:
    if aa>=0:
        p.append(aa)
        if cntp+cntm<K:
            cntp+=1
    elif aa<0:
        m.append(-aa)
        if cntp+cntm<K:
            cntm+=1
    
    if aa==0:
        zero=True

ans=1

if cntm%2==1:
    if cntm+1<=len(m) and cntm+1<=K and cntp+1<=len(p) and cntp+1<=K:
        if p[cntp]*p[cntp-1]>m[cntm]*m[cntm-1]:
            cntp+=1
            cntm-=1
        else:
            cntm+=1
            cntp-=1
    elif cntm+1<=len(m) and cntm+1<=K:
        cntm+=1
        cntp-=1
    elif cntp+1<=len(p) and cntp+1<=K:
        cntp+=1
        cntm-=1
    else:
        if zero:
            print(0)
            exit(0)
        
        for i in range(K):
            ans*=a[N-i-1]
            ans=(ans+mod*mod)%mod
        
        print(ans)
        exit(0)

for i in range(cntm):
    ans*=m[i]
    ans%=mod
for i in range(cntp):
    ans*=p[i]
    ans%=mod

print(ans)

Measured memory_bytes: 31640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H, W, B = 0;
    cin >> H >> W;
    vector<int> color(H * W);
    vector<vector<int>> grid(H * W);
    for (int i = 0; i < H; i++) {
        string S;
        cin >> S;
        for (int j = 0; j < W; j++) {
            color.at(i * W + j) = S.at(j);
            if (S.at(j) == '#') {
                B++;
            }
        }
    }
    for (int i = 0; i < H * W; i++) {
        if (color.at(i) == '#') {
            continue;
        }
        if (i >= W) {
            if (color.at(i - W) == '.') {
                grid.at(i).push_back(i - W);
            }
        }
        if (i < W * (H - 1)) {
            if (color.at(i + W) == '.') {
                grid.at(i).push_back(i + W);
            }
        }
        if (i % W != 0) {
            if (color.at(i - 1) == '.') {
                grid.at(i).push_back(i - 1);
            }
        }
        if (i % W != W - 1) {
            if (color.at(i + 1) == '.') {
                grid.at(i).push_back(i + 1);
            }
        }
    }
    vector<int> dist(H * W,-1);
    queue<int> que;
    que.push(0);
    dist.at(0) = 0;
    while(!que.empty()) {
        int v = que.front();
        que.pop();
        for (int i = 0; i < (int) grid.at(v).size(); i++){
            int nv = grid.at(v).at(i);
            if (dist.at(nv) != -1 && dist.at(nv) <= dist.at(v) + 1) {
                continue;
            }
            dist.at(nv) = dist.at(v) + 1;
            que.push(nv);
        }    
    }
    if (dist.at(H * W - 1) != -1) {
        cout << H * W - B - 1 - dist.at(H * W - 1) << endl;
    }
    else {
        cout << -1 << endl;
    }
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=1005;
int n;
char s[maxn][maxn];
int row[maxn],col[maxn];

void go(int x,int y,int c){
	if(x==n){
		if(!row[0])return;
		REP(i,n-1)if(row[i]!=row[0])return;
		rep(i,n)if(col[i]!=row[0])return;
		rep(i,n)printf("%s\n",s[i]);
		exit(0); 
	}
	if(y==n){
		if(!row[0])return;
		REP(i,x)if(row[i]!=row[0])return;
		rep(i,x+1)if((n%3)&&(row[i]%3))return;
		go(x+1,0,c);
		return;
	}
	if(s[x][y]!='.'){
		go(x,y+1,c);
		return;
	}
	go(x,y+1,c);
	if(y+1<n&&s[x][y+1]=='.'&&row[x]<=2&&col[y]<=2&&col[y+1]<=2){
		s[x][y]=s[x][y+1]='a'+c;
		row[x]++;
		col[y]++;col[y+1]++;
		go(x,y+1,c+1);
		s[x][y]=s[x][y+1]='.';
		row[x]--;
		col[y]--;col[y+1]--;
	}
	if(x+1<n&&s[x+1][y]=='.'&&col[y]<=2&&row[x]<=2&&row[x+1]<=2){
		s[x][y]=s[x+1][y]='a'+c;
		col[y]++;
		row[x]++;row[x+1]++;
		go(x,y+1,c+1);
		s[x][y]=s[x+1][y]='.';
		col[y]--;
		row[x]--;row[x+1]--;
	}
}

int main(){
	scanf("%d",&n);
	if(n==2)puts("-1");
	else if(n==3||n==6||n==7||n==11){
		rep(i,n)rep(j,n)s[i][j]='.';
		go(0,0,0);
	}
	else{
		rep(i,n)rep(j,n)s[i][j]='.';
		rep(a,n/5+1)if((n-5*a)%4==0){
			int b=(n-5*a)/4;
			rep(i,a){
				s[i*5+0][i*5+0]=s[i*5+0][i*5+1]='a';
				s[i*5+0][i*5+2]=s[i*5+1][i*5+2]='b';
				s[i*5+0][i*5+4]=s[i*5+1][i*5+4]='c';
				s[i*5+1][i*5+0]=s[i*5+2][i*5+0]='d';
				s[i*5+2][i*5+1]=s[i*5+3][i*5+1]='e';
				s[i*5+2][i*5+2]=s[i*5+2][i*5+3]='f';
				s[i*5+4][i*5+0]=s[i*5+4][i*5+1]='g';
				s[i*5+3][i*5+2]=s[i*5+4][i*5+2]='h';
				s[i*5+3][i*5+3]=s[i*5+3][i*5+4]='i';
				s[i*5+4][i*5+3]=s[i*5+4][i*5+4]='j';
			}
			rep(i,b){
				s[a*5+i*4+0][a*5+i*4+0]=s[a*5+i*4+1][a*5+i*4+0]='a';
				s[a*5+i*4+0][a*5+i*4+1]=s[a*5+i*4+1][a*5+i*4+1]='b';
				s[a*5+i*4+0][a*5+i*4+2]=s[a*5+i*4+0][a*5+i*4+3]='c';
				s[a*5+i*4+1][a*5+i*4+2]=s[a*5+i*4+1][a*5+i*4+3]='d';
				s[a*5+i*4+2][a*5+i*4+0]=s[a*5+i*4+2][a*5+i*4+1]='e';
				s[a*5+i*4+3][a*5+i*4+0]=s[a*5+i*4+3][a*5+i*4+1]='f';
				s[a*5+i*4+2][a*5+i*4+2]=s[a*5+i*4+3][a*5+i*4+2]='g';
				s[a*5+i*4+2][a*5+i*4+3]=s[a*5+i*4+3][a*5+i*4+3]='h';
			}
			break;
		}
		rep(i,n)printf("%s\n",s[i]);
	}
	return 0;
}

Measured memory_bytes: 2176
N,M,X=map(int,input().split())
ans=float("inf")
flag2=1
c=[]
for i in range(N):
    cc=list(map(int,input().split()))
    c.append(cc)
for i in range(2**N):
    flag=0
    score=[0 for _ in range(M+1)]
    for j in range(N):
        if i>>j & 1:
            for k in range(M+1):
                score[k]+=c[j][k]
    for j in range(1,M+1):
        if score[j]<X:
            flag=1
            break
    if flag==0:
        flag2=0
        ans=min(score[0],ans)
if flag2==1:
    print(-1)
else:
    print(ans)


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
int H[100100];

signed main() {
    cin >> N;
    rep(i, N) {
        cin >> H[i];
    }
    int prev = INF;
    int cnt = 0;
    int ans = 0;
    rep(i, N) {
        if (H[i] <= prev) {
            cnt++;
            prev = H[i];
        } else {
            ans = max(ans, cnt);
            cnt = 1;
            prev = H[i];
        }
    }
    ans = max(ans, cnt);
    cout << ans - 1 << endl;
    return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int n;
	while (cin >> n, n) {
		string c;
		cin >> c;
		vector<int>v(n, 0);
		int place = 0, mount = 100;

		for (int i = 0; i < c.size(); i++) {
			if (c[i] == 'M') {
				mount--;
				v[i%n]++;
			}
			else if (c[i] == 'S') {
				mount--;
				v[i%n]++;
				place += v[i%n];
				v[i%n] = 0;
			}
			else {
				mount--;
				v[i%n]++;
				v[i%n] += place;
				place = 0;
			}
		}
		sort(v.begin(), v.end());
		for (int i = 0; i < n; i++) {
			if (i)cout << " ";
			cout << v[i];
		}
		cout << " " << place;
		cout << endl;
	}
	return 0;
}

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


using namespace std;


int main() {
    string b;
    cin >> b;
    if (b == "A")cout << "T";
    if (b == "T") cout << "A";
    if (b == "C") cout << "G";
    if (b == "G") cout << "C";

    return 0;
} 


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define mod 1000000007
char ch[1001][1001];
int  getPaths(int h,int w){
    int  dp[1001][1001]{0};
    for(int i=0;i<w;++i){
        if(ch[0][i]!='#'){
            dp[0][i]=1;
        }
        else {break;}
    }
    for(int i=0;i<h;++i){
        if(ch[i][0]!='#'){
            dp[i][0]=1;
        }
        else {break;}
    }

    for(int i=1;i<h;++i){
        for(int j=1;j<w;++j){
            if(ch[i][j]!='#'){
                dp[i][j]=(dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
            }
        }
    }
    return dp[h-1][w-1];


}
int main() {

   int h, w;
   cin>>h>>w;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cin>>ch[i][j];
        }
    }

    cout<<getPaths(h,w);
  

   
}


Measured memory_bytes: 8416
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string n;
  cin >> n;
  
  if (n[1] == n[2]){
    if(n[0] == n[1]){
    	cout << "Yes" << endl;
    }
    else if(n[1] == n[3]){
    	cout << "Yes" << endl;
    }
    else {
    	cout << "No" << endl;
    }
   }
  else {
    cout << "No" << endl;
  }
}

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

vector<int> mojiretumake(string s,long long zentan){
    vector<int>gattai;
    bitset<10>bit(zentan);
    for (int i = 0; i < s.size(); i++){
        gattai.push_back(s.at(i)-'0');
        if (bit.test(i)){
            gattai.push_back(0);
        }
    }
    return gattai;
}

long long tashizan(vector<int>gattai){
    long long ans = 0;
    for (int i = 0; i < gattai.size(); i++){
        long long x = 0;
        while(1){
            if (i == gattai.size() || gattai.at(i) == 0) break;
            x *= 10;
            x += gattai.at(i);
            i++;
        }
        ans += x;
    }
    return ans;
}

int main(){
    string s;
    cin >> s;
    int N = s.size()-1;
    long long sum = 0;
    for (long long zentan = 0; zentan < (1LL << N); zentan++){
        sum += tashizan(mojiretumake(s,zentan));
    }
    cout << sum << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<string>

using namespace std;

int main(void)
{
	int n, m;
	cin >> n >> m;
	vector<int> a(m+1);
	vector<int> b(m+1);
	vector<int> ans(n+1,0);
	int i,j;
	for (i = 0; i < m; i++)
	{
		cin >> a[i] >> b[i];
	}
	for (i = 0; i < m; i++)
	{
		for (j = 1; j < n + 1; j++)
		{
			if (a[i] == j)
			{
				ans[j]++;
			}
			if (b[i] == j)
			{
				ans[j]++;
			}
		}
	}
	for (i = 1; i < n + 1; i++)
	{
		cout << ans[i] << endl;
	}
	return 0;
}


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

int arr[2001];
int n,x,y;

vector <int> v;

int f(int i, int m) {

  bool bm = 0, bn = 0;
  v[i] = m;

  if (i+1<n && v[i+1]>m+1) {
    f(i+1,m+1);
  }

  if (i>0 && v[i-1]>m+1) {
    f(i-1,m+1);
  }

  if (i==y) swap(x,y);
  if (i==x && v[y]>m+1) {
    f(y,m+1);
  }

  return 0;
}

int main() {
  scanf("%d %d %d",&n,&x,&y);
  x--;
  y--;

  for (int i = 0; i < n; i++) {

    v.resize(n,2002);
    f(i,0);

    for (int j = 0; j < n; j++) {
      arr[v[j]]++;
    }
    v.clear();
  }


  for (int i = 1; i < n; i++) {
    arr[i]/=2;
    printf("%d \n",arr[i]);
  }

}

Measured memory_bytes: 384
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}

void solv() {
	int n;
	cin >> n;
	int p[25];
	for (size_t i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	int c = 0;
	for (size_t i = 1; i < n - 1; i++)
	{
		int ma = max(p[i], max(p[i - 1], p[i + 1]));
		int mi = min(p[i], min(p[i - 1], p[i + 1]));
		if (ma != p[i] && mi != p[i]) c++;
	}
	cout << c << endl;
}

int main() {
	//	COMinit();
	solv();

	return 0;
}
 

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(bool);
void precalc();
clock_t start;
int main() {
#ifdef AIM
  freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
  //freopen("/home/alexandero/ClionProjects/ACM/output.txt", "w", stdout);
  //freopen("out.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
#endif
  start = clock();
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  precalc();
  cout.precision(10);
  cout << fixed;
  //cin >> t;
  int testNum = 1;
  while (t--) {
    //cout << "Case #" << testNum++ << ": ";
    //cerr << testNum << endl;
    solve(true);
    //cerr << testNum - 1 << endl;
  }
  cout.flush();
#ifdef AIM1
  while (true) {
      solve(false);
  }
#endif

#ifdef AIM
  cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

  return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
  if (!w)
    return 1 % mod;
  if (w & 1)
    return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template<typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}

void precalc() {

}

template<typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}

//#define int li
//const int mod = 1000000007;


void solve(bool read) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
      --a[i][j];
    }
  }

  int ans = n;
  vector<int> uk(n, 0);
  vector<char> used(m, false);
  for (int it = 0; it < m; ++it) {
    vector<int> cnt(m);
    for (int i = 0; i < n; ++i) {
      ++cnt[a[i][uk[i]]];
    }
    int mx = 0;
    int best_id = -1;
    for (int i = 0; i < m; ++i) {
      if (cnt[i] > mx) {
        mx = cnt[i];
        best_id = i;
      }
    }
    relax_min(ans, mx);
    used[best_id] = true;
    for (int i = 0; i < n; ++i) {
      while (uk[i] < m && used[a[i][uk[i]]]) {
        ++uk[i];
      }
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<vector>
#define ll long long
#define mod 1000000007
using namespace std;
string solve(int k,vector<int> &v)
{
    bool dp[k+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=k;i++)
    {
        for(int x: v)
        {
            if(x>i) continue;
            if(dp[i-x]==0)
            {
                dp[i]=1;
            }
        }
    }
    return (dp[k]?"First":"Second");
}
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    cout<<solve(k,v);
    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  string s;
  cin >> s;
  int n = s.size();
  n--;
  while(1){
    if(n % 2 == 0 && s.substr(0,n / 2) == s.substr(n / 2,n / 2))
    break;
    n--;
  }
  cout << n << endl;
  return 0;
} 

Measured memory_bytes: 256