akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T; cin >> S >>T;
    int ans = 0;
    REP(i,3){
        if(S[i]==T[i]) ans++;
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int t;
  cin >> t;
  vector<string> vect1 = {"1","2","3","4","5","6","7","8","9"};
  while(1){
    //cout << t << endl;
    if(vect1.size()>=t){
      cout << vect1[t-1];
      return 0;
    }
    vector<string> temp;
    for(auto k:vect1){
      if(k.at(k.length()-1)=='0'){
        temp.push_back(k+(char)(k.at(k.length()-1)));
        temp.push_back(k+(char)(k.at(k.length()-1)+1));

      }
      else if(k.at(k.length()-1)=='9'){
        temp.push_back(k+(char)(k.at(k.length()-1)-1));
        temp.push_back(k+(char)(k.at(k.length()-1)));
      }
      else{
        temp.push_back(k+(char)(k.at(k.length()-1)-1));
        temp.push_back(k+(char)(k.at(k.length()-1)));
        temp.push_back(k+(char)(k.at(k.length()-1)+1));
      }
    }
    t -= vect1.size();
    sort(temp.begin(),temp.end());
    vect1 = temp;
  }

}

Measured memory_bytes: 13600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b,m=0,c=0;
    string s;
    cin>>n;
   while(n--)
   {
       cin>>a>>b;
       if(a==b){
        c++;
        m=max(m,c);
       }
       else
        c=0;
   }
   if(m>=3)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;
}


Measured memory_bytes: 3624
//Trained.cpp (B)
#include <iostream>
using namespace std;

int main(){
  int N, total, t;
  total = 1;
  bool flag = false;
  int a[110000];
  cin >> N;
  for(int i = 1; i <= N; i++) cin >> a[i];
  t = a[1];
  for(int i = 1; i <= N; i++){
    if(t==2){
      flag = true;
      break;
    }
    t = a[t];
    ++total;

  }
  if(flag) printf("%d\n",total);
  else printf("-1\n");

}


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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	// vector <int> L(N, 0);
	int sum = 0;
	int cnt = 0;

	while (cnt < N) {
		int tmp;
		cin >> tmp;
		sum += tmp;
		if (sum > X){
			break;
		}
		cnt++;
	}



	cout << cnt+ 1 << endl;

	return 0;
}


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

int main(){
    int A, B, K;
    cin >> A >> B >> K;
    if(B-A+1 >= 2*K){
        for(int i = 0; i < K; i++){
            cout<<A+i<<endl;
        }
        for(int i = K-1; i >= 0; i--){
            cout<<B-i<<endl;
        }
    }else{
        for(int i = A; i <= B; i++){
            cout<<i<<endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
int main(){
  ll N,Q;
  string S;
  cin>>N>>Q>>S;
  vector<ll> vec(N);
  vector<ll> vec2(N);
  for(ll i=0;i<N-1;i++){
    if(S.at(i)=='A' && S.at(i+1)=='C'){
      if(i==0){vec.at(i)=1;}
      if(i!=0){vec.at(i)=vec.at(i-1)+1;}
    }
    else{
      if(i==0){vec.at(i)=0;}
      else{vec.at(i)=vec.at(i-1);}
    }
  }
  vec.at(N-1)=vec.at(N-2);
  for(ll i=0;i<N-1;i++){
    if(S.at(i)=='A' && S.at(i+1)=='C'){
      if(i==0){vec2.at(i+1)=1;}
      if(i!=0){vec2.at(i+1)=vec2.at(i)+1;}
    }
    else{
      if(i==0){vec2.at(i+1)=0;}
      else{vec2.at(i+1)=vec2.at(i);}
    }
  }
  vec2.at(0)=0;
  for(ll i=0;i<Q;i++){
    ll a,b;
    cin>>a>>b;
    cout<<vec2.at(b-1)-vec2.at(a-1)<<endl;
  }
}

Measured memory_bytes: 2688
#include <stdio.h>
  
   int main(void){
  
       int a,b,s,p;
       scanf("%d %d",&a,&b);
       if(a>=1 && b<=100){
  
           s=a*b;
          p=(a+b)*2;
          printf("%d %d\n",s,p);
 
      }
      return 0;
  }

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
const int bitlength{3};

class AllBitSearch
{//bitパターンを生成し，各パターンで処理
	vector<int> T;
	void values_set( ) {
		T.resize(4);
		vector<char> C(4);
		for (int i = 0; i < 4; ++i) { cin >> C[i]; }
		for (int i = 0; i < 4; ++i) { T[i] = int(C[i] - '0'); }
	}
	int check(bitset<bitlength> &Bit) {
		int x{T[0]};
		for (int b = 0; b < bitlength; ++b) {
			x = x - T[b + 1] * pow(-1, Bit.test(2 - b));
		}
		return x;
	}
	int patternDo( ) {
		string os = to_string(T[0]);
		for (int i = 0; i < (1 << 3); ++i) {
			bitset<bitlength> Bit(i);
			//cout << "pattern " << Bit << " ";
			int value = check(Bit); //cout << value << endl;
			if (value == 7) {
				for (int b = 0; b < bitlength; ++b) {
					if (Bit.test(2 - b) == 1) {
						os = os + "+" + to_string(T[b + 1]);
					} else {
						os = os + "-" + to_string(T[b + 1]);
					}
				}
				cout << os << "=7" << endl;
				return 0;
			}
		}
		return -1;
	}
public:
	void procedures( ) {
		values_set( );
		patternDo( );
	}
};

int main( ) {
	cin.tie(0); ios::sync_with_stdio(false);
	AllBitSearch niku;
	niku.procedures( );
}

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

using namespace std;

int n, a[100005], b[100005], ans = false;

vector <int> L, R;
map <int, int> M;

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a + n + 1);
    reverse(a, a + n + 1);
    for(int i = 0; i <= n; i++) b[i] = a[i] - i - 1;
    L.push_back(0);
    for(int i = 1; i <= n; i++) if(b[i] != b[i - 1] - 1) L.push_back(i);
    for(int i = 0; i < n; i++) if(b[i] != b[i + 1] + 1) R.push_back(i);
    R.push_back(n); // b[L[i]] ~ b[R[i]] ~ b[L[i + 1]] + 2
    for(int i = 0; i < L.size(); i++) M[b[L[i]]] = i;
    auto it = M.lower_bound(0);
    int i = it -> second;
    if(b[R[i]] % 2 == 0) ans = true;
    if(0 == b[L[i + 1]] + 1) {
        if(b[R[i + 1]] % 2 == 0) ans &= true;
        else ans = false;
        //extra_check
    }
    if(ans == false) printf("First\n");
    else printf("Second\n");
    //for(auto x : L) printf("%d ", b[x]); printf("\n");
    //for(auto x : R) printf("%d ", b[x]);
    return 0;
}

Measured memory_bytes: 5368
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			n = scanner.nextInt();
			m = scanner.nextInt();
			if ((n | m) == 0)
				break;
			lists = new ArrayList[n];
			for (int i = 0; i < n; i++)
				lists[i] = new ArrayList<Integer>();
			for (int i = 0; i < m; i++) {
				int a = scanner.nextInt() - 1;
				int b = scanner.nextInt() - 1;
				lists[a].add(b);
				lists[b].add(a);
			}
			b = new boolean[n];
			ans = 0;
			Deque<Integer> deque = new ArrayDeque<Integer>();
			deque.offer(0);
			b[0] = true;
			for (int k = 0; k < 2; k++) {
				int size = deque.size();
				for (int i = 0; i < size; i++) {
					int a = deque.poll();
					for (int t : lists[a]) {
						if (b[t])
							continue;
						b[t] = true;
						ans++;
						deque.offer(t);
					}
				}
			}
			System.out.println(ans);
		}
	}

	int n, m, ans;
	List<Integer>[] lists;
	boolean[] b;
}

Measured memory_bytes: 46356
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n,x=MI()
ms=sorted([I() for i in range(n)])
ans=n+(x-sum(ms))//ms[0]
print(ans)

Measured memory_bytes: 3316
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var h = hw[0];
        var w = hw[1];

        char[][] jag = new char[h][];
        for (int i = 0; i < h; i++)
        {
            jag[i] = Console.ReadLine().ToCharArray();
        }

        char[][] visited = new char[h][];
        for (int i = 0; i < h; i++)
        {
            visited[i] = new char[w];
            for (int k = 0; k < w; k++)
            {
                visited[i][k] = '.';
            }
        }

        var que1 = new Queue<int>();
        var que2 = new Queue<int>();

        visited[0][0] = '#';
        if (jag[0][1] == '#')
        {
            que1.Enqueue(0);
            que2.Enqueue(1);
        }
        else if (jag[1][0] == '#')
        {
            que1.Enqueue(1);
            que2.Enqueue(0);
        }

        while (que1.Count > 0)
        {
            var x = que1.Dequeue();
            var y = que2.Dequeue();

            visited[x][y] = '#';
            if (y + 1 < w && jag[x][y + 1] == '#')
            {
                que1.Enqueue(x);
                que2.Enqueue(y + 1);
            }
            else if (x + 1 < h && jag[x + 1][y] == '#')
            {
                que1.Enqueue(x + 1);
                que2.Enqueue(y);
            }
        }

        var ans = "Possible";
        for (int i = 0; i < h; i++)
        {
            for (int k = 0; k < w; k++)
            {
                if (jag[i][k] != visited[i][k])
                {
                    ans = "Impossible";
                    break;
                }
            }
        }

        // 出力
        Console.WriteLine(ans);
    }
}


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

using namespace std;

int main() {
  int H, W, M;
  cin >> H >> W >> M;
  vector<int> X(W, 0), Y(H, 0);
  unordered_map<int, vector<int>> S, T;
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> y >> x;
    x--;
    y--;
    X[x]++;
    Y[y]++;
    S[x].push_back(y);
    T[y].push_back(x);
  }

  int maxBombsX = 0;
  int maxBombsY = 0;
  for (int i = 0; i < W; i++) maxBombsX = max(maxBombsX, X[i]);
  for (int i = 0; i < H; i++) maxBombsY = max(maxBombsY, Y[i]);

  unordered_set<int> candX, candY;
  for (int i = 0; i < W; i++)
    if (X[i] == maxBombsX) candX.insert(i);
  for (int i = 0; i < H; i++)
    if (Y[i] == maxBombsY) candY.insert(i);

  int answer = maxBombsX + maxBombsY;
  for (int x : candX) {
    int attackY = 0;
    for (int y : S[x]) {
      if (candY.count(y)) attackY++;
    }
    if (attackY < candY.size()) {
      cout << answer << endl;
      return 0;
    }
  }
  for (int y : candY) {
    int attackX = 0;
    for (int x : T[y]) {
      if (candX.count(x)) attackX++;
    }
    if (attackX < candX.size()) {
      cout << answer << endl;
      return 0;
    }
  }
  cout << answer - 1 << endl;

  return 0;
}


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

int main() {
    int N, L;
    cin >> N >> L;
    vector<int> a(N);
    for(int i=0; i<N; ++i) cin >> a[i];

    int last = 0;
    for(int i=1; i<=N; ++i) {
        if(a[i- 1] + a[i] >= L) {
            last = i;
            break;
        }
    }

    if(last == 0) cout << "Impossible" << endl;
    else {
        cout << "Possible" << endl;
        for(int i=1; i<last; ++i) cout << i << endl;
        for(int i=N-1; i>last; --i) cout << i << endl;
        cout << last << endl;
    }
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long a = sc.nextInt();
		long b = sc.nextInt();
		long cities[] = new long[(int)n];
		for(int i=0;i<n;i++){
			cities[i] = sc.nextInt();
		}
		long poyasimi = 0;
		for(int i=0;i<n-1;i++){
			long sub = cities[i+1]-cities[i];
			poyasimi += Math.min(a*sub, b);
		}

		System.out.println(poyasimi);
	}

}

Measured memory_bytes: 33460
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.util.function.DoubleToLongFunction;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		long ans = K * (long)Math.pow((K-1), (N-1));
		System.out.println(ans);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21076
#include<cstdio>
const int N=1005,INF=~0u>>2;
struct Edge{int nxt,to;}edge[N*N];
int b[N],n,head[N],num_edge,vis[N],lk[N],even[N],odd[N],even_num,odd_num,ans,k,tot,tim;
int abs(int x){return x>0?x:-x;}
void add_edge(int from,int to){
	edge[++num_edge].nxt=head[from];
	edge[num_edge].to=to;
	head[from]=num_edge;
}
bool find(int x){
	for(int i=head[x];i;i=edge[i].nxt){
		if(vis[edge[i].to]!=tim){
			vis[edge[i].to]=tim;
			if(!lk[edge[i].to]||find(lk[edge[i].to])){
				lk[edge[i].to]=x;
				return 1;
			}
		}
	}
	return 0;
}
bool check(int x){
	if(x==1) return 0;
	for(int i=2;i*i<=x;++i){
		if(x%i==0) return 0;
	}
	return 1;
}
void solve(int x){
	if(x&1) odd[++odd_num]=x;
	else even[++even_num]=x;
}
int main(){
//	freopen("ex.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&b[i]);b[0]=-1;
	for(int i=1;i<=n;++i){
		if(b[i]!=b[i-1]+1) solve(b[i]);
		if(b[i]+1!=b[i+1]) solve(b[i]+1);
	}
	for(int i=1;i<=odd_num;++i){
		for(int j=1;j<=even_num;++j){
			if(check(abs(even[j]-odd[i]))) add_edge(i,j);
		}
	}
	for(int i=1;i<=odd_num;++i){
		tim++;
		if(find(i)) k++;
	}
	ans=k+((even_num-k)/2+(odd_num-k)/2)*2+((odd_num-k)%2)*3;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define tezi ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
typedef long long ll;

int main(){
    tezi;
    int a, b, c, k, ans = 0;
    cin >> a >> b >> c >> k;
    if(k >= a){
        k -= a;
        ans += a;
    }
    else{
        ans += k;
        k = 0;
    }
    if(k >= b){
        k -= b;
    }
    else{
        k = 0;
    }
    if(k >= c){
        k -= c;
        ans -= c;
    }
    else{
        ans -= k;
        k = 0;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=(1LL<<63) - 600;
const ll mod=1e9+7 ;


int main(){
  char S; cin >> S;
  cout << (char)(S+1) << endl;
}

Measured memory_bytes: 256
import itertools
n, k = map(int, input().split())
 
def c(n):
    if n <= 2:
        return 1
    return n * (n - 1) // 2
 
 
if n > 2 and k <= c(n - 1):
    print(n - 1 + c(n - 1) - k)
    nodes = list(range(2, n + 1))
    for i in nodes:
        print(1, i)
 
    combi = itertools.combinations(nodes, 2)
    for i in range(c(n - 1) - k):
        print(*next(combi))
else:
    print("1\n1 2" if k == 0 else -1)

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF=ll(1e18)+1;
int main() {
  ios::sync_with_stdio(false);
	cin.tie(0);
  ll n,k;
  cin>>n>>k;
  vector<ll>a(n);
rep(i,n){
  cin>>a[i];
}
sort(a.begin(),a.end());
ll l=-INF;
ll r=INF;
while (l+1<r){
  ll cnt=0;
  ll x=(l+r)/2;
//cout<<x<<endl;


  rep(i,n){
//  ll i=1;
  //cout<<a[i];
    if (a[i]>=0){
      ll l1=-1; ll r1=n;
      while(l1+1<r1){
        ll c1=(l1+r1)/2;
        if(a[c1]*a[i]<x)l1=c1;else r1=c1;
      }
      cnt+=r1;
    }
    else {
      ll l1=-1; ll r1=n;
      while(l1+1<r1){
        ll c1=(l1+r1)/2;
        if(a[c1]*a[i]<x)r1=c1;else l1=c1;
      }
      cnt+=n-r1;
    //  cout<<cnt<<endl;
    }
    if(a[i]*a[i]<x)cnt-=1;

  }

  //if (ok)l=x;else r=x;
cnt/=2;
//cout<<cnt<<endl;
  if (cnt<k)l=x;else r=x;

}


cout<<l;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int a, b;
	cin>>a>>b;
	cout<<max({a+b, a-b, a*b})<<'\n';
	return 0;
}


Measured memory_bytes: 256
ans=[4,6,9,11]
a,b=map(int,input().split())

def solve(x,y):
  if x==2 or y==2:
    return False
  elif (x in ans and y in ans) or (not(x in ans) and not(y in ans)):
    return True
  else:
    return False

if solve(a,b):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;  
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

////////////////////////////////////////////////////////

ll B[100010];

int main() {
    ll n, m; cin >> n >> m;
    rep(i, 0, m){
        ll a, b; cin >> a >> b;
        B[a]++, B[b]++;
    }

    bool f = true;
    Rep(i, 1, n) if(B[i]%2 != 0) f = false;
    if(f) co("YES");
    else co("NO");

    return 0;
}
 
 


Measured memory_bytes: 4416
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 55;
const int MAXM = 1000010;
const int MAXK = 510;
const int MAXQ = 200010;

int n, k;
ll dp[MAXN][MAXN][MAXN*MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    dp[0][0][0] = 1;
    FOR(i,0,n-1)
        FOR(j,0,i)
            FOR(p,0,k) {
                dp[i+1][j][p+2*j] = (dp[i+1][j][p+2*j] + dp[i][j][p]) % MODBASE;
                dp[i+1][j+1][p+2*j+2] = (dp[i+1][j+1][p+2*j+2] + dp[i][j][p]) % MODBASE;
                if (j) {
                    dp[i+1][j][p+2*j] = (dp[i+1][j][p+2*j] + dp[i][j][p] * j * 2) % MODBASE;
                    dp[i+1][j-1][p+2*j-2] = (dp[i+1][j-1][p+2*j-2] + dp[i][j][p] * j * j) % MODBASE;
                }
            }
    cout << dp[n][0][k];
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    vector<pii> x(n);

    rep(i, n)
    {
        cin >> x[i].first;
        x[i].second = i;
    }
    sort(ALL(x));
    int a = x[n / 2].first;
    int b = x[n / 2 - 1].first;
    rep(i, n)
    {
        x[i].first = i;
        swap(x[i].first, x[i].second);
    }
    sort(ALL(x));

    rep(i, n)
    {
        if (x[i].second <= n / 2 - 1)
            OP(a);
        else
            OP(b);
    }
    return 0;
}

Measured memory_bytes: 3712
import java.util.*;

public class Main {


    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();

        if (k==1) {
            System.out.println(0);
        }else{
            System.out.println(n-k);
        }


    }
}



Measured memory_bytes: 23764
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [hm,wm] <- getIntList
    [h,w] <- getIntList
    print $ (hm-h) * (wm-w)

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

class Main {

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

		long min = Long.MAX_VALUE;
		int count = 0;
		for (int i = 0; i < P.length; i++) {
			if (min > P[i]) {
				min = P[i];
				count++;
			}
		}
		System.out.println(count);
	}
}


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

int main()
{
	int a,b;
  	cin >> a >> b;
  	string s1,s2;
  	for(int i = 0;i < a;i++)
  	  s1 += to_string(b);
  	for(int i = 0;i < b;i++)
  	  s2 += to_string(a);
  	cout << min(s1,s2);
  return 0;
}

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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const int INF = 1e9 + 5;
const long long MAXN=2e5 + 5;;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool cmp(const string& a, const string& b) {
	return (a + b) < (b + a);
}

vector<int> Reversed(const vector<int>& s){
   vector<int> d = s;
   reverse(all(d));
   return d;
}

void solve(){
    string a, b, c;
    cin >> a >> b >> c;
    int sa = a.size(), sb = b.size(), sc = c.size(), i = 1, j = 0, k = 0;
    char ch = a[0];
    while(1){
        if(ch == 'a'){
            if(i == sa){
                cout << 'A';
                return;
            }
            ch = a[i];
            i++;
            continue;
        }
        if(ch == 'b'){
            if(j == sb){
                cout << 'B';
                return;
            }
            ch = b[j];
            j++;
            continue;
        }
        if(ch == 'c'){
            if(k == sc){
                cout << 'C';
                return;
            }
            ch = c[k];
            k++;
            continue;
        }
    }
}


int main(){
    //freopen("slalom.in","r",stdin);
    //freopen("slalom.out","w",stdout);
    //faster();
    int n = 1;
    //cin >> n;
    while(n--){
        solve();
        cout << endl;
    }
    //fclose(stdout);
}


Measured memory_bytes: 3596
#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<char>> VVc;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#ifdef LOCAL
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgset(st) cerr << #st << ":"<<endl; for (auto i = st.begin(); i != st.end(); ++i) { cerr << *i <<" ";}cerr<<endl;
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#else
#define dbg(...)
#define dbgmap(...)
#define dbgset(...)
#define dbgarr(...)
#define dbgdp(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int solve(){
    ll d,t,s;
    cin>>d>>t>>s;
    Yes(d<=t*s);
    return  0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
//    ll T;
//    cin>>T;
//    while(T--)
    solve();
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define     ll          long long int
#define     REP(i,x,n)    for(ll i=x;i<n;i++)
#define     SZ(v)       (ll)v.size()
#define     endl        "\n"
#define     ff          first
#define     ss          second
#define     PQ_MIN      priority_queue <ll, vector<ll>, greater<ll> >
#define     PQ          priority_queue <int>
#define     pbds        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define     setbit(x)   __builtin_popcount(x)
#define     prec(n)     fixed<<setprecision(n)
#define     pb(n)       push_back(n)
#define     mp(a,b)     make_pair(a,b)
#define     clr(n)      memset(n,0,sizeof(n))
#define     reset(n)    memset(n,-1,sizeof(n))
#define     ii          pair<ll,ll>
#define     vll         vector<ll>
using namespace std;
using namespace __gnu_pbds;
const ll INF=1e16;
const ll nxm=5e5+5;

struct node
{
    ll l,r,ind;
};
ll a[nxm];
ll n,q;
ll ans[nxm];
ll last[nxm];
ll bit[nxm];


bool comp(node a,node b) {

   return a.r <= b.r;
}
node query[nxm];

void update(ll ind,ll val)
{
    while(ind<=n)
    {
        bit[ind]+=val;
        ind+=(ind&(-ind));
    }
}
ll pref(ll ind)
{
    ll cnt=0;

    while(ind>0)
    {
        cnt+=bit[ind];
        ind-=(ind  & (-ind));
    }
    return cnt;
}
ll query_c(ll l,ll r)
{
    return pref(r)-pref(l-1);
}


void solve(){

memset(bit,0,sizeof(bit));

REP(i,0,nxm) last[i]=-1;

cin>>n>>q;

REP(i,1,n+1) cin>>a[i];


REP(i,0,q)
{
        cin>>query[i].l>>query[i].r;
        query[i].ind=i;
}

//REP(i,0,q) cout<<query[i].l<<" "<<query[i].r<<" "<<query[i].ind<<endl;

sort(query,query+q,comp);


//REP(i,0,q) cout<<query[i].l<<" "<<query[i].r<<" "<<query[i].ind<<endl;

ll qc=0;

REP(i,1,n+1){

    if(last[a[i]]!=-1)
    {
        update(last[a[i]],-1);
    }

    update(i,1);
    last[a[i]]=i;

while(qc<q && query[qc].r==i)
{
    ll l=query[qc].l,r=query[qc].r;

    ans[query[qc].ind]= query_c(l,r);
//    cout<<l<<" "<<r<<" "<<query_c(l,r)<<endl;
    qc++;
}

}

REP(i,0,q) cout<<ans[i]<<endl;



}
int main(){
//    freopen("timber_input", "r", stdin);
//    freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
//	cin>>t;
    REP(i,1,t+1)
    {
//    cout<<"Case #"<<i<<": ";
		solve();
    }
	return 0;
}
//  bitset<64>(x).to_ullong() // in my com  _ulong()
//  cout<<bitset<64>(ans).to_string().substr(64-m)<<endl;
/*

char s[100];

fgets(s,100,stdin);

stringstream stram(s);

string abc;

bool ok1=0,ok2=0;

while(stram>>abc)
*/


Measured memory_bytes: 31176
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys

sys.setrecursionlimit(10 ** 5 + 10)


# input = sys.stdin.readline

def resolve():
    S = input()
    s = [int(c) for c in S]
    K = int(input())

    if len(s) == 1:
        print(s[0])
    else:
        if K == 1:
            print(s[0])
        else:
            cnt=0
            for i in range(len(s)):
                if s[i] == 1:
                    cnt+=1
                    if cnt>=K:
                        print(1)
                        break
                else:
                    if cnt<K:
                        print(s[i])
                        break
                    print(s[i])
                    break


resolve()

Measured memory_bytes: 3064
#!/usr/bin/env python
# coding: utf-8

# In[15]:


N = int(input())
a = []
for _ in range(N):
    a += [int(input())]


# In[16]:


if all([x%2==0 for x in a]):
    print("second")
else:
    print("first")


# In[ ]:






Measured memory_bytes: 13852
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>

using namespace std;

#define ll long long
#define MAX 100000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    int a;
    cin >> a;
    cout << (a + a * a + a * a * a);

    return 0;
}

Measured memory_bytes: 3152
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<set>
#include<iomanip>
using namespace std;

int main() {

	int n;
	cin >> n;
	int t[110000], x[110000], y[110000];
	t[0] = x[0] = y[0] = 0;
	for (int i = 0; i < n; i++) {
		cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
	}

	bool can = true;
	for (int i = 0; i < n; i++) {
		int dt = t[i + 1] - t[i];
		int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);

		if (dt < dist) {
			can = false;
		}
		if (dt % 2 != dist % 2) {
			can = false;
		}
	}

	if (can) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll x;
  cin >> x;
  ll ans= (x/500) * (1000);
  x-= (x/500)*500;
  ans+= (x/5)*5;
  cout << ans << endl;
  return 0;
} //good night.

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	k := nextInt()
	a := make([]int64, n+10)
	b := make([]int64, m+10)
	a[0] = 0
	b[0] = 0
	for i := int64(1); i <= n; i++ {
		a[i] = a[i-1] + nextInt()
	}
	for i := int64(1); i <= m; i++ {
		b[i] = b[i-1] + nextInt()
	}
	res := int64(0)
	j := int64(0)
	for j = int64(0); j <= m && b[j] <= k; j++ {
	}
	if j == m+1 || b[j] > k {
		j--
	}
	res = j
	for i := int64(1); i <= n; i++ {
		if a[i] > k {
			break
		}
		for ; a[i]+b[j] > k && j > 0; j-- {
		}
		if i+j > res {
			res = i + j
		}
	}
	fmt.Println(res)
}


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

int main() {
	int a, b, c, x, y, ans = 0;
	cin >> a >> b >> c >> x >> y;
	int ans1 = (a * x + b * y);
	if (c + c <= a + b) {
		int z = min(x, y);
		x -= z;
		y -= z;
		ans += c * z * 2;	
	}
	ans += min(a * x + b * y, 2*c*(max(x, y)));
	cout << min(ans, ans1);
	return 0;
}

Measured memory_bytes: 256
import sys, math
from functools import lru_cache
from collections import defaultdict
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    D = list(mi())
    ans = 1

    if D[0] != 0:
        print(0)
        return

    dic = defaultdict(int)
    for i in range(N):
        dic[D[i]] += 1

    for i in range(1, N):
        ans *= dic[D[i]-1]
        ans %= 998244353

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 24024
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int a,b,c;
	cin >> a >> b >> c;
	for(int i = 0;i < 1000000;i++){
		if(a % 2 || b % 2 || c % 2){
			cout << i << endl;
			return 0;
		}
		int na = b / 2 + c / 2;
		int nb = a / 2 + c / 2;
		int nc = a / 2 + b / 2;
		a = na;
		b = nb;
		c = nc;
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair

// a + b = n (0 <= a, b <= 9)??¨??????????????????????????°
int calc(int n) {
    if (n > 18) return 0;
    if (n > 9) n = 18 - n;
    return n + 1;
}

int main(void)
{
    cin.sync_with_stdio(false);
    int n;

    while(cin >> n) {
        int ret = 0;
        REP(a_plus_b, n + 1) {
            int c_plus_d = n - a_plus_b;
            ret += calc(a_plus_b) * calc(c_plus_d);
        }
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 1188
import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {
    private static Scanner sc = new Scanner(new BufferedInputStream(System.in));

    static int N, M, X;
    static int[] prices = new int[12];
    static int[][] map = new int[12][12];
    static int[] cur_goal = new int[12];
    static int cur_cost = 0;
    static int mincost = Integer.MAX_VALUE;


    static void dfs(int i) {
        if (i == N) {
            return;
        }

        cur_cost += prices[i];
        for (int j = 0; j < M; j++) {
            cur_goal[j] += map[i][j];
        }

        boolean suc = true;
        for (int j = 0; j < M; j++) {
            if (cur_goal[j] < X) {
                suc = false;
                break;
            }
        }

        if (suc && cur_cost < mincost) {
            mincost = cur_cost;
        }

        dfs(i + 1);
        cur_cost -= prices[i];
        for (int j = 0; j < M; j++) {
            cur_goal[j] -= map[i][j];
        }
        dfs(i + 1);
    }

    public static void main(String[] args) {
        N = sc.nextInt();
        M = sc.nextInt();
        X = sc.nextInt();
        for (int i = 0; i < N; i++) {
            prices[i] = sc.nextInt();
            for (int j = 0; j < M; j++) {
                map[i][j] = sc.nextInt();
            }
        }
        dfs(0);
        if (mincost == Integer.MAX_VALUE) {
            System.out.println(-1);
        } else {
            System.out.println(mincost);
        }

    }
}


Measured memory_bytes: 38132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	string s;
	cin >> s;
	int k;
	cin >> k;
	set<string> a;
	for(int i = 0; i < (int)s.length(); i++){
		int lim = min(k, (int)s.length()-i);
		for(int j = 1; j <= lim; j++){
			a.insert(s.substr(i, j));
		}
	}
	auto it = a.begin();
	rep(i,k-1) it++;
	string ans = *it;
	cout << ans << endl;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(){
   char s[300000],c,r[300001];
   int q,i,j,mp,ap,np,d,f,t,next[300000];
 
   scanf("%s",s);
   for (i=0;s[i]!='\0';i++) next[i]=i+1;
   mp=0;ap=i-1;np=i;
   scanf("%d",&q);
   d=1;
   for (i=0;i<q;i++) {
      scanf("%d",&t);
      if (t==1)
         d=3-d;
      else {
         scanf("%d %c",&f,&c);
         s[np]=c;
         if (f==1 && d==1) {
            next[np]=mp;
            mp=np;
         } else if (f==2 && d==1){
            next[ap]=np;
            ap=np;
         } else if (f==1 && d==2){
            next[ap]=np;
            ap=np;
         } else {
            next[np]=mp;
            mp=np;
         }
         np++;
      }
   }
   if (d==1) {
      for (i=mp;i!=ap;i=next[i]) printf("%c",s[i]);
      printf("%c",s[i]);
   } else {
      j=np-1;
      for (i=mp;i!=ap;i=next[i]) r[j--]=s[i];
      r[0]=s[i];
      r[np]='\0';
      printf("%s",r);
   }
   puts("");
   return 0;
}


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

using namespace std;

int main()
{
   string U,S,T;
   int A,B;
   cin>>S>>T;
   cin >>A>>B;
   cin>>U;
   if(U==S)
     A--;
   else
    B--;
   cout <<A<<" "<<B;

    return 0;
}


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

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;


int dp[3500][3500];// dp[i][j]:= i番目まで見たときに合計時間時間jでの最大
int prev_w[3500][3500];//復元用テーブル
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,W;
	cin >> n >> W;
	W--;
	vector<int> weight(n+5),value(n+5);
	rep(i,n)cin >> weight[i] >> value[i];
	for (int i = 0; i < n; ++i){
		for(int w = 0;w<=W;w++){
			if (w >= weight[i]) {
                if (dp[i+1][w] < dp[i][w-weight[i]] + value[i]) {
                    dp[i+1][w] = dp[i][w-weight[i]] + value[i];
                    prev_w[i+1][w] = w - weight[i];
                }
            }
			// i 番目の品物を選ばない場合を考える
            if (dp[i+1][w] < dp[i][w]) {
                dp[i+1][w] = dp[i][w];
                prev_w[i+1][w] = w;
            }
		}
	}
	
	vector<bool> used(n);
	
    int cur_w = W;
    for (int i = n-1; i >= 0; --i) {
        // 選んでいた場合
        if (prev_w[i+1][cur_w] == cur_w - weight[i]) {
            //cout << i << " th item (weight = " << weight[i] << ", value = " << value[i] << ")" << endl;
        	used[i] = 1;
        }
        // 復元テーブルをたどる
        cur_w = prev_w[i+1][cur_w];
    }
	int plus = 0;
	for(int i=0;i<n;i++){
		if(used[i]==0)plus = max(plus,value[i]);
	}
	cout << dp[n][W] + plus << endl;
}

Measured memory_bytes: 86272
n, m = map(int, input().split())
a = []
b = []

for _ in range(n):
    l = list(map(int, input().split()))
    a.append(l)

for _ in range(m):
    e = int(input())
    b.append(e)
    
for row in a:
    sum = 0
    for i in range(m):
        sum += row[i] * b[i]
    print(sum)


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

typedef pair<int,int> P;

#define fr first
#define sc second
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)

int main(){
	int n,m;
	int a[305][305];
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			scanf("%d",&a[i][j]);
		}
		a[i][m+1]=0;
	}
	
	bool used[305];
	int cnt[305]={};
	int loc[305]={};
	priority_queue<P> que;
	for(int i=1;i<=n;i++){
		used[i]=false;
		cnt[a[i][1]]++;
		que.push(P(cnt[a[i][1]],a[i][1]));
		loc[i]=1;
	}
	int ret=n;
	used[0]=false;
	while(!que.empty()){
		P p=que.top(); que.pop();
		if(p.sc==0)break;
		if(used[p.sc])continue;
		used[p.sc]=true;
		chmin(ret,p.fr);
		for(int i=1;i<=n;i++){
			if(a[i][loc[i]]==p.sc){
				while(used[a[i][loc[i]]])loc[i]++;
				cnt[a[i][loc[i]]]++;
				que.push(P(cnt[a[i][loc[i]]],a[i][loc[i]]));
			}
		}
	}
	cout<<ret<<endl;
}


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

#define MAX_LENGTH 100

int main(void) 
{
	char str[MAX_LENGTH + 1];
	int palindrome = 0;
	int length;
	int i;

	while (scanf("%s", str) != EOF) {
		length = strlen(str);

		for (i = 0; i <= length / 2; i++) {
			if (str[i] != str[length - (i + 1)]) 
				break;
			else if (i == length / 2)
				palindrome++;
		}
	}

	printf("%d\n", palindrome);

	return 0;
}

Measured memory_bytes: 540