akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"
#include "string"


int32_t main(){
	boost;
	int t = 1;
	//cin >> t;
	while(t--) {
		int n, k;
		cin >> n >> k;
		string s;
		cin >> s;
		vector < int > v;
		for(int i = 0; i < n;) {
			int j = i;
			while(j < n && s[i] == s[j])
				j++;
			v.push_back(j - i);
			i = j;
		}

		int ans = 0;
		for(int &i : v)
			ans += i - 1;
		ans = min(n - 1, ans + 2*k);
		cout << ans << endl;
	}
}


Measured memory_bytes: 4440
import java.util.Scanner;
import java.lang.Math;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String b = stdIn.next();
		char[] a = new char[4];
		for (int j = 0; j < 4; j++) {
			a[j] = b.charAt(j);
		}
		int N = 0;
		for (int i = 0; i < 4; i++) {
			if (a[i] == '2') 
				N = N + 1;
		}

		System.out.println(N);

	}
}

Measured memory_bytes: 22228
#include <stdio.h>
int main(){
  int n,i,v,j,A[100],k;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<n;i++){
    for(k=0;k<n;k++){
      printf("%d",A[k]);
      if(k!=n-1)printf(" ");
    }
    v=A[i];
    j=i-1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;	
	}
      printf("\n");
  }
  for(k=0;k<n;k++){
      printf("%d",A[k]);
      if(k!=n-1)printf(" ");
    }
   printf("\n");
  return 0;
}



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

int main(){
    int n; cin >> n;
    vector<int> odd(n/2), even(n/2);
    map<int, int> o;
    map<int, int> e;
    for(int i = 0; i < n/2; i++){
        cin >> odd.at(i) >> even.at(i);
        o[odd.at(i)]++; e[even.at(i)]++;
    }
    int o1, o2, e1, e2;
    int key_o, value_o, key_e, value_e;
    int cnt = 0;
    for(auto nv: o){
        if(cnt < nv.second){
            cnt = nv.second;
            key_o = nv.first;
        }
    }
    o1 = cnt;
    cnt = 0;
    for(auto nv: o){
        if(key_o != nv.first && cnt < nv.second){
            cnt = nv.second;
        }
    }
    o2 = cnt;
     for(auto nv: e){
        if(cnt < nv.second){
            cnt = nv.second;
            key_e = nv.first;
        }
    }
    e1 = cnt;
    cnt = 0;
    for(auto nv: e){
        if(key_e != nv.first && cnt < nv.second){
            cnt = nv.second;
        }
    }
    e2 = cnt;
    if(key_o != key_e) cout << n - e1 - o1 << endl;
    else cout << min(n - e1 - o2, n - e2 - o1);
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
using namespace std;


int main() {
	long long int sum;
	int n, k;
	cin >> n >> k;
	sum = k * pow(k - 1, n - 1);
	cout << sum;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int cnt = 0;
		for (int i = a; i <= b; ++i) {
			if (c % i == 0)
				++cnt;
		}
		System.out.println(cnt);
		scanner.close();
	}

}


Measured memory_bytes: 26300
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] A = new int[N];
            int[] B = in.nextIntArray(N - 1);
            A[0] = B[0];
            long sum = 0;
            for (int i = 0; i < N - 1; i++) {
                if (A[i] > B[i]) {
                    A[i] = B[i];
                }
                A[i + 1] = B[i];
                sum += A[i];
            }
            sum += A[N - 1];
            out.println(sum);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

    }
}



Measured memory_bytes: 21460
def ans(i, j, k):
    if i == 3:
        if j == 7:
            print(k + '=7')
            exit()
    else:      #return ではなぜかけない？
        ans(i+1, j-int(n[i+1]), k+'-'+n[i+1]),
        ans(i+1, j+int(n[i+1]), k+'+'+n[i+1])

n = input()

print(ans(0, int(n[0]), n[0]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,K;
    cin >> n >> K;
    ll mn = (1LL << 60);
    rep(i,(1 << n)){
        ll st = 1;
        rep(j,n){
            if(i & (1 << j)){
                st += K;
            }else{
                st *= 2;
            }
        }
        cmn(mn,st);
    }
    cout << mn << "\n";
    return 0;
}


Measured memory_bytes: 256
import heapq
def dijkstra(start,goal,graph):

    INF = 2 << 20
    node_num = len(graph) 
    visited = [False] * node_num
    costs = [INF] * node_num
    pq = []
    costs[start] = 0
    heapq.heappush(pq, [0,start])
    while not len(pq) == 0:

        cur_cost,cur_node = heapq.heappop(pq)
        if visited[cur_node]:
            continue
        if all(visited[1:]):
            break
        visited[cur_node] = True
        costs[cur_node] = cur_cost
        for i in xrange(node_num):
            if not visited[i]:
                heapq.heappush(pq,[graph[cur_node][i] + costs[cur_node],i])
    return costs[goal]

n = input()
m = input()
INF = 2 << 20
graph = [[INF] * (n+1) for _ in xrange(n+1)]
for _ in xrange(m):
    a,b,c,d = map(int,raw_input().split(","))
    graph[a][b] = c
    graph[b][a] = d
home,shop,reward,price = map(int,raw_input().split(","))
cost = dijkstra(home,shop,graph) + dijkstra(shop,home,graph)
print reward - price - cost

Measured memory_bytes: 4504
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

ll A, B;
int main(){
    cin >> A >> B;
    ll lb = 0, ub = inf;
    while(ub - lb > 1){
        ll mid = (ub + lb) / 2;
        ll e = mid * 8 / 100;
        ll t = mid / 10;
        if(e >= A && t >= B) ub = mid;
        else lb = mid;
    }
    cout << (ub * 8 / 100 == A && ub / 10 == B ? ub : -1) << endl;
    return 0;
}

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

const int MAXN = ( int ) 2e5;

int N, X, Y;
int C[ MAXN ], W[ MAXN ];
vector< int > c2w[ MAXN ];

int cmax[ MAXN ];
int fact[ MAXN + 1 ];
int inv_fact[ MAXN + 1 ];

int int_pow( int v, int p, int m ){
  int res = not ( v == 0 and p != 0 );
  while( p ){
    if( p & 1 ){
      res = 1LL * res * v % m;
    }
    p >>= 1;
    v = 1LL * v * v % m;
  }
  return res;
}

int unite[ MAXN ];

signed main(){
  ios::sync_with_stdio( 0 );
  {
    cin >> N >> X >> Y;
    for( int i = 0; i < N; ++i ){
      cin >> C[ i ] >> W[ i ];
      --C[ i ];
      c2w[ C[ i ] ].emplace_back( W[ i ] );
    }
    for( int i = 0; i < N; ++i ){
      sort( c2w[ i ].begin(), c2w[ i ].end() );
    }
  }
  {
    sort( W, W + N );
    int minw = W[ 0 ];
    int minw2 = W[ 1 ];
    for( int i = 0; i < N; ++i ){
      if( c2w[ i ].empty() ) continue;
      {
        for( int lb = 2, ub = c2w[ i ].size(); lb <= ub; ){
          int mid = lb + ub >> 1;
          if( c2w[ i ][ 0 ] + c2w[ i ][ mid - 1 ] <= X ){
            cmax[ i ] = mid;
            lb = mid + 1;
          } else{
            ub = mid - 1;
          }
        }
      }
      {
        for( int lb = 1, ub = c2w[ i ].size(); lb <= ub; ){
          int mid = lb + ub >> 1;
          if( minw != minw2 and c2w[ i ][ 0 ] == minw ){
            if( minw2 + c2w[ i ][ mid - 1 ] <= Y ){
              unite[ i ] = mid;
              lb = mid + 1;
            } else{
              ub = mid - 1;
            }
            continue;
          }
          if( minw + c2w[ i ][ mid - 1 ] <= Y ){
            unite[ i ] = mid;
            lb = mid + 1;
          } else{
            ub = mid - 1;
          }
        }
      }
    }
  }
  {
    const int MOD = ( int ) 1e9 + 7;
    {
      for( int i = fact[ 0 ] = inv_fact[ 0 ] = 1; i <= MAXN; ++i ){
        fact[ i ] = 1LL * fact[ i - 1 ] * i % MOD;
        inv_fact[ i ] = int_pow( fact[ i ], MOD - 2, MOD );
      }
    }
    int sum = 0;
    for( int i = 0; i < N; ++i ){
      if( not unite[ i ] ) continue;
      sum += max( unite[ i ], cmax[ i ] );
    }
    int ans = fact[ sum ];
    for( int i = 0; i < N; ++i ){
      if( c2w[ i ].empty() ) continue;
      if( not unite[ i ] ) continue;
      ans = 1LL * ans * inv_fact[ max( unite[ i ], cmax[ i ] ) ] % MOD;
    }
    cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 13952
using System;
class gyakusu{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    string[] s =  Console.ReadLine().Split(' ');
    double[] a = new double[n];
    double[] inverse = new double[n];
    double sum = 0;
    for (int i = 0; i<n; i++)
    {
      a[i]=double.Parse(s[i]);
      inverse[i]=1/a[i];
      sum+=inverse[i];
  }
  double answer = 1/sum;
  Console.WriteLine("{0:F5}",answer);
}
}


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

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

    vector<int> c(N, 0);
    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        c.at(a)++;
        c.at(b)++;
    }

    for (int i = 0; i < N; i++)
    {
        cout << c.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
using namespace std;

int main() {
		int n;
		int date_x[100];
		int date_y[100];
		double sum = 0;
		double var = 0;
		double D[4] = { 0 };
		string haki;
		cin >> n;
		getline(cin, haki);
		for (int i = 0; i < n; i++) {
			cin >> date_x[i];
		}
		getline(cin, haki);
		for (int i = 0; i < n; i++) {
			cin >> date_y[i];
		}
		getline(cin, haki);
		for (int i = 0; i < n; i++) {
			D[0] += abs(date_x[i] - date_y[i]);
			D[1] += pow(abs(date_x[i] - date_y[i]), 2);
			D[2] += pow(abs(date_x[i] - date_y[i]), 3);
			if(D[3] < abs(date_x[i] - date_y[i]))D[3] = abs(date_x[i] - date_y[i]);
		}
		D[1] = pow(D[1], 1.0 / 2.0);
		D[2] = pow(D[2], 1.0 / 3.0);

		for (int i = 0; i < 4; i++) {
			cout << fixed << D[i] << endl;
		}

	return 0;
}


Measured memory_bytes: 3476
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


class Info:
    def __init__(self,arg_color,arg_length):
        self.color = arg_color
        self.length = arg_length


while True:
    N = int(input())
    if N == 0:
        break

    S = []

    tmp = int(input())
    S.append(Info(tmp,1)) #最初のデータ

    for i in range(1,N):
        tmp = int(input())

        if i%2 == 0:
            if tmp == S[len(S)-1].color:
                S[len(S)-1].length += 1
            else:
                S.append(Info(tmp,1))
            continue

        if tmp == S[len(S)-1].color: #最後の連と色が同じ
            S[len(S)-1].length += 1
        else: #最後の連と色が違う
            tmp_len = S[len(S)-1].length
            S.pop()
            if len(S) == 0:
                S.append(Info(tmp,tmp_len+1))
            else: #連の色は交互であるはず
                S[len(S)-1].length += tmp_len+1

    ans = 0
    for i in range(len(S)):
        if S[i].color == 0:
            ans += S[i].length

    print("%d"%(ans))





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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define pb push_back
#define eb emplace_back
#define fst first
#define snd second
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  int n; cin >> n;
  vector<pii> a(n); rep(i,n) cin >> a[i].second >> a[i].first;
  sort(all(a));
  int t = 0;
  rep(i,n){
    t += a[i].second;
    if(t <= a[i].first) continue;
    else{
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    map<string, int> ans;
    for(int i = 0; i< n; i++){
        string s;
        cin >> s;
        ans[s]++;
    }
    cout << "AC x " << ans["AC"] << endl;  
    cout << "WA x " << ans["WA"] << endl;
    cout << "TLE x " << ans["TLE"] << endl;
    cout << "RE x " << ans["RE"] << endl;
    return 0;
}

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

const int MAX = 1e5 + 111;

ll a[MAX];

ll init[MAX], c[MAX];

int id[MAX], go[MAX];

ll dif[MAX];

int b[MAX];

ll nw[MAX];

ll ans[MAX];

ll m, k, n;

void bin(ll k) {
    if (k <= 1)
        return;
    if (k % 2 == 1) {
        bin(k - 1);
        for (int i = 1; i < n; ++i)
            nw[i] = go[id[i]];
        for (int i = 1; i < n; ++i) 
            go[i] = nw[i];
    }
    else {
        bin(k / 2);
        for (int i = 1; i < n; ++i)
            nw[i] = go[go[i]];
        for (int i = 1; i < n; ++i)
            go[i] = nw[i];
    }
}

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);    
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    scanf("%lld", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%lld", &a[i]);        
        init[i] = a[i];
        if (i)
            dif[i] = a[i] - a[i - 1];
        id[i] = i;
    }
    scanf("%lld %lld", &m, &k);
    for (int i = 0; i < m; ++i) {
        scanf("%d", &b[i]);
        b[i]--;
        swap(id[b[i]], id[b[i] + 1]);
    }    
    for (int i = 1; i < n; ++i)
        go[i] = id[i];
    bin(k);
    for (int i = 1; i < n; ++i)
        ans[i] = dif[go[i]];
    printf("%lld\n", a[0]);
    ll cur = a[0];
    for (int i = 1; i < n; ++i) {
        cur += ans[i];
        printf("%lld\n", cur);
    }        
    return 0;
}

Measured memory_bytes: 6400
fun main(args: Array<String>) {
    val mod = 1000000007L
    val N = readInputLine().toInt()
    val AArr = readInputLine().split(" ").map { it.toLong() }
    val bits = LongArray(64)
    
    var ans = 0L
    
    for (A in AArr) {
        for (i in 0 until 64) {
            if ((A shr i) % 2L == 1L) {
                bits[i]++
            }
        }
    }
    
    for (i in 0 until 64) {
        ans += (((1L shl i) % mod) * bits[i] % mod) * (N.toLong() - bits[i]) % mod
        ans %= mod
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 112388
#include<stdio.h>

int main(void){
	int n;
	int sum;
	int x[5];
	int i, j;
	int max[100], min[100];


	for(j=0; j<100; j++){
		min[j]=500;
		max[j]=0;
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=0; i<n; i++){
			scanf("%d%d%d%d%d",&x[0],&x[1],&x[2],&x[3],&x[4]);
			sum=x[0]+x[1]+x[2]+x[3]+x[4];
			if(min[j] >= sum)
				min[j]=sum;
			if(max[j] <= sum)
				max[j]=sum;
		}
	}
	for(i=0; i<j; i++)
		printf("%d %d\n",max[i],min[i]);
	scanf("%d",n);
	return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define ll long long
using namespace std;



int main()
{
	int n;
	cin>>n;
	int ans;
	if(n>=400 && n<=599){
		ans=8;
	}
	else if(n>=600 && n<=799){
		ans=7;
	}
	else if(n>=800 && n<=999){
		ans=6;
	}
	else if(n>=1000 && n<=1199){
		ans=5;
	}
	else if(n>=1200 && n<=1399){
		ans=4;
	}
	else if(n>=1400 && n<=1599){
		ans=3;
	}
	else if(n>=1600 && n<=1799){
		ans=2;
	}
	else if(n>=1800 && n<=1999){
		ans=1;
	}
	cout <<ans << endl;
	return 0;
}

Measured memory_bytes: 3636
n = int(input())
a = list(map(str, input().split()))
a_swap = 0

flag = True
while flag:
    flag = False
    for j in range(n-1,0,-1):
      if int(a[j]) < int(a[j-1]):
       a[j],a[j-1] = a[j-1],a[j]
       flag = True
       a_swap += 1

print(" ".join(a))
print(a_swap)

Measured memory_bytes: 7632
x1, y1, x2, y2 = map(int, input().split())
v = [-y2+y1, x2-x1]
w = [x1-x2, y1-y2]
x3 = x2 + v[0]
y3 = y2 + v[1]
x4 = x3 + w[0]
y4 = y3 + w[1]
print(x3, y3, x4, y4)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> PP;

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

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

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

	int a[3];cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]+a[1]<<endl;

	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import Counter
def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = Counter(A)
    A.sort()
    ans = set()
    table = {i:-1 for i in range(1, 10 ** 6 + 1)}
    for a in A:
        table[a] = 0
    for a in A:
        if table[a] == 0 and cnt[a] == 1:
            ans.add(a)
        elif table[a] == 1:
            continue
        i = 2
        target = a
        while True:
            target = a * i
            if target > A[-1]:
                break
            if table[target] == 0:
                table[target] = 1
            i += 1
    print(len(ans))
if __name__ == "__main__":
    main()

Measured memory_bytes: 177608
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	int N, W, H;
	int X1, Y1, X2, Y2;
	int dis;
	
	scanf("%d%d%d", &W, &H, &N);
	
	scanf("%d%d", &X1, &Y1);
	dis = 0;
	for(int i = 0; i < N - 1; i++){
		scanf("%d%d", &X2, &Y2);
		if((X2 - X1) * (Y2 - Y1) < 0){
			dis += abs((X2 - X1)) + abs((Y2 - Y1));
		}
		else{
			dis += max(abs((X2 - X1)), abs((Y2 - Y1)));
		}
		
		X1 = X2; Y1 = Y2;
	}
	
	printf("%d\n", dis);
	
	return 0;
}

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

#include <iostream>
#include <vector>
#include <map>
// #include <string>
#include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

void check(char m, vector<int> vec) {
	sort(vec.begin(), vec.end());
	int card_idx = 0;
	for (int i = 1; i <= 13; i++) {
		while (i > vec[card_idx]) {
			card_idx++;
		}
		if (i != vec[card_idx]) {
			cout << m << " " << i << endl;
		}
	}
}

int main() {
	map<char, vector<int>> cards;
	int n;
	char marks[4] = {'S', 'H', 'C', 'D'};
	cin >> n;
	for (int i = 0; i < n; i++ ) {
		char mark;
		int num;
		cin >> mark >> num;
		cards[mark].push_back(num);
	}
	for (char i : marks) {
		cards[i].push_back(14);
		check(i, cards[i]);
	}
	return 0;
}



Measured memory_bytes: 3120
#include<iostream>
#include<map>
using namespace std;
int main(){
    long N,M,ans=0L;cin>>N>>M;
    map<long,long>m;
    for(long i=0,A,acc=0L;i<N;acc+=A,m[acc%M]++,i++)cin>>A;
    for(auto x:m)ans+=x.second*(x.second-1L)/2L;
    cout<<ans+m[0]<<endl;
    return 0;
}

Measured memory_bytes: 4224
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
// void fill(ll n, ll a[n], ll value){ rep(i,0,n) a[i] = value; }
void cin(ll *n){ scanf("%lld",&(*n)); }
void cin2(ll *a, ll *b){ scanf("%lld%lld",&(*a),&(*b)); }
void cin3(ll *a, ll *b, ll *c){ scanf("%lld%lld%lld",&(*a),&(*b),&(*c)); }
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
ll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}
ll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
// int int_sort( const void * a , const void * b ) {
//   return strcmp(( char * )a , ( char * )b );
// }
//     qsort((void*)s,n,sizeof(s[0]),int_sort );

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n,k;
    ll ans=0;
    cin(&n);
    cin(&k);
    // cin(&);
    // cin(&);
    // cin2(&,&);
    // cin3(&,&,&);
    // scanf("%s",);
    ll d,sna[n];
    rep(i,0,n) sna[i]=0;
    rep(i,0,k){
        cin(&d);
        ll a;
        rep(j,0,d){
            cin(&a);
            sna[a-1]++;
        }
    }
    rep(i,0,n){
        if(sna[i]==0) ans++; 
    }

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


Measured memory_bytes: 1732
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		for (int i=0;i<n;i++) {
			h[i]=sc.nextInt();
		}
		long[] cost = new long[n];

		cost[0]=0;
		for (int i=1;i<n;i++) {
			cost[i]=Long.MAX_VALUE;
			for (int j=Math.max(0, i-k);j<i;j++) {
				cost[i]=Math.min(cost[i], cost[j]+Math.abs(h[i]-h[j]));
			}
		}
		System.out.println(cost[n-1]);
	}

}

Measured memory_bytes: 50652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll dpx[] = {-1, 0, 0, 1};
ll dpy[] = {0, 1, -1, 0};
int main(){
  ll h,w;
  cin >> h>>w ;
  vector<string> s(h+2);
  rep(i, w + 2) s[0].pb('.');
  rep(i, h){
    s[i].pb('.');
    cin >> s[i];
    s[i].pb('.');
  }
  rep(i, w + 2) s[h + 1].pb('.');
  bool ans = true;
  for (ll i = 1; i < h + 1;i++){
    for (ll j = 1; j < w + 1;j++){
      if(s[i][j]=='#'){
        bool tmp = true;
        rep(k, 4){
          if (s[i + dpy[k]][j+dpx[k]]=='#'){
            tmp = false;
          }
        }
        if(tmp){
          ans = false;
        }
      }
    }
  }
  if(ans){
    print("Yes");
  }
  else{
    print("No");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define Scan(a) scanf("%I64d", &a);
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

int main()
{
    int a[4];
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    cin >> a[1] >> a[2] >> a[3];
    sort(a+1, a+4);
    if (a[1] + a[2] == a[3]) cout << "Yes";
    else cout << "No";
    return 0;
}


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

using namespace std;


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

	vector<set<int>> freq(26);

	for (int i = 0; i < n; i++) {
		freq[s[i] - 'a'].insert(i);
	}

	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		int type;
		cin >> type;
		if (type == 1) {
			int index;
			char ch;
			cin >> index >> ch;
			index--;
			char oldCharacter = s[index];
			s[index] = ch;
			freq[oldCharacter - 'a'].erase(index);
			freq[ch - 'a'].insert(index);
		}
		else {
			int left, right;
			cin >> left >> right;
			left--, right--;
			int res = 0;
			for (int j = 0; j < 26; j++) {
				auto it = freq[j].lower_bound(left);
				if (it == freq[j].end()) continue;
				int val = *it;
				if (val >= left && val <= right) res++;
			}

			cout << res << endl;
		}
	}
}

Measured memory_bytes: 24196
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	const int mod = 1e9 + 7;
	int n, cnt[26] = {}; cin >> n;
	string s; cin >> s;
	ll ans = 1;
	for(char c : s) cnt[c - 'a']++;
	rep(i, 26) ans = ans * (cnt[i] + 1) % mod;
	cout << (ans + mod - 1) % mod << endl;
	
	return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  for(int i=0;i<s.length();++i){
	s[i] = 'A'+((s[i]-'A')+n)%26;
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

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

int main(){
    ll n, m; cin >> n >> m;
    vector<map<ll,ll>> nn(n+1);
    vector<pair<ll, ll>> year(m);
    rep(i, m){
        ll p, y; cin >> p >> y;
        year[i].first = y;
        year[i].second = p;
        nn[p].emplace(y, y);
    }
    for(ll i = 1; i < n+1; ++i){
        ll inx = 1;
        for(auto j = nn[i].begin(); j != nn[i].end(); ++j){
            (*j).second = inx;
            inx++;
        }
    }
    rep(i, m){
        ll y = year[i].first, p = year[i].second;
        printf("%06lld%06lld\n", p, nn[p][y]);
    }
    return 0;
}

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

int main(void)
{
  vector<int>a(4);
  for(int i=0;i<4;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  if((a[0]*1000+a[1]*100+a[2]*10+a[3])==1479){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        char s[] = inp.next().toCharArray();
        if (s[2] == s[3] && s[4] == s[5]) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 22228
N=int(input())
uvw=[[] for _ in range(N)]
for i in range(N-1):
    u,v,w=map(int,input().split())
    uvw[u-1].append((v-1,w))
    uvw[v-1].append((u-1,w))
# print(uvw)
color=[-1]*N 
color[0]=0
now=0
nex=[0]
from copy import deepcopy
while nex:
    now=nex.pop()
    stack=deepcopy(uvw[now])
    uvw[now]=[]
    while stack:
        a=stack.pop()
        if a[1]%2==0:
            color[a[0]]=color[now]
        else:
            color[a[0]]=color[now]^1
        nex.append(a[0])
for c in color:
    print(c)

Measured memory_bytes: 38576
/* Which of the favors of your Lord will you deny? */

#include<bits/stdc++.h>
using namespace std;

#define pi       acos(-1)

#define SI(n)    scanf("%d",&n)
#define SLL(n)   scanf("%lld",&n)
#define SULL(n)   scanf("%llu",&n)
#define SC(n)    scanf("%c",&n)
#define SD(n)    scanf("%lf",&n)

#define fr(i,a,b) for(int i=a ,_b=(b) ;i<= _b;i++)

#define LL      long long
#define PUB     push_back
#define POB     pop_back
#define MP      make_pair;
#define PII     pair<int,int>
#define PLL     pair<ll,ll>


#define GCD     __gcd
#define DEBUG   cout<<"aw"<<endl;

char ara[100];

int main()
{
    char a[15],b[15],c[15];

    cin>>a>>b;

    strcat(a,b);

    int x = atoi(a);

    if(sqrt(x)==(int)(sqrt(x)))
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int par[100000];
int rank[100000];
int club[100000];
void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        rank[i]=0;
        club[i]=-1;
    }
}
int find(int x){
    if(par[x]==x){
        return par[x];
    }else{
        return par[x]=find(par[x]);
    }
}
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(rank[x]<rank[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(rank[x]==rank[y])rank[x]++;
    }
}
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    init(n);
    for(int times=1;times<=k;times++){
        int a,b,c;
        cin>>a>>b>>c;b--;c--;
        if(a==1){
            int bb=find(b);
            int cc=find(c);
            if(club[bb]!=-1){
                if(club[cc]!=-1){
                    if(club[bb]!=club[cc]){
                        cout<<times<<endl;
                        return 0;
                    }
                }else{
                    club[cc]=club[bb];
                    unite(b,c);
                }
            }else{
                if(club[cc]!=-1){
                    club[bb]=club[cc];
                    unite(b,c);
                }else{
                    unite(b,c);
                }
            }
        }else{
            int bb=find(b);
            if(club[bb]!=-1&&club[bb]!=c){
                cout<<times<<endl;
                return 0;
            }else{
                club[bb]=c;
            }
        }
    }
    cout<<0<<endl;
}

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

int main() {
	// your code goes here
	int n,m,s,sum;
	while(cin >> n && n!=0){
		sum=0;
		int i;
		for(i=0;i<12;i++){
			cin >> m >> s;
			sum+=m-s;
			if(sum>=n){
				cout << i+1 << endl;
			break;
			}
		}
		for(i=i+1;i<12;i++)
		cin >> m >> s;
		if(sum<n)
		cout << "NA" << endl;
	}
	return 0;
}

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

flug=0
for x in range(n+1):
    for y in range(n+1):
        if 10000*x+5000*y+1000*(n-x-y)==Y and n-x-y>=0:
            print(x,y,n-x-y)
            flug=1
            break
    if flug==1:
        break

if flug==0:
    print("-1 -1 -1")


Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  ll t = 1900*m+100*(n-m);
  ll p = pow(2, m);
  cout << t * p << "\n";
  return 0;
}


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

typedef long long ll;

ll infl = 100000000000000000000;//inflは十分大きい

//N,a[404];入力値、b[404]:b[n]はa[0]からb[n]までの和
int N;
ll a[404],b[404];

//bの初期化
void init_b()
{
    b[0] = a[0];
    for(int i = 1; i < N; i++) b[i] = a[i] + b[i - 1];
}

//a[L]からa[R]までの総和
ll get(int L,int R)
{
    ll res = b[R];
    if(L) res -= b[L - 1];
    return res;
}

//探索フラグ:Have visted
bool vis[404][404];
//メモ
ll memo[404][404];
//メモ化再帰
ll dp(int L,int R)
{
    if(vis[L][R] == true) return memo[L][R];
    else if(L == R){
     vis[L][R] = true; //フラグを立てる
     return memo[L][R] = 0; //メモしながらリターン
    }
    else {
        vis[L][R] = true; //フラグを立てる
        ll res = infl; //inflは十分に大きい
        //cで二つに区切ってmin全探索
        for(int c = L; c < R; c++){
            res = min(res,dp(L,c) + dp(c + 1,R) + get(L,R));  
        }
        return memo[L][R] = res; //メモしながらリターン
    }
}

int main()
{
    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];
    init_b();
    cout << dp(0,N - 1) << endl;
    return 0;
}

Measured memory_bytes: 1664
N = int(input())

A = list(map(int,input().split()))

ans = 1
dec = False
start = True
now = A[0]
for nex in A[1:]:
    if nex-now>0:
        if start:
            start=False
            dec=False
        elif dec:
            start=True
            ans += 1
    elif nex-now<0:
        if start:
            start=False
            dec=True
        elif not dec:
            start=True
            ans += 1
    now = nex

print(ans)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
string x,y,z;
int n,m;
int main()
{
	cin >>x>>y>>n>>m>>z;
	if (x==z) cout <<n-1<<" "<<m;
	else cout <<n<<" "<<m-1;
	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	while (1) {
		string n;
		cin >> n;
		if (n == "0") break;
		int ans = 0;
		for (int i = 0; i < (int)n.length(); i++) {
			ans += n[i] - '0';
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3220
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(T);
    scanVecInt(t, N);
    ll result = 0;
    int before = -T;
    for (auto& ti : t){
        if (before + T <= ti){
            result += T;
        }else{
            result += (ti - before);
        }
        before = ti;
    }
    printf("%lld\n", result);
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long a, long long b){
  long long t;
  if (a < b) {
    t = a;
    a = b;
    b = t;
  }
  for (int i = 0; i < a; ++i) {
    std::cout <<  b;
  }
  std::cout << std::endl;
}

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


Measured memory_bytes: 256
#include <iostream>

int main()
{

    int K, A, B;
    bool f;
    std::cin >> K >> A >> B;

    for (int i = A; i <= B; i++)
    {

        if (i % K == 0)
        {
            std::cout << "OK" << std::endl;
            return 0;
        }
    }

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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int ans = 0, y;
    rep(i, a+1){
        rep(j, b+1){
            rep(k, c+1){
                y = i*500 + j*100 + k*50; 
                if(x == y)
                    ans++; 
            }
        }
    }
    cout << ans;

    return 0;
}

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

using namespace std;

int main() {
    /*int A,B,C,D,seconds,minutes;
    cin >> A >> B >> C >> D;
    seconds = A + B + C + D;
    minutes = seconds / 60;
    seconds = seconds - minutes *60;
    cout << minutes << endl << seconds << endl;*/
    
    /*int AB,BC,CA,answer;
    cin >> AB >> BC >> CA;
    answer = AB * BC / 2;
    cout << answer << endl;*/
    
    /*int X,Y,sum;
    cin >> X >> Y;
    sum = X + Y/2;
    cout << sum << endl;*/
    
    int A,B,s;
    cin >> A >> B;
    s=(A-1)*(B-1);
    cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 1e5 + 10;
int a[maxN];
int x;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> x;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll ans = 0;
    while (n >= 2) {
        if (a[n] + a[n - 1] <= x) {
            n--;
            continue;
        }
        if (a[n] > x) {
            ans += a[n] - x;
            a[n] = x;
        }
        int will = max(0, x - a[n]);
        ans += a[n - 1] - will;
        a[n - 1] = will;
        n--;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    S = list(input())
    S.pop()
    while len(S) != 1:
        n = len(S)
        if n % 2 == 0:
            if S[: n // 2] == S[n // 2:]:
                break
        S.pop()

    print(len(S))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <ctime>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123456;
char s[MAXN];

int main() {
    scanf("%s", s);
    int N = strlen(s);
    int cnt = 0, cur = 0;
    int ans = N;
    for (int i = 0; i < N; i++) {
        if (s[i] - '0' != cur) cnt++;
        cur ^= 1;
    }
    ans = min(ans, cnt);
    cur = 1, cnt = 0;
    for (int i = 0; i < N; i++) {
        if (s[i] - '0' != cur) cnt++;
        cur ^= 1;
    }
    printf("%d\n", min(ans, cnt));
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1005;
int X,Y,Z,K;
ll A[maxn],B[maxn],C[maxn];
priority_queue<ll>Q;
int main(){
	cin>>X>>Y>>Z>>K;
	for(int i=0;i<X;i++)cin>>A[i];
	for(int i=0;i<Y;i++)cin>>B[i];
	for(int i=0;i<Z;i++)cin>>C[i];
	sort(A,A+X,greater<ll>());
	sort(B,B+Y,greater<ll>());
	sort(C,C+Z,greater<ll>());
	for(int x=0;x<X;x++)
		for(int y=0;y<Y;y++){
			if((x+1)*(y+1)-1>=K)break;
			for(int z=0;z<Z;z++){
				if((x+1)*(y+1)*(z+1)-1>=K)break;
				ll tmp=A[x]+B[y]+C[z];
				Q.push(tmp);
			}
		}
	for(int i=0;i<K;i++){
		cout<<Q.top()<<endl;
		Q.pop();
	}
	return 0;
} 


Measured memory_bytes: 1400
package main

import "fmt"

func xor(x int) (ans int) {
	switch x % 4 {
	case 0:
		ans = x
	case 1:
		ans = 1
	case 2:
		ans = 1 ^ x
	case 3:
		ans = 0
	}
	return
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	fmt.Println(xor(a-1) ^ xor(b))
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>

using namespace std;

const int N = 10+1;
const int S = 330+1; // 作れる値の最大値+1
int dp[N][S][1<<N];  // 残り個数, 作る値, 今迄どれを使ったか

int solve(int n, int s, int used) {
    //cout << n << ' ' << s << ' ' << used << endl;
    if (s < 0) return 0;
    if (n == 0) {
        if (s == 0) return 1;
        return 0;
    }
    if (dp[n][s][used] != -1) return dp[n][s][used];
    int cnt = 0;
    for (int i = 0; i <= 9; i++) {
        if (used & (1<<i)) continue;
        //cout << "used " << i << endl;
        cnt += solve(n-1, s - i*n, used | (1<<i));
    }
    return dp[n][s][used] = cnt;
}

void init() {
    memset(dp, -1, sizeof(dp));
}

int main() {
    int n, s;
    init();
    while (cin >> n >> s) {
        if (s >= S) {
            cout << 0 << endl;
            continue;
        }
        cout << solve(n, s, 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 30296
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int d, i, j, c[28], s[370][28], b[28] = {}, ans;

    scanf("%d", &d);
    for (i = 0; i < 26; i++) {
        scanf("%d", &c[i]);
    }
    for (i = 0; i < d; i++) for (j = 0; j < 26; j++) {
        scanf("%d", &s[i][j]);
    }

    for (i = 0; i < 26; i++) {
        b[i] = 1;
    }

    //-----------------------
    int t[28], scmax, scmi;

    for (i = 0; i < d; i++) {
        scmax = 0;
        scmi = 0;
        for (j = 0; j < 26; j++) {
            if (scmax < s[i][j]) {
                scmax = s[i][j];
                scmi = j;
            }
        }
        t[i] = scmi;
    }

    //-----------------------

    ans = 0;
    for (i = 0; i < d; i++) {
        ans += s[i][t[i]];
        b[t[i]] = 0;
        for (j = 0; j < 26; j++) {
            ans -= c[j] * b[j];
            b[j]++;
        }
    }

    for (i = 0; i < d; i++) {
        printf("%d\n", t[i] + 1);
    }
    
    return 0;
}

Measured memory_bytes: 3856
cnt = [0 for i in range(26)]
while True:
      try:
            s = input()
      except:
            break
      for i in range(len(s)):
            m = ord(s[i])-ord('A')
            if(m >= 0 and m < 26):
                  cnt[m]+=1
            m = ord(s[i])-ord('a')
            if(m >= 0 and m < 26):
                  cnt[m]+=1
for i in range(26):
      print(chr(i+ord('a')),":",cnt[i])


Measured memory_bytes: 5568
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from bisect import *

Max = 300000
p_c = [True]*Max
p_c[0:2] = [False]*2
for i in range(2, Max):
    if i%7 in (1,6):
        p_c[i*2::i] = [False]*len(p_c[i*2::i])
    else:
        p_c[i] = False
prime = [i for i in range(Max) if p_c[i] == True]

while True:
    n = int(raw_input())
    if n==1: break
    ans = [i for i in prime[:bisect(prime, n+1)] if n%i == 0]
    print str(n) + ':' + ' ' + ' '.join(map(str, ans))

Measured memory_bytes: 16700
#include <cstdio>
#include <algorithm>
#include <numeric>
int N, a[100001];
int gcd(int x, int y)
{
	int r;
	while (y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
bool F()
{
	auto is_odd = [] (int x) { return x & 1; };
	int odd = std::count_if(a + 1, a + N + 1, is_odd), even = N - odd;
	if (even & 1)
		return true;
	if (odd == 1)
	{
		int &D = *std::find_if(a + 1, a + N + 1, is_odd);
		if (D == 1)
			return false;
		D--;
		int G = std::accumulate(a + 1, a + N + 1, 0, gcd);
		std::for_each(a + 1, a + N + 1, [G] (int &x) { x /= G; });
		return !F();
	}
	return false;
}
int main()
{
	scanf("%d", &N);
	std::for_each(a + 1, a + N + 1, [] (int &x) { scanf("%d", &x); });
	puts(F() ? "First" : "Second");
	return 0;
}


Measured memory_bytes: 512