akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll c=0,d=0,k=0,n,m,h,w,p,q,min,max,ans=0;
    string s,s1,s2;
    map<string,int> mp;
    cin >> n;
    rep(i,n){
        cin >> s;
        sort(ALL(s));
        auto itr = mp.find(s);
        if(itr!=mp.end()){
            ans+= itr->second;
            mp[s]++;
        }
        else{
            mp[s] = 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int n,a,count=0;
    cin>>n;
    vector<int>v,v1;

    for(int i=0;i<n;i++)
    {
        cin>>a;
        v.push_back(a);
        v1.push_back(a);
    }
    sort(v1.begin(),v1.end());

    for(int i=0;i<v.size();i++)
    {
        if(v[i]!=v1[i])
           {
                count++;
                //cout<<v1[i]<<" ";
           }
    }
    if(count<=2)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;


    return 0;

}


Measured memory_bytes: 256
S = input()
T = input()

l = len(S)
S_lst = [None] * l
T_lst = [None] * l
S_dic = {}
T_dic = {}

s_cnt = 0
for i, s in enumerate(S):
    if s in S_dic:
        n = S_dic[s]
        S_lst[i] = n
    else:
        S_lst[i] = s_cnt
        S_dic[s] = s_cnt
        s_cnt += 1


t_cnt = 0
for i, t in enumerate(T):
    if t in T_dic:
        n = T_dic[t]
        T_lst[i] = n
    else:
        T_lst[i] = t_cnt
        T_dic[t] = t_cnt
        t_cnt += 1


if s_cnt != t_cnt:
    print('No')
    exit()

for i in range(l):
    if S_lst[i] != T_lst[i]:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 12836
N, A = [int(_) for _ in input().split()]
X = [int(_) - A for _ in input().split()]
M = max(X + [A])
dp = [0] * (2 * N * M + 1)
dp[N * M] = 1
for x in X:
    dp_old = dp.copy()
    for i in range(max(-x, 0), min(2 * N * M + 1, 2 * N * M + 1 - x)):
        dp[i + x] += dp_old[i]
print(dp[N * M] - 1)


Measured memory_bytes: 3188
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
# from fractions import *
# from heapq import*
from bisect import *
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
ALPHA='abcdefghijklmnopqrstuvwxyz'
M=10**9+7
EPS=1e-6
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]


#-------------------------code---------------------------#
#vsInput()


a,b,c,d=value()
ans=a*c

for i in (a,b):
    for j in (c,d):
        ans=max(i*j,ans)

print(ans)



    
    
    



    
        

   



































    

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

int main() {
	int n, m;							//調査時間n、トンネル内の台数mを定義
	cin >> n >> m;

	int x = m;							//トンネル内の最大台数xを定義
	int y = 0;							//トンネル内の0以下台数yを定義

	for (int i = 0; i < n; i++) {
		int in, out;					//入口in、出口outを定義
		cin >> in >> out;
		m = m + in - out;				//[トンネル内の台数]＝[トンネル内の台数]＋[入って来た台数]ー[出て行く台数]
		x = max(x, m);
		y = min(y, m);
	}

	if (y < 0) cout << 0 << endl;
	else cout << x << endl;

	return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int x;
    cin >> x;
    int p = x;
    while (true){
        bool flag = true;
        for (int i = 2; i*i <= p; i++){
            if (p % i == 0){
                flag = false;
                break;
            }
        }
        if (flag){
            cout << p << '\n';
            return;
        }
        p++;
    }
}

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

    //int t; cin >> t; while (t--)
        solve();
}

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

const int MAX_N = 104;
const int MAX_V = 100004;
const long long INF = 1LL<<60;

long long dp[MAX_N][MAX_V];

int main() {
  int N, W;
  cin >> N >> W;
  int w[MAX_N], v[MAX_N];

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

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < MAX_V; j++) {
      dp[i][j] = INF;
    }
  }

  dp[0][0] = 0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < MAX_V; j++) {
      if (j - v[i] >= 0) dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
      else dp[i + 1][j] = dp[i][j];
    }
  }

  long long ans = 0;
  for (int i = 0; i < MAX_V; i++) {
    if (dp[N][i] <= W) ans = i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 80256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

main() {
	long long int a=0,b=0,c=0,n, m, k = 0;
	int str[5],str2[5];
	
	scanf("%d%d%d", &str[0],&str[1],&str[2]);
	
	if (str[0] == str[1]&&str[2]==7&&str[0]==5) { printf("YES"); }
	else if (str[0] == str[2]&&str[1]==7&&str[0]==5) {  printf("YES"); }
	else if(str[1] == str[2]&&str[0]==7&&str[1]==5){  printf("YES"); }else{printf("NO");}
}


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

int main()
{
    int input;
    int seven = 0, five = 0;

    for(int i = 1; i <= 3; i++)
    {
        cin>> input;
        if(input == 7)
            seven++;

        else if(input == 5)
            five++;
    }

    if((five == 2)&&(seven == 1))
        cout<< "YES\n";

    else
        cout<< "NO\n";

    return 0;
}


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

int main() {
  long long N;
  string S;
  cin >> N >> S;
  long long R = 0,G = 0,B = 0;
  for (long long i = 0; i < N; i++) {
    if (S.at(i) == 'R')
      R++;
    if (S.at(i) == 'G')
      G++;
    if (S.at(i) == 'B')
      B++;
  }
  long long count = 0;
  for (long long j = 0; j < (N - 3)/2 + 1; j++) {
    for (long long k = 0; k < N - (j*2 + 3) + 1; k++) {
      if(S.at(k) != S.at(k + j + 1) && S.at(k) != S.at(k + 2*j + 2) && S.at(k + 2*j + 2) != S.at(k + j + 1))
        count++;
    }
  }
   
  cout << R*G*B - count << endl;
  
  
  
  
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main() {
  ios::sync_with_stdio(0);cin.tie(0);   //A题 
  int a,b;
  cin>>a>>b;
  a=a*500;
  if(a>=b)
  cout<<"Yes";
  else if(a<b)
  cout<<"No";
  
  
  
}

Measured memory_bytes: 256
#include<iostream>

bool aho(int a){
    while(a){
        if(a%10==3) return true;
        a/=10;
    }
    return false;
}

int main(void){
    int n;
    std::cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3==0 || aho(i)) std::cout<<" "<<i;
    }
    std::cout<<std::endl;
    return 0;
}

Measured memory_bytes: 3080
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int[][] arr = new int[n][3];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                arr[i][j] = s.nextInt();
            }
        }

        Pair[] dp = new Pair[n];
        for (int i = 0; i < n; i++) {
            dp[i] = new Pair();
        }

        dp[n - 1].ai = arr[n - 1][0];
        dp[n - 1].bi = arr[n - 1][1];
        dp[n - 1].ci = arr[n - 1][2];

        for (int i = n - 2; i >= 0; i--) {

            dp[i].ai = Math.max(dp[i + 1].bi, dp[i + 1].ci) + arr[i][0];
            dp[i].bi = Math.max(dp[i + 1].ai, dp[i + 1].ci) + arr[i][1];
            dp[i].ci = Math.max(dp[i + 1].bi, dp[i + 1].ai) + arr[i][2];

        }

        System.out.println(Math.max(dp[0].ai, Math.max(dp[0].bi, dp[0].ci)));

    }
}

class Pair {
    int ai;
    int bi;
    int ci;

}

Measured memory_bytes: 64020
#include<stdio.h>
int main()
{
  int A,B,K;
  scanf("%d%d",&A,&B);

   K=(A+B)/2;


     if((A+B)%2==0)
     {
           printf("%d",K);
     }


else{
    printf("IMPOSSIBLE");

}

   return 0;


}


Measured memory_bytes: 128
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int a,b,c;
signed main(){
    scanf("%lld %lld %lld\n",&a,&b,&c);
    int d=(c-a-b);
    if(d>0&&4*a*b<d*d){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var k, s int
	fmt.Scan(&k, &s)

	var cnt int
	for x := 0; x <= k; x++ {
		for y := 0; y <= k; y++ {
			z := s - (x + y)
			if x+y <= s && z <= k {
				cnt += 1
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include <stdio.h>
int main (void){
    int a[6],b,c,d,e,i,j;
    for(i=0;i<3;i++){
        for(j=0;j<6;j++){
            scanf("%d",&b);
            a[j]=b;
        }
        if(a[5]-a[2]<0){
            a[5]=a[5]+60;
            a[4]=a[4]-1;
        }
        if(a[4]<0){
            a[4]+60;
        }
        c=a[5]-a[2];
        if(a[4]-a[1]<0){
            a[4]=a[4]+60;
            a[3]=a[3]-1;
        }
        d=a[4]-a[1];
        e=a[3]-a[0];
        printf("%d %d %d\n",e,d,c);
    }
return 0;
}

Measured memory_bytes: 600
N=int(input())
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()
M=N//2

if N%2:
    print(B[M]-A[M]+1)
else:
    print((B[M-1]+B[M]) - (A[M-1]+A[M]) + 1)

Measured memory_bytes: 25472
*z,a[2][101],n,m,i,j,c,p;main(s){for(;scanf(m=z="%d\n\0NA\n",&n),n;printf(z+(m>210),m)){for(a[0][n]=a[1][n]=i=2;i--;)for(j=0;j-n;scanf(z,a[i]+j++));for(i=2;i--;m>c?m=c:0)for(j=i,c=p=0;s=a[j][p],c<220&&s==2|n+~p;)s-2?s-1|a[j][p+1]-1?p+=2,j=1&~j,++c:++p:--p;}exit(0);}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;

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

int main() {

    ll S,W;
    cin >> S >> W;
    string out = "unsafe";
    if(S>W) out = "safe";
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;



int main() {
  int n,t=0;
  cin >> n;
  rep(i,n){
    int u;
    cin >> u;
    if (i+1!=u) t++;
  }
  //cout << t << endl;
  if (t==0 || t==2) cout << "YES" << endl;
  
  else cout << "NO" << endl;
  }

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function bsearch(a,x);l,r=0,length(a)+1;while r-l>1;m=(r+l)>>1;if a[m]<=x;l=m;else;r=m;end;end;l;end
function bsearchg(a,x);l,r=0,length(a)+1;while r-l>1;m=(r+l)>>1;if a[m]<x;l=m;else;r=m;end;end;l;end
function main()
	n,d,a = readline() |> split |> parseMap
	b = Tuple{Int,Int}[(0,0) for i in 1:n]
	for i in 1:n
		p,q = readline() |> split |> parseMap
		b[i]=(p,q)
	end
	b = sort(b,by=x->x[1])
	x = [b[i][1] for i in 1:n]
	h = [b[i][2] for i in 1:n]
	lm = Int[0]
	v = Int[0]
	s = 0
	m = 1
	for i in 1:n
		r = bsearch(x,x[i]+2*d)
		l = bsearchg(lm,x[i]-2*d)
		if l==0
			y = cld(max(h[i]-v[m]*a,0),a)
		else
			y = cld(max(h[i]-(v[m]-v[l])*a,0),a)
		end
		if y > 0
			push!(lm,x[i])
			s += y
			push!(v,v[m]+y)
			m += 1
		end
	end
	println(s)
end

main()

Measured memory_bytes: 181364
s = input()

r = s[::-1]
hug = 0
if len(s) % 2 == 0:
    mid = int(len(s)/2)
else:
    mid = int((len(s) - 1)/2)

for i in range(mid):
    if s[i] != r[i]:
        hug += 1

print(hug)



Measured memory_bytes: 3060
k = int(input())
#print(k)
l = [[0 for i in range(10)] for j in range(10)]

for j in range(10):
	l[0][j] = 1

for i in range(1,10):
	for j in range(10):
		if(j != 0)and(j != 9):
			l[i][j] = l[i-1][j-1]+l[i-1][j]+l[i-1][j+1]
		elif j == 0:
			l[i][j] = l[i-1][j]+l[i-1][j+1]
		else:
			l[i][j] = l[i-1][j-1]+l[i-1][j]

#print(l)
ai = 0
aj = 0
sum = 0
ret = 0
for i in range(10):
	for j in range(1,10):
		sum += l[i][j]
		if(sum >= k):
			ai = i
			aj = j
			sum -= l[i][j]
#			print("ai: ",ai,", aj: ",aj,", sum:",sum) 
			break
	if(ai != 0)or(aj != 0):
		break

ret = aj*(10**ai)
m = aj
for i in range(ai):
	if(ai-1-i < 0):
		break
	if(m != 0):
		sum += l[ai-1-i][m-1]
#		print(sum)
		if(sum >= k):
			sum -= l[ai-1-i][m-1]
			m = m-1
			ret += m*(10**(ai-1-i))
#			print("ai-1-i: ",ai-1-i," m:",m," sum:",sum," ret: ",ret,"!!") 
			continue
	
	sum += l[ai-1-i][m]
	if(sum >= k):
		sum -=l[ai-1-i][m]
		ret += m*(10**(ai-1-i))
#		print("ai-1-i: ",ai-1-i," m:",m," sum:",sum," ret: ",ret,"!") 
		continue
	
	m = m+1
	ret += m*(10**(ai-1-i))
#	print("ai-1-i: ",ai-1-i," m:",m," sum:",sum," ret: ",ret) 

#print("ret:",ret)
print(ret)

Measured memory_bytes: 3192
# 具体例を試す
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")

A,B,N = LI()
# ans = 0

# a = [0]*N

# for x in range(1,N+1):
#     # ans = max(ans,math.floor(A*x/B) - A * math.floor(x/B))
#     a[x-1]=math.floor(A*x/B) - A * math.floor(x/B)

x = min(N,B-1)
ans = math.floor(A*x/B) - A * math.floor(x/B)
print(ans)

Measured memory_bytes: 62564
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define foi(i,k,n) for(int i=(k); i<(int)(n); i+=1)
#define fod(i,n,k) for(int i=k; i>=(int)n; i-=1)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define endl "\n"


#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long int llint;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<llint> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
llint toint(string s) {stringstream ss(s); llint x; ss >> x; return x;}
//gp_hash_table<string, llint> table;


//int mpow(llint base, llint exp) {
  //base %= MOD;
  //llint result = 1;
  //while (exp > 0) {
    //if (exp & 1) result = ((llint)result * base) % MOD;
    //base = ((llint)base * base) % MOD;
    //exp >>= 1;
  //}
  //return result;
//}


//void makegraph(int n, int m){
	//int i, u, v;
	//while(m--){
		//cin>>u>>v;
		//u--, v--;
		//g[u].pb(v);
		//g[v].pb(u);
	//}
//}

//void dfs(int u, int par){
	//for(int v:g[u]){
		//if (v == par) continue;
		//dfs(v, u);
	//}
//}


// ------------------------------------------------------------------ILB----------------------------------------------------------------  //

const int MX = 5e5 + 100;



void solve(){
	int n, x, t;
	cin >> n >> x >> t;
	cout << t * ((n  + x - 1) / x);
}




int main() {
	fast_io;
    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }
    return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
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; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

#define MOD 1000000007

int main(){
  ll M, N;
  cin >> M >> N;
  if(abs(M-N) >= 2){
    cout << 0 << endl;
    return 0;
  }

  ll MM = 1;
  for(int i = 1; i <= M; i++){
    MM *= i;
    MM %= MOD;
  }
  ll NN = 1;
  for(int i = 1; i <= N; i++){
    NN *= i;
    NN %= MOD;
  }

  if(M == N) cout << MM * NN % MOD * 2 % MOD << endl;
  else cout << MM * NN % MOD << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
using namespace std;

int MOD = 1000000007;
int dp[100002][13];

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

  memset(dp, 0, sizeof(dp));

  dp[0][0] = 1;

  for (int i = 0; i < s.size(); i++) {
    for (int rem = 0; rem < 13; rem++) {
      if (dp[i][rem] == 0) continue;

      for (int digit = 0; digit < 10; digit++) {
        if (s[i] != '?' && s[i] - '0' != digit) {
          continue;
        }
        int target = rem * 10 + digit;
        int nextRem = target % 13;
        dp[i + 1][nextRem] += dp[i][rem];
        dp[i + 1][nextRem] %= MOD;
      }
    }
  }

  cout << dp[s.size()][5] << endl;
}


Measured memory_bytes: 5504
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define xam INT_MIN
#define nim INT_MAX
#define mp make_pair

using namespace std;
///check n=1;

///check corner case;
int main()
{
    ll n,m,i,j,cc=1;
    cin>>n>>m;
    ll ara[n];
    memset(ara,-1,sizeof(ara));
    for(i=0;i<m;i++){
        ll x,y;
        cin>>x>>y;
        if(ara[x-1]==-1)ara[x-1]=y;
        else
            if(ara[x-1] != y)cc=0;
    }
    if(n != 1 && ara[0]==0)cc=0;
    j=-1;
    if(cc){
       j=0;
       for(i=0;i<n;i++){
        ll mx=0;
        if(n != 1 && i==0)mx=1;
        j=j*10+max(ara[i],mx);
        //cout<<ara[i]<<endl;
       }
    }
    cout<<j<<endl;
return 0;
}


Measured memory_bytes: 256
N = int(input())
L = list()
for i in range(N):
    s, p = input().split()
    p = int(p)
    L.append((s, p, i+1))

L.sort(key=lambda x: x[1], )
L.sort(key=lambda x: x[0], reverse=True)
for _, _, i in reversed(L):
    print(i)

Measured memory_bytes: 38256
/**
    AUTHOR:JUNSH
    TIME:19/5/19
**/
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rev(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
const int inf=0x3f3f3f3f;
int main(){
    string s;
    int n,k;
    cin>>n>>k;
    cin>>s;
    s[k-1]+=32;
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#include <random>
#include <stack>
#include <ctime>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    long n, m;
    cin >> n >> m;
    VI sums[8];
    REP(i,n) {
        long x, y, z;
        cin >> x >> y >> z;
        sums[0].push_back(x + y + z);
        sums[1].push_back(x + y - z);
        sums[2].push_back(x - y + z);
        sums[3].push_back(x - y - z);
        sums[4].push_back(-x + y + z);
        sums[5].push_back(-x + y - z);
        sums[6].push_back(-x - y + z);
        sums[7].push_back(-x - y - z);
    }
    long ans = 0;
    REP(i,8) sort(sums[i].begin(), sums[i].end());
    REP(i,8) {
        long sum = 0;
        REP(j,m) {
            sum += sums[i][n - 1 - j];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<stdio.h>

int main()
{
  int a,b,c;

  a=1;
  b=1;

  for(;a<10;a++){
    b=1;
    for(;b<10;b++){
      c=a*b;
      printf("%dx%d=%d\n",a,b,c);
    }
  }
return 0;
}

Measured memory_bytes: 524
#include<stdio.h>

int min(int x, int y, int z)
{
  int w;
  w=x;
  if(w>=y) w=y;
  if(w>=z) w=z;
  return w;
}

int main(void)
{
    int i,j,H,W,S=0;
    int dp[2][1400];
	int a[1400][1400];

    scanf("%d%d",&H,&W);
    for(i=0;i<=H-1;i++)
	{
		for(j=0;j<=W-1;j++)
		{
	       scanf("%d",&a[i][j]);
		}
    }
    for(i=0;i<=W-1;i++)
    {
        if(a[0][i]==0)
	    {
	        dp[0][i]=1;
	    }
        else
	    {
	        dp[0][i]=0;
	    }
        if(S<dp[0][i])
	    {
	        S=dp[0][i];
	    }
    }
    for(i=1;i<=H-1;i++)
    {
        for(j=0;j<=W-1;j++)
	    {
			if(j==0)
			{
				if(a[i][j]==0)
				{
					dp[1][j]=1;
				}
				else
				{
					dp[1][j]=0;
				}
			}
			else
			{
	            if(a[i][j]==0)
	            {
	               if(dp[0][j-1]==dp[0][j] && dp[0][j-1]==dp[1][j-1])
	               {
	                  dp[1][j]=dp[0][j-1]+1;
	               }
	               else
	               {
	                  dp[1][j]=min(dp[0][j-1],dp[0][j],dp[1][j-1])+1;
	               }
	               
	            }
	            else
	            {
	               dp[1][j]=0;
	            }
			}
			if(S<dp[1][j])
	        {
	            S=dp[1][j];
	        }
	    }
		for(j=0;j<=W-1;j++)
		{
			dp[0][j]=dp[1][j];
		}
    }
  printf("%d\n",S*S);
  return 0;
}

Measured memory_bytes: 8268
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
ll modcombi[2001][2001]={0}; //[i][j] iCj
void makecombi(){
  modcombi[0][0]=1;
  for(int i=1;i<=2000;i++){
    modcombi[i][0]=1;
    for(int j=1;j<=2000;j++){
      modcombi[i][j]=(modcombi[i-1][j-1]+modcombi[i-1][j])%mod;
    }
  }
}
ll fact(int n) {
  if (n == 0) return 1;
  return n * fact(n - 1) % mod;
}

int main(){
  int N,M;
  cin>>N>>M;
  if (abs(N-M)>1){
    cout << 0 << endl;
    return 0;
  }
  int ma=max(N,M);
  int mi=min(N,M);
  if (ma==mi){
    cout << (fact(ma)*fact(ma)*2)%mod<<endl;
  }else{
    cout << (fact(mi)*fact(ma))%mod << endl;
  }
}


Measured memory_bytes: 1792
#include<stdlib.h>
#include<stdio.h>
#include<string.h>



int main(){
    int N,K;
    scanf("%d %d",&N,&K);
    int S[100]={};
    for (int i=0; i<K; i++) {
        int d;
        scanf("%d",&d);
        for (int j=0; j<d; j++) {
            int A;
            scanf("%d",&A);
            S[A-1]++;
        }
    }
    int sum=0;
    for (int i=0; i<N; i++) {
        if(S[i]==0){
            sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define rep(i,a,b) for(ll i = a;i <= b;i++)
#define repv(i,a,b) for(ll i = a;i >= b;i--)
#define e endl
#define all(v) v.begin(), v.end()
typedef pair<ll,ll> pp;

int lcm(int a, int b)
{
    int lar = max(a, b);
    int small = min(a, b);
    for (int i = lar; ; i += lar) {
        if (i % small == 0)
            return i;
    }
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b) {
    return (a.second < b.second);
}

ll power(ll x, unsigned ll y, ll p)
{
    ll res = 1;     // Initialize result
  
    x = x % p; // Update x if it is more than or
                // equal to p
   
    if (x == 0) return 0; // In case x is divisible by p;
  
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
  
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

bool isPowerOfTwo (ll x)
{
    return x && (!(x&(x-1)));
} //cout << h[i] << " " << cnt[i] << " " << good[i] << " " << bad[i] << e;


void solve(){
    ll n; cin >> n;
    vector<ll> v;
    for(ll i = 0;i < n;i++){
        ll x; cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    ll count = 0;
    for(ll i = 0;i < n;i++){
        for(ll j = i+1;j < n;j++){
            for(ll k = j+1;k < n;k++){
                if(v[i] + v[j] > v[k] && (v[i] != v[j]) && (v[j] != v[k])) count++;
            }
        }
    }
    cout << count << endl;
}
        
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    //ll t; cin >> t; while(t--)
        solve();
}


Measured memory_bytes: 3652
# -*- coding: utf-8 -*-

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

grid = [['.'] * 100 for i in range(100)]
for i in range(50, 100):
	for j in range(100):
		grid[i][j] = '#'
A -= 1
B -= 1
# 白い面に黒点
for i in range(1, B//50*2+1, 2):
	for j in range(100):
		if j % 2 == 0:
			grid[i][j] = '#'
for i in range(0, B%50*2, 2):
	grid[B//50*2+1][i] = '#'
# 黒い面に白点
for i in range(51, A//50*2+51, 2):
	for j in range(100):
		if j % 2 == 0:
			grid[i][j] = '.'
for i in range(0, A%50*2, 2):
	grid[A//50*2+51][i] = '.'

print(100, 100)
for i in range(100):
	print(''.join(grid[i]))


Measured memory_bytes: 3188
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		long X = nextLong();

		long ans=0;
		long m=100;
		while(X>m){
			ans++;
			m=m+(long)(m*0.01);
		}

		System.out.println(ans);
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 25396
import java.util.Scanner;

public class Main {
  
      public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        String T = sc.nextLine();


        int changeCount = 1001;

        for (int i = 0; i <= S.length() - T.length(); i++) {

            int count = 0;
            for (int j = 0; j < T.length(); j++) {


                if (T.charAt(j) != S.charAt(i + j)){
                    count++;
                }
            }

            if (count < changeCount) {
                changeCount  = count;
            }
        }
        System.out.println(changeCount);
    }
}

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

using namespace std;

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int N;
    cin >> N;
    vector<int> v;
    for(int i = 2; i * i <= N; i++){
        if(N % i == 0){
            v.pb(i);
            if(N != i * i) {
                v.pb(N/i);
            }
        }
    }
    int ans = 0;
    for(int i = 1; i * i <= N - 1; i++) {
        if(( N - 1) % i == 0) {
            if(i * i == N - 1) ans ++;
            else ans += 2;
        }
    }
    
    for(auto x: v){
        int K = N;
        while(K % x == 0) K/=x;
        if((K - 1) % x == 0) ans++;
    }
    cout << ans << endl;


    return 0;
}



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

vector<char> vc;

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

    int index = 0;
    vc.push_back(s[0]);
    index++;
    for(int i = 1; i <= n; ++i){
        if(vc[index - 1] != s[i]){
            vc.push_back(s[i]);
            index++;
        }
    }

    cout << (vc.size() - 1) << endl;
}

Measured memory_bytes: 640
import math
a, b, h, m = map(int, input().split())
ang = min(h * 30 + (m / 60) * 30 - m * 6, 360 - (h * 30 + (m / 60) * 30 - m * 6))
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(ang))))

Measured memory_bytes: 9512
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		long sum=1;
		int all = 2147483647;
		for(int i=0;i<a;i++){
			sum*=b;
			if(i==0)
				b--;
		}
		if(sum*-1>0||sum>all){
			sum = 2147483647;
		}
		System.out.print(sum);
	}
}


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

int main(){
  int n;
  cin >> n;
  int l[n];
  int i,j,k;
  int ans=0;

  for(i=0;i<n;i++){
    cin >> l[i];
  }

  sort(l,l+n);

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(k=j+1;k<n;k++){
        if(l[k]>=l[i]+l[j]){
          break;
        }else{
          ans++;
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
  }

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] a = br.readLine().split(" ");
		int[] data = new int[5];
		for(int i =  0 ; i < 5 ; i++){
			data[i] = Integer.parseInt(a[i]);
		}
		Arrays.sort(data);
		for(int i = 4 ; i != -1 ; i --){
			System.out.print((i==0)?data[i]:data[i]+" ");
		}
		System.out.println("");
	}
}

Measured memory_bytes: 17052
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
//1232
int a,b,c,n,m,l[100000110],o[100010],k,i,d,dx[10]={0,1,-1,0,0,-1,-1,1,1},dy[10]={0,0,0,-1,1,1,-1,1,-1};
long long x,y,z[100010];
stack<int> s;
struct P
{
    int x;
    int y;
    bool operator<(const P &a)const
    {
        return y>a.y;
    }
};
 //map<int, int> p;
queue<P> q;
priority_queue<int> q1;
string r;
vector<int> v[200010];

bool sdf(P a,P b){return a.y<b.y;}



int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;t++)
    {
        scanf("%d",&b);
        if(!o[b]) o[b]=1,k++;
    }

    if(k%2==1) printf("%d",k);
    else printf("%d",k-1);
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<int> f(n);
    rep(i, n) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.begin(), f.end());
    reverse(f.begin(), f.end());
    ll l = -1, r = 1e18;
    while(r-l>1) {
        ll m = (r+l)/2LL;
        ll cnt = 0;
        rep(i, n) {
            if (a[i] * f[i] > m) {
                cnt += (a[i] * f[i] - m) / f[i];
                if ((a[i] * f[i] - m) % f[i]) ++cnt;
            }
        }
        if (cnt > k) l = m;
        else r = m;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 5632
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var s = input.ReadLine() + (char)('a'-1);
        var hash = new HashSet<char>(s.ToCharArray());

        //if(s.Length < 26) {
        //    for(char c = 'a'; c <= 'z'; c++) {
        //        if(!hash.Contains(c)) return s + c.ToString();
        //    }
        //}

        var sb = new StringBuilder(s);

        for(int i=0; i<s.Length; i++) {
            char c = s[s.Length - i -1];
            char cc = (char)(c+1);

            while(cc <= 'z') {
                if (!hash.Contains(cc)) {
                    sb[s.Length - i - 1] = cc;
                    return sb.ToString().Trim();
                }
                cc++;
            }
            sb[s.Length - i - 1] = ' ';
            hash.Remove(c);
        }

        return -1;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13396
n = int(input())
ns = 10 ** 9 +7

def npower(n, b):
    q = n // 10
    r = n % 10
    pwr10 = (b ** 10) % ns
    pwr_r = (b ** r) % ns
    temp = 1
    for t in range(q):
        temp = (temp * pwr10) % ns
    return (temp * pwr_r) % ns

ans = npower(n, 10) -npower(n, 9) * 2 + npower(n, 8)
if ans >= 0:
    print(ans % ns)
else:
    ans = ans + 2*ns
    print(ans % ns)

Measured memory_bytes: 9028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans,a,b,c,d;
unordered_map<ll,ll> mp;
ll dfs(ll n){
	if(n<=1) return n*d;
	if(mp[n]!=0) return mp[n];
//	printf("[%lld %lld]\n",n,ret);
	ll ret=(ll)2e18;
	if(n<=(ll)2e18/d+1)
		ret=n*d;
	int t=n%5;
	if(t<=2)
		ret=min(ret,dfs((n-t)/5)+c+t*d);
	else 
		ret=min(ret,dfs((n+5-t)/5)+c+(5-t)*d);
	t=n%3;
	if(t<=1)
		ret=min(ret,dfs((n-t)/3)+b+t*d);
	else
		ret=min(ret,dfs((n+3-t)/3)+b+(3-t)*d);
	t=n%2;
	if(t==0) ret=min(ret,dfs(n/2)+a);
	else
		ret=min(ret,min(dfs((n-1)/2),dfs((n+1)/2))+a+d);
	mp[n]=ret;
//	printf("[%lld %lld]\n",n,ret);
	return ret;
}
int main(){
	int T; scanf("%d",&T);
	while(T--){
		mp.clear();
		ll n; scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
		printf("%lld\n",dfs(n));
	}
	return 0;
}

Measured memory_bytes: 4204
import numpy as np


def inputs(func=lambda x: x, sep=None, maxsplit=-1):
	return map(func, input().split(sep=sep, maxsplit=maxsplit))

def input_row(n : int, type=np.int, *args, **kwargs):
	return np.fromiter(inputs(type, *args, **kwargs), dtype=type)

def input_2d(nrows : int, ncols : int, type=np.int, *args, **kwargs):
	data = np.zeros((nrows, ncols), dtype=type)
	for i in range(nrows):
		data[i, :] = input_row(ncols, type, *args, **kwargs)
	return data

from itertools import repeat

class IntAddition (object):
	'''整数の加法'''
	def operate(self, x, y):
		return x + y
	@property
	def identity(self):
		return 0
	def cancel(self, x, y):
		return x - y
	def invert(self, x):
		return -x
	def accumulate(self, x, count):
		return x * count

class UnionFind (object):
	'''重み付きUnion-Find木'''
	def __init__(
			self,
			num_nodes=0,
			abelian_operator=IntAddition()):
		self.parent = []
		self.potential = []
		self.op = abelian_operator
		
		self.extend(num_nodes)
	
	def append(self):
		self.parent.append(-1)
		self.potential.append(self.op.identity)
	
	def extend(self, num_nodes):
		self.parent.extend(repeat(-1, num_nodes))
		self.potential.extend(repeat(self.op.identity, num_nodes))
	
	def root(self, x):
		parent = self.parent[x]
		if 0 <= parent:
			self.parent[x] = self.root(parent)
			self.potential[x] = self.op.operate(
				self.potential[x], self.potential[parent]
			)
			x = self.parent[x]
		return x
	
	def difference_from_root_to(self, x):
		self.root(x)
		return self.potential[x]
		
	def size(self, x):
		return -self.parent[self.root(x)]
	
	def difference(self, x, y):
		if not self.issame(x, y):
			raise RuntimeError('x と y は同じ集合に属していません。')
		return self.op.cancel(
			self.difference_from_root_to(y),
			self.difference_from_root_to(x)
		)
	
	def unite(self, x, y, difference=None):
		if difference is None:
			difference = self.op.identity
		
		x, px = self.root(x), self.potential[x]
		y, py = self.root(y), self.potential[y]
		difference = self.op.cancel(difference, py)
		difference = self.op.operate(difference, px)
		if x == y:
			return difference == 0
		
		if self.size(x) < self.size(y):
			x, y = y, x
			difference = self.op.invert(difference)
		self.parent[x] += self.parent[y]
		self.parent[y] = x
		self.potential[y] = difference
		
		return True
	
	def issame(self, x, y):
		return self.root(x) == self.root(y)



N, M = inputs(int)
uf = UnionFind(num_nodes=N)

valid = True
for i in range(M):
	L, R, D = inputs(int)
	L -= 1
	R -= 1
	
	if not uf.unite(L, R, D):
		valid = False

print('Yes' if valid else 'No')


Measured memory_bytes: 17912
#include <iostream>

using namespace std;

int main()
{
    long long n, k, count = 0;
    long long res;
    cin >> n >> k;

    long long zero = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % k == 0)
            zero++;
    }
    res = zero * zero * zero;

    if (k % 2 == 0)
    {
        for (int i = 1; i <= n; i++)
        {
            if (i % k == k / 2)
                count++;
        }
        res += (count * count * count);
    }
    cout << res << endl;
}

Measured memory_bytes: 384
qty = gets.chomp.to_i
int_array = gets.chomp.split.map(&:to_i)
division_count = 0
until int_array.detect { |int| int % 2 != 0 } do
  int_array = int_array.map { |int| int / 2}
  division_count += 1
end

puts division_count

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

using namespace std;
using ll = long long;

#define MOD 1000000007

int main() {
    ll n;
    cin >> n;

    vector<ll> a(n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum = (sum + a[i]) % MOD;
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        sum = (sum - a[i] + MOD) % MOD;
        ans = (ans + a[i] * sum) % MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define MAX 1010
#define rep(i,n)	for(int i=0;i<n;i++)
const int INF=1e9;
int dp[MAX];
int main(){
	int n,m;	cin>>n>>m;
	int d[n];	rep(i,n)	cin>>d[i];
	int c[m];	rep(i,m)	cin>>c[i];
	rep(i,n+1)	dp[i]=INF;
	dp[0]=0;
	for(int i=0;i<m;i++){
		for(int j=n-1;j>=0;j--){
			if(dp[j]!=INF)	dp[j+1]=min(dp[j+1],dp[j]+d[j]*c[i]);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}
	

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)

void chmax(ll& a, ll b) { a = max(a, b); }
void chmin(ll& a, ll b) { a = min(a, b); }



int main() {
    ll x; cin >> x;
    for(ll a=1; a < 1000; a++) for(ll b=-1000; b < 1000; b++) {
        if(a*a*a*a*a - b*b*b*b*b == x) {
            cout << a << " " << b << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        switch(n % 10){
            case 2:
            case 4:
            case 5:
            case 7:
            case 9:
                System.out.println("hon");
                break;
            case 0:
            case 1:
            case 6:
            case 8:
                System.out.println("pon");
                break;
            default:
                System.out.println("bon");
                break;
        }

    }
}


Measured memory_bytes: 35716
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define int          long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define pi           pair<int,int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define FIO         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}


void solve()
{
     string s;cin>>s;
     rep(i,0,3)
     {
        if(s[i]==s[i+1])
        {
            cout<<"Bad";return;
        }
     }
     cout<<"Good";

}

signed main()
{
        FIO
        
        
        int t=1;
        //cin>>t;
        while(t--)
        solve();
        cerr<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

        return 0;
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 5e3 + 9, M = 5e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;



int main(){
    init();

    int a, b;   cin >> a >> b;
    cout << (a + b) % 24;

}


Measured memory_bytes: 256
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 1000000007

#n = int(input())
#b = int(input())
#n, k, l = [int(i) for i in input().split()]
#table = [int(i)  for i in input().split()] for j in range(h)] #table[h][w]
#table = [list(input()) for n in range(r)] #table[h][w]
#s = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#s = [int(input()) for i in range(n)]
s = input()
t = input()

#list = list(s)
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#a = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

u = len(s)
v = len(t)
flag = 0
if (u + 1 == v):
    for i in range (u):
        if (s[i] != t[i]):
            break
        if ( i == u - 1):
            flag = 1

if (flag == 1):
    print ("Yes")
else:
    print("No")

Measured memory_bytes: 27092
from collections import Counter
import sys

N, K = map(int, input().split())
A = list(input().split())
ball = [int(A[i]) for i in range(N)]
kinds = len(set(ball))
Cou = list(Counter(ball).most_common())
dele = [int(Cou[i][1]) for i in range(len(Cou) - kinds + K, len(Cou))]
print(sum(dele))


Measured memory_bytes: 61208
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define mod 1000000007
#define N 500043
#define mp(a,b) make_pair(a,b)
#define loop(a,b) for(int i=a;i<b;i++)
#define test int t; cin >> t; while(t--)
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<vector<ll>>vec(n,vector<ll>(3));
    for(int i=0;i<n;i++)
        for(int j=0;j<3;j++)
            cin >> vec[i][j];
    loop(1,n){
        vec[i][0]+=max(vec[i-1][1],vec[i-1][2]);
        vec[i][1]+=max(vec[i-1][0],vec[i-1][2]);
        vec[i][2]+=max(vec[i-1][1],vec[i-1][0]);
    }
    cout << max(vec[n-1][0],max(vec[n-1][1],vec[n-1][2]));
}


Measured memory_bytes: 8684