akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;vector<int> p;int main(){int i=2,j,k=0,o;for(;i<70000;i++){o=1;for(j=0;j<p.size();j++)o=o&(i%p[j]>0);if(o)p.push_back(i);}cin>>i;while(i--){long long x;cin>>x;x=x*2+1;o=1;for(j=0;j<p.size();j++)o=x>p[j]?o&(x%p[j]>0):o;k+=o;}cout<<k<<endl;return 0;}

Measured memory_bytes: 3212
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000000000000LL
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n;
P a[MAXN];
vector<int> v;
ll calc(ll x,ll y)
{
    return abs(x)+abs(y);
}
char check(ll &x,ll &y,ll d)
{
    ll now=INF;
    char ret='X';
    if(calc(x-d,y)<now) {now=calc(x-d,y); ret='L';}
    if(calc(x+d,y)<now) {now=calc(x+d,y); ret='R';}
    if(calc(x,y-d)<now) {now=calc(x,y-d); ret='D';}
    if(calc(x,y+d)<now) {now=calc(x,y+d); ret='U';}
    assert(ret!='X');
    if(ret=='L') x-=d; else if(ret=='R') x+=d; else if(ret=='D') y-=d; else y+=d;
    return ret;
}
void solve()
{
    for(auto x:v) printf("%lld ",x);
    puts("");
    for(ll i=0;i<n;i++)
    {
        a[i].F=-a[i].F;a[i].S=-a[i].S;
        for(auto x:v) printf("%c",check(a[i].F,a[i].S,x));
        assert(a[i].F==0&&a[i].S==0);
        puts("");
    }
}
int main()
{
    scanf("%lld",&n);
    ll parity=-1;
    bool f=true;
    for(ll i=0;i<n;i++)
    {
        scanf("%lld%lld",&a[i].F,&a[i].S);
        if(parity!=-1&&((a[i].F+a[i].S)&1)!=parity) f=false;
        parity=(a[i].F+a[i].S)&1;
    }
    if(!f)
    {
        puts("-1");
        return 0;
    }
    if(parity)
    {
        printf("%lld\n",31);
        for(ll i=30;i>=0;i--) v.push_back(1<<i);
    }
    else
    {
        printf("%lld\n",32);
        for(ll i=30;i>=0;i--) v.push_back(1<<i);
        v.push_back(1);
    }
    solve();
    return 0;
}



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

def choose2(n):
  if n <= 1:
    return 0
  return n*(n-1)//2

inp = [0]*(n+1)
for i in range(n):
  inp[a[i]] += 1

total = 0
for i in range(n+1):
  total += choose2(inp[i])

for i in range(n):
  count = total - choose2(inp[a[i]]) + choose2(inp[a[i]]-1)
  print(count)


Measured memory_bytes: 32216
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define P pair
#define X first
#define Y second
#define VSORT(v) sort(v.begin(), v.end())
#define VREV(v) reverse(v.begin(), v.end())
#define VMAX_P(v) max_element(v.begin(), v.end())
#define VMIN_P(v) min_element(v.begin(), v.end())
#define VMAX_IDX(v) distance(v.begin(), VMAX_P(v))
#define VMIN_IDX(v) distance(v.begin(), VMIN_P(v))
#define VCOPY(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define SUPPER(src, dst) transform(src.begin(), src.end(), dst.begin(), toupper);
#define SLOWER(src, dst) transform(src.begin(), src.end(), dst.begin(), tolower);

using namespace std;
using ll = long long;

void displayVec(vector<int> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int binarySearch(vector<int> v, int target)
{
    int left = -1;
    int right = v.size();

    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (v[mid] >= target)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    if (right < v.size() && v[right] == target)
    {
        return right;
    }
    return -1;
}

int main(int argc, const char *argv[])
{
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'o')
        {
            cnt++;
        }
    }

    if (cnt + 15 - s.length() >= 8)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
<?php

$n=intval(trim(fgets(STDIN)));
$d=array_map("intval",explode(" ",fgets(STDIN)));
$ans=0;
for($i=0;$i<$n;$i++)
{
    for($j=$i+1;$j<$n;$j++)
    {
        $ans+=$d[$i]*$d[$j];
    }
}
echo $ans;
?>

Measured memory_bytes: 4728
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

int main() {
	int n,h,w;
	cin >> n >> h >> w;
	vector<int> a(n);
	vector<int> b(n);
	REP(i, n) {
		cin >> a[i] >> b[i];
	}
	int res = 0;
	REP(i, n) {
		if (h <= a[i] && w <= b[i]) {
			res++;
		}
	}
	put(res);
	return 0;
}



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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

#define repa(i, a, b) for (auto i = (a); i <= (b); i++)
#define repd(i, a, b) for (auto i = (a); i >= (b); i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define zero(a)  memset((a), 0, sizeof (a))
#define sz(x) (int)(x).size()
#define debug(x) cout << (x) << "\n";
#define mp make_pair
#define pb push_back

void solve() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll r[n + 1], g[n + 1], b[n + 1];
    r[n] = g[n] = b[n] = 0;
    repd(i, n - 1, 0) {
        r[i] = r[i + 1];
        g[i] = g[i + 1];
        b[i] = b[i + 1];
        r[i] += s[i] == 'R';
        g[i] += s[i] == 'G';
        b[i] += s[i] == 'B';
    }
    auto sum = 0LL;
    rep(i, n) {
        auto c1 = s[i];
        repa(j, 1LL, n - i - 1LL) {
            auto c2 = s[i + j];
            if (c1 == c2) continue;
            if (c1 == 'R' && c2 == 'G') sum += b[i + j + 1LL] - ((i + 2LL * j < n) ? (s[i + 2LL * j] == 'B') : 0);
            if (c1 == 'G' && c2 == 'R') sum += b[i + j + 1LL] - ((i + 2LL * j < n) ? (s[i + 2LL * j] == 'B') : 0);
            if (c1 == 'R' && c2 == 'B') sum += g[i + j + 1LL] - ((i + 2LL * j < n) ? (s[i + 2LL * j] == 'G') : 0);
            if (c1 == 'B' && c2 == 'R') sum += g[i + j + 1LL] - ((i + 2LL * j < n) ? (s[i + 2LL * j] == 'G') : 0);
            if (c1 == 'G' && c2 == 'B') sum += r[i + j + 1LL] - ((i + 2LL * j < n) ? (s[i + 2LL * j] == 'R') : 0);
            if (c1 == 'B' && c2 == 'G') sum += r[i + j + 1LL] - ((i + 2LL * j < n) ? (s[i + 2LL * j] == 'R') : 0);
        }
    }
    cout << sum;    
	cout << "\n";
}

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

Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        double minRad = m / 30.0 * Math.PI;
        double hourRad = (h / 6.0 + m / (30.0 * 12.0)) * Math.PI;

        double minx = b * Math.sin(minRad);
        double miny = b * Math.cos(minRad);

        double houx = a * Math.sin(hourRad);
        double houy = a * Math.cos(hourRad);

        double difx = minx - houx;
        double dify = miny - houy;

        // 出力
        System.out.println(Math.sqrt(difx *difx + dify * dify));
    }
}

Measured memory_bytes: 35984
import sys
#input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n=II()

	a=[0]*(2*10**5+100)
	for i in range(1,2*10**5+50):
		b=bin(i).count("1")
		a[i]=a[i%b]+1
	#print(a)

	s=input()
	c=s.count("1")
	#print(c)

	if c==1:
		ans=[]
		for i,ss in enumerate(reversed(s)):
			if ss=="1":
				ans.append(0)
			else:
				if s[-1]=="1" or i==0:
					ans.append(2)
				else:
					ans.append(1)

		for i in reversed(ans):
			print(i)
		exit()


	p=c+1
	n=c-1
	pp=0
	nn=0

	for i,ss in enumerate(reversed(s)):
		#print(i)
		if ss=="1":
			pp+=pow(2,i,p)
			nn+=pow(2,i,n)
			pp%=p
			nn%=n


	ans=[]

	for i,ss in enumerate(reversed(s)):
		if ss=="0":
			k=pp+pow(2,i,p)%p
			k%=p
			ans.append(a[k]+1)
		else:
			k=nn-pow(2,i,n)%n
			k%=n
			ans.append(a[k]+1)

	for i in reversed(ans):
		print(i)






if __name__ == "__main__":
	main()


Measured memory_bytes: 84308
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int T,N;
int fact[20],invf[20];
int pow_mod(int a,int i)
{
    int s=1;
    while(i)
    {
        if(i&1) s=1LL*s*a%MOD;
        a=1LL*a*a%MOD;
        i>>=1;
    }
    return s;
}
int comb(int n,int k)
{
    if(n<k) return 0;
    return 1LL*fact[n]*invf[k]%MOD*invf[n-k]%MOD;
}
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
int main()
{
    fact[0]=invf[0]=1;
    for(int i=1;i<=15;i++) fact[i]=1LL*fact[i-1]*i%MOD;
    invf[15]=pow_mod(fact[15],MOD-2);
    for(int i=14;i>=1;i--) invf[i]=1LL*invf[i+1]*(i+1)%MOD;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&N);
        int ans=0;
        for(int i=0;i<=11;i++)
        {
            if(N-5-i>=0&&(N-5-i)%2==0)
            {
                int j=(N-5-i)/2;
                int res=comb(11,i);
                res=1LL*res*invf[15]%MOD;
                for(int k=j+1;k<=j+15;k++) res=1LL*res*k%MOD;
                add(ans,res);
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3824
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,x;
    std::cin >> a >> b>> c>>x;
    int ans=0;
    for (int i = 0; i*500 <= x && i<=a; i++) {
        for (int j = 0; i*500+j*100 <= x && j<=b; j++) {
            for (int k = 0; i*500+j*100+k*50 <= x && k<=c; k++) {
                if(i*500+j*100+k*50==x)ans++;   
            }
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    ans=1
    md=10**9+7
    n,k=MI()
    for a in range(k,n+1):
        ans+=(n-a+1)*a+1
        ans%=md
    print(ans)

main()

Measured memory_bytes: 9232
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 1; s[i]; ++ i) {
        ans += (s[i] == s[i - 1]);
    }
    while (k --) {
        ans += 2;
    }
    if (ans >= n) ans = n - 1;
    cout << ans;
    
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#define M 100005
using namespace std;
map<char, int> cnt;
char s[100005];
int main() {
	scanf("%s", s);
	int n = strlen(s);
	int i, j;
	for (i = 0; i < n; i++) {
		if (s[i] == s[i + 1] && i + 1 < n) {
			printf("%d %d", i+1, i + 1+1);
			return 0;
		}
		if (i + 2 < n && s[i] == s[i + 2]) {
			printf("%d %d", i+1, i + 2+1);
			return 0;
		}
	}
	printf("-1 -1");
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<long long>S(5);
	for (int i = 0; i < N; ++i) {
		string s;
		cin >> s;
		if ('M' == s[0]) {
			S[0]++;
		}
		else if ('A' == s[0]) {
			S[1]++;
		}
		else if ('R' == s[0]) {
			S[2]++;
		}
		else if ('C' == s[0]) {
			S[3]++;
		}
		else if ('H' == s[0]) {
			S[4]++;
		}
	}
	long long ans = 0;
	for (int i = 0; i < 5; ++i) {
		for (int j = i + 1; j < 5; ++j) {
			for (int k = j + 1; k < 5; ++k) {
				ans += S[i] * S[j] * S[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3612
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long M;
        M = sc.nextLong();
        long[] p = new long[(int)(M)];
        String[] S = new String[(int)(M)];
        for(int i = 0 ; i < M ; i++){
                p[i] = sc.nextLong();
                S[i] = sc.next();
        }

        final Solver solver = new Solver();
        solver.solve(N, M, p, S);
    }
}

class Solver {
    private static final String AC = "AC";
    private static final String WA = "WA";

    public void solve(long N, long M, long[] p, String[] S) {
        Map<Long, Long> was = new HashMap<>();
        Set<Long> acs = new HashSet<>();
        for (int i = 0; i < M; i++) {
            if (S[i].equals(AC)) {
                acs.add( p[i]);
            }
            else {
                final long currentPenalty =
                        was.containsKey(p[i]) ? was.get(p[i]) : 0;
                was.put(p[i], acs.contains(p[i]) ? currentPenalty : currentPenalty + 1);
            }
        }

        long wa = 0;
        for (final Long ac : acs) {
            wa += was.containsKey(ac) ? was.get(ac) : 0;
        }
        System.out.println(String.format("%d %d", acs.size(), wa));
    }
}



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

int main(){
int n, cnt = 0;
cin >> n;
for(int i = 1; i <= n; ++ i){
int x;
cin >> x;
if(x % 2) cnt ++;
}
if(cnt % 2){
cout << "NO";
} else {
cout << "YES";
}
    return 0;
}

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

int main(){
    int N,K;
    int sum=0;
    cin >> N >> K ;
    vector<int> p(N);
    rep(i,N){
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    rep(i,K){
        sum+=p[i];
    } 
    cout << sum << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {

    int N, K;
    vector<char> D;

    cin >> N >> K;
    for (int i = 0; i < K; ++i) {
        char d;
        cin >> d;
        D.push_back(d);
    }

    for (int i = N; i < 10 * N; ++i) {
        string s = to_string(i);
        bool f = true;
        for (int j = 0; j < s.length(); ++j) {
            if(!f){
                break;
            }
            char c = s[j];
            for (int k = 0; k < D.size(); ++k) {
                if (c == D[k]) {
                    f = false;
                    break;
                }
            }

        }
        if (f) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
L = len(S)
St = []
Tr = []
ans = 'No'
for i in range(L):
    St.append(S[i:i+1])
    Tr.append(T[i:i+1])

for i in range(L):
    if St == Tr:
        ans = 'Yes'
        break
    else:
        St.insert(0,St[L-1])
        del St[L]

print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int a[300010], b[300010], n;
int check(int l, int r) {
    for (int i = l; i <= r; i++) if (a[i] < l || a[i] > r) return 0;
    int lst1 = 0, lst2 = 0;
    for (int i = l; i <= r; i++) {
        if (a[i] < i) {
            if (lst1 > a[i]) return 0;
            else lst1 = a[i];
        }
        else if (a[i] > i) {
            if (lst2 > a[i]) return 0;
            else lst2 = a[i];
        }
    }
    return 1;
}
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    for (int i = 1; i <= n; i++) b[i] = a[i] == i;
    for (int l = 1, r = 1; l <= n; l = r = r + 1) {
        if (b[l]) continue;
        while (r < n && b[r + 1] != b[r]) r++;
        if (!check(l, r)) return puts("No"), 0;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 2560
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {

	map<char, ll> po;
	ll N;
	cin >> N;
	rep(i, N) {
		char p; cin >> p;
		po[p];
	}
	cout << (po.size() == 4 ? "Four" : "Three") << endl;

}

Measured memory_bytes: 256
n = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
r = ""

for i in range(n):
  r = str(input())
  if r == "AC":
    AC += 1
  elif r == "WA":
    WA += 1
  elif r == "TLE":
    TLE += 1
  elif r == "RE":
    RE += 1

print(f"AC x {AC}")
print(f"WA x {WA}")
print(f"TLE x {TLE}")
print(f"RE x {RE}")

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  for(int i=1;i<=a*b;i++){
    if((a*i)%b==c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var s = int.Parse(Console.ReadLine().Trim());
            if (s == 0) break;
            var ret = 999999999;
            for (int i = 0; i <= s; i += 100)
                for (int j = 0; j <= s; j += 100)
                {
                    var k = s - i - j;
                    if (k < 0 || i % 200 != 0 || j % 300 != 0 || k % 500 != 0) continue;
                    var w = getA(i / 200) + getB(j / 300) + getC(k / 500);
                    ret = Math.Min(ret, w);
                }
            Console.WriteLine(ret);
        }
    }
    public static int getA(int n)
    {
        var a = n % 5;
        var b = n / 5;
        return 1520 * b + a * 380;
    }
    public static int getB(int n)
    {
        var a = n % 4;
        var b = n / 4;
        return 1870 * b + a * 550;
    }
    public static int getC(int n)
    {
        var a = n % 3;
        var b = n / 3;
        return 2244 * b + a * 850;
    }
}




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

public class AtCoderC
{
    static List<string> patterns;

    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        while (true)
        {
            if (IsPrime(n))
            {
                Console.WriteLine(n);
                return;
            }
            n++;
        }
    }

    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}

Measured memory_bytes: 11092
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int n,m;
vvi cost,out;
vvp G;
vi used,t;
void dfs(int a,int no){
	used[a]=true;
	rep(i,G[a].size()){
		int to=G[a][i].first;
		if(!used[to]&&a-no)dfs(to,no);
	}
}
void f(int a){
	used=vi(n);
	rep(i,t.size()){
		if(used[G[a][t[i]].first])out[G[a][t[i]].second][0]=1;
		else dfs(G[a][t[i]].first,a);
	}
}
signed main(){
	cin>>n>>m;
	G=vvp(n);
	cost=vvi(n,vi(n));
	rep(i,n)cost[i][i]=1;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		cost[a][b]=1;
		G[a].pb({b,i});
	}
	out=vvi(m,vi(2));
	rep(k,n)rep(i,n)rep(j,n)
		cost[i][j]|=cost[i][k]&cost[k][j];
	rep(i,n)rep(j,G[i].size())out[G[i][j].second][1]=cost[G[i][j].first][i];
	rep(i,n){
		t=vi(G[i].size());
		rep(j,t.size())t[j]=j;
		f(i);
		reverse(all(t));
		f(i);
	}
	rep(i,m)if(out[i][0]^out[i][1])cout<<"diff"<<endl;
	else cout<<"same"<<endl;
}















Measured memory_bytes: 27520
while True:
    n, m = map(int, input().split())
    if n == 0 and m == 0:
        break
    sections = []
    for i in range(n):
        d, p = map(int, input().split())
        sections.append([p, d])
    sections.sort()
    sections.reverse()

    e = 0
    for p, d in sections:
        if d <= m:
            m -= d
            d = 0
        elif m > 0:
            d -= m
            m = 0
        e += p * d
    print(e)

Measured memory_bytes: 8980
def selectionSort(a,n)
  count = 0
  for i in 0..n-1 do
    minj = i
    for j in i..n-1 do
      if a[j] < a[minj]
        minj = j
      end
    end
    if i != minj
      a[i],a[minj] = a[minj],a[i]
      count += 1
    end
  end
  return count
end

n = gets.chomp.to_i
a = gets.chomp.split(" ").map{|x| x.to_i}
count = selectionSort(a,n)
printf("%s\n",a.join(" "))
printf("%d\n",count)


Measured memory_bytes: 6888
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int64_t> h(n);
    map<int,vector<int>> p;
    rep(i,n){
        cin>>h[i];
    }
    int ans=0;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        p[a].push_back(b);
        p[b].push_back(a);
    }
    rep(i,n){//H[i]ごとにやってく
        bool good = true;
        rep(j,p[i].size()){
            int observe = p[i][j];
            if(h[i]<=h[observe]){
                good = false;
                break;
            }
        }
        if(good){
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

wa = 0
kazu = 10**9 + 7
for i in range(60):
    b = 0
    for j in a:
        b += j & 1
    wa = (wa + b*(n-b)*(1<<i)) % kazu
    for j in range(n):
        a[j] = a[j] >> 1

print(wa)

Measured memory_bytes: 122936
#include<iostream>
#include<vector>
#include<cstdlib>
#include<algorithm>
#define N 1001
using namespace std;

vector<int> fibo;
void makeFiboModN( int V ){
	fibo.resize( V+1 );
	fibo[0] = 1;
	fibo[1] = 2;
	for(int i = 2; i <= V; ++i){
		fibo[i] = ( (fibo[i - 1]%N) + (fibo[i - 2]%N) ) % N;
	}
}
int main(){
	while(true){
		int ans = 0;
		int V,d;
		cin>>V>>d;
		if(cin.eof())break;
		makeFiboModN( V );
		
		sort(fibo.begin()+1,fibo.end());
		for(int i = 1; i <= V-1; ++i){
			if( abs( fibo[i] - fibo[i+1] ) < d ){
				;
			}else{
				++ans;
			}
		}
		cout << ans+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#include <numeric>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;
vector<LL> divisor(LL sum) {
    vector<LL> ret;
    for (LL x = 1; x * x <= sum; x++) {
        if (sum % x == 0) {
            ret.push_back(x);
            if (x * x != sum) {
                ret.push_back(sum / x);
            }
        }
    }
    return ret;
}

int main() {
    LL n, k;
    cin >> n >> k;
    vector<LL> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    LL sum = accumulate(a.begin(), a.end(), 0);
    auto divs = divisor(sum);
    sort(divs.begin(), divs.end());
    LL ans = 1;
    for (auto d : divs) {
        LL tmp_ans= 101010101;
        vector<LL> tmp;
        LL rem = 0;
        for (auto j : a) {
            if (j % d <= (d - j % d)) {
                tmp.push_back(-j % d);
                rem += j % d;
            } else {
                tmp.push_back(d - j % d);
                rem += -d + j % d;

            }
        }
        sort(tmp.begin(), tmp.end());

        if (rem < 0) reverse(tmp.begin(), tmp.end());
        rem /= d;

        if (rem < 0) {
            rem *= -1;
            rep(i, rem) {
                tmp[i] -= d;
            }
        } else {
            rep(i, rem) {
                tmp[i] += d;
            }
        }
        LL pos = 0;
        LL neg = 0;
        for (auto i : tmp) {
            if (i >= 0) pos += i;
            else neg -= i;
        }
        tmp_ans = max(pos, neg);
        if (tmp_ans <= k) ans = d;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF (9e18)
#define EPS (1e-6)
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
void INIT(){
	ios::sync_with_stdio(false); cin.tie(0);
}

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
	INIT();
	//code...
	ll n; cin>>n;
	if(n%2){
		cout<<0<<"\n";
		return 0;
	}
	n/=2;
	ll ans=0;
	while(n){
		n/=5; ans+=n;
	}
	cout<<ans<<"\n";
	return 0;
}






















Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long cnt=100;
long long a,sum=0,t;
int main()
{
	cin>>a;
	while(cnt<a)
	{
		cnt=cnt*1.01;
		sum++;
		//cout<<cnt<<" "<<sum<<endl;
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3192
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
ans = [[0]*W for _ in range(H)]
h = -1
w = -1
flag = False
for i in range(N):
    for j in range(a[i]):
        w+=1
        w%=W
        if w==0:
            w=0
            h+=1
            if flag:
                flag = False
            else:
                flag = True
        if flag:
            ans[h][w] = i+1
        else:
            ans[h][W-1-w] = i+1
    
for i in range(H):
    print(*ans[i])

Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const ll INF = +10010010000;

typedef pair<ll,ll> P;
const ll MO = 1000000007;


int main(){
    int n;cin >> n;
    vector<ll>a(n,0);
    map<ll,ll> mpl,mpr;
    rep(i,n)cin>>a[i];
    rep(i,n){
        ll x,y;
        x = i+a[i];
        y = i-a[i];
        mpl[x]++;mpr[y]++;
    }
    ll ans=0;
    for(auto ele :mpl){
        ans+=ele.second*mpr[ele.first];
    }

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

Measured memory_bytes: 39148
#include<iostream>
#include<stdio.h>
#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;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   string s,t;
   cin>>s>>t;
   vi v[26];
   for(int i=0;i<s.length();i++)
   {
       v[s[i]-'a'].pb(i+1);
   }
   int cnt=0;
   int last=0;
   for(int i=0;i<t.length();i++)
   {
       int  x= t[i]-'a';
       if(v[x].size()==0)
       {
           cout<<-1<<endl;
           return 0;
       }
       auto it = upper_bound(all(v[x]),last);
       if(it != v[x].end())
       {
           int val = *(it);
           if(val < last)
           {
               cnt++;
           }
           last = val;
       }
       else
       {
           cnt++;
           last = v[x][0];
       }
   }
   cout<<cnt*s.length() + last <<endl;
}



Measured memory_bytes: 1736
/* 二分木　*/
#include <stdio.h>

#define MAX 25       /*　最大ノード数　*/
#define NIL -1

typedef struct{

  int left;          /*　左の子ども　*/
  int right;         /*　右の子ども　*/
  int parent;        /*　親　*/  
}Node;

Node T[MAX];         /*　二分木　*/
int n;               /* ノード数　*/
int depth[MAX];      /* 各ノードの深さ　*/
int height[MAX];     /* 各ノードの高さ　*/
int degree[MAX];     /* 各ノードの子の数　*/

/*　関数プロトタイプ宣言　*/
void GetDepth(int, int);
int  GetHeight(int);
void print(int);

int main()
{
  int i, j, d, v, c, l, root;

  scanf("%d", &n);

  /*　二分木をNILで初期化　*/
  for( i = 0; i<n; i++ )
    T[i].left = T[i].right = T[i].parent = NIL;
  
  /* 二分木の各ノードの情報を読み込み　*/
  for( i = 0; i<n; i++ )
    {
      scanf("%d", &v);
      scanf("%d%d", &T[v].left, &T[v].right);

      /*　子どもの数を設定　*/
      if( T[v].left != NIL && T[v].right != NIL )
	degree[v] = 2;
      else if( T[v].left == NIL && T[v].right == NIL )
	degree[v] = 0;
      else
	degree[v] = 1;
      
      /*　左の子、右の子それぞれに親の番号を設定　*/
      if( T[v].left != NIL )
	T[ T[v].left ].parent = v;
      if( T[v].right != NIL )
	T[ T[v].right ].parent = v;
    }

  /* ルートノードを求める　*/
  for( i = 0; i<n; i++ )
    {
      if( T[i].parent == NIL )
        {
          root = i;
          break;
        }
    }

  /*　各ノードの深さを求める　*/
  GetDepth(root, 0);

  /*　各ノードの高さを求める　*/
  GetHeight(root);

  /*　根付きノードの情報を表示*/
  for( i = 0; i<n; i++ )
    print(i);
  
  return 0;
}

/*　各ノードの深さを再帰的に求める関数　
    引数：　u -> その時着目しているノードの番号　　p ->　その時着目しているノードの深さ　*/
void GetDepth(int u, int p)
{
  if( u == NIL )
    return;
  depth[u] = p;

  GetDepth(T[u].left, p+1);         /*　左の子の深さを求める　*/
  GetDepth(T[u].right, p+1);        /*　右の子の深さを求める　*/
}


/*  各ノードの高さを再帰的に求める関数　
    引数：　u -> その時着目しているノードの番号      戻り値：その時着目しているノードの高さ　*/
int GetHeight(int u)
{
  int h1 = 0, h2 = 0;

  if( T[u].left != NIL )
    h1 = GetHeight(T[u].left) + 1;        /*　左の子の高さを求める　*/
  if( T[u].right != NIL )
    h2 = GetHeight(T[u].right) + 1;       /*　右の子の高さを求める　*/

  return height[u] = ( h1 > h2 ? h1 : h2);
}


/*　ノードT[u]の情報を出力する関数　*/
void print(int u)
{
  int c;

  /* node, parentを表示　*/
  printf("node %d: parent = %d, ", u, T[u].parent);

  /* 兄弟の番号を表示　*/
  if( T[u].parent == NIL )
    printf("sibling = %d, ", NIL);
  else if( T[ T[u].parent ].left == u )
    printf("sibling = %d, ", T[ T[u].parent ].right);
  else
    printf("sibling = %d, ", T[ T[u].parent ].left);

  /*　子の数、深さ、高さを表示　*/
  printf("degree = %d, depth = %d, height = %d, ", degree[u], depth[u], height[u]);

  /* ノードのタイプを表示　*/
  if( T[u].parent == NIL )
    printf("root\n");
  else if( T[u].left == NIL && T[u].right == NIL )
    printf("leaf\n");
  else
    printf("internal node\n");
}



Measured memory_bytes: 2076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    
    cout << N/3 << endl;


    return 0;
    

}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){
  long N;
  cin >> N;
  
  int ans = 1;
  
  for(int i=0;i<=sqrt(N);i++){
    if(N >= i * i)
      ans = i * i;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
dp = [0]*31
dp[0] = 1
dp[1] = 1
dp[2] = 2
dp[3] = 4
for i in range(4,31):
    dp[i] = dp[i-1]+dp[i-2]+dp[i-3]
while True:
    n = int(input())
    if n == 0:
        exit()
    else:
        if dp[n]%3650 == 0:
            print(dp[n]//3650)
        else:
            print(dp[n]//3650+1)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 4e3 + 5, MOD = 998244353;
int dp[N][N];

void add(int &a, int b) {
    a += b;
    if (a >= MOD)   
        a -= MOD;
}

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

    string s;
    cin >> s;

    dp[0][0] = 1;

    int red = 0, n = s.size();

    for (int i = 0; i < n * 2; i++) {
        if (i < n)
            red += s[i] - '0';
        for (int j = 0; j <= red; j++) {
            if (j + 1 <= red) {
                add(dp[i + 1][j + 1], dp[i][j]);
            }
            if (min(n, i + 1) * 2 - red - (i - j) > 0) {
                add(dp[i + 1][j], dp[i][j]);
            }
        }
    }

    cout << dp[2 * n][red] << "\n";

    return 0;
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;



int main() {

    ll K, N;
    cin >> K >> N;
    vector<ll> A(N);
    REP(i, N)cin >> A[i];
    ll kyori = 1e10;
    sort(A.begin(), A.end());
    REP(i, N-1){
        kyori = min(kyori, (K-(A[i+1]-A[i])));
    }
    kyori = min(kyori, (K-((A[0]+K)-A[N-1])));
    cout << kyori << endl;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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

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

    string a, b, c;
    cin >> a >> b >> c;
    b.pop_back();
    cout << a.front();
    cout << b.back();
    cout << c.back();
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
using namespace std;
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
inline int rd(){
	int res=0,sign=1;char ch;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')sign=-1;res=res*10+ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;
	return res*sign;
}
int a,b,c;
int main(){
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <complex>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define ten(x) ((int)1e##x)

using namespace std;

int main(){
	int n; cin >> n;
	int q; cin >> q;
	vector<int> A(n,0);
	int interval = sqrt(n);
	vector<int> B(n / interval + 1,0);

	FOR(i,q){
		int com, x, y; cin >> com >> x >> y;
		if(com == 0){
			x--;
			int s = x/interval;
			B[s] -= A[x];
			A[x] += y;
			B[s] += A[x];
		}
		if(com == 1){
			x--;y--;
			int j = x;
			int sum = 0;
			// cout << "fin:"<< x << " " << y << endl;
			// FOR(ii,B.size()) cout << B[ii] << " ";
			// cout << endl;
			// FOR(ii,A.size()) cout << A[ii] << " ";
			// cout << endl;
			while(j <= y){
				// cout << j << " ";
				if(j % interval == 0 && y - j >= interval - 1){
					sum += B[j/interval];
					j += interval;
				}
				else{
					sum += A[j];
					j++;
				}
			}
			// cout << "ans:" << tmp << endl << endl;
			cout << sum << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1532
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N;
    cin >> N;

    ll ans = 0;
    REP(i, N) ans += (i + 1) * (N - i);

    REP(i, N - 1) {
        ll u, v;
        cin >> u >> v; --u; --v;
        if (u > v) swap(u, v);
        ans -= (u + 1) * (N - v);
    }

    print(ans);

}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

typedef struct UnionFind
{
	vector<int> par;

	UnionFind(int N)
	{
		par.resize(N);
		for(int i=0; i<N; i++)
		{
			par[i] = i;
		}
	}

	int root(int x)
	{
		if(par[x]==x)
		{
			return x;
		}
		else
		{
			return par[x] = root(par[x]);
		}
	}

	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx==ry)
		{
			return;
		}
		par[rx] = ry;
	}

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

int main()
{
	int N,M;
	cin>>N>>M;

	UnionFind tree(N);

	for(int i=0; i<M; i++)
	{
		int x,y,z;
		cin>>x>>y>>z;
		x--;
		y--;
		tree.unite(x,y);
	}

	set<int> s;

	for(int i=0; i<N; i++)
	{
		s.insert(tree.root(i));
	}

	cout<<s.size()<<endl;
	
	return 0;
}

Measured memory_bytes: 5376
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 5050;
const llint inf = 1e18;

int main(void) {
  int N;
  scanf("%d", &N);
  vector<pair<int, int>> v;
  REP(i, N) {
    int L, R;
    scanf("%d %d", &L, &R);
    v.push_back({L+R, L});
  }

  sort(v.begin(), v.end(), greater<pair<int, int>>());
  llint ans = inf;
  for (int n = (N-1) / 2; n <= N / 2; ++n) {
    int m = N-1-n;

    llint f[MAX][2];
    llint nf[MAX][2];

    f[0][0] = 0;
    f[0][1] = inf;

    REP(i, N) {
      int L = v[i].second;
      int R = v[i].first - v[i].second;

      REP(j, i+2) REP(k, 2) nf[j][k] = inf;
      REP(j, i+1) REP(k, 2) {
        if (f[j][k] < inf) {
          nf[j+1][k] = min(nf[j+1][k], f[j][k] + R + j*1LL*(R+L));
          nf[j][k] = min(nf[j][k], f[j][k] + L + (i-j-k)*1LL*(R+L));
          if (k == 0) {
            nf[j][1] = min(nf[j][1], f[j][k] + n*1LL*L + m*1LL*R);
          }
        }
      }
      REP(j, i+2) REP(k, 2) f[j][k] = nf[j][k];
    }

    ans = min(ans, f[n][1]);
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n; sc(n)
    int p[n];
    ll ans = 0, tmp = 0;
    for (int i = 0; i < n; i++) sc(p[i])
    for (int i = 0; i < n; i++){
        if (tmp == 0){
            if (p[i] == i + 1) tmp += 1;
        }else {
            if (p[i] == i + 1) tmp += 1;
            else {
                if (tmp % 2 == 0) ans += tmp / 2;
                else ans += tmp / 2 + 1;
                tmp = 0;
            }
        }
    }
    if (tmp % 2 == 0) ans += tmp / 2;
    else ans += tmp / 2 + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>

using namespace std;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

int main() {
	string s1, s2;
	cin >> s1 >> s2;
	for (int i = 0; i < s1.length(); i++)
	{
		cout << s1[i];
		if (s2[i])
			cout << s2[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  char S[16];
  
  scanf( "%s", S );
  
  if ( S[0] == S[1] || S[1] == S[2] || S[2] == S[3] ) {
    printf( "Bad\n" );
  } else {
    printf( "Good\n");
  }
  
  return 0;
}


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

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

    int N; cin>>N;
    int ans = 1;
    while(ans*2<=N){
        ans = ans*2;
    }
    ans = ans * (N/ans);
    cout << ans << endl;
}

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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  int ans=0;
  rep(i,n) {
    for(int j=i+1;j<n;j++) {
      ans+=a[i]*a[j];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll N=0,sum=0;
    scanf("%lld",&N);
    pair<set<int>,int> s;
    ll cnt[N+1]= {0},array[N] ={0};
    for (ll i = 0; i < N; i++)
    {
        scanf("%lld",array+i);
        cnt[array[i]]++;
    }
    for (ll i = 1; i <= N; i++)
    {
        sum += cnt[i]*(cnt[i]-1)/2;
    }

    for(ll j = 0;j<N;j++){
        ll before =cnt[array[j]];
        ll after = before -1;
        printf("%lld\n",sum-before*(before-1)/2+after*(after-1)/2);
    }
    return 0;
}

Measured memory_bytes: 5760