akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
int main(){
    llint R;
    cin >> R;
    if(R < 1200){
        cout << "ABC" << endl;
        return 0;
    }
    if(R < 2800){
        cout << "ARC" << endl;
        return 0;
    }
        cout << "AGC" << endl;
        return 0;
}

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

int memo[100010];
bool flag[100010];
vector<int> g[100010];

int solve(int i){
	if(flag[i])return memo[i];
	
	flag[i]=true;
	
	int res=0;
	int sz=g[i].size();
	
	for(int j=0;j<sz;j++)res=max(res,solve(g[i][j])+1);
	
	return memo[i]=res;
}

int main(){
	int n,m;
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int x,y;
		cin >> x >> y;
		--x;
		--y;
		g[x].push_back(y);
	}
	
	for(int i=0;i<n;i++)flag[i]=false;
	
	int ans=0;
	for(int i=0;i<n;i++)ans=max(ans,solve(i));
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;
 
int main(){
   int k; cin >> k;
   vector<ll> a(k);
   rep(i,k) cin >> a[i];
   ll mn=2; ll ma=2;
   if(a[k-1]>2){
       cout << -1 << endl;
       return 0;
   }
   for(int i=k-1; i>=0; i--){
       //mn=a[i]*((mn-1)/a[i]+1);
       //ma=((ma/a[i])+1)*a[i]-1;
       mn=((mn-1)/a[i]+1)*a[i];
       ma=(ma/a[i])*a[i]+a[i]-1;
       //cout << ma << endl;
       //cout << mn << ' ' << ma << endl;
       if(mn>ma){
           cout << -1 << endl;
           return 0;
       }
   }
 
   cout << mn << ' ' << ma << endl;
return 0;
}

Measured memory_bytes: 4016
def main():
    H, W = map(int, input().split())
    A = [list(map(int, input().split())) for h in range(H)]
    cnt = 0
    out = []
    for h in range(H):
        for w in range(W):
            if A[h][w]%2 == 1:
                cnt += 1
                if w < W-1:
                    A[h][w+1] += 1
                    out.append(list(map(str, [h+1, w+1, h+1, w+2])))
                elif h < H-1:
                    A[h+1][w] += 1
                    out.append(list(map(str, [h+1, w+1, h+2, w+1])))
                else:
                    cnt -= 1
    print(cnt)
    for posi in out:
        print(" ".join(posi))


if __name__ == '__main__':
    main()


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

int main() {
	char C;
	cin >> C;

	if (C == 'a' || C == 'i' || C == 'u' || C == 'e' || C == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}


int main(){

    string s; cin >> s;

    ll cnt = 0;
    char c = s[0];
    rep2(i, 1, s.size()){
        if(c!=s[i]) cnt++;
        c = s[i];
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3764
#include <iostream>

using namespace std;

struct Process
{
    char name[10];
    int time;
    Process(int t=0) : time(t) {}
};

class Queue
{
    int nelem, head, tail;
    Process *vec;

public:
    Queue(int n) : nelem(n), head(0), tail(n), vec(new Process[nelem+1]) {
        set_vec();
    }

    void set_vec(){
        for(int i=0; i < nelem; i++){
            cin >> vec[i].name >> vec[i].time;
        }
    }

    void inqueue(Process& v){
        if(tail == nelem + 1) tail = 0;
        vec[tail++] = v;
    }

    Process& dequeue(){
        if(head == nelem){
            head = 0;
            return vec[nelem];
        }
        return vec[head++];
    }

    bool empty(){
        return head == tail;
    }
};

int main()
{
    int n, qms, sum=0;
    cin >> n >> qms;
    Process temp;

    Queue queue(n);

    while(!(queue.empty())){
        temp = queue.dequeue();
        if(temp.time > qms)
        {
            temp.time -= qms;
            sum += qms;
            queue.inqueue(temp);
        }
        else{
            sum += temp.time;
            cout << temp.name << " " << sum << endl;
        }
    }
}


Measured memory_bytes: 3788
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

"""
うーん，二部グラフっぽい？
言語と人の対応で，パスが8以内にあればOKみたいな
木の直径みたいな感じで行ける？
ある人から見て一番遠い人を1人選んで，その人から見て全員が8以内に入ればOKそう？
誤読っぽ，単純にUFで良いかも
"""

def main():
    ################
    class UnionFind():
        """
        parents : 親要素(findしない場合は根ではないことの注意)，根の場合は"-(要素数）"
        find(x):要素xの属するグループの根を返す
        size(x):要素xの属するグループの要素数を返す
        same(x,y):x,yが同じグループに属しているか返す
        重いかも！　　members(x):要素xが属するグループに属する要素をリストで返す
        roots:全ての根の要素を返す
        group_count():グループの数を返す
        重いかも！　all_group_members():{根要素：[そのグループに含まれる要素のリスト]}の辞書を返す
        """
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        def find(self, x):
            #根を探す&つなぎかえる
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)

            if x == y:
                return

            if self.parents[x] > self.parents[y]:
                x, y = y, x

            self.parents[x] += self.parents[y]
            self.parents[y] = x

        def size(self, x):
            return -self.parents[self.find(x)]

        def same(self, x, y):
            return self.find(x) == self.find(y)

        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]

        def group_count(self):
            return len(self.roots())

        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}

        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
        
    ################


    
    N,M=MI()
    uf=UnionFind(N+M)
    for i in range(N):
        L=LI()
        for j in range(1,L[0]+1):
            l=L[j]
            l-=1
            uf.union(i,l+N)
            
    roots=uf.roots()
    temp=0
    for v in roots:
        if v<N:
            temp+=1
        
            
    if temp<=1:
        print("YES")
    else:
        print("NO")
        

        
            
    
main()


Measured memory_bytes: 82068
from collections import deque

class Puzzle:
    def __init__(self, ls, answer_flag=False):
        self.piece_vec = list(ls)
        self.update_value = [-3, 3, -1, 1]
        for idx, piece in enumerate(ls):
            if piece == 0:
                self.space_idx = idx
        
        self.space_idx_before_slide = deque()
        self.manhattan_distance = list()
        if answer_flag:
            for i in range(9):
                self.manhattan_distance.append([(abs(i % 3 - j % 3) + abs(i // 3 - j // 3)) for j in range(9)])
                    
        
    def GetManhattanDistance(self, ans_idx, idx):
        return self.manhattan_distance[ans_idx][idx]
        
    def SumManhattanDistance(self, answer_board):
        sum_MD = 0
        for idx, piece in enumerate(self.piece_vec):
            if piece == 0:
                continue
            answer_idx = piece - 1
            sum_MD += answer_board.GetManhattanDistance(answer_idx, idx)
        return sum_MD
    
    def SlideSpace(self, command):
        is_frame = [self.space_idx < 3, self.space_idx >= 6, self.space_idx % 3 == 0, self.space_idx % 3 == 2]
        if is_frame[command]:
            return False
        
        next_space_idx = self.space_idx + self.update_value[command]
        if len(self.space_idx_before_slide) > 0 and next_space_idx == self.space_idx_before_slide[-1]:
            return False
        
        self.piece_vec[self.space_idx], self.piece_vec[next_space_idx] = self.piece_vec[next_space_idx], self.piece_vec[self.space_idx]
        self.space_idx_before_slide.append(self.space_idx)
        self.space_idx = next_space_idx
        return True
    
    def BackState(self):
        self.piece_vec[self.space_idx], self.piece_vec[self.space_idx_before_slide[-1]] = self.piece_vec[self.space_idx_before_slide[-1]], self.piece_vec[self.space_idx]
        self.space_idx = self.space_idx_before_slide.pop()

def SolvePuzzleByDFS(board, answer_board, limit, depth = 0):
    if board.SumManhattanDistance(answer_board) == 0:
        return True
    
    if depth + board.SumManhattanDistance(answer_board) > limit:
        return False
    
    for command in range(4):
        if board.SlideSpace(command) == False:
            continue
        
        if SolvePuzzleByDFS(board, answer_board, limit, depth+1):
            return True
        board.BackState()
    
    return False

def CalcMinStepOf15Puzzle(board, answer_board):
    for limit in range(board.SumManhattanDistance(answer_board), 35):
        if SolvePuzzleByDFS(board, answer_board, limit):
            return limit
    
    return -1

def main():
    inputLs = list()
    answerLs = [ 1, 2, 3,
                 4, 5, 6, 
                 7, 8, 9]
    for _ in range(3):
        inputLs += list(map(int, input().split()))

    start_board = Puzzle(inputLs)
    answer_board = Puzzle(answerLs, True)
    
    min_step = CalcMinStepOf15Puzzle(start_board, answer_board);
    
    print(min_step)

if __name__ == '__main__':
    main()



Measured memory_bytes: 6024
def increase(a, b, c, d):
    k = (b + d - 1) // d
    return k*c, k*d

n = int(raw_input())
a, b = map(int, raw_input().split())
for i in range(n - 1):
    c, d = map(int, raw_input().split())
    if a*d == b*c:
        continue
    if a*d < b*c:
        a, b = increase(a, b, c, d)
    else:
        b, a = increase(b, a, d, c)
print(a + b)


Measured memory_bytes: 2568
/*input

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii; 


#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define syso(n) cout<<n<<endl;
#define sysom(message, n) cout<<message<<n<<endl;
#define all(c) c.begin(), c.end() 
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end())  //map, set
#define cpresent(container, element) (find(all(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 


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

ll lcm(ll fir, ll sec){
	return (fir*sec)/(gcd(fir, sec));
}


const int MOD = 1e9 + 7;
const string small_alphabets = "abcdefghijklmnopqrstuvwxyz";
const int month_days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(5) << f << '\n';


int main(){
	int n,a,b;
	cin>>n>>a>>b;
	if(abs(a-b)%2==0){
		syso("Alice");
	}else{
		syso("Borys");
	}
	return 0;
}


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

public class Main {
	public static void main (String[] args) {
	   InputReader in = new InputReader(System.in);
	   int n = in.readInt();
	   long k = in.readLong();
	   long range[] = new long[100005]; 
	   for(int i = 0; i<n; i++) {
		   int a = in.readInt();
		   int b = in.readInt();
		   range[a] += b; 
	   }
	   long d = 0; 
	   for(int i = 1; i<100005; i++) {  
           d += range[i]; 
           if(d >= k) {
			   System.out.println(i);
			   return; 
		   } 
	   }
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e12;
using Graph = vector<vector<int>>;

signed main(){
  string S;
  cin >> S;
  int N = (int)S.size();
  if( N == 1 ){
    cout << 1 << endl;
    return 0;
  }

  vector<int> dp(N+10);
  dp[0] = 1;
  if( S[0] == S[1] ) dp[1] = 1;
  else dp[1] = 2;
  if( N == 2 ){
    cout << dp[1] << endl;
    return 0;
  }

  if( S[0] != S[1] && S[1] != S[2] ) dp[2] = 3;
  else dp[2] = 2;

  for( int i = 3; i < N; i++ ){
    if( S[i] == S[i-1] ) dp[i] = dp[i-3]+2;
    else dp[i] = dp[i-1]+1;
  }
  cout << dp[N-1] << endl;


}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

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

  set<char>ss,tt;
  map<char,int>ms,mt;
  int n=s.size();
  rep(i,0,n){
    ss.insert(s[i]);
    ms[s[i]]++;
    tt.insert(t[i]);
    mt[t[i]]++;
  }

  if(ss.size()!=tt.size()){
    out("No");
    return 0;
  }
  vector<int>vs,vt;

  set<char>::iterator is=ss.begin(),it=tt.begin();
  rep(i,0,ss.size()){
    vs.push_back(ms[*is]);
    vt.push_back(mt[*it]);
    is++;
    it++;
  }
  sort(vs.begin(),vs.end());
  sort(vt.begin(),vt.end());

  rep(i,0,vs.size()){
    if(vs[i]!=vt[i]){
      out("No");
      return 0;
    }
  }

  out("Yes");
  // set<int>sc,tc;
  // for(set<char>::iterator itr=ss.begin();itr!=ss.end();itr++){

  // }


  return 0;
}


Measured memory_bytes: 776
n,x,y = map(int,input().split())
x -= 1
y -= 1
dis = [0 for i in range(n)]
for i in range(n):
    for j in range(i+1,n):
        dis[min(abs(j-i),min(abs(j-y)+abs(x-i)+1,abs(j-x)+abs(y-i)+1))] += 1
print("\n".join(map(str,dis[1:])))

Measured memory_bytes: 45148
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,k;cin>>n>>k;
    cout<<n-k+1;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
	int n;
	float height;
	int t[6] = {0};
	
	scanf("%d", &n);
	
	while(n-- > 0){
		scanf("%f", &height);
		
		if(height < 165.0) t[0]++;
		else if(height < 170.0) t[1]++;
		else if(height < 175.0) t[2]++;
		else if(height < 180.0) t[3]++;
		else if(height < 185.0) t[4]++;
		else t[5]++;
	}
	
	for(int i = 0; i < 6;i++){
		printf("%d:", i+1);
		for(int j = 0; j < t[i]; j++){
			printf("*");
		}
		puts("");
	}
	
	return(0);
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

signed 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
import java.util.Scanner;
import java.util.Stack;

public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int x;

		String s= sc.nextLine();
		String num[] = s.split(" ");

		Stack<Integer> st = new Stack<Integer>();

		for (int i=0;i<num.length;++i){
			if(num[i].equals("+")==true){
				x=st.pop()+st.pop();
				st.push(x);
			}
			else if(num[i].equals("-")==true){
				x=-st.pop()+st.pop();
				st.push(x);
			}
			else if(num[i].equals("*")==true){
				x=st.pop()*st.pop();
				st.push(x);
			}
			else st.push(Integer.valueOf(num[i]));
		}

		System.out.println(st.pop());


	}
}


Measured memory_bytes: 26268
N = gets.chomp.to_i

def cul(x,y,z)
  x**2 + y**2 + z**2 + x*y + y*z + z*x
end

ans = Array.new(10**5, 0)
1.upto(100) do |x|
  1.upto(100) do |y|
    1.upto(100) do |z|
      v = cul(x,y,z)
      break if v > 10**4
      ans[v] += 1
    end
  end
end

1.upto(N) do |n|
  p ans[n]
end


Measured memory_bytes: 14912
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections

S = sys.stdin.readline().rstrip()
T = sys.stdin.readline().rstrip()
SN = len(S)
TN = len(T)
m = 0

for i in range(SN-TN+1):
    t = 0
    for j in range(TN):
        if T[j]==S[i+j]:
            t += 1
    m = max(m,t)
print(TN-m)


Measured memory_bytes: 9332
// https://atcoder.jp/contests/abc172/tasks/abc172_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll a;
  cin >> a;

  ll res = a + pow(a, 2) + pow(a, 3);
  cout << res << "\n";
}


Measured memory_bytes: 4104
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll a, b;
    cin >> a >> b;
    ll n = b - a; // n-th tower
    ll height = (n + 1) * n / 2;
    cout << height - b << endl;
    return 0;
}

Measured memory_bytes: 256
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long 
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

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

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int vis[N],par[N],a[N];

void go()
{
	cin >> m >> n;

	fo(i,0,n) cin >> a[i];

	sort( a , a + n ) ;

	rfo( i,n-1 , 0)
	{
		m -= a[i];
	}

	if( m  <= 0 ) cout << "Yes\n";
	else cout << "No\n";	
}

int32_t main()
{
	//INP(); 
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}



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

int main() {
	long long n,m,i,j,k,ans=0,b=1,cur,res,mod=1000000007;
	
	cin >> n;
	vector<long long> a(n);
	for(i=0; i<n; i++){
		cin >> a[i];
	}
	
	b=1;
	for(i=0; i<61; i++){
		cur=0;
		for(j=0; j<n; j++){
			cur+=a[j]%2;
			a[j]/=2;
			cur%=mod;
		}
		ans+=(((b*cur)%mod)*(n-cur))%mod;
		ans%=mod;
		b*=2;
		b%=mod;
	}
	cout << ans;
	
}


Measured memory_bytes: 2560
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n=k()
if n == 1:
    print(1)
    sys.exit()

if n % 2==0:
    print((n/2)/n)
else:
    print((n//2+1)/n)


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


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

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

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

    int npm;
   
    if(a[i]  > a[i-1]) npm = 1;
    else if(a[i] == a[i-1])  npm = 0;
    else npm = -1;

 
    if(pm == -npm && pm != 0){ pm = 0; ans += 1; }
    else if(pm == 0){ pm = npm; }

  }

  cout << ans;
}

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

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;

int n, m, q;
int a[50], b[50], c[50], d[50];
int ar[11];
int ans;

void brute(int i = 1) {
	if (i == n + 1) {
		int cur = 0;
		for (int it = 0; it < q; it++)
			if (ar[b[it]] - ar[a[it]] == c[it]) cur += d[it];
		ans = max(ans, cur);
		return;
	}

	for (int j = ar[i - 1]; j < m; j++) {
		ar[i] = j;
		brute(i + 1);
	}
}

void solve() {
	cin >> n >> m >> q;
	for (int i = 0; i < q; i++)
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	brute();
	cout << ans << endl;
}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--)
		solve();
}

Measured memory_bytes: 3636
use std::io;


/// https://beta.atcoder.jp/contests/abc099/tasks/abc099_b
fn main() {
    let (a, b) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    println!("{}", (1..(b - a + 1)).sum::<usize>() - b);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL((a))), (a).end());} while(0)
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  ll N = S.size();
  VVll dp(N+1, Vll(4, 0));
  dp.at(0).at(0) = 1;
  REP(i, N)
  {
    if (S.at(i) == 'A' || S.at(i) == '?')
    {
      dp.at(i+1).at(0) += dp.at(i).at(0);
      dp.at(i+1).at(1) += dp.at(i).at(1);
      dp.at(i+1).at(2) += dp.at(i).at(2);
      dp.at(i+1).at(3) += dp.at(i).at(3);
      dp.at(i+1).at(1) += dp.at(i).at(0);
      dp.at(i+1).at(0) %= MOD;
      dp.at(i+1).at(1) %= MOD;
      dp.at(i+1).at(2) %= MOD;
      dp.at(i+1).at(3) %= MOD;
    }
    if (S.at(i) == 'B' || S.at(i) == '?')
    {
      dp.at(i+1).at(0) += dp.at(i).at(0);
      dp.at(i+1).at(1) += dp.at(i).at(1);
      dp.at(i+1).at(2) += dp.at(i).at(2);
      dp.at(i+1).at(3) += dp.at(i).at(3);
      dp.at(i+1).at(2) += dp.at(i).at(1);
      dp.at(i+1).at(0) %= MOD;
      dp.at(i+1).at(1) %= MOD;
      dp.at(i+1).at(2) %= MOD;
      dp.at(i+1).at(3) %= MOD;
    }
    if (S.at(i) == 'C' || S.at(i) == '?')
    {
      dp.at(i+1).at(0) += dp.at(i).at(0);
      dp.at(i+1).at(1) += dp.at(i).at(1);
      dp.at(i+1).at(2) += dp.at(i).at(2);
      dp.at(i+1).at(3) += dp.at(i).at(3);
      dp.at(i+1).at(3) += dp.at(i).at(2);
      dp.at(i+1).at(0) %= MOD;
      dp.at(i+1).at(1) %= MOD;
      dp.at(i+1).at(2) %= MOD;
      dp.at(i+1).at(3) %= MOD;
    }
  }
  cout << dp.at(N).at(3) << endl;

  return 0;
}

Measured memory_bytes: 7376
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
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; }

struct edge { int to, cost; };
int N, M;
vector<vector<edge>> G;
int dp[400];
int rec(int v) {
  if(dp[v] != -1) return dp[v];
  int res = 0;
  for(auto nv : G[v]) chmax(res, rec(nv.to) + nv.cost);
  return dp[v] = res;
}

int main() {
  cin >> N >> M;
  G.assign(N, vector<edge>());
  rep(i, 0, M) {
    int a, b, c;
    cin >> a >> b >> c;
    G[b].push_back({a, c});
  }
  rep(i, 0, N) dp[i] = -1;
  cout << rec(N - 1) << endl;
  return 0;
}



Measured memory_bytes: 3176
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N, K, A[200005];
map<int, int> m;

/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N>>K;
    REP(i,0,N){
        cin>>A[i];
        m[A[i]]++;
    }

    vector<pair<int, int>> v;
    auto itr = m.begin();
    while(itr != m.end()){
        v.push_back(make_pair((*itr).S, (*itr).F));
        itr++;
    }

    sort(v.begin(), v.end());

    int ans = 0;
    REP(i,0,v.size()){
        if(m.size() <= K) break;
        ans += v[i].F;
        m.erase(v[i].S);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 12536
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1],b[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
	}
	int h=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]<b[i])
		{
			continue;
		}
		else
		{
			h+=a[i]-b[i];
		}
	}
	cout<<h<<endl;
	return 0;
} 

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = c-a-b;
        if(4*a*b < d * d && d > 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23636
import sys
from itertools import accumulate, islice

n, m, q = map(int, input().split())
ipt = (map(int, line.split()) for line in sys.stdin.readlines())
rails = [[0] * n for _ in range(n)]
for l, r in islice(ipt, m):
    rails[l - 1][r - 1] += 1
rails = [list(accumulate(reversed(s))) for s in zip(*(accumulate(s) for s in rails))]
print('\n'.join(str(rails[q - 1][n - p]) for p, q in ipt))


Measured memory_bytes: 37092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;

int main(void){
  int r;
  cin>>r;
  cout<<r*r*3<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<string, int> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


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

	ll k;
	string s;
	cin >> s >> k;
	vs v;
	rep(i, s.size()) {
		REP(j, i + 1, i + 10) v.pb(s.substr(i, j - i));
	}
	sort(all(v));
	v.erase(unique(v.begin(), v.end()), v.end());
	cout << v[k - 1] << endl;
	return 0;
}


Measured memory_bytes: 2680
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main()
{
	int W, H, N;
	cin >> W >> H >> N;

	int x1 = 0;
	int y1 = 0;
	int x2 = W;
	int y2 = H;
	for (int i = 0; i < N; ++i) {
		int x, y, a;
		cin >> x >> y >> a;
		if (a == 1) {
			x1 = max(x1, x);
		}
		else if (a == 2) {
			x2 = min(x2, x);
		}
		else if (a == 3) {
			y1 = max(y1, y);
		}
		else if (a == 4) {
			y2 = min(y2, y);
		}
	}
  int area;
  if(x1 >= x2 || y1 >= y2){
    area = 0;
  }else{
    area = (x2 - x1) * (y2 - y1);
  }
	cout << area << endl;
 

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
struct SegTreeMax {
    vector<Int> A;
    int N;
    SegTreeMax(int n) {
        N = 1;
        while (N < n) N *= 2;
        A.resize(2*N, LONG_LONG_MIN);
    }
    void set(int i, Int val) {
        i += N;
        A[i] = val;
        i /= 2;
        while (i > 0) {
            A[i] = max(A[2*i+0], A[2*i+1]);
            i /= 2;
        }
    }
    Int query(int L, int R) {
        L += N, R += N;
        Int ans = LONG_LONG_MIN;
        while (L < R) {
            if (R & 1) ans = max(ans, A[--R]);
            if (L & 1) ans = max(ans, A[L++]);
            L /= 2, R /= 2;
        }
        return ans;
    }
};
int main()
{
    int N; cin >> N;
    vector<Int> X(N), S(N);
    for (int i = 0; i < N; i++) cin >> X[i] >> S[i];
    vector<Int> sum(N+1);
    for (int i = 0; i < N; i++) sum[i+1] = sum[i] + S[i];
    SegTreeMax st(N+1);
    st.set(0, 0);
    for (int i = 0; i < N; i++) st.set(i+1, sum[i+1] - X[i]);
    Int ans = 0;
    for (int i = 0; i < N; i++) {
        Int score = st.query(i+1, N+1) - st.query(i, i+1) + X[i] - (i > 0 ? X[i-1] : 0);
        ans = max(ans, score);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9088
import Control.Monad

main :: IO ()
main = do
  n <- readLn :: IO Int
  names <- replicateM n getLine :: IO [String]
  let numM = length $ filter (\name -> head name == 'M') names
      numA = length $ filter (\name -> head name == 'A') names
      numR = length $ filter (\name -> head name == 'R') names
      numC = length $ filter (\name -> head name == 'C') names
      numH = length $ filter (\name -> head name == 'H') names

      c1 = numM * numA * numR
      c2 = numM * numA * numC
      c3 = numM * numA * numH
      c4 = numM * numR * numC
      c5 = numM * numR * numH
      c6 = numM * numC * numH
      c7 = numA * numR * numC
      c8 = numA * numR * numH
      c9 = numA * numC * numH
      c10 = numR * numC * numH

      ans = c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9 + c10

  print ans


Measured memory_bytes: 49532
#include <cstdio>

int v[200009];

int main() {
    int n;
    scanf("%d", &n);

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);

        v[x] = v[x - 1] + 1;
        if (v[x] > ans)
            ans = v[x];
    }
    printf("%d\n", n - ans);

    return 0;
}


Measured memory_bytes: 896
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = a - 1; i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};
struct edge2{ll from, to, cost;};

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

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

const int MXN=1000;
vector<edge2> G;
ll MN0,MN1;
ll N,M;

void kruscal(int v) {
    vl d(N,INF);
    d[v]=0;
    rep(i,N){
        rep(j,M){
            edge2 e=G[j];
            chmin(d[e.to],d[e.from]+e.cost);
        }
    }
    /*rep(i,N){
        cout << d[i] << '\n';
    }*/
    MN0=d[N-1];
    rep(i,N){
        rep(j,M){
            edge2 e=G[j];
            chmin(d[e.to],d[e.from]+e.cost);
        }
    }
    MN1=d[N-1];
    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> M;
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        G.pb({a,b,-c});
    }
    kruscal(0);
    //cout << MN0 << ' ' << MN1 << '\n';
    if(MN0==MN1){
        cout << -MN0 << '\n';
    }
    else{
        cout << "inf" << '\n';
    }
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/


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

void solve(){
   int l,r; cin>>l>>r;
    long long ans =1e9;
   if(r-l < 2019){
       for(int i=l;i<r;i++){
           for(int j=i+1;j<=r;j++){
               ans = min(ans,(1ll*i*j)%2019);
           }
       }
       cout << ans ;

   }else{
       cout << 0;
   }


}


int main(){
   solve();
}

Measured memory_bytes: 256
while True:
    l = input().split()
    H = int(l[0])
    W = int(l[1])

    if 0 == H == W:
        break

    odd_str = ''
    even_str = ''
    for i in range(W):
        if (i % 2) == 0:
            odd_str  += '.'
            even_str += '#'
        else :
            odd_str  += '#'
            even_str += '.'

    
    #
    for i in range(H):
        if (i % 2) == 0:
            print(even_str)
        else:
            print(odd_str)

    print()


Measured memory_bytes: 5608
#include <cstdio>
#include <iostream>
#include <cstring>

int main() {
	int x; std::cin >> x;
	int res = 0;
	res = x / 500 * 1000;
	x %= 500;
	res += x / 5 * 5;
	std::printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A_list = list(map(int,input().split()))
A_dict = {}

cnt = 1
for i in A_list:
    A_dict[cnt] = i
    cnt += 1

A_dict_sorted = sorted(A_dict.items(),key= lambda x:x[1])
#print(A_dict)
#print(A_dict_sorted)
#print(A_dict_sorted[0][0])

for i in range(N):
    print(A_dict_sorted[i][0], end=" ")

Measured memory_bytes: 25696
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>

using namespace std;

typedef long long LL;
class UF{
public:
	//par[i]<0??????i?????£??¨?????§
	//-par[i]???????????°?????????????±???????????????°
	vector<int> par;
	UF(int n){
		par=vector<int>(n,-1);
	}

	int find(int x){
		return par[x]<0 ? x : par[x]=find(par[x]);
	}

	bool unite(int x, int y){
		x=find(x);
		y=find(y);

		if(x!=y){
			//??????????§???????????????????????????¬????????????
			//??§?????????????°?????????????
			//??§???????????£????????¢????????????????????????????????¨???->size???????????????
			if(size(y)>size(x)) swap(x,y);
			par[x]+=par[y];
			par[y]=x;
		}
		
		return x!=y;
	}

	bool same(int x, int y){
		return find(x)==find(y);
	}
	
	int size(int x){
		return -par[find(x)];
	}
};

int main(){
	int n,q;
	cin>>n>>q;
	
	UF uf(n);
	
	for(int i=0;i<q;i++){
		int c,x,y;
		cin>>c>>x>>y;
		
		if(c) cout<<uf.same(x,y)<<endl;
		else uf.unite(x,y);
	}
	
}

Measured memory_bytes: 3128
#include <stdio.h>

int main()
{
	int a;
	int b;
	scanf("%d%d",&a,&b);
	if(a>b)
	{
		printf("a > b\n");
	}else if(a<b)
	{
		printf("a < b\n");
	}else if(a==b)
	{
		printf("a == b\n");
	}
	return 0;
}



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

int main()
{
  i64 n, k, s;
  cin >> n >> k >> s;
  for (i64 i = 0; i < k; i++)
    cout << s << (i + 1 == n ? "\n" : " ");
  for (i64 i = k; i < n; i++)
    if (s == 1e9)
      cout << 1 << (i + 1 == n ? "\n" : " ");
    else
      cout << (i64)1e9 << (i + 1 == n ? "\n" : " ");

  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll A[101];

vector<pair<int,int>> V;
void add(int x,int y) {
	A[y]+=A[x];
	V.push_back({x+1,y+1});
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	int ma=0,mi=0;
	FOR(i,N) {
		cin>>A[i];
		if(A[ma]<A[i]) ma=i;
		if(A[mi]>A[i]) mi=i;
	}
	if(A[ma]>-A[mi]) {
		FOR(i,N) if(i!=ma) add(ma,i);
		FOR(i,N-1) add(i,i+1);
	}
	else {
		FOR(i,N) if(i!=mi) add(mi,i);
		for(i=N-1;i>=1;i--) add(i,i-1);
	}
	
	cout<<V.size()<<endl;
	FORR(r,V) cout<<r.first<<" "<<r.second<<endl;

}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int cal[5];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i=1;i<=n;i++)
        cin>>A[i];

    ll res = 1;

    for(int i=1;i<=n;i++){
        cnt = 0;
        for(int j=1;j<=3;j++){
            if(cal[j]==A[i])cnt++;
        }
        res*=cnt;
        res%=MOD;
        for(int j=1;j<=3;j++){
            if(cal[j]==A[i]){
                cal[j]++;
                break;
            }
        }
    }


    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 640
n, m = map(int, input().split())
a = list(map(int, input().split()))

a.sort(reverse=True)
num_of_matches = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1] * (n+1)
dp[0] = 0
for i in range(1, n+1):
    val = -1
    for aa in a:
        if i - num_of_matches[aa] < 0:
            continue
        if i - num_of_matches[aa] == 0:
            val = 1
        elif dp[i - num_of_matches[aa]] > 0:
            val = max(val, dp[i - num_of_matches[aa]] + 1)
    dp[i] = val

res = ''
remain = dp[n]
match = n
while match > 0:
    for i in range(m):
        if match - num_of_matches[a[i]] >= 0 and remain - 1 == dp[match-num_of_matches[a[i]]]:
            match -= num_of_matches[a[i]]
            remain -= 1
            res += str(a[i])
            break
print(res)


Measured memory_bytes: 9340