akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int t[30];
int main() {
    ios_base::sync_with_stdio(0);
    int h, w;
    cin >> h >> w;
    char x;
    int ind = 0;
    for (int i = 0; i < h; i++) {
        for ( int j = 0; j < w; j++) {
            cin >> x;
            t[x - 'a']++;
        }
    }
    if ( h % 2 == 0 && w % 2 == 0) {
        for ( int i = 0; i <= 28; i++) {
            if ( t[i] % 4 != 0) {
                cout << "No";
                return 0;
            }
        }
        cout << "Yes";
        return 0;
    }
    if ( h % 2 != 0 && w % 2 != 0) {
        int cur1 = 0;
        int cur2 = 0;
        for ( int i = 0; i <= 28; i++) {
            if ( t[i] % 4 == 2) cur2++;
            if ( t[i] % 2 == 1) {
                    cur1++;
                    ind = i;
            }
        }
        if ( cur1 > 1) cout <<"No";
        else {
            if (t[ind] % 4 == 3 ) {
                cur2++;
            }
            if ( cur2 > h / 2 + w / 2) cout << "No";
            //else if ( cur2  % 2 != (h / 2 + w / 2) % 2) cout << "No";
            else cout << "Yes";
        }
        return 0;
    }
    int cur1 = 0; int cur2 = 0;
    if ( h % 2 != 0) swap(h, w);
    for ( int i = 0; i <= 28; i++) {
            if ( t[i] % 4 == 2) cur2++;
            if ( t[i] % 2 == 1) cur1++;
        }
    if ( cur1 > 0) cout << "No";
    else if ( cur2 > h / 2) cout << "No";
    //else if ( cur2 % 2 != (h / 2) % 2) cout << "No";
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
D = int(input())
C = list(map(int, input().split()))
S = [[] for _ in range(D)]
for i in range(D):
    S[i] = list(map(int, input().split()))

def based_b():
    last = [0 for _ in range(26)]
    for i in range(D):
        max_score = 0
        t = 0
        for contest in range(26):
            score = S[i][contest]
            d = i + 1
            last[contest] = d
            for x in range(26):
                score -= C[x] * (d - last[x])
            if max_score < score:
                t = contest
                max_score = score
        print(t+1)

based_b()

Measured memory_bytes: 69116
n = int(input())
#n, k = map(int,input().split())
#plst = [int(i) for i in input().split()]
if n == 1:
    print(int(input()))
else:
    lst = [int(input()) for _ in range(n)]

    def a(p, q):
        if p % q == 0:
            return q
        else:
            return a(q, p % q)

    f = lst[0] * (lst[1] // a(lst[0], lst[1]))
    for i in range(2, n):
        f = f * (lst[i] // a(f, lst[i]))
    print(f)

Measured memory_bytes: 3064
import static java.util.Arrays.deepToString;

import java.util.ArrayDeque;
import java.util.HashSet;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}
	
	Scanner sc = new Scanner(System.in);
	
	char[] goal = "0123456789ab0".toCharArray();
	int[] rs = {0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4};
	int[] cs = {2, 1, 2, 3, 0, 1, 2, 3, 4, 1, 2, 3, 2};
	int[] dr = {0, 1, 0, -1};
	int[] dc = {1, 0, -1, 0};
	
	int[][] rm = {
		{-1, -1, -1,-1, -1, -1, -1},
		{-1, -1, -1, 0, -1, -1, -1},
		{-1, -1,  1, 2,  3, -1, -1},
		{-1,  4,  5, 6,  7,  8, -1},
		{-1, -1,  9, 10, 11, -1, -1},
		{-1, -1, -1, 12, -1, -1, -1},
		{-1, -1, -1, -1, -1, -1, -1},
	};
	
	public void run() {
		for (;sc.hasNext();) {
			char[] s = new char[13];
			int x = sc.nextInt();
			if (x == -1) break;
			s[0] = toc(x);
			for (int i = 1; i < 13; i++) {
				s[i] = toc(sc.nextInt());
			}
			Set<String> vis = new HashSet<String>();
			vis.add(new String(s));
			Queue<String> q1 = new ArrayDeque<String>();
			Queue<Integer> q2 = new ArrayDeque<Integer>();
			q1.add(new String(s));
			q2.add(0);
			int ans = -1;
			while (q1.size() > 0) {
				s = q1.poll().toCharArray();
				int step = q2.poll();
//				tr(vis.size(), q1.size(), step);
				if (isGoal(s)) {
					ans = step;
					break;
				}
				
				
				if (step < 20) {
					for (int i = 0; i < s.length; i++) if (s[i] == '0') {
						final int zr = rs[i];
						final int zc = cs[i];
						for (int k = 0; k < 4; k++) {
							int nr = zr + dr[k];
							int nc = zc + dc[k];
							int ni = rm[nr + 1][nc + 1];
							if (ni == -1) continue;
							swap(s, i, ni);
							String nxt = new String(s);
							if (!vis.contains(nxt)) {
								if (step + estimate(s) <= 20) {
									vis.add(nxt);
									q1.add(nxt);
									q2.add(step+1);
								}
							}
							swap(s, i, ni);
						}
					}
				}
			}
			
			if (ans == -1) System.out.println("NA"); else System.out.println(ans);
		}
	}
	int estimate(char[] s) {
		int sum = 0;
		for (int i = 0; i < s.length; i++) if (s[i] != '0') {
			int n = getNum(s[i]);
			int d = Math.abs(rs[i] - rs[n]) + Math.abs(cs[i] - cs[n]);
			sum += d;
		}
		return Math.max(0, sum - 2);
	}
	int getNum(char c) {
		if (c == 'a') return 10;
		if (c == 'b') return 11;
		return c - '0';
	}
	void swap(char[] s, int i, int j) {
		char t = s[i]; s[i] = s[j]; s[j] = t;
	}
	boolean isGoal(char[] s) {
		for (int i = 0; i < s.length; i++) if (s[i] != goal[i]) return false;
		return true;
	}
	char toc(int x) {
		return String.format("%x", x).charAt(0);
	}
}

Measured memory_bytes: 65072
n, c, k, *t = map(int, open(0).read().split())
t.sort()
tmp = 0
cnt = 0
limit = t[0] + k
for time in t:
    if tmp == c or time > limit:
        limit = time + k
        tmp = 1
        cnt += 1
    else:
        tmp += 1
if tmp != 0:
    print(cnt + 1)
else:
    print(cnt)

Measured memory_bytes: 20136
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define ll              long long
#define dd              double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vll             vector<long long>
#define vdd             vector<double>
#define vpii            vector<pair<int,int>>
#define vpll            vector<pair<long long,long long>>
#define vvi             vector<vector<int>>
#define vvl             vector<vector<long long>>
#define mii             map<int,int>
#define mll             map<long long,long long>
#define umii            unordered_map<int,int>
#define umll            unordered_map<long long,long long>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep2(i,a,b)     for(int i=a;i<b;i++)
#define rev(i,n)        for(int i=n;i>=0;i--)
#define rev2(i,a,b)     for(int i=a;i>=b;i--)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             9e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define fio             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl            '\n'
#define all(x)          x.begin(),x.end()
#define d0(x)           cout <<x<<" "
#define d1(x)           cout <<x<<endl
#define d2(x,y)         cout <<x<<" "<<y<<endl
#define d3(x,y,z)       cout <<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w)     cout <<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define read2(x,y)      cin>>x>>y
#define read3(x,y,z)    cin>>x>>y>>z
#define read4(x,y,z,w)  cin>>x>>y>>z>>w
#define read5(x,y,z,w,a)cin>>x>>y>>z>>w>>a
#define sz(a)           (int)a.size()
const ll mod=1e9+7;
const double PI = 3.14159265359;
const ll MOD=998244353;
void i_o()
{
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
}
ll help(vll& A,ll k){
   ll n=sz(A)-1,curr=1,k1=k,st,i;
   set<ll> s;
   for(i=0;i<=n+3;i++){
      if(k1==0) return curr;
      if(s.count(curr)){
         st=curr;
         break;
      }
      s.insert(curr);
      curr=A[curr];
      k1--;

   }
  // d2("st is ",st);
   ll j=i;
   curr=st;
   unordered_map<ll,ll> m;
   m[curr]=j;
   while(1>0){
      curr=A[curr];
      j++;
      if(curr==st){
         break;
      }
      else m[curr]=j;
   }
   ll len=j-i;
   k=k%len;
   for(auto it:m){
      if(it.ss%len==k) return it.ff;
   }
   return 1;



}
int main() {
   fio
   i_o();
   ll n,k;
   cin>>n>>k;
   vll A(n+1);
   rep2(i,1,n+1) cin>>A[i];
   d1(help(A,k));
   return 0;
}



Measured memory_bytes: 18384
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;


int main(){
   string s,t;
   cin>>s>>t;
   for(int i=s.size()-t.size();i>=0;i--){
      bool flag=false;
      if(s[i]==t[0] || s[i]=='?'){
         flag=true;
         for(int j=i;j<i+t.size();j++){
            if(s[j]==t[j-i] || s[j]=='?'){
               continue;
            }
            else {
               flag=false;
               break;
            }
         }
         if(flag){
            for(int k=0;k<s.size();k++){
               if(k<i){
                  if(s[k]=='?')cout<<'a';
                  else cout<<s[k];
               }
               else if(i<=k && k<i+t.size()){
                  cout<<t[k-i];
               }
               else {
                  if(s[k]=='?')cout<<'a';
                  else cout<<s[k];
               }
            }
            cout<<endl;
            return 0;
         }
      }
   }
   cout<<"UNRESTORABLE"<<endl;

}

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

int main()
{
	string sa, sb, sc; cin >> sa >> sb >> sc;
	
	int num_a = sa.size();
	int num_b = sb.size();
	int num_c = sc.size();

	char ans;
	char pointer = 'a';
	int a_index = 0;
	int b_index = 0;
	int c_index = 0;

	while (true) {
		
		if (num_a == -1) {
			ans = 'A';
			break;
		}
		else if (num_b == -1) {
			ans = 'B';
			break;
		}
		else if (num_c == -1) {
			ans = 'C';
			break;
		}

		if (pointer == 'a') {
			if (sa[a_index] == 'a') pointer = 'a';
			else if (sa[a_index] == 'b') pointer = 'b';
			else pointer = 'c';
			a_index++;
			num_a--;
		}
		else if (pointer == 'b') {
			if (sb[b_index] == 'a') pointer = 'a';
			else if (sb[b_index] == 'b') pointer = 'b';
			else pointer = 'c';
			b_index++;
			num_b--;
		}
		else {
			if (sc[c_index] == 'a') pointer = 'a';
			else if (sc[c_index] == 'b') pointer = 'b';
			else pointer = 'c';
			c_index++;
			num_c--;
		}

	}

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

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int cards[4][13];
    int i,j,n,Number;
    char Mark;
    
    scanf("%d",&n);
    
    for (i=0; i<4; i++) {
        for (j=0; j<13; j++) {
            cards[i][j]=0;
        }
    }
    
    for (i=0; i<n; i++) {
        scanf(" %c %d",&Mark,&Number);
        
        if (Mark == 'S') {
            cards[0][Number-1]=1;
        }else if(Mark == 'H'){
            cards[1][Number-1]=1;
        }else if(Mark == 'C'){
            cards[2][Number-1]=1;
        }else if(Mark == 'D'){
            cards[3][Number-1]=1;
        }
    }
    for (i=0; i<4; i++) {
        for (j=0; j<13; j++) {
            if(i == 0 && cards[i][j] == 0){
                printf("S %d\n", j+1);
            }else if(i == 1 && cards[i][j] == 0){
                printf("H %d\n", j+1);
            }else if(i == 2 && cards[i][j] == 0){
                printf("C %d\n", j+1);
            }else if(i == 3 && cards[i][j] == 0){
                printf("D %d\n", j+1);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////
 
ll n,k;
 
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>k;
    ll ans = 1;
    while(n>=k){
        n/=k;
        ans++;
        if(n<k)break;
    }
    print(ans);
    return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

const int MOD=1e9+7;
int D[100001];
bool chk[100001];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, M;
	for(cin>>N>>M;M;M--) {
		int a;
		cin>>a;
		chk[a]=true;
	}
	D[0]=1;
	if(!chk[1]) D[1]=1;
	for(int i=2;i<=N;i++) {
		if(chk[i]) continue;
		D[i]=D[i-2];
		if(!chk[i-1]) D[i]=(D[i]+D[i-1])%MOD;
	}
	cout<<D[N]<<'\n';
	return 0;
}

Measured memory_bytes: 768
num = int(input())
a = num // 100
b = (num - 100 * a) // 10
c = num - 100 * a - 10 * b

count = 0
if a == 1:
  count += 1
if b == 1:
  count += 1
if c == 1:
  count += 1
print(count)


Measured memory_bytes: 9116
k=int(input())
l=[1,2,3,4,5,6,7,8,9]
t=[1,2,3,4,5,6,7,8,9]

while len(l)<k:
    t2=[]
    for i in t:
        m=i%10
        if m != 0:
            t2.append(i*10+(m-1))
        t2.append(i*10 + m)
        if m != 9:
            t2.append(i*10+(m+1))
    l.extend(t2)
    t=t2
print(l[k-1])


Measured memory_bytes: 13400
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    int possible = 0;
    for (int i = 0; i < n; i++) {
        possible += a[i] >= sum / (4.0*m);
    }
    cout << (possible >= m ? "Yes" : "No");
    return 0;
}


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

int main() {
  vector<string> s_(3);
  for (int i = 0; i < 3; ++i) {
    cin >> s_[i];
  }
  
  int turn = 0;
  char ch[3] = {'a', 'b', 'c'};
  do {
    char c = s_[turn][0];
    s_[turn].erase(s_[turn].begin());
    for (int i = 0; i < 3; ++i) {
      if (c == ch[i]) {
        turn = i;
        break;
      }
    }
  } while (0 < s_[turn].size());
  char CH[3] = {'A', 'B', 'C'};
  cout << CH[turn] << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    a = [int(i) for i in input().split()]

    c = [0] * n
    b = []

    for i in range(n - 1, -1, -1):
        if i < n // 2:
            if (sum(c[j] for j in range(i, n, i + 1)) % 2) != a[i]:
                c[i] = 1
                b.append(i + 1)
        elif a[i]:
            c[i] = 1
            b.append(i + 1)

    print(len(b))
    print(*b)


# 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")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    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: 54696
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)1e5+20
#define INF 1e9+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int,int> pii;
const int delta=(int)1e9+7;
string s,t="";
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
    cin>>s;
    if(s.size()>3) for(int i=0;i<4;++i) t+=s[i];
    if(t=="YAKI") cout<<"Yes";
    else cout<<"No";
	return cout<<endl,0;
}

Measured memory_bytes: 256
// solution for m-solutions2020-E
// author : lynmisakura
#include<bits/stdc++.h>
using namespace std;

using ll = long long;
#define REP(i,n) for(int (i) = 0;(i) < (n);(i)++)

template<class T> bool chmin(T& a,T b){ if(b < a){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){ if(b > a){a = b;return true;}else return false;}

#define maxn 15

int n;
ll x[maxn],y[maxn],p[maxn];

void read(){
  cin >> n;
  REP(i,n)cin >> x[i] >> y[i] >> p[i];
}

ll par[maxn][1 << maxn],ver[maxn][1 << maxn];

void calc_par(int i,int mask){
  ll dist = abs(y[i]);
  REP(j,n){
    if(mask >> j & 1){
      chmin(dist,abs(y[j] - y[i]));
    }
  }
  par[i][mask] = dist * p[i];
}

void calc_ver(int i,int mask){
  ll dist = abs(x[i]);
  REP(j,n){
    if(mask >> j & 1){
      chmin(dist,abs(x[j] - x[i]));
    }
  }
  ver[i][mask] = dist * p[i];
}

void pre(){
  REP(mask,(1 << n)){
    REP(i,n){
      calc_par(i,mask);
      calc_ver(i,mask);
    }
  }
}

ll ans[maxn+1];

void solve(int mask_p,int mask_v){
  int ps = __builtin_popcount(mask_p);
  int pv = __builtin_popcount(mask_v);

  ll res = 0;

  REP(i,n){
    res += min(par[i][mask_p] , ver[i][mask_v]);
  }
  
  chmin(ans[ps + pv] , res);
}

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

  read();
  pre();
  
  REP(i,n+1) ans[i] = (1LL << 55);

  REP(mask_v,1 << n){
    int left = (1<< n) - 1 - mask_v;
    int mask_p = left;
    do{
      solve(mask_p,mask_v);
      mask_p = (mask_p - 1) & left;
    }while(mask_p != left);
  } 

  REP(i,n+1)cout << ans[i] << '\n';

}


Measured memory_bytes: 11228
#include <stdio.h>
int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if(a<b && a<c){
		if(b<c){
			printf("%d %d %d\n", a, b, c);
		} else {
			printf("%d %d %d\n", a, c, b);
		} 
	}else if(b<a && b<c){
		if(a<c){
			printf("%d %d %d\n", b, a, c);
		} else {
			printf("%d %d %d\n", b, c, a);
		}
	} else {
		if(a<b){
			printf("%d %d %d\n", c, a, b);
		} else {
			printf("%d %d %d\n", c, b, a);
		}
	}
	return 0;
}

Measured memory_bytes: 596
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
c = [LI() for _ in range(3)]
x,y,z = c[0]
for x2,y2,z2 in c[1:]:
    d = x2-x
    if not y+d==y2 or not z+d==z2:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


struct State{
    int at;
    ll cost;
    State(int a, ll c) : at(a), cost(c){}
    bool operator>(const State& s) const{
        return cost > s.cost;
    }
};

struct Edge{
    int to;
    ll cost;
    Edge(int t, ll c) : to(t), cost(c){}
};

using Graph = vector<vector<Edge> >;
const ll INF = 1e15;

void dijkstra(int s, const Graph& G, vector<ll>& minc){
    minc.assign(G.size(), INF);
    priority_queue<State, vector<State>, greater<State> > pq;
    pq.emplace(s, 0);
    minc[s] = 0;
    while(!pq.empty()){
        State cur = pq.top();
        pq.pop();
        if(minc[cur.at] < cur.cost) continue;
        for(const Edge& e : G[cur.at]){
            ll cost = cur.cost + e.cost;
            if(minc[e.to] <= cost) continue;
            minc[e.to] = cost;
            pq.emplace(e.to, cost);
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    Graph G(n);
    rep(i,n-1){
        int a, b;
        ll c;
        cin >> a >> b >> c;
        --a; --b;
        G[a].push_back(Edge(b, c));
        G[b].push_back(Edge(a, c));
    }
    int q, k;
    cin >> q >> k;
    --k;
    vector<ll> minc(n, INF);
    dijkstra(k, G, minc);
    rep(i,q){
        int x, y;
        cin >> x >> y;
        --x; --y;
        cout << minc[x] + minc[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 11120
#include <algorithm>
#include <cstdio>
#include <functional>
#include <fstream>
#include <iostream>
#include <set>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("file.1", "r", stdin);

  int p, q, r;
  cin >> p >> q >> r;
  int ans = 0;
  ans = min(min(p + q, p + r), q + r);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8

def main():
    N, K = map(int, input().split(" "))
    xp = []
    xm = []
    for x in map(int, input().split(" ")):
        if x > 0:
            xp.append(x)
        elif x < 0:
            xm.append(-x)
        else:
            K -= 1
    if K <= 0:
        return 0
    xm.sort()

    ans = float("inf")
    kp = min(len(xp), K)
    while kp >= 0:
        km = K - kp
        if kp == 0 and len(xm) >= km:
            ans = min(ans, xm[km-1])
        elif km == 0:
            ans = min(ans, xp[kp-1])
        elif len(xm) >= km:
            ans = min(ans, xp[kp-1] * 2 + xm[km-1], xp[kp-1] + xm[km-1] * 2)
        kp -= 1
    return ans

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 14480
def main():
    n = int(input())
    s = input()

    sum_count = s.count('R') * s.count('G') * s.count('B')

    r_list = set()
    g_list = set()
    b_list = set()

    for i in range(n):
        if s[i] == 'R':
            r_list.add(i)
        elif s[i] == 'G':
            g_list.add(i)
        elif s[i] == 'B':
            b_list.add(i)

    for r in r_list:
        for g in g_list:
            L = g - r
            if g + L in b_list:
                sum_count -= 1
            if r - L in b_list:
                sum_count -= 1
            if L % 2 == 0 and L//2 + r in b_list:
                sum_count -= 1

    print(sum_count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 79708
import           Control.Monad
import qualified Data.Array.IO               as IO
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

main = do
  n <- getInt
  s <- getLine

  let checkIdx []     rs gs bs _ = (V.fromList rs, V.fromList gs, bs)
      checkIdx (c:cs) rs gs bs i | c == 'R' = checkIdx cs (i:rs) gs bs (i+1)
                                 | c == 'G' = checkIdx cs rs (i:gs) bs (i+1)
                                 | c == 'B' = checkIdx cs rs gs (i:bs) (i+1)

      (rs, gs, bs) = checkIdx s [] [] [] 1 :: (V.Vector Int, V.Vector Int, [Int])

      nbs = length bs
      h = Set.fromList bs

  ans <- VM.new 1
  VM.set ans (0::Int)

  V.forM_ rs $ \i -> do
    V.forM_ gs $ \j -> do
      let (i', j') = if i > j then (i, j) else (j, i)
          c = nbs -
              (if (j' + (j' - i')) `Set.member` h then 1 else 0) -
              (if (i' - (j' - i')) `Set.member` h then 1 else 0) -
              (if (i' + j') `mod` 2 == 0 && ((i'+j') `div` 2) `Set.member` h then 1 else 0)
      t <- VM.read ans 0
      VM.write ans 0 (t+c)

  res <- VM.read ans (0::Int)
  print res

Measured memory_bytes: 5284
#include<iostream>
using namespace std;
int main() {
  int N;
  cin >> N;
  int F[N][10], P[N][11];
  for (int i = 0;i < N;++ i) for (int j = 0;j < 10;++ j) cin >> F[i][j];
  for (int i = 0;i < N;++ i) for (int j = 0;j <= 10;++ j) cin >> P[i][j];
  int ans = -1e9;
  for (int i = 1, s;i < (1 << 10);++ i) {
    s = 0;
    for (int j = 0, t;j < N;++ j) {
      t = 0;
      for (int k = 0;k < 10;++ k) if(i >> k & F[j][k]) ++ t;
      s += P[j][t];
    }
    ans = max(s, ans);
  }
  cout << ans;
  return 0;
}


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

int32_t main()
{
    int n, d, a;
    cin >> n >> d >> a;
    vector<pair<int ,int>> v(n);
    for(int i=0;i<n;i++)
    {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(),v.end());
    vector<int> x(n), y(n);
    for(int i=0;i<n;i++)
    {
        x[i] = v[i].first;
        y[i] = v[i].second;
    }
    vector<int> z(n, 0);
    int ans = 0, curr = 0;
    for(int i=0;i<n;i++)
    {
        y[i] -= curr*a;
        curr += z[i];
        if(y[i] <=0) continue;
        int times = y[i]/a;
        if(y[i]%a) times++;
        ans += times;
        int till = lower_bound(x.begin(),x.end(), x[i]+2*d) - x.begin();
        if(till == n) till--;
        if(x[till] > x[i]+2*d) till--;
        if(till != i)
            curr+=times;
        z[till] -= times;
    }
    cout << ans << "\n";
        
    return 0;
}



Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
int judge(int n,vector<vector<int>>v){
    vector<int>J(n,0);
    queue<int>q;
    q.push(0);J[0]=1;
    while(q.empty()==false){
        int x=q.front();q.pop();
        rep(i,n){
            if(v[x][i]==1&&J[i]==0){J[i]=1;q.push(i);}
        }
    }
    bool ans=true;
    rep(i,n){
        if(J[i]==0){ans=false;break;}
    }
    if(ans)return 0;
    else return 1;
}
int main(void){
    int n,m;cin>>n>>m;
    vector<vector<int>>ac(m,vector<int>(2));
    rep(i,m){cin>>ac[i][0]>>ac[i][1];ac[i][0]--;ac[i][1]--;}
    vector<vector<int>>v(n,vector<int>(n));
    int ans=0;
    rep(i,m){
        rep(j,n){
            rep(k,n)v[j][k]=-1;
        }
        rep(j,m){
            if(i==j)continue;
            else {int x=ac[j][0];int y=ac[j][1];v[x][y]=1;v[y][x]=1;}
        }
        ans+=judge(n,v);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = acos(-1);

int main()
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if (a1 + a2 + a3 >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

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

using namespace std;

int N;
int F[100][14];
int P[100][15];

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

    string s;
    cin>>s;
    int count=0;
    for(int i=0;i<3;i++){
        if(s[i]=='1'){
            count++;
        }
    }

    printf("%d\n",count);
    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
int n; cin>>n;
string s; cin>>s;
//入力
int ans = 0;
rep(i,s.size()){
    string dy1 = s,dy2 = s;
    int count = 0;
    map<char,bool> m;
    dy1.erase(i);//i番目移行の文字を消去
    dy2 = dy2.substr(i);//i番目以降を取り出す
    //cout<<dy1<<" "<<dy2<<endl;
    rep(j,dy1.size()){
        m[dy1[j]] =true;
    }//dy1に含まれる文字種類
    rep(j,dy2.size()){
        if(m[dy2[j]]) {
            count++;//両方にいる
        m[dy2[j]] = false;//同じ文字は無し
        }
    }//dy2にもいるかどうか
ans = max(ans,count);//最大数
}//分割したもの全部調べる
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc126/tasks/abc126_c
# 最初のサイコロでコインを最大何回降るか決まる
# 最大表が出続ける確率がすぬけくんの勝つ確率
# はじめにサイコロの確率も考慮したい

N, K = read_ints()
mul = 1 / N
ans = 0
for i in ra(1, N + 1):
    n_coin = 0
    prob_win = 1
    while i < K:
        i *= 2
        prob_win /= 2
    ans += prob_win
print(ans * mul)


Measured memory_bytes: 3436
n,m = map(int, input().split())
a=[list(map(int,list(input().split()))) for i in range(n)]

food = [0] * (m + 1)

for i in range(n):
    for j in range(1, a[i][0] + 1):
        food[a[i][j]] += 1

print(food.count(n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K; cin >> N >> K;
  vector<int> A(N, 0);
  REP(i, K){
    int d; cin >> d;
    REP(i, d){
      int a; cin >> a; a--;
      A[a]++;
    }
  }
  int ans = 0;
  REP(i, N){
    if(A[i] == 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3656
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
from operator import attrgetter, itemgetter

# import math

# from numba import jit
# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    spi = []

    for i in range(n):
        s, p = input().split()
        spi.append([s, -int(p), i + 1])

    spi.sort(key=itemgetter(0,1))

    for i in range(n):
        print(spi[i][2])

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<stdio.h>
int main()
{
    int n, x;
    scanf("%d %d", &n, &x);
    int i;
    int min = 1000000000;
    int ans = 0;
    int m;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &m);
        ans++;
        x -= m;
        if (min > m)
            min = m;
    }
    ans += (x / min);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
int main(){
      int n,m;
      while(cin>>n&&n){
            int x1[1000],y1[1000];
            int x2[1000],y2[1000];
            REP(i,n)cin>>x1[i]>>y1[i];
            cin>>m;
            set<P> f;
            int k;
            REP(i,m){
                  cin>>x2[i]>>y2[i];
                  f.insert(P(x2[i],y2[i]));
            }
            P ans;
            REP(i,m){
                  int xb=x2[i]-x1[0],yb=y2[i]-y1[0];
                  bool t=true;
                  for(int i=0;i<n;i++){
                        if(f.count(P(x1[i]+xb,y1[i]+yb))==0)t=false;
                  }
                  if(t)ans=P(xb,yb);
            }
            cout<<ans.first<<" "<<ans.second<<endl;
      }
}

Measured memory_bytes: 1256
N, M = map(int, input().split())
data = []
for i in range(M):
    P, Y = list(map(int, input().split()))
    data.append((i, P, Y))
data = sorted(data, key = lambda x:(x[1],x[2]))

city_id = []
cnt = 0
pref = 1
for ci in data:
  if ci[1] != pref:
    pref = ci[1]
    cnt = 0
  cnt += 1
  id = '{0:0>6}{1:0>6}'.format(pref, cnt)
  city_id.append([ci[0], id])
city_id.sort(key=lambda x: x[0])
for ci in city_id:
  print(ci[1])

Measured memory_bytes: 40428
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <set>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

struct Point {
  int x;
  int y;
  char type;
  Point() {;}
  Point(double x, double y, int type) : x(x), y(y), type(type) {;}
  bool operator<(const Point &rhs) const {
    if (y != rhs.y) { return y < rhs.y; }
    return x < rhs.x;
  }
};

struct Event {
  int x;
  Point p;
  char in;
  Event() {;}
  Event(int x, Point p, int in) : x(x), p(p), in(in) {;}
  bool operator<(const Event &rhs) const {
    if (x != rhs.x) { return x < rhs.x; }
    return in > rhs.in;
  }
};

inline int square(int x) { return x * x; }

inline int dist2(const Point &a, const Point &b) {
  return square(a.x - b.x) + square(a.y - b.y);
}

int an, bn, n;
int r;
Event event[500000];

int PlaneSweep() {
  int ans = 0;
  int r4 = 4 * r;
  int r2 = 16 * r * r;
  set<Point> open[2];
  REP(iter, n) {
    Event &e = event[iter];
    Point &p = e.p;
    if (e.in) {
      set<Point>::iterator lower = open[(int)p.type ^ 1].lower_bound(Point(0, p.y - r4 - 1, 0));
      set<Point>::iterator upper = open[(int)p.type ^ 1].upper_bound(Point(0, p.y + r4 + 1, 0));
      for (set<Point>::iterator it = lower; it != upper; it++) {
        if (dist2(*it, p) <= r2) { ans++; }
      }
      open[(int)p.type].insert(p);
    } else {
      open[(int)p.type].erase(open[(int)p.type].find(p));
    }
  }
  return ans;
}

int main() {
  while (scanf("%d %d %d", &an, &bn, &r), an|bn) {
    n = (an + bn) * 2;
    REP(i, an) {
      int x, y;
      scanf("%d %d", &x, &y);
      event[2 * i + 0] = Event(x - 2 * r, Point(x, y, 0), 1);
      event[2 * i + 1] = Event(x + 2 * r, Point(x, y, 0), 0);
    }
    REP(i, bn) {
      int x, y;
      scanf("%d %d", &x, &y);
      event[2 * an + 2 * i + 0] = Event(x - 2 * r, Point(x, y, 1), 1);
      event[2 * an + 2 * i + 1] = Event(x + 2 * r, Point(x, y, 1), 0);
    }
    sort(event, event + n);
    int ans = PlaneSweep();
    printf("%d\n", ans);
  }
}

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

int main() {
  int a,b,c; cin >> a >> b >> c;
  if(a == b)cout << c;
  if(a == c)cout << b;
  if(b == c)cout << a;
}

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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

class BIT {
private:
	int* FT;
	int n;
public:
	void updateBIT(int index , int val) {
		index += 1;
		while (index <= n) {
			FT[index] += val;
			index += (index & (-index));
		}
	}

	int getSum(int index) {
		index += 1;
		int sum = 0 ;
		while (index > 0) {
			sum += FT[index];
			index -= (index & (-index));
		}
		return sum;
	}


	BIT(int* a , int v) {
		n = v ;
		FT = new int[n + 1];
		for (int i = 1 ; i <= n ; i++) {
			FT[i] = 0 ;
		}
		for (int i = 0 ; i < n ; i++) {
			updateBIT(i, a[i]);
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}

int sum(int n) {
	int ans = 0;
	while (n) {
		ans += (n % 10);
		n /= 10;
	}
	return ans;
}

int32_t main() {
	FIO;

	int n ;
	cin >> n;


	int val = sum(n);

	if (n % val == 0) {
		cout << "Yes";
	}
	else {
		cout << "No\n";
	}





	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	int N;
	cin >> N;

	int ans = 0;

	for (int i = 1; i <= N; ++i) {
		ans += i;
	}

	cout << ans << endl;

	
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  int ans = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '2') {
      ans++;
    }
  }

  cout << ans << '\n';
}

Measured memory_bytes: 3628
#include<stdio.h>

int main() {
	int a;
	scanf("%d", &a);
	int b[100];
	int count=0;
	int z = 1;
	for (int i = 0;i < a;i++) {
		b[i] =  z ;
		z++;
	}
	for ( int i = 0;i < a;i++) {
		if (b[i] % 2 == 1) {
			count++;
		}
	}
	printf("%lf", (double)count / a);

}


Measured memory_bytes: 128
#include <iostream>
#include<cmath>
using namespace std;
int main(){
  int a,b;
  cin >> a>>b;
  int total=0;
  int aa=a;
  int bb=b;
  if (a>b){a=b;b=aa;}
    int i=0;for(;i<b;i++){total=total+pow(10.0,i);} 
  cout<<a*total;}

Measured memory_bytes: 256
n=int(input())
ar=[]
def g(i):
    return i[2]
for _ in range(n):
    a,b,c=map(int,input().strip().split(" "))
    ar.append((a,b,c))
ar.sort(key=g,reverse=True)

for x in range(101):
    for y in range(101):
        t=1
        p=(x,y)
        h=0
        for i in range(n):
            if h==0:
                h=ar[i][2]+abs(ar[i][0]-x)+abs(ar[i][1]-y)
            elif ar[i][2]>0:
                c_h=ar[i][2]+abs(ar[i][0]-x)+abs(ar[i][1]-y)
                if c_h!=h:
                    t=0
                    break
            else:
                if h-(abs(ar[i][0]-x)+abs(ar[i][1]-y))>0:
                    t=0
                    break
        if t==1:
            ans=(x,y,h)
            break
for i in ans:
    print(i,end=" ")


Measured memory_bytes: 74044
import numpy as np
import itertools

N, M, X = map(int, input().split())
CA = []
cost = 12 * (10**5) + 1

for _ in range(N):
  CA.append(list(map(int, input().split())))

for T in itertools.product([1,0], repeat = N):
  Flag = True
  ans = np.zeros(M+1)
  for i in range(N):
    if T[i] == 1:
      ans += np.array(CA[i])

  for j in range(1, M+1):
    if ans[j] < X:
      Flag = False
      break
  
  if Flag:
    cost = min(cost, ans[0])

if cost == 12 * (10**5) + 1:
  print(-1)
else:
  print(int(cost))

Measured memory_bytes: 27144
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int n,k,tot=0;
	scanf("%d",&n);
	k=n;
	while(k!=0)
	{
		tot+=(k%10);
		k/=10;
	}
	if(n%tot==0) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    vector<int64_t> vs(s.size() + 1, 0);

    // vs[i] = 0;
    vector<int> zeros;
    for (int i = 0; i < s.size() - 1; i++)
    {
        if (s[i] == '>' && s[i + 1] == '<')
        {
            zeros.push_back(i + 1);
        }
    }
    if (s[0] == '<')
    {
        zeros.push_back(0);
    }
    if (s.back() == '>')
    {
        zeros.push_back(vs.size() - 1);
    }

    for (auto p : zeros)
    {
        {
            int index = p;
            int v = 0;
            while (0 < index && s[index - 1] == '>')
            {
                index--;
                v++;
                vs[index] = max<int64_t>(vs[index], v);
            }
        }
        {
            int index = p;
            int v = 0;
            while (index < vs.size() - 1 && s[index] == '<')
            {
                index++;
                v++;
                vs[index] = max<int64_t>(vs[index], v);
            }
        }
    }
    int64_t sum = 0;
    for (auto v : vs)
    {
        sum += v;
    }
    cout << sum << endl;
}


Measured memory_bytes: 5380
#include "bits/stdc++.h"

using namespace std;
using ll = unsigned long long;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; ++i) {
        cin >> A[i];
        if(A[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    sort(A.begin(), A.end());

    ll INF = ll(pow(10, 18));
    ll ans = 1ULL;
    double x = 0;
    for(int i = N - 1; i >= 0; --i)
    {
        x += log10(A[i]);
        if(x > 18.0)
        {
            cout << -1 << endl;
            return 0;
        }
        ans = ll(ans * A[i]);
    }
    if(ans <= INF)
        cout << ans << endl;
    else
        cout << -1 << endl;
}


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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int H,W;
  cin >> H >> W;
  int a[510][510];
  rep(i,H){
    rep(j,W){
      cin >> a[i][j];
    }
  }
  vector<tuple<int,int,int,int> > ans;
  int x[250001],y[250001];
  int cnt = 0;
  rep(i,H){
    rep(j,W){
      if(i%2==0){
        x[cnt]=j;
      }else{
        x[cnt]=W-1-j;
      }
      y[cnt]=i;
      cnt++;
    }
  }
  /*rep(i,H*W){
    cout << y[i] << " " << x[i] << endl;
  }*/
  rep(i,H*W-1){
    if(a[y[i]][x[i]]%2==1){
      a[y[i]][x[i]]--;
      a[y[i+1]][x[i+1]]++;
      ans.push_back(make_tuple(y[i]+1,x[i]+1,y[i+1]+1,x[i+1]+1));
    }
  }
  int n = ans.size();
  cout << n << endl;
  rep(i,ans.size()){
    cout << get<0>(ans[i]) << " " << get<1>(ans[i]) << " " << get<2>(ans[i]) << " " << get<3>(ans[i]);
    cout << endl;
  }
}

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

int main() {
	int w, h, n;
	cin >> w >> h >> n;
	vector<int> x(n), y(n), a(n);
	rep(i, n) cin >> x[i] >> y[i] >> a[i];
	int xa = 0, xb = w, ya = 0, yb = h;
	rep(i, n) {
		if(a[i] == 1) {
			xa = max(xa, x[i]);
		} else if(a[i] == 2) {
			xb = min(xb, x[i]);
		} else if(a[i] == 3) {
			ya = max(ya, y[i]);
		} else {
			yb = min(yb, y[i]);
		}
	}
	cout << max(0, xb-xa) * max(0, yb-ya) << endl;
	
	return 0;
}

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

int main() {
  int N; ll K; cin >> N >> K;
  map<ll,ll> map;
  
  rep(i,0,N) {
    ll a,b; cin >> a >> b;
    if (map[a] ==0) map[a] = b;
    else map[a] += b;
  }
  
  ll tmp =0, ans;
  for (auto x: map) {
    tmp += x.second;
    if (tmp >= K) {
      ans = x.first; break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 7356
k=int(input())

if k<=9:
    print(k)
    exit(0)

ans=[1,2,3,4,5,6,7,8,9]

i=0
while len(ans)<k:
    v=ans[i]

    mod=v%10

    if mod==0:
        ans.append(10*v+mod)
        ans.append(10*v+mod+1)
    elif mod==9:
        ans.append(10*v+mod-1)
        ans.append(10*v+mod)
    else:
        ans.append(10*v+mod-1)
        ans.append(10*v+mod)
        ans.append(10*v+mod+1)

    i+=1

print(ans[k-1])

        



Measured memory_bytes: 13344