akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <iomanip>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

const int N = 100 + 1;

int arr[N][N];

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    int n, m;
    cin >> n >> m;
    int h;
    cin >> h;
    vector <int> a(h);
    for (int i = 0; i < h; i++)
    {
        cin >> a[i];
    }
    int sz = 0;
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0)
        {
            for (int j = 0; j < m; j++)
            {
                if (a[sz] == 0)
                {
                    sz++;
                }
                arr[i][j] = sz + 1;
                a[sz]--;
            }
        }
        else
        {
            for (int j = m - 1; j >= 0; j--)
            {
                if (a[sz] == 0)
                {
                    sz++;
                }
                arr[i][j] = sz + 1;
                a[sz]--;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cout << arr[i][j] << ' ';
        }
        cout << '\n';
    }
}


Measured memory_bytes: 384
import sys
import collections
#
# class UnionFind():
#     def __init__(self,n):
#         self.par = [i for i in range(n+1)]
#         self.rank = [0 for _ in range(n+ 1)]
#     def find(self,x):
#         if self.par[x] == x:
#             return x
#         self.par[x] = self.find(self.par[x])
#         return  self.par[x]
#
#     def same_check(self,a,b):
#             return self.find(a) == self.find(b)
#
#     def union(self,x,y):
#         if self.rank[x] > self.rank[y]:
#             self.par[y] = self.par[x]
#         else:
#             self.par[x] = self.par[y]
#             if self.rank[x] == self.rank[y]:
#                 self.rank[x] += 1

class UnionFind:
    def __init__(self, size):
        self.parent = [-1] * (size + 1)  # 非負なら親ノード，負ならグループの要素数

    def root(self, x):  # root(x): xの根ノードを返す．
        if self.parent[x] < 0:
            return x
        elif self.parent[self.parent[x]] < 0:
            return self.parent[x]
        else:
            self.parent[x] = self.root(self.parent[x])  # xをxの根に直接つなぐ
            return self.parent[x]

    def merge(self, x, y):  # merge(x,y): xのいるグループと$y$のいるグループをまとめる
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.parent[x] > self.parent[y]:  # xの要素数がyの要素数より「小さい」とき入れ替える
            x, y = y, x
        self.parent[x] += self.parent[y]  # xの要素数を更新
        self.parent[y] = x  # yをxにつなぐ
        return True

    def issame(self, x, y):  # same(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)

    def size(self, x):  # size(x): xのいるグループの要素数を返す
        return -self.parent[self.root(x)]


def do():
    sys.setrecursionlimit(100000000)

    N,K,L = list(map(int, input().split(" ")))
    querys1 = [list(map(int, input().split(" "))) for i in range(K)]
    querys2 = [list(map(int, input().split(" "))) for i in range(L)]
    uf1 = UnionFind(N + 1)
    uf2 = UnionFind(N + 1)
    for query in querys1:
        a,b= query
        uf1.merge(a,b)
    for query in querys2:
        a, b = query
        uf2.merge(a, b)
    di = collections.defaultdict(lambda :0)
    for i in range(1,N+1):
        di[ (uf1.root(i),uf2.root(i))] += 1
    anss = []
    for i in range(1,N+1):

        anss.append( str(di[(uf1.root(i),uf2.root(i))]))
    print(" ".join(anss))

if __name__ == "__main__":
    do()

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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------
class MyClass         // 中身が空のクラス宣言
{
};
//main
//------------------------------------------
signed main(){
  int A, B;
  cin >> A >> B;

  int ans=0;
  if(A>B){
    ans+=A;
    A--;
  }else{
    ans+=B;
    B--;
  }

  if(A>B){
    ans+=A;
  }else{
    ans+=B;
  }
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<ll> A(N),cnt(N);
    for(int i=0;i<N;i++){
        int a;cin>>a;
        a--;
        A[i]=a;
        cnt[a]++;
    }
    
    ll ans=0;
    
    for(int i=0;i<N;i++){
        ans+=cnt[i]*(cnt[i]-1)/2;
    }
    
    for(int i=0;i<N;i++){
        int a=A[i];
        if(cnt[a]<=1) cout<<ans<<endl;
        else{
            ans-=cnt[a]*(cnt[a]-1)/2;
            ans+=(cnt[a]-1)*(cnt[a]-2)/2;
            
            cout<<ans<<endl;
            
            ans+=cnt[a]*(cnt[a]-1)/2;
            ans-=(cnt[a]-1)*(cnt[a]-2)/2;
        }
    }
}


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

class Dice{

private:

public:

  int num[6];

  void roll(char c){
    int b;
    if(c == 'S'){
      b = num[0];
      num[0] = num[4];
      num[4] = num[5];
      num[5] = num[1];
      num[1] = b;
    }
    if(c == 'W'){
      b = num[0];
      num[0] = num[2];
      num[2] = num[5];
      num[5] = num[3];
      num[3] = b;
    }
    if(c == 'N'){
      b = num[0];
      num[0] = num[1];
      num[1] = num[5];
      num[5] = num[4];
      num[4] = b;
    }
    if(c == 'E'){
      b = num[0];
      num[0] = num[3];
      num[3] = num[5];
      num[5] = num[2];
      num[2] = b;
    }
  }
};

bool isSame(Dice d1, Dice d2){
  int top = d1.num[0], front = d1.num[1];
  if(d2.num[2] == front || d2.num[3] == front) d2.roll('W');
  while(d2.num[1] != front) d2.roll('S');
  while(d2.num[0] != top) d2.roll('W');
  for(int i=2;i<6;i++){
    if(d1.num[i] != d2.num[i]) return false;
  }
  return true;
}
  
int main(){
  Dice d1, d2;
  for(int i=0;i<6;i++) cin >> d1.num[i];
  for(int i=0;i<6;i++) cin >> d2.num[i];
  if(isSame(d1, d2)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int dp[2][2001][2001];
 
int main() {
  string s;
  int m,ans=0;
  cin>>s>>m;
  string s1="UD",s2="LR";
  for(int l=0;l<2;l++) {
    for(int r=0;r<2;r++) {
      for(int i=0;i<=s.size();i++)for(int j=0;j<=m;j++)dp[0][i][j]=dp[1][i][j]=-(1<<29);
      dp[0][0][0]=dp[1][0][0]=0;
      for(int i=0; i<s.size(); i++) {
        for(int j=m; j>=0; j--) {
          if(s[i]=='U'||s[i]=='D') {
            dp[1][i+1][j]=dp[1][i][j];
            int x=1;
            if(s[i]==s1[(l+j)%2]) x=-1;
            dp[0][i+1][j]=max(dp[0][i+1][j],dp[0][i][j]+x);
            if(j<m) dp[0][i+1][j+1]=max(dp[0][i+1][j+1],dp[0][i][j]-x);
          } else {
            dp[0][i+1][j]=dp[0][i][j];
            int x=1;
            if(s[i]==s2[(r+j)%2]) x=-1;
            dp[1][i+1][j]=max(dp[1][i+1][j],dp[1][i][j]+x);
            if(j<m) dp[1][i+1][j+1]=max(dp[1][i+1][j+1],dp[1][i][j]-x);
          }
        }
      }
      for(int i=0;i<=m;i++)for(int j=m-i;j>=0;j--)ans=max(ans,dp[0][s.size()][i]+dp[1][s.size()][j]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 34480
import java.util.*;
public class Main{
  static double xp,yp,z,x1,y1;
  public static double[] w(double[] x, double[] y) {
	  x[2] = -x[2];
	  y[2] = -y[2];
	  z = (x[0] * y[1] )- (x[1] * y[0]);
	  x1 = +(y[1] * x[2]) - (x[1] * y[2]);
	  y1 = +(x[0] * y[2]) - (y[0] * x[2]);
	  return new double[] { (x1 / z), (y1 / z) };
	}
public static void main(String [] args){
	  Scanner cs = new Scanner(System.in);
	  double[] x = new double[4];
	  double[] y = new double[4];
	  while (cs.hasNextDouble()) {  {
	      for (int i = 0; i < 3; i++) {
	        x[i] = cs.nextDouble();
	        y[i] = cs.nextDouble();
	      }
	       xp = cs.nextDouble();
	       yp = cs.nextDouble();
	      for (int i = 0; i < 3; i++) {
	        x[i] -= xp;
	        y[i] -= yp;
	      }
	    }
	    double[] X = w(x, y);
	    if (X[0] >= 0 && X[1] >= 0) System.out.println("YES");
	   else System.out.println("NO");
	    }
	  }
	
	}

Measured memory_bytes: 23276
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int comp(char x[],char y[])
{
    //return strcmp(x,y);
    for(int i=0;i<12;i++){
    if(x[i]>y[i]){
        return 1;
    }else if(x[i]<y[i]){
        return -1;
    }
    }
}

int main(void)
{
    char a[100][13]={0};
    int n,p;

scanf("%d",&n);

for(int i=0;i<n;i++){
    scanf("%s%d",a[i],&p);
    a[i][12]=i;
    a[i][11]=-p;
}


for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
        if(comp(a[i],a[j])==1){
            char t[13];
            memcpy(t,a[i],13);
            memcpy(a[i],a[j],13);
            memcpy(a[j],t,13);
        }
    }
}
    for(int i=0;i<n;i++){
    printf("%d\n",a[i][12]+1);
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define x first
#define y second

int solve(vector<pair<int,int> >& p,
	  set<pair<int,int> >& sp,
	  int i, 
	  int j){
  int dx = p[j].x - p[i].x;
  int dy = p[j].y - p[i].y;
  pair<int,int> n1 = make_pair( p[j].x-dy, p[j].y+dx );
  pair<int,int> n2 = make_pair( p[i].x-dy, p[i].y+dx );
  if(sp.find(n1) != sp.end() && sp.find(n2) != sp.end() )
    return dx*dx + dy*dy;
  else 
    return 0;
}


int main(){
  while(1){
    int n; cin >> n;
    if(n==0)break;
    
    vector<pair<int,int> > point(n);
    set<pair<int,int> > sp;
    for(int i=0; i<n; i++){
      cin >> point[i].x >> point[i].y;
      sp.insert(point[i]);
    }

    sort(point.begin(),point.end());
    int ans=0;
    for(int i=0; i<n-1; i++){
      for(int j=i+1; j<n; j++){
	int tmp = solve(point,sp,i,j);
	ans = max(ans,tmp);
	//	cout << tmp << endl;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3212
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#define REP(i,n) for(ll(i)=0;(i)<(int)(n);(i)++)
#define REPN(i,n) for(int(i)=1;(i)<(int)(n);(i)++)
#define _abs(x) ((x)>0?(x):-(x))
#define ll  long long 
using namespace std;    
int main()
{
    ll n;
    cin>>n;
    ll c[n],v[n];
    ll x,y,sum=0;
    REP(i,n)
    {
        cin>>c[i];
    }
    REP(i,n)
    {
        cin>>v[i];
    }
    REP(i,n)
    {
        if(c[i]>v[i])
        {
                sum+=c[i]-v[i];
        }
    }
    cout<<sum<<endl;
           
    //system("pause");
    return 0;
} 

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

int main () {
  string S;
  cin >> S;
  
  int N;
  N=S.size();
  
  string s1 = S.substr(0, (N-1)/2);
  string s2 = S.substr((N+1)/2);
  
  if (s1==s2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
	int n,k,h[100100],dir = 2e9;
	cin >> n >> k;
	for(int i=0; i<n; i++){
		cin >> h[i];
	}
	sort(h,h+n);
	for(int i=0; i<n-k+1; i++){
		dir = min(dir, h[i + k -1] - h[i]);
	}
	cout << dir << endl;
	
	return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


def main():
    a,b,n=map(int,input().split())
    ans=0
    m=n
    ans=max(ans,(a*m)//b-a*(m//b))
    m=(n//b)*b-1
    m=max(m,0)
    # print(n,m)
    ans=max(ans,(a*m)//b-a*(m//b))
    print(ans)

# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 62688
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n;
	string s;
	cin >> n >> s;
	int r = 0,g = 0,b = 0;
	for(int i = 0;i < n;i++){
		if(s[i] == 'R') r++;
		else if(s[i] == 'G') g++;
		else b++;
	}
	int ans = r * g * b;
	for(int i = 0;i < n;i++){
		for(int j = 1;;j++){
			if(i - j < 0 || i + j >= n) break;
			if(s[i] != s[i - j] && s[i - j] != s[i + j] && s[i] != s[i + j]) ans--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    A += B;
    if (A % 2 == 0) {
        cout << A / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end() 
#define endl "\n"
#define int long long int
#define ll long long
#define ld long double
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
const int mod = 1000000007;
const int N=200005;
const int inf=1e18;
vector<vector<int>>adj(N);

bool isprime(int n){for(int i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
int factorial(int n){return (n==1 || n==0) ? 1:n*factorial(n-1);} 
int gcd(int a,int b){if (a==0)return b;return gcd(b%a,a);}
int lcm(int a,int b){return (a/gcd(a,b)*b);}
int max(int a,int b){int sol=a>b?a:b;return sol;}
int min(int a,int b){int sol=a<b?a:b;return sol;} 

void fun(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}


signed main(){
    flash;
    fun();
    int t=1;
    //cin>>t;
    while(t--){
        int n,m,x;
        cin>>n>>m>>x;
        int p;
        int cnt=0;
        for(int i=0;i<n;i++){
            cin>>p;
            if(p<x)
                cnt++;
        }
        cout<<min(cnt,abs(m-cnt));
    }
    return 0;
}

Measured memory_bytes: 7864
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define mod 1000000007
#define maxn 110
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buff[20],len; len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buff[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buff[--len]+'0');
}
inline void writeln(ll x)
{
	write(x); putchar('\n');
}
inline void writesp(ll x)
{
	write(x); putchar(' ');
}
int a[maxn];
int n,A,B;
int main()
{
	n=read();
	A=read(); B=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	int cnt0=0,cnt1=0,cnt2=0;
	for(int i=1;i<=n;i++)
		if(a[i]<=A)++cnt0;
		else if(a[i]<=B)++cnt1;
		else ++cnt2;
	writeln(std::min(std::min(cnt0,cnt1),cnt2));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>

using namespace std;
using boost::algorithm::split;
using boost::algorithm::join;
using boost::algorithm::replace_all;

typedef long long int lli;
typedef vector<int> iv;
typedef vector<bool> bv;
typedef vector<string> sv;
typedef vector<long long int> llv;
typedef vector<double> dv;

#define sor_(vec) sort(vec.begin(),vec.end())
#define rev_(vec) reverse(vec.begin(),vec.end())
#define rep(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define reps(i,n,s) for(int i=static_cast<int>(s);i<static_cast<int>(n);i++)
#define isposi(num) if(num>0)
const long long mod = 1000000007;
#define PI 3.141592653589793

template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
    static const char table[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string ret;
    static numeric_limits<TypeInt> t;
    TypeInt n = v;
    if (t.is_signed) {
        if (v < 0) n *= -1;
    }

    while (n >= base) {
        ret += table[n%base];
        n /= base;
    }
    ret += table[n];
    if (t.is_signed) {
        if (v < 0 && base == 10) ret += '-';
    }
    std::reverse(ret.begin(), ret.end());

    return ret;
}

void printm(char const *format,...){
    va_list arguments;
    va_start(arguments,format);
    unsigned index=0;
    while (format[index]!='\0') {
        if(format[index]=='%'){
            index++;
            if(format[index]=='d')printf("%d",va_arg(arguments, int));
            else if(format[index]=='c')printf("%c",va_arg(arguments, int));
            else if(format[index]=='x')printf("%x",va_arg(arguments,int));
            else if(format[index]=='o')printf("%o",va_arg(arguments,int));
            else if(format[index]=='f')printf("%f",va_arg(arguments, double));
            else if(format[index]=='s')printf("%s",va_arg(arguments, char const *));
            else if(format[index]=='p')printf("%p",va_arg(arguments,void*));
            else if(format[index]=='y')printf("Yes");
            else if(format[index]=='n')printf("No");
            else if(format[index]=='%')printf("%%");
            else assert(!"Unknown format with %.");
        }
        else printf("%c",format[index]);
        index++;
    }
    va_end(arguments);
    return;
}

struct Chara{
    int hp;
    int sp;
};
bool pairCompare(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{
    return firstElof.second > secondElof.second;
}

int main(void){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << std::setprecision(15);
    //
    unsigned long long n,buf,ans;
    bool flag=false;
    cin>>n>>ans;
    for(unsigned long long i=0;i<n-1;i++){
        cin>>buf;
        if(flag&&buf==0){cout<<"0";return 0;}
        else if(ans*buf>1000000000000000000||ans*buf/ans!=buf)flag=true;
        else ans*=buf;
    }
    if(flag)cout<<"-1";
    else cout<<ans;
    //
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>

int main(void) {
  int i;
  bool flg[26];
  char s[30];
  scanf("%s", s);
  for(i = 0; i < 26; ++i) flg[i] = true;
  if(strlen(s) == 26) {
    bool f = false;
    char c;
    for(i = 24; i >= 0; --i) {
      flg[s[i + 1] - 'a'] = false;
      if(s[i + 1] > s[i]) {
        c = s[i], f = false, s[i] = 0, f = true;
        break;
      }
    }
    if(f) {
      printf("%s", s);
      for(i = c - 'a'; i < 26; ++i) if(!flg[i]) {
        printf("%c", i + 'a');
        break;
      }
    } else printf("-1\n");
  } else {
    for(i = 0; i < strlen(s); ++i) flg[s[i] - 'a'] = false;
    printf("%s", s);
    for(i = 0; i < 26; ++i) if(flg[i]) {
      printf("%c", i + 'a');
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
class mairala
{
public:
    void solve()
    {
        int d, t, s;
        cin>>d>>t>>s;
        puts(s *t >= d ? "Yes" : "No");
    }
};

int main(void)
{
    mairala m;
    m.solve();
}


Measured memory_bytes: 3620
use std::io;
use std::io::prelude::*;
use std::collections::HashMap;

fn main() {
    let _ = get_line();
    let mut initials: HashMap<char, i64> = HashMap::new();
    for name in get_lines() {
        *initials.entry(name.chars().next().unwrap()).or_insert(0) += 1;
    }
    println!("{}", solve(&initials));
}

fn solve(initials: &HashMap<char, i64>) -> i64 {
    let nums: Vec<i64> = "MARCH"
        .chars()
        .map(|c| *initials.get(&c).unwrap_or(&0))
        .collect();
    let mut ans = 0;
    for a in 0..3 {
        for b in a + 1..4 {
            for c in b + 1..5 {
                ans += nums[a] * nums[b] * nums[c];
            }
        }
    }
    ans
}

fn get_lines() -> Vec<String> {
    let stdin = io::stdin();
    let lock = stdin.lock();
    let lines = lock.lines().map(|l| l.unwrap()).collect(); // for lifetime?
    lines
}

fn get_line() -> String {
    let mut inp = String::new();
    io::stdin().read_line(&mut inp).expect("read error");
    inp.trim().to_string()
}

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 







int main(){
int N;
cin >> N;
vector<int>A(N),B(N),C(N - 1);
REP(i, N) {
  cin >> A.at(i);
  A.at(i)--;
}
REP(i, N) cin >> B.at(i);
REP(i, N - 1) cin >> C.at(i);

int sum = 0;
int an = -10;
REP(i, N){
    sum += B.at(A.at(i));
    if(A.at(i) - 1 == an) sum += C.at(an);
    an = A.at(i);
}

print(sum);

}

Measured memory_bytes: 256
using System;
using System.Linq;

class C
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		int k = h[0], n = h[1];
		var a = Read();
		a = a.Append(k + a[0]).ToArray();
		Console.WriteLine(k - Enumerable.Range(0, n).Max(i => a[i + 1] - a[i]));
	}
}


Measured memory_bytes: 44696
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    int n;cin >> n;
    vector<int>d(n);
    rep(i,n){
        cin >> d[i];
    }
    int max=101;
    int cnt=0;
    
    sort(d.begin(),d.end());
    reverse(d.begin(),d.end());
    
    for(int x:d){
        if(x<max){
            max=x;
            cnt++;
        }
    }
    
    out(cnt);
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}


void Main()
{
	ll n,m,l,k; ll res=0;
	cin>>n>>k;
	VVI dp(n*2,VI(k+1,0));
	VI wei(n),val(n);
	rep(i, n) cin >> wei[i]>>val[i];
	//初期条件
	rep(i,k) dp[0][i]=0;
	rep(i,n){//すべての試行
		rep(w,k+1){//すべての重さw以下の場合の最大値を探索
			//価値[次の試行,重さ]＝最大( 価値[前の試行][重さ]+価値[重さ],価値[次の試行,重さ])
			if(w>=wei[i]) dp[i+1][w]=max(dp[i+1][w],dp[i][w-wei[i]]+val[i]);
			dp[i+1][w]=max(dp[i+1][w],dp[i][w]);
		}
	}
	res=MAX(dp[n]);
	cout << res << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 157824
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = n/(a+b)*a;
    ans += min(a, n%(a+b));
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
#include <ctype.h>

// 太郎と花子がカードゲームをする
// 二人はそれぞれn枚のカードを持っており、nターンの勝負を行う
// 各ターンではそれぞれ1枚ずつカードを出す
// カードにはアルファベットからなる動物の名前が書かれており、辞書順で大きいものがそのターンの勝者
// 勝者:3pt 引き分け:1pt
// Output: それぞれの最終得点

int main() {
    int iNumOfCards;        // 所持カード数
    int iTaroPoint = 0;     // 太郎のポイント
    int iHanakoPoint = 0;   // 花子のポイント
    int iCount;             // カウント変数
    int iStrIndex;          // 比較時のインデックス
    char szTaroCard[110];   // 太郎のカード
    char szHanakoCard[110]; // 花子のカード

    // In: 所持カード数
    scanf("%d", &iNumOfCards);

    // nターン行う
    for (iCount = 0; iCount < iNumOfCards; iCount++) {
        // 初期化
        iStrIndex = 0;
        // In: それぞれのカード
        scanf("%s %s", szTaroCard, szHanakoCard);
        // 最初に完全一致を判定
        if (strcmp(szTaroCard, szHanakoCard) == 0) {
            // 引き分け
            iTaroPoint++;
            iHanakoPoint++;
        }
        else {
            while (1) {
                if (szTaroCard[iStrIndex] > szHanakoCard[iStrIndex]) { // 太郎の勝ち
                    iTaroPoint += 3;
                    break;
                }
                else if (szTaroCard[iStrIndex] < szHanakoCard[iStrIndex]) { // 花子の勝ち
                    iHanakoPoint += 3;
                    break;
                }
                else {  // 一致
                    iStrIndex++; // 比較インデックスを移動
                }
            }
        }
    }

    // Out: それぞれの得点
    printf("%d %d\n", iTaroPoint, iHanakoPoint);

    return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

template <class T>
struct segment_tree{
    using func = function< T(T, T) >;
    int size;
    T ide;
    vector<T> data;
    func f = [](T a, T b){ return ((a>b)?a:b); };
    segment_tree(){}
    segment_tree(int n, T ide){
        init(n, ide);
    }
    segment_tree(const vector<T>& vec, T ide){
        init(vec, ide);
    }

    void init(int n, T ide){
        size = 1;
        while(size <= n) size *= 2;
        this->ide = ide;
        data.assign(size*2, ide);
    }

    void init(const vector<T>& vec, T ide){
        init(vec.size(), ide);
        for(int i=0;i<vec.size();i++) data[i+size-1] = vec[i];
        for(int i=size-2;i>=0;i--) data[i] = f(data[i*2+1], data[i*2+2]);
    }

    // data[index] <- val
    void update(int index, T val){
        index += size-1;
        data[index] = val;
        while(index > 0){
            --index /= 2;
            data[index] = f(data[index*2+1], data[index*2+2]);
        }
    }

    // return the answer for [lft, rit)
    T query(int lft, int rit){
        if(rit >= size){
            // cerr << "out of range" << endl;
            return ide;
        }
        lft += size-1;
        rit += size-1;
        vector< T > lhs, rhs;
        while(lft < rit){
            if(lft + 1 == rit){
                lhs.push_back(data[lft]);
                break;
            }
            if(lft%2 == 0) lhs.push_back(data[lft]);
            lft >>= 1;
            if(rit%2 == 0) rhs.push_back(data[--rit]);
            rit >>= 1;
        }
        while(!rhs.empty()){
            lhs.push_back(rhs.back());
            rhs.pop_back();
        }
        T res = lhs[0];
        for(int i=1;i<lhs.size();i++) res = f(res, lhs[i]);
        return res;
    }
};

int main(void){
    int n, k, ans = 0;
    cin >> n >> k;
    vector<int> a(n+1, -k-1), dp(n+1, 0);
    for(int i=1;i<=n;i++) cin >> a[i];
    segment_tree<int> st(300002, 0);
    for(int i=1;i<=n;i++){
        int l = max(0, a[i]-k), r = min(300000, a[i]+k);
        dp[i] = st.query(l, r+1) + 1;
        st.update(a[i], dp[i]);
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
}


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

int main(){
	int i, num[5];

	for(i = 0; i < 5; i++){
		cin >> num[i];
	}

	sort(num, num+5);
	for(i = 4; i > 0; i--){
		cout << num[i] << " ";
	}
	cout << num[0] << endl;

	return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll N; cin >> N;
  vector<vector<ll>> tri(1000);
  ll cnt = 1;
  for(ll i=0; i<1000; i++){
    for(ll j=0; j<=i; j++){
      tri[i].pb(cnt);
      cnt++;
      if(cnt>=100000) {
        i = 10000;
        break;
      }
    }
  }
  vector<ll> tris;
  ll a=1;
  while(1){
    ll mul = a*(a+1)/2;
    if(mul >= 100000) break;
    tris.pb(mul);
    a++;
  }

  for(int i=0; i<(int)tris.size(); i++){
    if(tris[i]==N){
      cout << "Yes" << endl;
      int onelen = i+1;
      int allnum = onelen+1;
      cout << allnum << endl;
      rep(j,allnum-1){
        cout << onelen;
        int start = j;
        int k=0;
        for(k=0; k<(int)tri[start].size(); k++){
          cout << " " << tri[start][k];
        }
        k--;
        rep(kk, onelen-k-1){
          cout << " " << tri[start+kk+1][k];
        }
        cout << endl;
      }
      cout << onelen;
      rep(j, onelen){
        cout << " ";
        cout << tri[j].back();
      }
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int N,K;
   cin >> N >> K;
   int t[N],d[N];
   for(int i=0;i<N;i++){
      cin >> t[i] >> d[i];
   }
   vector<pair<int,int>> v;
   for(int i=0;i<N;i++){
      v.push_back(make_pair(d[i],t[i]));
   }
   sort(v.begin(),v.end());
   reverse(v.begin(),v.end());
   long long tmp = 0;
   long long ans = 0;
   int can_be_deleted[N];
   int size = 0;
   set <int> S;
   for(int i=0; i<N;i++){
      int t = v[i].second;
      int d = v[i].first;
      //cout << t << ", "<< d << endl;
      if(S.find(t)==S.end()){
         if(i>=K){
            if(size==0){
               break;
            }
            else{
               //cout << "delete: "<< can_be_deleted[size-1]<<endl;
               tmp -= can_be_deleted[size-1];
               size--;
            }
         }
         S.insert(t);
         long long s = S.size();
         tmp -= (s-1)*(s-1);
         tmp += s*s;
         tmp += d;
      }
      else{
         if(i<K){
            can_be_deleted[size++]=d;
            tmp += d;
         }
      }
      ans = max(ans,tmp);
      //cout << i <<":" << ans << endl;
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
const int inf=1e9+1;
template <class T>
void print(T x){cout << x << '\n';}


const string YES = "Yes";
const string NO = "No";

void solve(long long a, long long b){
    string c = to_string(a)+to_string(b);
    int d = atoi(c.c_str());

    if(pow((int)sqrt((double)d), 2) == double(d))print(YES);
    else print(NO);


}

int main(){
  long long a;
  scanf("%lld",&a);
  long long b;
  scanf("%lld",&b);
  solve(a, b);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
    cin>>s;
    int num=stoi(s);
    int high=num/100;int low=num%100;
    if(high>0&&high<13){
        if(low>0&&low<13)cout<<"AMBIGUOUS"<<endl;
        else cout<<"MMYY"<<endl;
    }
    else if(low>0&&low<13){
        cout<<"YYMM"<<endl;
    }
    else{cout<<"NA"<<endl;}
}

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

map<pair<ll, ll>, ll> mp, mp2;

ll rec(ll L, ll R);
ll rec2(ll L, ll R);

ll rec(ll L, ll R) {
    ll mod = 1e9+7;
    if (L > R) return 0;
    if (L == R) return 1;
    if (L == 0 && R == 1) {
        return 2;
    }
    if (mp.find({L, R}) != mp.end()) return mp[{L, R}];
    
    ll res = 0;
    res += rec(L/2, (R-1)/2);
    res += rec2((L+1)/2, (R-1)/2);
    res += rec((L+1)/2, R/2);
    return mp[{L, R}] = res%mod;
}

ll rec2(ll L, ll R) {
    ll mod = 1e9+7;
    if (L > R) return 0;
    if (L == R) {
        if (R == 0) return 0;
        return 1;
    }
    if (L == 0 && R == 1) {
        return 1;
    }
    if (mp2.find({L, R}) != mp2.end()) return mp2[{L, R}];
    
    ll res = 0;
    res += rec(L/2, (R-1)/2);
    res += rec2((L+1)/2, (R-1)/2);
    res += rec2((L+1)/2, R/2);
    return mp2[{L, R}] = res%mod;
}

int main() {
    ll L, R;
    cin >> L >> R;
    cout << rec(L, R) << endl;
    return 0;
}

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

#define LL long long
LL n,bil,b=0,c=0,a=0;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	cin>>n;
    for(int i=1;i<=n;i++){
        cin>>bil;
        if(bil%4==0){
            a++;
        }else if(bil%2==0 && bil%4!=0){
            b++;
        }else{
            c++;
        }
    }
    if(abs(a)==abs(c-1) && abs(b)==0){
        cout<<"Yes"<<endl; 
    }else if(abs(a)<abs(c)){
        cout<<"No"<<endl;
    }else if(abs(a)==abs(c)){
        cout<<"Yes"<<endl;
    }else if(abs(a)>abs(c)){
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
#define pi 2*acos(0.0)
const int INF = 1e7;
const int mod = 1e9 + 7;

ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}

ll nCr(ll n,ll k){
   ll C[n + 1][k + 1];

   REP(i,0,n+1){
      REP(j,0,min(i,k)+1) {
         if(j==0 || j==i) {
            C[i][j] = 1;
         } else {
            C[i][j] = C[i-1][j-1] + C[i-1][j];
         }
      }
   }
   return C[n][k];
}

int main(){
   faster;
   //freopen("input.txt","r",stdin);
	 //freopen("output.txt","w",stdout);

   string s, t;
   cin >> s >> t;

   int n = s.size(); bool flag = 1;
   for(int i = 0; i < n; i++) {
      if(s[i] != t[i]) {
         flag = 0;
         break;
      }
   }

   if(!flag) p1("No");
   else p1("Yes");
}


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

int main(){
	
	long long n,mn,mx,sum=0;
	cin>>n;
	cin>>sum;
	mn=sum;
	mx=sum;
	for(long long i=1,t;i<n;i++){
		cin>>t;
		mn=min(mn,t);
		mx=max(mx,t);
		sum+=t;
	}
	cout<<mn<<" "<<mx<<" "<<sum<<endl;
	
	return 0;
}


Measured memory_bytes: 1160
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if b > a {
		a, b = b, a
	}
	if a == b {
		fmt.Println(a * 2)
	} else {
		fmt.Println(a*2 - 1)
	}
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    int S,n1,n10,n100,n1000;
    int flag=0;

    scanf("%d", &S);

    n1 = S %10;
    n10 = (S / 10) % 10;
    n100  = (S / 100) % 10;
    n1000  = (S / 1000);

    if(n1 == n10 || n10 == n100 || n100 == n1000) flag =1;

    if(flag == 1) printf("Bad\n");
    else printf("Good\n");
}


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int a,b,c;
  cin >>a>>b>>c;
  cout << min(a+b,min(b+c,c+a)) << endl;  
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
struct KDTree{
  class Node{
  public:
    int location;
    int p,l,r;
    Node(){}
  };
  class Point{
  public:
    int id,x,y;
    Point(){}
    Point(int id,int x,int y): id(id),x(x),y(y){}
    bool operator<(const Point &p)const{
      return id<p.id;
    }
    void print(){
      printf("%d\n",id);
    }
  };
  
  static const int NIL = -1;

  int N;
  vector<Point> P;
  vector<Node> T;
  int np;

  KDTree(){}
  KDTree(int N){init(N);}

  void init(int N_){
    N=N_;
    P.clear();
    T.clear();
    P.resize(N);
    T.resize(N);
  }
  
  static bool lessX(const Point &p1,const Point &p2){return p1.x<p2.x;}
  static bool lessY(const Point &p1,const Point &p2){return p1.y<p2.y;}
  
  int makeKDTree(int l,int r,int depth){
    if(!(l<r)) return NIL;
    int mid=(l+r)/2;
    int t = np++;
    if(depth%2==0){
      sort(P.begin()+l,P.begin()+r,lessX);
    }else{
      sort(P.begin()+l,P.begin()+r,lessY);
    }
    T[t].location=mid;
    T[t].l=makeKDTree(l,mid,depth+1);
    T[t].r=makeKDTree(mid+1,r,depth+1);
    return t;
  }
  
  void find(int v,int sx,int tx,int sy,int ty,int depth,vector<Point> &ans){
    int x=P[T[v].location].x;
    int y=P[T[v].location].y;
    if(sx<=x&&x<=tx&&sy<=y&&y<=ty){
      ans.push_back(P[T[v].location]);
    }
    if(depth%2==0){
      if(T[v].l!=NIL){
	if(sx<=x) find(T[v].l,sx,tx,sy,ty,depth+1,ans);
      }
      if(T[v].r!=NIL){
	if(x<=tx) find(T[v].r,sx,tx,sy,ty,depth+1,ans);
      }
    }else{
      if(T[v].l!=NIL){
	if(sy<=y) find(T[v].l,sx,tx,sy,ty,depth+1,ans);
      }
      if(T[v].r!=NIL){
	if(y<=ty) find(T[v].r,sx,tx,sy,ty,depth+1,ans);
      }
    }
  } 
};
int main(){
  int x,y;
  int N;
  scanf("%d",&N);
  KDTree kd(N);
  for(int i=0;i<N;i++) {
    scanf("%d %d",&x,&y);
    kd.P[i]=KDTree::Point(i,x,y);
    kd.T[i].l = kd.T[i].r = kd.T[i].p = kd.NIL;
  }
  kd.np=0;
  int root=kd.makeKDTree(0,N,0);

  int q;
  scanf("%d",&q);
  int sx,tx,sy,ty;
  vector<KDTree::Point> ans;
  for(int i=0;i<q;i++){
    scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
    ans.clear();
    kd.find(root,sx,tx,sy,ty,0,ans);
    sort(ans.begin(),ans.end());
    for(int j=0;j<(int)ans.size();j++){
      ans[j].print();
    }
    printf("\n");
  }
  
  return 0;
}

/*
verified on 2017/07/13
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_C&lang=jp
*/

Measured memory_bytes: 16236
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque> 
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype> 
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i=0; i<N; i++) {
        cin >> a.at(i);
    }
    int x=a.at(0);
    for (int i=0; i<N; i++) {
        if (x==2) {
            cout << i+1 << endl;
            return 0;
        }
        x=a.at(x-1);
    }
    cout << -1 << endl;
}

Measured memory_bytes: 1272
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

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

    int cur = 1;
    for(int i=0; i<n; i++){
        if(a[i] == cur){
            cur++;
        }
    }

    if(cur == 1) cout << -1 << endl;
    else cout << n - (cur - 1) << endl;

    return 0;
}

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

signed main(){
	int X, ans = 0;
	scanf("%d", &X);
	ans += X / 500 * 1000;
	X %= 500;
	ans += X / 5 * 5;
	printf("%d\n", ans);
	return 0;
}

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

int main() {
  ll n,x,count=0;
  cin >> n>>x;
  vector<int> v(n);
  r(i,n)cin >> v[i];
  r(i,n-1){   
  if(i==0&&v[0]>x){
    count+=v[0]-x;
    v[0]=x;
  }
    if(v[i]+v[i+1]>x){
      count+=v[i+1]+v[i]-x;
      v[i+1] = x-v[i];
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
  int n; cin >> n;
  int odd = 0;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    if(a % 2 == 1) odd++;
  }
  if(odd % 2 == 0)
    cout << "YES";
  else
    cout << "NO";
    
}

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

struct city{
    int num;
    int pre;
    int year;

    bool operator<(const city &right) const{
        return year < right.year;
    }
};

int main() {
    int N=0,M=0;
    cin >> N >> M;
    vector<city> c(M);
    for(int m=0; m<M; m++){
        int pr=0,ye=0;
        cin >> pr >> ye;
        city x = {m,pr,ye};
        c[m] = x;
    }
    sort(c.begin(),c.end());
 
    int prenum[N];
    string ans[M];
    memset(prenum,0,sizeof(prenum));
    for(int i=0; i<M; i++){
        int pre = c[i].pre;
        prenum[pre-1] = prenum[pre-1] + 1;
        ostringstream sout;
        sout << setfill('0') << setw(6) << pre;
        sout << setfill('0') << setw(6) << prenum[pre-1];
        string z = sout.str();
        ans[c[i].num] = z;
    }

    for(int i=0; i<M; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

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

long long MOD = 1e9 + 7;
int cnt[33];

int main() {
    int N; scanf("%d",&N);
    while(N--) {
        char c; scanf(" %c",&c);
        ++cnt[c - 'a'];
    }
    long long ans = 1;
    for(int i=0; i<26; i++) ans *= (cnt[i] + 1), ans %= MOD;
    printf("%lld", (ans - 1 + MOD) % MOD);
    return 0;
}


Measured memory_bytes: 256