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

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

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

int main(){
	cin.sync_with_stdio(false);
    ll n;
    cin>>n;
    vi v(n);
    rep(i,0,n) cin>>v[i];
    sort(all(v));
    ll sum = 0;
    rep(i,0,n) sum+=v[i];
    if(sum%10==0){
        rep(i,0,n){
            if((sum-v[i])%10!=0){
                sum-=v[i];
                break;
            }
        }
    }
    if(sum%10==0) cout<<0<<endl;
    else cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main() 
{
	long long n, m;
	scanf("%lld%lld", &n, &m);
	if (2 * n <= m)
		printf("%lld\n", (m - n * 2) / 4 + n);
	else
		printf("%lld\n", m / 2);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>

using namespace std;


int main(){
  string s, tmps;
  cin >> s;

  int count1 = 0, count2 = 0;
  tmps = s;
  for(int i = 0; i < s.length(); ++i){
    if(i % 2 == 0){
      if(s[i] == '0') count1++;
    } else {
      if(s[i] == '1') count1++;
    }
  }

  for(int i = 0; i < s.length(); ++i){
    if(i % 2 == 0){
      if(s[i] == '1') count2++;
    } else {
      if(s[i] == '0') count2++;
    }
  }

  if(count1 > count2){
    cout << count2 << endl;
  } else {
    cout << count1 << endl;
  }

}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    // Your code here
    string s;
    cin>>s;
    int n=0;
    if(s[0]==s[1]){
        n++;
    }
    if(s[2]==s[3]){
        n++;
    }
    if(s[0]==s[3]){
        n++;
    }
    if(s[1]==s[2]){
        n++;
    }
    if(s[0]==s[2]){
        n++;
    }
    if(s[1]==s[3]){
        n++;
    }
    if(n==2){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    
    
    return 0;
}


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

#define mp       make_pair
#define mt	  make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF=1<<29;
const double EPS=1e-9;
const ll MOD = 1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int W = 3;
const int H = 3;
int board[H][W];
int A,B,C;
bool check(){
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if (board[i][j] < 0)return false;
    }
  }
  return true;
}
int main(){
  cin >> A >> B >> C;
  board[0][0] = A;
  board[0][1] = B;
  board[1][1] = C;
  int sum = 3 * C;
  board[0][2] = sum - (A + B);
  board[2][1] = sum - (B + C);
  board[2][2] = sum - (A + C);
     
  //int X20 = sum - (X02 + C);
  board[2][0] = sum - (board[2][1] + board[2][2]);
  //int X22 = sum - (X20 + X21);

  //int X10 = sum - (A + X20);
  board[1][0] = sum - (A + board[2][0]);
  board[1][2] = sum - (board[0][2] + board[2][2]);
  for (int i = 0; i < H; i++){
    for (int j =0; j < W; j++){
      cout << board[i][j] << " ";
    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from fractions import gcd

def readln():
    _res = list(map(int,str(input()).split(' ')))
    return _res

def dfs(deep,now,v):
    if deep == n:
        return 1
    res = 0
    for i in range(1,n+1):
        if v[i] == 0 and e[now][i] == 1:
            v[i] = 1
            res = res + dfs(deep+1, i, v)
            v[i] = 0
    return res


a = readln()
n,m = a[0],a[1]
e = [[0 for i in range(0,n+1)] for j in range(0,n+1)]
for i in range(0,m):
    a = readln()
    e[a[0]][a[1]] = 1
    e[a[1]][a[0]] = 1
v = [0 for i in range(0,n+1)]
v[1] = 1
print(dfs(1,1,v))


Measured memory_bytes: 5460
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 c = sc.nextInt();
		int d = sc.nextInt();
		System.out.println(a * b >= c * d ? a * b : c * d);
	}
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    char X;
    cin >> X;
    if (X>='a') {
        cout << 'a';
    }
    else {
        cout << "A";
    }
    cout << endl;
}


Measured memory_bytes: 3624
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,m,p[1010],d[1010][1010],w[2][310][310];
  int a,b,c,i,j,k,l,t,M=100000000;
  char r;
  while(scanf("%d %d",&n,&m),n+m){
    for(i=0;i<n*n;i++)w[0][i/n][i%n]=w[1][i/n][i%n]=M;
    for(i=0;i<1010;i++){
      for(j=0;j<1010;j++)d[i][j]=M;
    }
    for(i=0;i<n;i++)w[0][i][i]=w[1][i][i]=0;
    while(m--){
      scanf("%d %d %d %c",&a,&b,&c,&r);
      t=(r=='L')?0:1;
      w[t][a-1][b-1]=w[t][b-1][a-1]=c;
    }
    for(i=0;i<2;i++){
      for(j=0;j<n;j++){
	for(k=0;k<n;k++){
	  for(l=0;l<n;l++)w[i][k][l]=MIN(w[i][k][l],w[i][k][j]+w[i][j][l]);
	}
      }
    }
    /*for(i=0;i<2;i++){
      for(j=0;j<n;j++){
	for(k=0;k<n;k++)printf("%10d ",w[i][j][k]);printf("\n");
      }printf("\n");
      }//*/
    scanf("%d",&l);
    for(i=0;i<l;i++)scanf("%d",&p[i]);
    for(i=0;i<l;i++)p[i]--;
    d[0][p[0]]=0;
    for(i=0;i<l-1;i++){
      for(j=0;j<n;j++){
	if(d[i][j]==M)continue;
	d[i+1][j]=MIN(d[i+1][j],d[i][j]+w[0][p[i]][p[i+1]]);
	for(k=0;k<n;k++){
	  d[i+1][k]=MIN(d[i+1][k],d[i][j]+w[0][p[i]][j]+w[1][j][k]+w[0][k][p[i+1]]);
	}
      }
    }
    for(i=0;i<n;i++)d[l-1][0]=MIN(d[l-1][0],d[l-1][i]);
    printf("%d\n",d[l-1][0]);
  }
  return 0;
}

Measured memory_bytes: 5224
import java.util.*;

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      long A = Long.parseLong(sc.next());
      long B = Long.parseLong(sc.next());

      //F(A,B) = F(0,A-1) ^ F(0,B)

      long a = aaa(A-1);
      long b = aaa(B);

      System.out.println(a^b);

    }

    public static long aaa(long x){
      long ans = 0;
      long kk = 0;
      if(x%2==1 && ((x+1)/2)%2==0){ //odd
        ans = 0;
      }
      else if(x%2==1 && ((x+1)/2)%2==1){ //odd
        ans = 1;
      }
      else if(x%2==0 && (x/2)%2==0){
        ans = x;
      }
      else if(x%2==0 && (x/2)%2==1){
        ans = x^1;
      }
      return ans;
    }

}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		var pf=new Pf(n);
		long ans=n;
		pf.Get((k,v)=>{ans-=ans/k;});
		Console.WriteLine("{0}",ans);
	}
	static long Gcd(long a,long b){
		long c=Math.Max(a,b)%Math.Min(a,b);
		b=Math.Min(a,b);
		while(c!=0){
			a=b%c;
			b=c;
			c=a;
		}
		return b;
	}
}
public class Pf{
	public Dictionary<long,int> hs=new Dictionary<long,int>();
	public Pf(int n){
		while(n%2==0){
			n>>=1;
			if(hs.ContainsKey(2)){hs[2]++;}
			else{hs.Add(2,1);}
		}
		long q=(long)Sqrt(n)+1;
		int i=3;
		while(n!=1&&i<q){
			if(n%i==0){
				n/=i;
				q=(long)Sqrt(n)+1;
				if(hs.ContainsKey(i)){hs[i]++;}
				else{hs.Add(i,1);}
				i=3;
			}
			else{i+=2;}
		}
		if(n!=1){
			if(hs.ContainsKey(n)){hs[n]++;}
			else{hs.Add(n,1);}
		}
	}
	public void Get(Action<long,int> f){
		foreach(var e in hs){f(e.Key,e.Value);}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


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

int main() {
  int n,m;cin>>n>>m;
  vector<int> ac(n),wa(n);
  int a=0,w=0;
  rep(i,m){
    int p;string s;cin>>p>>s;
    p--;
    if(s=="WA")wa[p]++;
    else {
      if(ac[p]==0){
        ac[p]++;
        a++;
        w+=wa[p];
      }
    }
  }
    cout<<a<<" "<<w<<endl;
}

Measured memory_bytes: 4048
#include<iostream>
#include<cassert>
#include<ctime>
#include<climits>
#include<queue>
#include<fstream>
#include<deque>
#include<iomanip>
#include<list>
#include<sstream>
#include<string>
#include<cctype>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#include<stack>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-10
#define F first
#define S second
#define all(n) n.begin(),n.end()
#define pb push_back
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define INF (1<<27)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
int N,M,r,q;
vector<P> info[10001];
//map<int,bool> Index;
 
int main(){
 
  while(true){
    cin >> N >> M;
    if(N+M == 0)break;
    rep(i,10000)
      info[i].clear();
    //Index.clear();
    stack<char> staq[M+1];
 
    cin >> r;
    rep(i,r){
      int t,n,m,s;
      cin >> t >> n >> m >> s;
      if(s == 1){
    if(staq[m].empty()){
      info[m].pb(P(t,-1));
      //Index[m] = true;
      
    }
    staq[m].push('a');
      }
      else{
    //if(index[m]){
    assert(info[m].size()-1 >= 0);
    info[m][info[m].size()-1].S = max(info[m][info[m].size()-1].S,t);
    staq[m].pop();
    //Index[m] = false;
    //}
      }
    }
    //cout << "deg --------" << endl;
 
    //rep(i,M){
    //cout << "strudent is " << i+1 << endl;
    //rep(j,info[i+1].size()){
    //cout << info[i+1][j].F << " "  << info[i+1][j].S << endl;
    //}
    //}
    //cout << "M = " << M << endl;
    cin >> q;
    rep(i,q){
      int ts,te,m,total;
      cin >> ts >> te >> m;
      total = 0;
      //assert(!Index[m]);
      assert(staq[m].empty());
      //cout << "info[" << i << "].size = " << info[m].size() << endl;
      rep(j,info[m].size()){
 
    if(ts <= info[m][j].F && info[m][j].S <= te){
      total += info[m][j].S - info[m][j].F;
    }
    else if(info[m][j].F <= ts && te <= info[m][j].S ){
      total += te - ts;
    }
    else if(info[m][j].F <= ts && ts <= info[m][j].S && info[m][j].S <= te){
      total += info[m][j].S - ts;
    }
    else if(ts <= info[m][j].F && info[m][j].F <= te && te <= info[m][j].S){
      total += te - info[m][j].F;
    }
    else if((te < info[m][j].F) || (ts > info[m][j].S)){
      //  cout << "MISS!" << endl;
    }
    else assert(false);
      }
 
      cout << total << endl;
    }
 
 
  }
 
return 0;
}

Measured memory_bytes: 7948
#include <bits/stdc++.h>
using namespace std;
int k, a[111], d[100001], n;
int main() {
	for(int i = 1; i <= 100000; i <<= 1) d[i] = 1;
	cin >> n; 
	if(d[n]) {printf("No\n"); return 0;} 
	printf("Yes\n");
	printf("1 2\n2 3\n3 %d\n%d %d\n%d %d\n", n + 1, n + 1, n + 2, n + 2, n + 3);
	for(int i = 4; i < n; i += 2){
		printf("%d %d\n", i, 1 + n); printf("%d %d\n", i + 1, 1 + n);
		printf("%d %d\n", i + n, i + 1); printf("%d %d\n", i + n + 1, i);
	}
	if(n % 2 == 0){
		for(int i = 2; i <= n; i++){
			int p = i ^ 1 ^ n;
			if(p < n && p > 1) {
				if(i == 2) printf("%d %d\n", i + n, n);
				else printf("%d %d\n", i, n);
				printf("%d %d\n", p, n + n);
				return 0;
			}
		}
	}
}


Measured memory_bytes: 2816
import sys
sys.setrecursionlimit(10 ** 7)
INF = 1<<60
from heapq import heappush, heappop

V, E, r = map(int, input().split())
G = [[] for _ in range(V)]
for _ in range(E):
    f, t, c = map(int, input().split())
    G[f].append((t, c))

dist = [INF]*V
dist[r] = 0

q = [(0,r)] # cost, root
while q:
    cost, v = heappop(q)
    for to, c in G[v]:
        sum_C = cost + c
        if sum_C < dist[to]:
            dist[to] = sum_C
            heappush(q,(sum_C, to))

for c in dist:
    print(c if c<INF else "INF")





Measured memory_bytes: 89288
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

vector<bool> seen;

void dfs(vecveci &G, int v) {
    seen[v] = true;
    for(int w : G[v]) {
        if(seen[w]) continue; 
        dfs(G,w);
    }
}

int main() {
    int N,M;
    cin >> N >> M;
    vector<P> res(M);
    int ans = 0;

    REP(i,M) {
        int a,b; cin >> a >> b;
        a--;b--;
        res[i] = P(a,b);
    }

    REP(i,M) {
        vecveci G(N);
        REP(j,M) {
            if(i != j) {
                int a = res[j].first;
                int b = res[j].second;
                G[a].push_back(b);
                G[b].push_back(a);
            }
        }
        /*
        cout << endl;
        REP(i,N) {
            cout << "{";
            for(int v:G[i]) cout << v << " ";
            cout << "}" << endl;
        }
        cout << endl;
        */
        seen.assign(N,false);
        int cnt = 0;
        REP(v,N) {
            if(seen[v]) continue;
            dfs(G,v);
            cnt++;
        }
        if(cnt > 1) ans++; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define		vii 			vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
#define     test(i)        cout<<i<<endl
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
const int mxN=3e3+5,oo=0x3f3f3f3f,mod=1e9+7;
int n;
double arr[mxN];
double dp[mxN][mxN];
double go(int idx,int cnt){
    if(idx==n){
        return (n+1)/2<=cnt?1:-5;
    }
    double &ret=dp[idx][cnt];
    if(ret==ret)
        return ret;
    return ret=max(go(idx+1,cnt+1)*arr[idx],0.0)+max(go(idx+1,cnt)*(1-arr[idx]),0.0);
}
void solve(){
   cin>>n;
   loop(n,i,0)
    cin>>arr[i];
   mem(dp,-1.0);
   cout<<fixed<<setprecision(10)<<go(0,0)<<endl;
}
int main() {
    fast();
    solve();
}


Measured memory_bytes: 71040
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        double[] a = new double[n];
        double b = 0;
        for(int i = 0; i < n; i++){
            a[i] = scan.nextInt();
        }
        for(int i = 0; i < n; i++){
            b += 1 / a[i];
        }
        System.out.println((double)1 / b);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;

    string ans = "";
    rep(i, dx) ans+='R';
    rep(i, dy) ans+='U';
    rep(i, dx) ans+='L';
    rep(i, dy) ans+='D';
    ans+='D';
    rep(i, dx+1) ans+='R';
    rep(i, dy+1) ans+='U';
    ans+='L';    
    ans+='U';
    rep(i, dx+1) ans+='L';
    rep(i, dy+1) ans+='D';
    ans+='R';
    
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <map>
#include <ctime>
#include <queue>

/*ゴール状態をそれぞれ
0 1 2
3 4 5
6 7 *

0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 *
とする
 */
int n;
struct Hairetu{
	char array[4][4];
	bool operator< (const Hairetu &a) const{
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				if(array[i][j] == a.array[i][j]) continue;
				return array[i][j] < a.array[i][j];
			}
		}
		return false;
	}
};
Hairetu a;
std::map<Hairetu,bool> mp;

void init(){
	int N = n*n;
	std::vector<bool> use(N,false);
	int now = 0;
	while(now < N){
		int x = rand() % N;
		if(!use[x]){
			a.array[now/n][now%n] = x;
			use[x] = true;
			now++;
		}
	}
}

bool goal(){
	bool res = true;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(a.array[i][j] != i*n+j) res = false;
		}
	}
	return res;
}

void print(){
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++) std::cout << a.array[i][j] << " ";
		std::cout << "\n";
	}
}

int h(int mode){
	if(mode == 0) return 0;
	int res = 0;
	if(mode == 1){
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				if(a.array[i][j]==n*n-1) continue;
				if(a.array[i][j] != i*n+j) res++;
			}
		}
	}else if(mode == 2){
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				if(a.array[i][j]==n*n-1) continue;
				int y = a.array[i][j]/n;
				int x = a.array[i][j]%n;
				res += abs(y-i) + abs(x-j);
			}
		}
	}else{
		return 1<<30;
	}
	return res;
}

int f(int mode, int g){
	return h(mode) + g;
}


bool in(int y, int x){
	return 0 <= y && y < n && 0 <= x && x < n;
}

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

struct dat{
	int f,g;
	Hairetu vec;
	bool operator< (const dat &d) const {
		return f > d.f;
	}
};

int search(int mode){
	std::priority_queue<dat> pq;
	pq.push({f(mode,0),0,a});
	mp[a] = f(mode,0);
	while(!pq.empty()){
		auto p = pq.top(); pq.pop();
		a = p.vec;
		if(goal()) return p.g;
		int y,x;
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				if(a.array[i][j] == n*n-1){
					y = i; x = j; break;
				}
			}
		}
		for(int i=0; i<4; i++){
			int ny = y + dy[i];
			int nx = x + dx[i];
			if(!in(ny,nx)) continue;
			std::swap(a.array[ny][nx], a.array[y][x]);
			if(mp.find(a) != mp.end()){
				std::swap(a.array[ny][nx], a.array[y][x]);
				continue;
			}
			int cost = f(mode, p.g + 1);
			mp[a] = true;
			pq.push({cost, p.g + 1, a});
			std::swap(a.array[ny][nx], a.array[y][x]);
		}
	}
	return -1;
}


signed main(){
	//srand(unsigned(time(NULL)));
	int mode = 2;
	n = 4;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			int c; std::cin >> c;
			a.array[i][j] = c - 1;
			if(a.array[i][j] < 0) a.array[i][j] += 16;
		}
	}
	//std::cin >> n >> mode;
	//cin >> n;
	//init();
	std::cout << search(mode) << "\n";
}


Measured memory_bytes: 140904
import random
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(D)]
t = [0] * D
for i in range(D):
    r=((i+1)%26)+1
    t[i] = r
 
    
M=22*10*2
day=[random.randint(1,365) for i in range(M)]
q=[random.randint(1,26) for i in range(M)]
    
m=[0]*D
 
a=[[0 for i in range(26)] for j in range(D)]
R=[[0 for i in range(26)] for j in range(D)]
for u in range(D):
    i=t[u]
    for y in range(u,D):
        a[y][i-1]=u+1
    if u==0:
        m[u]=s[u][i-1]
    else:
        m[u]=m[u-1]+s[u][i-1]
mm=[0]*D
for d  in range(D):
    for i in range(26):
        mm[d]+=c[i]*(d+1-a[d][i])
    if not d==0:
        mm[d]+=mm[d-1]
for d in range(D):
    m[d]-=mm[d]
mmm=m[D-1]
 
 
 
for p in range(M):
    new_type=q[p]
    old_type=t[day[p]-1]
    #print(new_type,old_type)
    A=0
    B=0
    C=0
    C=s[day[p]-1][old_type-1]-s[day[p]-1][new_type-1]
    for d in range(D):
        A+=c[new_type-1]*(d+1-a[d][new_type-1])+c[old_type-1]*(d+1-a[d][old_type-1])
    xday=day[p]
    R=a
    if xday>1:
        before_new=a[xday-2][new_type-1]
        before_old=a[xday-2][old_type-1]
        now_new=a[day[p]-1][new_type-1]
        now_old=a[day[p]-1][old_type-1]
        for d in range(day[p]-1,D):
            if a[d][new_type-1]==now_new:
                a[d][new_type-1]=xday
            if a[d][old_type-1]==now_old:
                a[d][old_type-1]=before_old
    else:
        for d in range(day[p]-1,D):
            if a[d][old_type-1]==1:
                a[d][old_type-1]=0
            if a[d][new_type-1]==0:
                a[d][new_type-1]=1   
    t[day[p]-1]=new_type
    for d in range(D):
        B+=c[new_type-1]*(d+1-a[d][new_type-1])+c[old_type-1]*(d+1-a[d][old_type-1])
    T=mmm-(B-A+C)
    if T>mmm:
        mmm=T
    else:
        a=R
    #print(mmm)
for i in range(len(t)):
    print(t[i])

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll A, B; cin >> A >> B;
  cout << A * B << endl;

  return 0;
}



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

using namespace std;
const int N = 2e5+100;
struct node{
    long long a,b;
}s[N];
bool cmp(node a,node b){
    return a.a>b.a;
}
long long L[N],R[N];
long long minnore[N];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>L[i]>>R[i];
    long long maxx=0;long long minn=1e18;
    int p,q;
    long long maxxlength=0;
    for(int i=1;i<=n;i++){
        if(L[i]>maxx){
            maxx=L[i];
            p=i;
        }
        if(R[i]<minn){
            q=i;
            minn=R[i];
        }
        maxxlength=max(maxxlength,R[i]-L[i]+1);
    }
    long long ans1=maxxlength+(minn>=maxx?minn-maxx+1:0);
    for(int i=1;i<=n;i++){
        s[i].a=max(R[i]-maxx+1,0LL);
        s[i].b=max(minn-L[i]+1,0LL);
    }
  //  for(int i=1;i<=n;i++) cout<<i<<' '<<s[i].a<<' '<<s[i].b<<endl;
    sort(s+1,s+n+1,cmp);
    minnore[n+1]=(1e18);
    for(int i=n;i>=1;i--) minnore[i]=min(minnore[i+1],s[i].b);
    long long ans2=0;
    for(int i=1;i<=n-1;i++){
        ans2=max(ans2,s[i].a+minnore[i+1]);
    }
    cout<<max(ans1,ans2)<<endl;
    return 0;
}


Measured memory_bytes: 5760
/*Lucky_Glass*/
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    scanf("%lld",&n);
    long long ans=n-1;
    for(long long i=1;i*i<=n;i++)
        if(n%i==0)
            ans=min(ans,i+n/i-2);
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

int main() {
	int n;
	long long T, ans = 0;
	vector<long long> t;
	cin >> n >> T;
	t.resize(n);
	for (int i = 0; i < n; i++)
		cin >> t[i];
	for (int i = 1; i < n; i++) {
		ans += min(T, t[i] - t[i - 1]);
	}
	ans += T;
	cout << ans << endl;
//	cin >> n;
	return 0;
}

Measured memory_bytes: 1792
while(True):
    a,b,c = map(str,input().split())
    if b == "?":
        break
    else:
        if b == "+":
            print(int(a)+int(c))
        elif b == "-":
             print(int(a)-int(c))
        elif b == "*":
             print(int(a)*int(c))
        elif b == "/":
             print(int(a)//int(c))


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
int main() 
{
  int n;
  cin>>n;
  
  int inclass[n],order[n];
  for(int i=0;i<n;i++)
  {
   	order[i]=0; 
  }
  for(int id=0;id<n;id++)
  {
   	 cin>>inclass[id];
    
    order[inclass[id]-1]=id+1;
  }
  for(int i=0;i<n;i++)
  {
   	cout<<order[i]<<" "; 
  }
  cout<<endl;
  
  
  
  return 0;
  
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int main() {
    int m1, m2, d1, d2; cin >> m1 >> d1 >> m2 >> d2;
    if (d1 > d2) {
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np


def pd(s):
    # print(s)
    pass


# input
H, W, M = map(int, input().split())
ms = [
    [int(i) for i in input().split()]
    for m in range(M)
]
pd(f"{H=} {W=} {M=}")
pd(f"{ms=}")

rows = [0]*(H+1)
cols = [0]*(W+1)
bombs = {}
for m in ms:
    h = m[0]
    w = m[1]
    rows[h] += 1
    cols[w] += 1
    bombs[f"{h},{w}"] = True

rmax = max(rows)
cmax = max(cols)
rmax_hs = [i for i, v in enumerate(rows) if v == rmax]
cmax_wh = [i for i, v in enumerate(cols) if v == cmax]

for h in rmax_hs:
    for w in cmax_wh:
        if f"{h},{w}" not in bombs:
            print(rmax + cmax)
            exit()
print(rmax + cmax - 1)


Measured memory_bytes: 134732
def Kyu_in_atcoder():
    score = int(input())
    if score >= 1800:
        print(1)
    elif score >= 1600:
        print(2)
    elif score >= 1400:
        print(3)
    elif score >= 1200:
        print(4)
    elif score >= 1000:
        print(5)
    elif score >= 800:
        print(6)
    elif score >= 600:
        print(7)
    elif score >= 400:
        print(8)


def main():
	Kyu_in_atcoder()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
#include<bits/stdc++.h>
#define ll long long
const double PI= 3.141592653589793238;
using namespace std;
const int mxn=2*100005;
const ll mod=1e9+7;
void solve()
{	
	
	ll n,k;cin>>n>>k;
	ll sum=0;
	for(int i=k;i<=n+1;i++)
	{
		sum+=+(n-i+1)*i+1;
		sum=sum%1000000007;
	}
	cout<<sum<<endl;
}
int main()
{
	//int t;cin>>t;
	//while(t--)
	solve();
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

void Main() {
  Cin(int, n);
  for (int x = 111; x <= 999; x += 111) {
    if (x >= n) {
      cout << x << endl;
      return;
    }
  }
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  string s;
  cin >> s;
  int n = s.size();
  vi32 cnt(4, false);
  rep(i, n) {
    switch (s[i]) {
      case 'N': cnt[0] = true; break;
      case 'W': cnt[1] = true; break;
      case 'S': cnt[2] = true; break;
      case 'E': cnt[3] = true; break;
    }
  }
  if (cnt[0] != cnt[2] || cnt[1] != cnt[3]) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main() {
  long n,m,a,ans=0;
  cin >> n >> m;
  priority_queue<long> q;
  for(int i=0;i<n;i++) {
    cin >> a;
    q.push(a);
  };

  for(int i=0;i<m;i++) {
    q.push(q.top()/2);
    q.pop();
  };

  for(int i=0;i<n;i++) {
    ans+=q.top();
    q.pop();
  };

  cout << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
 int N,M;cin>>N>>M;vi a(M),b(M);rep(i,M)cin>>a[i]>>b[i];
  set<int> one,n;
  rep(i,M){
    if(a[i]==1)one.insert(b[i]);
    if(b[i]==N)n.insert(a[i]);
  }
  bool ok=false;
  for(auto x:n){
   if( one.count(x)){
     ok=true;
     break;         
   }
  }
  if(ok)cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  
    
}





Measured memory_bytes: 11136
#include <stdio.h>
#define LEN 100

int main(void){
	char s[LEN+1];
	char ss[LEN*2+1];
	char p[LEN+1];
	
	scanf("%s", s);
	scanf("%s", p);
	
	strcpy(ss, s);
	strcat(ss, s);
	
	if(strstr(ss, p) != NULL){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	int n, k;
	cin >> n >> k;
	int arr[n];
	ll dp[n];
	for(int i=0; i<n; i++) cin >> arr[i];
	dp[0] = 0;
	for(int i=1; i<n; i++) dp[i] = 1LL*INT_MAX*INT_MAX;
	for(int i=0; i<n; i++){
		for(int j=1; j<=k; j++){
			if(i+j >= n) break; 
			dp[i+j] = min(dp[i+j],dp[i]+abs(arr[i]-arr[i+j]));
		}
	}
	cout << dp[n-1];
	/*dp[1] = abs(arr[1]-arr[0]);
	
	for(int i=2; i<n; i++){
		dp[i] = min(dp[i-1] + abs(arr[i]-arr[i-1]),dp[i-2] + abs(arr[i]-arr[i-2]));
	}
	cout << dp[n-1];*/
	return 0;
}

Measured memory_bytes: 4756
package main

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

func main() {
	fsc := NewFastScanner()
	N := fsc.NextInt()
	A := fsc.NextInt()
	fmt.Println(N*N - A)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

func (s *FastScanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
n,A,B,C = map(int, input().split())
l = [int(input()) for _ in range(n)]

def dfs(dep, a,b,c):
    if dep == n:
        return abs(a-A) + abs(b-B) + abs(c-C) if min(a,b,c) > 0 else 10**8
    re0 = dfs(dep+1, a,b,c)
    re1 = dfs(dep+1, a+l[dep], b,c) + (10 if a != 0 else 0)
    re2 = dfs(dep+1, a, b+l[dep],c) + (10 if b != 0 else 0)
    re3 = dfs(dep+1, a, b, c+l[dep]) + (10 if c != 0 else 0)
    return min(re0, re1, re2, re3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include<stdio.h>
#define N 100

int main(){
  int a,b[N],i,j,k,key=0;
  scanf("%d",&a);

  for(i = 0; i < a; i++)
    scanf("%d",&b[i]);
  
  for(i = 1; i < a; i++){
    for(k = 0; k < a-1; k++)
      printf("%d ",b[k]);

    printf("%d\n",b[a-1]);
    
    key = b[i];
    j = i-1;

    while(j >= 0 && b[j] > key){
      b[j+1] = b[j];
      j--;
    }
    
    b[j+1] = key;
    
  }

  for(k = 0; k < a-1; k++)
    printf("%d ",b[k]);
  
  printf("%d\n",b[a-1]);
  
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
const int MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    char c;
    cin >> c;
    char c2 = 'A';
    if(c == 'A') c2 = 'T';
    if(c == 'T') c2 = 'A';
    if(c == 'C') c2 = 'G';
    if(c == 'G') c2 = 'C';
    cout << c2 << endl;
    return 0;
}

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

using namespace std;

long long f(long long a, long long b) {
	long long tmp = a % b;
	if (tmp == 0)return b;
	f(b, tmp);
}

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

	long long a, b, c, d;
	cin >> a >> b >> c >> d;

	long long lcm = c / f(max(c, d), min(c, d)) * d;

	long long num1 = b / c - (a - 1) / c;
	long long num2 = b / d - (a - 1) / d;
	long long num3 = b / lcm - (a - 1) / lcm;

	cout << (b - (a - 1)) - (num1 + num2 - num3) << endl;

	return 0;

}

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

int n ;
long long tmp ;
int h[100000] ;
long long dp[100000]={} ;
	
/*int abs(int a ,int b)
	{
	if(a>b)
		return a-b ;
	return b-a ;
	}*/
	
int main()
	{
	cin>>n ;
	for(int k=0 ;k<n ;k++)
		cin>>h[k] ;
	dp[1]=abs(h[1]-h[0]) ;
	for(int j=2 ;j<n ;j++)
		{
		dp[j]=min(dp[j-2]+abs(h[j]-h[j-2]),dp[j-1]+abs(h[j]-h[j-1])) ;
		}
	cout<<dp[n-1]<<endl ;
	}

Measured memory_bytes: 1408
import sys
input = lambda: sys.stdin.readline().rstrip()

N,M,Q = map(int, input().split())

ls = [[0]*(N+1) for _ in range(N+1)]

for i in range(M):
    L,R = map(int, input().split())
    ls[L][R] += 1

for i in range(1, N+1):
    for j in range(1, N+1):
        ls[i][j] += ls[i-1][j] + ls[i][j-1] - ls[i-1][j-1]


for _ in range(Q):
    p,q = map(int, input().split())
    print(ls[q][q] - ls[p-1][q] - ls[q][p-1] + ls[p-1][p-1])

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

#define int long long

#define rep(i, n) for (signed i = 0; i < signed(n); i++)
#define REP(i, s, n) for (signed i = signed(s); i < signed(n); i++)
#define rrep(i, n) for (signed i = signed(n) - 1; i >= 0; i--)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, const T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

void calc() {
	int N, A, B; cin >> N >> A >> B;
	int C = A - B;
	int l = -1, r = 1e9 / B + 2;
	V h(N); input(h);
	auto ok = [&](int x) {
		int sum = 0;
		rep(i, N) {
			int res = h[i] - B * x;
			sum += res > 0 ? (res - 1) / C + 1 : 0;
		}
		return sum <= x;
	};
	while (l + 1 < r) {
		int mid = (l + r) / 2;
		if (ok(mid)) r = mid;
		else l = mid;
	}
	cout << r << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	calc();
#ifdef _MSC_VER
	system("pause");
#endif
}

Measured memory_bytes: 1024
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

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

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	string s; cin >> s;
	int n = s.size();
	vector<vector<int>> dp(n + 1, vector<int>(13));
	dp[0][0] = 1;
	int MOD = 1e9 + 7;
	rep(i, n)
	{
		rep(j, 13)
		{
			if (s[i] == '?')
			{
				rep(k, 10)
				{
					int d = j * 10 + k;
					d %= 13;
					dp[i + 1][d] += dp[i][j];
					dp[i + 1][d] %= MOD;
				}
			}
			else
			{
				int d = j * 10 + (s[i] - '0');
				d %= 13;
				dp[i + 1][d] += dp[i][j];
				dp[i + 1][d] %= MOD;
			}
		}
	}
	cout << dp[n][5] << endl;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define io ios_base::sync_with_stdio(0);cin.tie(0);
#define mod 1000000007
#define pi 2*acos(0)
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
using namespace std;



int main()
{

	io;
	
	string s; cin >> s;
	auto it = s.end();
	it--;
	if (*it == 's') cout << s << "es";
	else cout << s << "s";
	
}



Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <utility>

int main() {
		
	// recieve |V| and |E|
	int V, E; std::cin >> V >> E;
	std::vector<std::vector<std::pair<int, int>>> G(V);
	
	for(int i = 0; i < E; i++) {
		// recieve edges
		int u, v, d; std::cin >> u >> v >> d;
		u--; v--;
		G[u].push_back({v, d});
		G[v].push_back({u, d});
	}

	// calc cost
	std::vector<std::vector<int>> D(V,std::vector<int>(V));
	for(int i = 0; i < V; i++){
		for(int j = 0; j < V; j++){
			D[i][j] = 999999999;
		}
		std::vector<bool> flag(V);
		D[i][i] = 0;
		for(int j = 0; j < V; j++){
			int minnode = -1;
			int mincost = 999999999;
			for(int k = 0; k < V; k++){
				if(flag[k]==false && D[i][k] < mincost){
					minnode = k;
					mincost = D[i][k];
				}
			}
			flag[minnode] = true;
			for(int k = 0; k < G[minnode].size(); k++){
				if(D[i][minnode]+G[minnode][k].second < D[i][G[minnode][k].first]){
					D[i][G[minnode][k].first] = D[i][minnode]+G[minnode][k].second;
				}
			}
		}
	}
	//for(int i = 0; i < V; i++){
	//	for(int j = 0; j < V; j++){
	//		std::cerr << D[i][j] << " ";
	//	}
	//	std::cerr << std::endl;
	//}
	
	int Tmax; std::cin >> Tmax;
	
	std::vector<std::pair<int, int>> ORDER;
	
	int nowNode = 0;
	int targetNode = 0;
	int remainDist = 0;

	// recieve info
	for(int i = 0; i < Tmax; i++) {
		int Nnew; std::cin >> Nnew;
		for(int j = 0; j < Nnew; j++) {
			int new_id, dst; std::cin >> new_id >> dst;
			dst--;
			ORDER.push_back({0, dst});
		}
		int ans = -1;
		if(remainDist == 0){
			nowNode = targetNode;
			int mintarget = -1;
			int mincost = 999999999;
			for(int j = 0; j < ORDER.size(); j++){
				if(ORDER[j].first == 1 && nowNode == ORDER[j].second){
					ORDER[j].first = 2;
				}
				if(nowNode == 0 && ORDER[j].first == 0){
					ORDER[j].first = 1;
				}
				if(ORDER[j].first == 1){
					if(D[nowNode][ORDER[j].second] < mincost){
						mintarget = ORDER[j].second;
						mincost = D[nowNode][ORDER[j].second];
					}
				}
			}
			if(mintarget == -1 && nowNode > 0){
				mintarget = 0;
			}
			int minNextCost = 999999999;
			if(mintarget >= 0){
				for(int j = 0; j < G[nowNode].size(); j++){
					if(D[G[nowNode][j].first][mintarget] < minNextCost){
						ans = G[nowNode][j].first + 1;
						targetNode = ans - 1;
						remainDist = G[nowNode][j].second - 1;
						minNextCost = D[G[nowNode][j].first][mintarget];
					}
				}
			}
		} else {
			ans = targetNode + 1;
			remainDist--;
        }
		std::cout << ans << std::endl;
		//std::cerr << nowNode << " " << targetNode << " " << remainDist << std::endl;
	}

  // insert your code here to get more meaningful output
	// all stay
//	for(int i = 0; i < Tmax; i++) std::cout << -1 << std::endl;
	return 0;
}

Measured memory_bytes: 1024
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,ans=0; cin>>n; 
    int a[n],mn=1000;
    for (int i=0;i<n;i++){
        cin >> a[i];
        if (a[i]>0) mn = min(a[i],mn);
    }
    while (true){
        int c=1000,ok=1,fl=0;
        for (int i=0;i<n;i++){
            if (a[i]==0) ok=1;
            else  {
                if (ok) ans += mn;
                a[i] -= mn,ok=0; 
                if (a[i]>0) c=min(c,a[i]),fl=1;
            }
        }
        mn=c; 
        if (fl==0) break;
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3632