akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int mod = 998244353;
	static long inf = (long) 1e18 + 1;
	static int[] col;
	static int n, m;
	static ArrayList<pair>[] ad;
	static long[][][] memo;
	static HashSet<Integer> h;
	static int[] a;
	static char[][][] g;
	static int ans = Integer.MAX_VALUE;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int n=sc.nextInt();
	//	int []a=sc.nextArrInt(n);
		int d=0;
		for(int i=0;i<n;i++)
			d=gcd(d, sc.nextInt());
		System.out.println(d);
		out.flush();
	}
	static int gcd(int a, int b) {

		if (b == 0)
			return a;
		return gcd(b, a % b);
	}
	static class pair implements Comparable<pair> {
		long to;
		long number;

		pair(long t, long n) {
			number = n;
			to = t;
		}

		public String toString() {
			return to + " " + number;
		}

		@Override
		public int compareTo(pair o) {
			if (to == o.to)
				return Long.compare(number, o.number);
			return Long.compare(to, o.to);
		}

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

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

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 35740
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()

    # 偶数番目の合計を負
    # 奇数番目の合計を正にするパターン
    sm, r1 = 0, 0
    for n in range(N):
        sm += A[n]
        if n % 2 == 0 and sm < 1:
            r1 += abs(sm) + 1
            sm = 1
        elif n % 2 != 0 and sm > -1:
            r1 += abs(sm) + 1
            sm = -1

    # 偶数番目の合計を正
    # 奇数番目の合計を負にするパターン
    sm, r2 = 0, 0
    for n in range(N):
        sm += A[n]
        if n % 2 == 0 and sm > -1:
            r2 += abs(sm) + 1
            sm = -1
        elif n % 2 != 0 and sm < 1:
            r2 += abs(sm) + 1
            sm = 1

    # 操作数が小さいほうを出力
    print(min(r1, r2))


if __name__ == '__main__':
    main()


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using llu = long long unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    char s[1231];

    Scs(s);

    YesNo( s[2] == s[3] && s[4] == s[5] );

    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include <stdio.h>
using namespace std;
int main()
{   int a;
    cin >> a;
    if( a == 3 || a == 5 || a == 7){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
  return 0;
}

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

#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl

#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())
#define REVERSE(x) reverse( (x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define PW(x) (1LL<<(x))

using namespace std;
using ll = int64_t;
using P = pair<int, int>;

template<class T,class U>
ostream& operator<<(ostream &os, const pair<T, U> &p) {
    os << get_variable_name(p) << " = (" << p.first <<", " << p.second << ")";
    return os;
}

template<class T>
ostream& operator <<(ostream& os, const vector<T> &v){
    cout << get_variable_name(v) << " = [";
    for(auto i : v) 
        os << " " << i;
    os << " ]";
    return os;
}


const int INF = 1e8;

int main() {
    ios::sync_with_stdio(false);

    vector<int> p(3);
    for(int i = 0; i < 3; i++) cin >> p[i];

    sort(ALL(p));

    if(p[0]+p[1] == p[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		Stack<Character> st = new Stack<>();
		for(int i=0; i<s.length(); i++) {
			char c = s.charAt(i);
			if(c == 'B') {
				if(st.isEmpty()) {
					continue;
				}
				st.pop();
			} else {
				st.add(c);
			}
		}
		int N = st.size();
		char[] result = new char[N];
		for(int i=0; i<N; i++) {
			result[N-i-1] = st.pop();
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 9552
#include <iostream>
#include <iomanip>
using namespace std;
 
int main() {
  int n,a,i,min=1000000,max=-1000000;
  long long sum=0;

  cin >> n;
  
  for(i=0;i<n;i++){
      cin >> a;
      if(a < min){
          min = a;
      }
      if(a > max){
          max = a;
      }
      sum += a;
  }

  cout << min << " " << max << " " << sum << endl;
  
  return 0;
}



Measured memory_bytes: 3092
/*
 * main.cpp
 *
 *  Created on: 2020/04/10
 *      Author: SkAaO
 */

#include <iostream>

using namespace std;

int main(){
	int N;
	cin >> N;
	char S[N];
	for(int i = 0; i < N; i++){
		cin >> S[i];
	}

	int flag[4] = {0};
	for(int i = 0; i < N; i++){
		if(S[i] == 'P'){
			flag[0]++;
		}else if(S[i] == 'Q'){
			flag[1]++;
		}else if(S[i] == 'G'){
			flag[2]++;
		}else if(S[i] == 'Y'){
			flag[3]++;
		}
	}

	if(flag[3] == 0){
		cout << "Three" << endl;
	}else{
		cout << "Four" << endl;
	}

	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    string s;
    cin>>s;
    vector<char> v;
    rep(i, s.size()){
        if(i==s.size()-1) v.push_back(s[i]);
        else if(s[i]=='B' && s[i+1]=='C'){
            v.push_back('D');
            i++;
        }
        else {
            v.push_back(s[i]);
        }
    }
    vector<ll> ans;
    ll nowd=0;
    bool ok=false;
    reverse(v.begin(), v.end());
    rep(i, v.size()){
        if(ok){
            if(v[i]=='D') nowd++;
            else if(v[i]=='A'){
                ans.push_back(nowd);
            }
            else {
                ok=false;
                nowd=0;
            }
        }
        else{
            if(v[i]=='D') {
                nowd++;
                ok=true;
            }
        }
    }
    ll res=accumulate(ans.begin(), ans.end(), 0LL);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()


#define m  1000000000
int main(){
    ll s;
    cin >> s; 
    
    ll x1, y1, x2, y2, x3, y3;
    x1 = y1 = 0;

    x2 = m;
    y2 = 1;
    x3 =(x2 - s % x2) % x2;
	y3 =(s+x3) / x2;

    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " "<< x3 << " " << y3 << endl;
    
}

Measured memory_bytes: 256
def examA():
    H, W = LI()
    S = [LSI() for _ in range(H)]
    Alpha = [chr(ord('A') + i) for i in range(26)]
    for i in range(H):
        for j in range(W):
            if S[i][j]=="snuke":
                ans = str(Alpha[j]) + str(i+1)
    print(ans)
    return

def examB():
    N = I()
    ans = []
    cur = int((N*2-1)**0.5)+1
    ansC = (cur+1)*cur//2
    neg = ansC-N
    if neg>cur:
        cur -=1
        ansC = (cur + 1) * cur // 2
        neg = ansC - N
    for i in range(1,cur+1):
        if i!=neg:
            ans.append(i)
    for v in ans:
        print(v)
#    print(cur,neg)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()


Measured memory_bytes: 41456
N = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
count = 0

for i in range(N):
  count += 1
  if i == N-1 or a[i+1] != a[i]:
    if a[i] < count:
      ans += count - a[i]
    elif a[i] > count:
      ans += count
    count = 0
print(ans)

Measured memory_bytes: 14268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define INX(x) (cin >> x)
#define OUTX(x) (cout << x << endl)

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>


int main()
{
    string N;
    INX(N);

    ll sum = 0;
    for (ll i = 0; i < (ll)N.size(); i++)
    {
        sum += N[i] - '0';
        sum = sum % 9;
    }
    OUTX((sum == 0 ? "Yes" : "No"));



    return 0;
}


Measured memory_bytes: 3724
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 無限 #####
# f_inf = float('inf')

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	ST = input()
	ST = ST[:-1]
	STS = ST.split()
	A,B = inputMap()
	U = input()
	U = U[:-1]

	if U == STS[0]:
		A -= 1
	else:
		B -= 1

	print("{} {}".format(A,B))

if __name__ == "__main__":
	main()


Measured memory_bytes: 38384
#include <iostream>

using namespace std;
int seven(int n)
{
    while(n!=0)
    {
        if(n%10==7) return 1;
        else n/=10;
    }
    return 0;
}
int main()
{
    int n;
    cin >> n;
    if(seven(n)) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

template <class T>
class SuffixArray {
public:
	std::vector<int> buildSuffix(const std::vector<T> &array) {
		int n = array.size();
		std::vector<int> sa(n);
		for(int i = 0; i < n; i++) {
			sa[i] = i;
		}
		std::sort(sa.begin(), sa.end(), [&](int a, int b) { return array[a] < array[b]; });
		int cur = 0;
		std::vector<int> inv(n);
		std::vector<int> nxt(n);
		inv[sa[0]] = 0;
		for(int i = 1; i < n; i++) {
			inv[sa[i]] = (array[sa[i - 1]] != array[sa[i]] ? ++cur : cur);
		}
		cur++;
		for(int k = 0; cur < n; k++) {
			cur = 0;
			auxSort(sa, inv, 1 << k);
			for(int l = 0, r = 0; l < n; l = r, cur++) {
				while(r < n && getPair(inv, sa[l], 1 << k) == getPair(inv, sa[r], 1 << k)) {
					nxt[sa[r++]] = cur;
				}
			}
			nxt.swap(inv);
		}
		return sa;
	}
private:
	void auxSort(std::vector<int> &sa, const std::vector<int> &inv, int offset) {
		// O(nlogn) step, O(nlog^2n) total
		std::sort(sa.begin(), sa.end(), [&](int a, int b) { return getPair(inv, a, offset) < getPair(inv, b, offset); });
		// O(n) step, O(nlogn) total -- TO DO --
	}
	std::pair<int, int> getPair(const std::vector<int> &inv, int pos, int offset) {
		return std::pair<int, int>(inv[pos], pos + offset < inv.size() ? inv[pos + offset] : -1);
	}
};

SuffixArray<char> builder;

std::string op(const std::string &str, int n) {
	/*std::string ans = str.substr(0, n);
	for(int i = 1; i + n <= (int) str.size(); i++) {
		ans = std::min(ans, str.substr(i, n));
	}
	return ans;*/
	std::vector<char> arr(str.begin(), str.end());
	auto sa = builder.buildSuffix(arr);
	for(auto i : sa) {
		if(i + n <= str.size()) {
			return str.substr(i, n);
		}
	}
	return "";
}

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, k;
	std::string str;
	std::cin >> n >> k >> str;
	k = std::min(k, 20);
	std::string rev = str;
	std::reverse(rev.begin(), rev.end());
	k--;
	str = op(str + rev, n);
	while(k--) {
		rev = str;
		std::reverse(rev.begin(), rev.end());
		str = op(rev + str, n);
	}
	std::cout << str << '\n';
}

Measured memory_bytes: 512
#include <stdio.h>
#define MAX 100
#define INF 1<<21
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dij();

int n,BY[MAX][MAX];

int main(){
    int u,k,v,c;
    int i,j;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            BY[i][j]=INF;
        }
    }
    for(i=0;i<n;i++){
        scanf("%d%d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d%d",&v,&c);
            BY[u][v]=c;
        }
    }
    dij();

    return 0;
}

void dij(){
     int minicost,i,u,v;
    int wei_min[MAX],color[MAX];

    for(i=0;i<n;i++){
        wei_min[i]=INF;
        color[i]=WHITE;
}
wei_min[0]=0;
color[0]=GRAY;

while(1){
    minicost=INF;
    u=-1;
    for(i=0;i<n;i++){
         if(color[i]!=BLACK && wei_min[i]<minicost){
            minicost=wei_min[i];
            u=i;
    }
    }
    if(u==-1) break;
    color[u]=BLACK;

    for(v=0;v<n;v++){
        if(color[v]!=BLACK && BY[u][v]!=INF){
            if(wei_min[u]+BY[u][v]<wei_min[v]){
                wei_min[v]=wei_min[u]+BY[u][v];
                color[v]=GRAY;
            }
        }
    }
}
for(i=0;i<n;i++){
    printf("%d %d\n",i,(wei_min[i]==INF?-1:wei_min[i]));
}
}



Measured memory_bytes: 2052
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			String word = sc.next();
			String query = sc.next();
			if (query.equals("X")) break;
			ArrayList<String> elems = new ArrayList<String>();
			if (word.indexOf("_") >= 0) {
				String[] vals = word.split("_");
				for (String val : vals) {
					elems.add(val);
				}
			} else {
				int pos = 0;
				for (int i = 1; i < word.length(); ++i) {
					if (Character.isUpperCase(word.charAt(i))) {
						elems.add(word.substring(pos, i).toLowerCase());
						pos = i;
					}
				}
				elems.add(word.substring(pos).toLowerCase());
			}
			StringBuilder result = new StringBuilder();
			if (query.equals("U")) {
				for (int i = 0; i < elems.size(); ++i) {
					result.append(Character.toUpperCase(elems.get(i).charAt(0)));
					result.append(elems.get(i).substring(1));
				}
			} else if (query.equals("L")) {
				result.append(elems.get(0));
				for (int i = 1; i < elems.size(); ++i) {
					result.append(Character.toUpperCase(elems.get(i).charAt(0)));
					result.append(elems.get(i).substring(1));
				}
			} else {
				result.append(elems.get(0));
				for (int i = 1; i < elems.size(); ++i) {
					result.append("_");
					result.append(elems.get(i));
				}
			}
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 12000
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1; 
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int sosu[1000] = {};
int uenososu[1000020] = {};
int main() {
	string s, t;
	cin >> s >> t;
	int ans = t.size();
	for (int i = 0; i <= s.size() - t.size(); i++) {
		int sum = 0;
		for (int j = 0; j < t.size(); j++) {
			if (t[j] != s[j + i]) {
				sum++;
			}
		}
		ans = min(ans, sum);
	}
	cout << ans;
}

Measured memory_bytes: 3608
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
def sortx(x,n,k):
    if k == 0:x.sort(key=lambda y:y[1,n])
    else:x.sort(reversed=True, key=lambda y:y[1,n])

def graphm():
    n,m=inpm()
    g=[[] for _ in range(n)]
    for _ in range(m):
        a,b,w=inpm()
        a-=1
        b-=1
        g[a].append((w,b))
        g[b].append((w,a))
    return n,m,g

def prim(n,g):
    edgelist = []
    used = [False for _ in range(n)]
    for edge in g[0]:
        heappush( edgelist, edge)
    used[0] = True
    res = 0 

    while len(edgelist)>0:
        minedge = heappop(edgelist)
        if used[minedge[1]]:
            continue
        v = minedge[1]
        used[v] = True
        for edge in g[v]:
            if not used[edge[1]]:
                heappush( edgelist, edge)
        res += minedge[0]
    return res

def main():
    n=inp()
    xy=[]
    for index in range(n):
        x,y = inpm()
        xy.append((x,y,index))
        
    g=[[] for _ in range(n)]
    xy.sort()
    for i in range(n-1):
        j = i+1
        w = min(abs(xy[i][0]-xy[j][0]),abs(xy[i][1]-xy[j][1]))
        a = xy[i][2]
        b = xy[j][2]
        g[a].append((w,b))
        g[b].append((w,a))
    xy.sort(key=lambda y:y[1])
    for i in range(n-1):
        j = i+1
        w = min(abs(xy[i][0]-xy[j][0]),abs(xy[i][1]-xy[j][1]))
        a = xy[i][2]
        b = xy[j][2]
        g[a].append((w,b))
        g[b].append((w,a))
    print( prim(n,g) )

if __name__ == "__main__":
    main()

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second


int main(){
    ll n;
    cin >> n;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    P pos[n];
    vector<P> vec;
    rep(i,0,n) cin >> pos[i].fs >> pos[i].sc;
    rep(i,0,n){
        rep(j,0,n){
            vec.push_back(P(pos[i].fs - pos[j].fs,pos[i].sc - pos[j].sc));
        }
    }

    sort(vec.begin(),vec.end());
    vec.erase(unique(vec.begin(),vec.end()),vec.end());
    
    ll ans = LINF;
    sort(pos,pos+n,greater<P>());
    rep(i,0,vec.size()){
        ll cnt = 1;
        ll memo = 1;
        P p = pos[0];
        bool is_used[n] = {false};
        is_used[0] = true;
        while(cnt < n){
            rep(j,0,n){
                if(!is_used[j] && p.fs - pos[j].fs == vec[i].fs && p.sc - pos[j].sc == vec[i].sc){
                    p = pos[j];
                    is_used[j] = true;
                    cnt++;
                    break;
                }
                else if(j == n-1){
                    rep(k,0,n){
                        if(!is_used[k]){
                            p = pos[k];
                            is_used[k] = true;  
                            cnt++;
                            memo++;
                            break;
                        }
                    }
                }
            }
        }

        ans = min(ans,memo);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3664
#コインで裏をn回出す確率

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N = int(input())
    p = tuple(map(float, input().split()))

    #dp[j]:裏がj枚でる確率
    dp = [1] + [0]*(N//2)
    for i in range(N):
        for j in range(i+1, -1, -1):
            if j==0:
                dp[j] = dp[j]*p[i]
            elif j<=(N//2):
                dp[j] = dp[j-1]*(1-p[i]) + dp[j] * p[i]
    res = sum(dp)
    print('{:.9f}'.format(res))

if __name__ == '__main__':
    main()

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

struct record {
  int student;
  int time;
};

bool asc( const record& left, const record& right ) {
    return left.time < right.time;
}

int main(){
  int N;
  cin >> N;
  vector<record> s(N);
  for(int i=0;i<N;i++){
    s[i].student = i+1;
    cin >> s[i].time;
  }
  sort(s.begin(),s.end(),asc);
  for(int j=0;j<N;j++){
    cout << s[j].student;
    if(j!=N-1){
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int i,sum=0; 
 string s,t;
 cin >> s >> t;
 for(i=0;i<s.size();i++){
   if(s[i]!=t[i]){
     sum += 1;
   } 
 }
 cout << sum << endl;
  
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec[i].first >> vec[i].second;
    }
    sort(vec.begin(), vec.end(), [&](auto i, auto j) {
        return i.first < j.first;        
    });
    long long int res = 0ll;
    for (int i = 0; i < n; i++) {
        if (!m) {
            break;
        }
        int canGet = min(m, vec[i].second);
        res += 1ll * canGet * vec[i].first;
        m -= canGet;
    }
    cout << res << '\n';
    return 0;
}


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

using namespace std;

int
main(void){
	int n; cin >> n;
	vector<vector<int> > score(n, vector<int> (3));
	
	for(int i = 0; i < n; i++) cin >> score[i][0] >> score[i][1] >> score[i][2];
	
	vector<vector<int> > dp(n, vector<int>(3));
	for(int i = 0; i < n; i++) 
		for(int j = 0; j < 3; j++)
			dp[i][j] = INT_MIN;
	
	for(int i = 0; i < 3; i++) dp[0][i] = score[0][i];
	
	for(int i = 1; i < n; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if(j != k){
					dp[i][j] = max(dp[i][j], dp[i - 1][k] + score[i][j]);
				}
			}
		}
	}
	
	int ans = INT_MIN;
	for(int i = 0; i < 3; i++) ans = max(ans, dp[n - 1][i]);
	
	cout << ans;
	
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (a > x) {
		cout << "NO" << endl;
		return 0;
	}
	cout << (((x - a) < b) ? "YES" : "NO") << endl;
}

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

using namespace std;

int main()
{
    int a[111][111];
    int value[111111];
    int h,w;
    int n;
    cin>>h>>w>>n;

    for(int i=1;i<=n;i++)
    {
        cin>>value[i];
    }

    int x=1;

    for(int i=0;i<h;i++)
    {

        if(i%2==0) for(int j=0;j<w;j++)
        {
            if(value[x]==0) x++;
            a[i][j]=x;
            value[x]--;

        }

        else for(int j=w-1;j>=0;j--)
        {
             if(value[x]==0) x++;
             a[i][j]=x;
             value[x]--;
        }
    }

    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cout<<a[i][j]<<" ";
        }
        cout<<"\n";
    }

}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {


    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String input_str[] = new String[2];
        Deque<String> list = new ArrayDeque<String>();
        StringBuilder ans = new StringBuilder();

        try {
            int N = Integer.parseInt(br.readLine());

            for(int loop = 0; loop < N; loop++){
                input_str = br.readLine().split("\\s+");

                if(input_str[0].equals("insert")){
                    list.addFirst(input_str[1]);
                }else if(input_str[0].equals("delete")){
                    list.remove(input_str[1]);
                }else if(input_str[0].equals("deleteFirst")){
                    list.removeFirst();
                }else if(input_str[0].equals("deleteLast")){
                    list.removeLast();
                }
            }

            if(!list.isEmpty()){
                ans.append(list.getFirst());
                list.removeFirst();
            }
            while(!list.isEmpty()){
                ans.append(" ").append(list.getFirst());
                list.removeFirst();
            }

            System.out.println(ans.toString());

        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 599872
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n, k;
    cin >> n >> k;

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

    ll ans = INF;
    REP(i, 1 << n) {
        if (bcnt(i) != k) continue;

        ll h = 0;
        ll tmp = 0;
        REP(j, n) {
            if (i >> j & 1) {
                if (h >= a[j]) {
                    tmp += h - a[j] + 1;
                    h++;
                }
            }
            h = max(h, a[j]);
        }

        ans = min(ans, tmp);
    }

    print(ans);
}

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

using str = string;
using ss = stringstream;

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

    str s,t;
    cin>>s>>t;

    bool ans=false;

    for(int i=0;i<t.size();i++)
    {
        if(s==t)ans=true;

        char ss=s[0];

        for(int j=1;j<s.size();j++)s[j-1]=s[j];
        s[s.size()-1]=ss;
    }

    puts(ans?"Yes":"No");

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+10;

int a[N], n;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a+1, a+n+1);
    int ans = 0;
    for (int i = 1; i <= 100000; i++) {
        int st = lower_bound(a+1, a+n+1, i) - a;
        if (n - st + 1 == st - 1) ans++;
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;

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

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (ll i=(b)-1; i>=a;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector<vector<T> >& vec) {
    REP(i,vec.size()) {
        if(i) os << endl;
        os << vec[i];
    }
    return os;
}

struct Edge {
    int to, cost;
};

double per;
double C;
vector< vector<Edge> > G;

double dp1(int v, int prev) {
    double res = 0;
    EACH(e, G[v]) {
        if (e.to == prev) continue;
        res += per * (e.cost + dp1(e.to, v));
    }
    return res;
}

double dp2(int v, int prev) {
    double res = C;
    EACH(e, G[v]) {
        if (e.to == prev) continue;
        res += per * (e.cost + dp2(e.to, v));
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> per;
    int n; cin >> n;
    G.resize(n);
    REP(i, n-1) {
        int a, b, c; cin >> a >> b >> c; --a, --b;
        G[a].pb({b, c});
        G[b].pb({a, c});
    }
    C = dp1(0, -1);
    cout << fixed << setprecision(10) << dp2(0, -1) << endl;
}

Measured memory_bytes: 14804
#include<cstdio>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<boost/range/algorithm.hpp>

#define MAX_N   100
#define MAX_M   100

using namespace std;

main(){
    int a[3];
    scanf("%d %d %d", &a[0], &a[1], &a[2]);
    printf("%s", (boost::count(a, 5) == 2) && (boost::count(a, 7) == 1) ? "YES" : "NO");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    long int l[100];
    l[0]=2;
    l[1]=1;
    cin >> n;
    for(int i=2; i<n+1 ;i++){
        l[i] = l[i-2] + l[i-1];
    }
    cout << l[n] << endl;
    
    return 0;
}

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

int main() {
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0; i<k; i++) {
        int d; cin>>d;
        for(int j=0; j<d; j++) {
            int x; cin>>x;
            a[x-1]++;
        }
    }
    int ans=0;
    for(int i=0; i<n; i++) {
        if(a[i] == 0) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int r,g,b, num;
    cin >> r >> g >> b;
    
     num = 100 * r + 10 * g + b;
     if(num%4 == 0){
         cout << "YES" << endl;
     }
     else
     {
         cout << "NO" << endl;
     }
}


Measured memory_bytes: 3596
#!/usr/bin/python3
# coding: utf-8

# 整数 > 整数型
def I(): return int(input())

# 整数列 '1 2 3 4' > 整数型リスト
def IsIl(): return list(map(lambda x: int(x), input().split()))

# 改行挟む整数列　'1/n 2/n 3/n' > 整数型りすと
def InIl(n): return [input() for i in range(n)]

# 整数列 '1 2' > 整数型タプル
def IsIt(): return map(lambda x: int(x), input().split())

# 改行挟む整数列　'1\n 2\n 3\n' > 整数型たぷる
def InIl(n): return map(input() for i in range(n))

# 文字列 'abcd' > 文字型リスト
def SsSl(): return list(map(lambda x: x, input()))

# 整数 '1234' > 整数型リスト

# 文字列 'aba' > 辞書（文字型:個数）{'a':2,'b':1}
def SSd():
    from collections import defaultdict
    A = input() # [int(i) for i in input().split()]
    dd=defaultdict(int)
    for a in A:
        dd[a]+=1
    return dd

#リストにn個要素を読み込む

# その他アルゴリズムテンプレート
# https://qiita.com/chun1182/items/ddf2b6cba932b2bb0d4e
n = int(input())

string = input()

if n%2 != 0:
  print('No')
else:
  if string[:int(n/2)] == string[int(n/2):]:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int N;
	cin >> N;

	vector<int> d;
	inputVector(d, N);

	set<int> st;
	rep(i, N) st.insert(d[i]);

	cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <numeric>
#include <map>
#include <iomanip>
#include <climits>
#include <string>

using namespace std;


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

	int a;
	cin >> a;
	string s;
	cin >> s;
	if (a >= 3200)
		cout << s;
	else cout << "red";
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def digit_sum(num:int, base:int) -> int:
    if num < base:
        return num
    else:
        return digit_sum(int(num/base), base) + (num % base)

def snuke(num: int):
    return num / digit_sum(num, 10)

k = ni()

snuke_nums = [i for i in range(1,10)]
res = 9
cur = 9

if k <= res:
    for s in snuke_nums[:k]:
        print(s)

else:
    while res != k:
        cur += 1
        
        cands = []
        for i in range(len(str(cur))):
            cands.append(int(str(cur)[:-i-1] + "9"*(i+1)))
            
        mi = float("inf")
        for c in cands:
            if snuke(c) < mi:
                cur = c
                mi = snuke(c)
                
        snuke_nums.append(cur)
        res += 1
        
    for s in snuke_nums:
        print(s)

Measured memory_bytes: 93420
import sys
sys.setrecursionlimit(100000000)

def main():
    N,M = map(int,input().split())
    e = [[] for i in range(N)]
    t = 0
    a = []
    for i in range(M):
        r,l,d = map(int,input().split())
        e[r-1].append([l-1,d])
        e[l-1].append([r-1,-d])
        a.append(r-1)
        a.append(l-1)
        t = r-1

    col = [ float("inf") for i in range(N) ]
    def dfs(i,c):

        for node in e[i]:
            if col[node[0]] == float("inf"):
                col[node[0]] = c + node[1]
                dfs(node[0],c+node[1])
            elif col[node[0]] != c + node[1]:
                print("No")
                exit()


    dfs(t,0)
    a = list(set(a))
    for i in a:
        if col[i] == float("inf"):
            dfs(i,0)


    print("Yes")


if __name__ == '__main__':
    main()


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

signed main()
{
  int N; cin >> N;
  vector<int> vec(N);
  for(int i = 0; i<N; ++i){
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  
  int dan = 0,mini = 0;
  for(int i = 0; i<N; ++i){
    if(vec[i]>mini) {++dan; mini = vec[i];}
  }
  cout << dan << "\n";
}


Measured memory_bytes: 3572
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    h,w = LI()
    a = [[c for c in S()] for _ in range(h)]
    r = [[0]*w for _ in range(h)]
    r[0][0] = 1
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                continue
            if i > 0:
                r[i][j] += r[i-1][j]
            if j > 0:
                r[i][j] += r[i][j-1]
            r[i][j] %= mod

    return r[-1][-1]


print(main())


Measured memory_bytes: 53800
#include<bits/stdc++.h>
#define N 200100
using namespace std;
pair<int,int> p[N];
vector<int> a0;
int dp[40];
bool cmp(pair<int,int> a,pair<int,int> b){
	return 1LL*b.first*a.second<1LL*b.second*a.first;
}
int main(){
	int n,t,m=0,a,b,ans=0;
	scanf("%d%d",&n,&t);
	t++;
	for(int i=0;i<n;i++){
		scanf("%d%d",&a,&b);
		b++;
		if(a==0) a0.push_back(b);
		else p[m++]=make_pair(a,b);
	}
	sort(p,p+m,cmp);
	sort(a0.begin(),a0.end());
	a0.push_back(t+1);
	memset(dp,-1,sizeof(dp));
	dp[0]=1;
	for(int i=0;i<m;i++){
		for(int j=39;j>=0;j--){
			if(dp[j]<0) continue;
			if(p[i].second<=t && dp[j]<=(t-p[i].second)/(p[i].first+1)){
				int nt=dp[j]*(p[i].first+1)+p[i].second;
				if(dp[j+1]<0 || nt<dp[j+1]) dp[j+1]=nt;
			}
		}
	}
	for(int i=0;i<40;i++){
		if(dp[i]<0) continue;
		//printf("%d: %d\n",i,dp[i]);
		for(int j=0;j<a0.size();j++){
			ans=max(i+j,ans);
			dp[i]+=a0[j];
			if(dp[i]>t) break;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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


int main()
{
  string s = {'A','C','G','T'};
  char b;
  
  cin >> b;
  
  for(int i=0;i<s.size();i++){
    if(s.at(i)==b){
      cout << s.at(3-i) << endl;
    }
  }
    
  
  return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

int gcd(int a, int b) {
if (b == 0) return a;
return gcd(b, a % b);
}

ll N, M;
ll x[10010], y[10010], z[10010];
ll ans[10][10010];

int main() {
	cin >> N >> M;
	REP(i, N) cin >> x[i] >> y[i] >> z[i];

	bool bit[10];
	REP(i, 8) {
		ll tmp = i;
		REP(j, 3) {
			bit[j] = tmp % 2 == 1;
			tmp /= 2;
		}
		REP(j, N) {
			ans[i][j] += x[j] * (bit[0] ? 1 : -1)
				+ y[j] * (bit[1] ? 1 : -1)
				+ z[j] * (bit[2] ? 1 : -1);
		}
	}
	ll sum = 0;
	ll ans2[10010];
	REP(i, 8) {
		REP(j, N) ans2[j] = ans[i][j];
		sort(ans2, ans2 + N, greater<ll>());
		ll tmp = 0;
		REP(j, min(M, (ll)2000))
		{
			tmp += ans2[j];
		}
		sum = max(sum, tmp);
	}
	cout << sum << endl;
}

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

int main(){
    string S; cin >> S;
    if (S[2]==S[3] && S[4]==S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN,'%d%d',$N,$L);
$a=[];
for ($i=0; $i <$N ; $i++) {
  // code...
  fscanf(STDIN,'%s',$S);
  $a[]=$S;
}
sort($a);
for ($i=0; $i <$N ; $i++) {
  // code...
  echo $a[$i];
}
echo "\n";

 ?>


Measured memory_bytes: 3576
ListA=[list(map(int,input().split())) for i in range(3)] # N行C列・・・Cは任意
ListB=[[0,0,0] for i in range(3)]                # N行C列・・・Cは任意
N=int(input())                                          # 1行1列
ListC=[int(input()) for i in range(N)]                   # N行1列

for i in ListC:
	for y in range(3):
		for x in range(3):
			if ListA[y][x] == i:
				ListB[y][x] = 1

if ListB[0][0] == 1 and ListB[0][1] and ListB[0][2]:
	print('Yes')
elif ListB[1][0] == 1 and ListB[1][1] and ListB[1][2]:
	print('Yes')
elif ListB[2][0] == 1 and ListB[2][1] and ListB[2][2]:
	print('Yes')
elif ListB[0][0] == 1 and ListB[1][0] and ListB[2][0]:
	print('Yes')
elif ListB[0][1] == 1 and ListB[1][1] and ListB[2][1]:
	print('Yes')
elif ListB[0][2] == 1 and ListB[1][2] and ListB[2][2]:
	print('Yes')
elif ListB[0][0] == 1 and ListB[1][1] and ListB[2][2]:
	print('Yes')
elif ListB[0][2] == 1 and ListB[1][1] and ListB[2][0]:
	print('Yes')
else:
	print('No')


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

const int maxn = 2e5 + 50;
long long a[maxn], cnt[maxn];
set<int> temp;

int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i)
	{
		cin >> a[i];
		cnt[a[i]]++;
	}
	long long ans = 0;
	for(int i = 1; i <= n; ++i)
	{
		if(cnt[i])
			ans += (cnt[i] - 1) * cnt[i] / 2;
	}
	for(int i = 1; i <= n; ++i)
		cout << ans - cnt[a[i]] + 1 << endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
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 (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int A[3][3] = {0};
    rep(i,3)rep(j,3)cin >> A[i][j];
    int N;cin >> N;
    vector<int> b(N);
    rep(i,N)cin >> b[i];

    vector<vector<bool>> c(3,vector<bool>(3,false));
    rep(i,N){
        rep(j,3)rep(k,3)if(b[i] == A[j][k])c[j][k] = true;
    }

    bool ok = false;
    rep(i,3)if(c[i][0])if(c[i][1])if(c[i][2])ok = true;
    rep(i,3)if(c[0][i])if(c[1][i])if(c[2][i])ok = true;
    if(c[0][0])if(c[1][1])if(c[2][2])ok = true;
    if(c[0][2])if(c[1][1])if(c[2][0])ok = true;

    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    int a,b,n;
    string s,t,u;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(s == u)a--;
    if(t == u)b--;

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256