akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
	int a,b,c;
	int ans;
	int cnt=0;
	
	while(cin>>a>>b){
		//-----test-----
		if(a==37564) continue;
		
		
		//--------------
		c=a+b;
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
		cnt++;
	}
	
	return 0;
}

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

min_val = len(S)
for i in range(0,len(S)-len(T)+1):
  count = 0
  for j in range(i, i+len(T)):
    if S[j] == T[j-i]:
      count += 1
  min_val = min(min_val, len(T)-count)
print(min_val)

Measured memory_bytes: 9064
#include <iostream>
#include <math.h>//累乗計算用
#include <cstring>//配列初期化
using namespace std;
 
bool field[ 10 ][ 10000 ];//せんべいの初期状態
bool binary[ 10 ];//2進数カウンタ
long flag;//解答の候補
int r ,c ,ans;//r,c:入力用  ans:答え
 
long FlagMake( void );//解答の候補の列挙
void Count( int area );//2進数カウンタの計算
 
int main( void ){
    cin >> r >> c;
    while(r != 0 && c != 0){//r=0,c=0でプログラム終了
        for(long i = 0 ; i < r ; i++ ){
            for(long j = 0 ; j < c ; j++ ){
                cin >> field[ i ][ j ];
            }
        }//ここまで入力
 
        ans = 0;//解答の初期化
        memset(binary , 0 , sizeof( binary ) );//配列の初期化
 
        for(long i = 0 ; i < pow( 2 , r ) ; i++ ){
            if(i != 0){Count( 0 );}//カウンタを1進める
            FlagMake();//カウンタごとの解答の候補を検索
            if( ans < flag ) ans = flag;//解答の候補が現状の解答より多ければ、解答更新
        }
 
        cout << ans << endl;//解答出力
 
        cin >> r >> c;//再入力
    }
}
 
long FlagMake(){
    int low ,high;
     
    flag = 0;
     
    for(long i = 0 ; i < c ; i++ ){
         
        low = 0; high = 0;//low:裏側の枚数,high:表側の枚数
         
        for(int j = 0 ; j < r ; j++ ){
            if( binary[ j ] == 1 ){//行が裏返されているとき
                if( field[ j ][ i ] == 0){high++; }
                else{low++; }
            }
            else{//行が裏返っていないとき
                if( field[ j ][ i ] == 0 ){low++; }
                else{high++; }
            }
        }
        if( low > high ){flag += low; }//列を裏返すかどうかの判定
        else{flag += high; }
    }
     
    return flag;//解答の候補を返す
}
 
void Count( int area ){
    if( binary[ area ] == 0 ){binary[ area ] = 1;}//繰り上げなしの時
    else{//繰り上げありの時
        binary[ area ] = 0;
        Count( area + 1 );
    }
}



Measured memory_bytes: 3256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <regex>
#include <climits>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define forin(i, a) for(auto i: (a))
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](auto const &a, auto const &b){ return c ;}
#define key(t, x, compare) [](const t &a, const t &b){ return a x compare b x ;}
#define unless(a) if(!(a))

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}

int main(){
  string in(a);
  if(
    a.find("a") != string::npos and
    a.find("b") != string::npos and
    a.find("c") != string::npos
  ) {
    out("Yes");
  } else {
    out("No");
  }
}


Measured memory_bytes: 256
import java.io.IOException; 
import java.io.InputStream; 
import java.io.PrintWriter; 
 
class Main{ 
 	static long gcd(long a, long b){
      if(b==0)return a;
      return gcd(b, a%b);
    }
	static void solve(){ 
		int T = ni();
		for(int i=0;i<T;++i){
			long a=nl();
			long b=nl();
			long c=nl();
			long d=nl();
			if(a<b || d<b){
				System.out.println("No");
				continue;
			}
			a%=b;
			d=gcd(d,b);
			long div = (b-a)/d;
			long max = Math.max((div*d+a+b)%b, ((div+1)*d+a+b)%b);
			max = Math.max(max, ((div-1)*d+a+b)%b);
			System.out.println(max>c ? "No":"Yes");
		}
 
	} 
 
 
 
 
	public static void main(String[] args){ 
		 solve(); 
		 out.flush(); 
	 } 
	 private static InputStream in = System.in; 
	 private static PrintWriter out = new PrintWriter(System.out); 
 
	 private static final byte[] buffer = new byte[1<<15]; 
	 private static int ptr = 0; 
	 private static int buflen = 0; 
	 private static boolean hasNextByte(){ 
		 if(ptr<buflen)return true; 
		 ptr = 0; 
		 try{ 
			 buflen = in.read(buffer); 
		 } catch (IOException e){ 
			 e.printStackTrace(); 
		 } 
		 return buflen>0; 
	 } 
	 private static int readByte(){ if(hasNextByte()) return buffer[ptr++]; else return -1;} 
	 private static boolean isSpaceChar(int c){ return !(33<=c && c<=126);} 
	 private static int skip(){int res; while((res=readByte())!=-1 && isSpaceChar(res)); return res;} 
 
	 private static double nd(){ return Double.parseDouble(ns()); } 
	 private static char nc(){ return (char)skip(); } 
	 private static String ns(){ 
		 StringBuilder sb = new StringBuilder(); 
		 for(int b=skip();!isSpaceChar(b);b=readByte())sb.append((char)b); 
		 return sb.toString(); 
	 } 
	 private static int[] nia(int n){ 
		 int[] res = new int[n]; 
		 for(int i=0;i<n;++i)res[i]=ni(); 
		 return res; 
	 } 
	 private static long[] nla(int n){ 
		 long[] res = new long[n]; 
		 for(int i=0;i<n;++i)res[i]=nl(); 
		 return res; 
	 } 
	 private static int ni(){ 
		 int res=0,b; 
		 boolean minus=false; 
		 while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-')); 
		 if(b=='-'){ 
			 minus=true; 
			 b=readByte(); 
		 } 
		 for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0'); 
		 return minus ? -res:res; 
	 } 
	 private static long nl(){ 
		 long res=0,b; 
		 boolean minus=false; 
		 while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-')); 
		 if(b=='-'){ 
			 minus=true; 
			 b=readByte(); 
		 } 
		 for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0'); 
		 return minus ? -res:res; 
	} 
} 

Measured memory_bytes: 21204
n, k = map(int, input().split())

havesnack = [0 for x in range(n + 1)]

for i in range(k):
    d = int(input())
    dlist = list(map(int, input().split()))
    for dl in dlist:
        havesnack[dl] = 1

count = 0

for i in range(1, n + 1):
    if havesnack[i] == 0:
        count += 1

print(count)



Measured memory_bytes: 9128
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int a,b;
  cin>>a>>b;
  int d = b - a;
  int sum = 0;
  rep(i,d) sum += i;
  cout << sum - a << endl;

  return 0;
}


Measured memory_bytes: 256
N, M = [int(x) for x in input().split()]

def main():
    n = N - 1
    m = M - 1
    if not n and not m:
        ans = 1
    elif not n or not m:
        ans = n + m -1
    else:
        ans = (n - 1) * (m - 1)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n;
  cin >> n;
  long long ans = n;
  for (long long i = 1;i*i <= n;i++){
    long long x = n / i;
    if (n % x == 0){
      long long c = x + i;
      ans = min(ans, c-2);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int main(){
	int N,A, B ;
	cin >> N >> A >> B;
	int sum;
	int n1,n2,n3,n4,n5,n_sum = 0;

	for (int i = 1; i <= N; i++)
	{
		 n1 = i / 10000;
		 n2 = i / 1000 % 10;
		 n3 = i / 100 % 10;
		 n4 = i / 10 % 10;
		 n5 = i % 10;
		 n_sum = n1 + n2 + n3 + n4 + n5;

		 if(A<= n_sum & n_sum <= B)
		 	sum += i;
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
void swap(int x,int y,int a[])
{
 int temp;
 temp = a[x-1];
 a[x-1] = a[y-1];
 a[y-1] = temp;
}
 
int main()
{
 int val[30];
 int i;
 int w,n;
 int a,b;
 
 scanf("%d",&w);
 scanf("%d",&n);
 for(i = 0; i < w; val[i] = i+1,i++);
 
 for(i = 0; i < n; i++)
 {
  scanf("%d,%d",&a,&b);
  swap(a,b,val);
 }
 for(i = 0; i < w; i++)
  printf("%d\n",val[i]);
 
 return 0;
}

Measured memory_bytes: 0
// https://atcoder.jp/contests/abc153/tasks/abc153_d

#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);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

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

  ll ct = 1;
  while (H > 1) {
    H /= 2;
    ct++;
  }

  ll res = pow(2, ct) - 1;
  cout << res << endl;
}

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

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

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

  return 0;
}
#endif

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;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

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


Measured memory_bytes: 384
S = input()
N = len(S)+1
arr=[0]*N

if S[len(S)-1] == '>':
    arr[len(arr)-2] = 1
for i in range(len(S)-2, -1, -1):
    if S[i] == '>':
        arr[i] = arr[i+1] + 1
 
for i in range(len(S)):
    if S[i] == '<' and arr[i] >= arr[i+1]:
        arr[i+1] = arr[i] + 1
        
print(sum(arr))


Measured memory_bytes: 23336
s=list(input())
a=s[0]
b=s[1]
c=s[2]
e=s[3]

for i in range(8):
    d=0
    x=[a,b,c,e]
    for j in range(3):
        if (i >> j)&1:
            x.insert(-j-1-d,'+')
            d+=1
        else:
            x.insert(-1-j-d,'-')
            d+=1
    q="".join(x)
    f=int(a)
    g=int(b)
    h=int(c)
    k=int(e)
    if q[1]=="-":
        g=-g
    if q[3]=="-":
        h=-h
    if q[5]=="-":
        k=-k
    if f+g+h+k==7:
        ans=q+"=7"
        print(ans)
        exit()
    
            


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  cin >> s >> t;
  Yes(t.substr(0,s.size())==s);
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main(void){
    int day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    
    int x, y;
    cin >> x >> y;
    
    if(day[x] == day[y]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    W = []
    for i in range(N):
        W.append(input())
    
    alr = [W[0], ]
    for i in range(1, N):
        if W[i] in alr:
            return "No"
        elif W[i][0] != W[i-1][-1]:
            return "No"
        else:
            alr.append(W[i])
    return "Yes"

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 3060
N = int(input())
A = [int(input()) for _ in range(N)]

M1 = max(A)
M1idx = A.index(M1)
M2 = max(A[:M1idx]+A[M1idx+1:])
for i in range(N):
  if A[i] != M1:
    print(M1)
  else:
    print(M2)

Measured memory_bytes: 14124
<?php
$n = trim(fgets(STDIN));
for ($i = 0; $i < $n; $i++) {
    $s[$i]=trim(fgets(STDIN));
}
$s_name = array_count_values($s);
$s_max = array_keys($s_name,max($s_name));
asort($s_max);
foreach ($s_max as $value) {
    echo $value."\n";
}
?>


Measured memory_bytes: 107732
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
long long mod_pow(long long a,int b) {
    if(b==0){return 1;}
    long long res=mod_pow(a*a%MOD,b/2);
    if(b&1)res=res*a%MOD;
    return res;
}
vector<long long> fact, fact_inv, inv;
void init_nCk(int n){
  fact.resize(n+5);
  fact_inv.resize(n+5);
  inv.resize(n+5);
  fact[0]=fact[1]=1;
  fact_inv[0]=fact_inv[1]=1;
  inv[1]=1;
  for(int i=2;i<n+5;i++){
    fact[i]=fact[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    fact_inv[i]=fact_inv[i-1]*inv[i]%MOD;
  }
}
int nCk(int n,int k){
  return fact[n]*(fact_inv[k]*fact_inv[n-k]%MOD)%MOD;
}
int main(){
  int K;
  string S;
  cin>>K>>S;
  int a=S.size(),dp[K+10];
  long long ans=0,rock[K+10];
  for(int i=0;i<=K;i++){
    dp[i]=mod_pow(26,i);
  }
  init_nCk(a+K);
  for(int i=0;i<=K;i++){
    rock[i]=nCk(i+a-1,a-1)*mod_pow(25,i)%MOD;
  }
  for(int j=0;j<=K;j++){
    ans+=dp[K-j]*rock[j];
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 63108
a,b=sorted(map(int,input().split()))
mod=10**9+7
ans=1
if a==b:
    for i in range(1,a+1):
            ans=ans*i*i%mod
    ans=ans*2%mod        
elif b-a>1:ans=0
else:
    for i in range(1,a+1):
        ans=ans*i*i%mod
    ans=ans*b%mod
print(ans)

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

int main() {
  int n;
  cin >> n;
  int a[110];
  int ans = 0;
  for(int b = 0; b < n; ++b)cin >> a[b];
  for(int i = 0; i < n; ++i){
    for(int j = i + 1; j < n; j++){
      ans += a[i] * a[j];
    }
  }
  cout << ans << endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint n,a,b;
llint x[100005];

llint calc(int i){
	llint ret;
	ret=x[i]-x[i-1];
	ret*=a;
	return min(ret,b);
}

void solve(){
	cin >>n >> a >> b;
	for(int i=0;i<n;i++)cin >> x[i];
	llint ans=0;
	//ans+=min((x[0]-1)*a,b);
	for(int i=1;i<n;i++){
		ans+=calc(i);
	}
	cout << ans << endl;
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 1024
import sys
N = int(input())
array = []
for I in range(N):
    array.append(int(input()))

if not ( 1 <= N <= 100 ):
    sys.exit()
for J in range(len(array)):
    if not ( 1 <= array[J] <= 100 ):
        sys.exit()

print(len(set(array)))

Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    int M=INF,ans=0;
    rep(i,N){
        if (M>=A[i]) ++ans;
        chmin(M,A[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,a,b=MI()
    xx=LI()
    now=xx[0]
    ans=0
    for x in xx[1:]:
        if (x-now)*a<b:ans+=(x-now)*a
        else:ans+=b
        now=x
    print(ans)

main()

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

void solve(long long A, long long B, long long C, long long K)
{
    if (K <= A) {
        cout << K << endl;
    } else if (K <= A + B) {
        cout << A << endl;
    } else {
        cout << A - (K - (A + B)) << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    long long K;
    scanf("%lld", &K);
    solve(A, B, C, K);
    return 0;
}


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

int main(){
    //int flag=1;
    long long MAX;
    int a,b,c,k;
    long long ans=0;

    cin >>a>>b>>c>>k;
    ans = a+b+c;

    MAX=max(c,max(a,b));
    ans -= MAX;
    MAX <<= k;
    ans +=MAX;

    cout << ans <<endl;
    //cout <<fixed<<setprecision(16)<< ans <<endl;
    
    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

#define ll long long 

using namespace std;

bool isPrime(int n) 
{ 

    if (n <= 1) 
        return false; 
  
    
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
} 

int main(){
    int x;
    cin >> x;
    if(isPrime(x)){
        x = x;
    }
    else{
        
        while(!isPrime(x)){
            x = x + 1;
        }
    }
    cout << x;
}

Measured memory_bytes: 256
n = int(input())
s = input()
ans =0
for i in range(10):
    if str(i) in s:
        t = s[s.index(str(i))+1:]
        for j in range(10):
            if str(j) in t:
                u = t[t.index(str(j))+1:]
                for k in range(10):
                    if str(k) in u:
                        ans += 1
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define mp makepair
#define pb push_back
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main(){
	ull n,m,sum,route;
	vector<ull> v;
	while(cin >> n && n){
		v.clear();
		sum = route = 0;
		rep(i,n){
			cin >> m;
			v.pb(m);
		}
		sort(v.begin(),v.end());
		rep(i,n){
			sum += route;
			route += v[i];
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll int>
#define vs vector<string>
#define v vector<int>
#define mi map<int,int>
#define mc map<char,int>
//ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n,i,j,sum=0;
	cin>>n;
	v A(n);
	for(auto &x:A)cin>>x;
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			sum+=(A[i]*A[j]);
			}
		}
		cout<<sum <<"\n";
}


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

int main(){
    int a,b;
    cin >> a >> b;
    if(0 < a && a <= 9){
        if(0 < b && b <= 9){
            cout << a * b << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
L=[]
for i in range(3):
    l=list(map(int,input().split()))
    L.append(l)
#print(L)

B=[[0,0,0]for i in range(3)]
#print(B)
N=int(input())
for i in range(N):
    n=int(input())
    for h in range(3):
        for w in range(3):
            if L[h][w]==n:
                B[h][w]=1

F=0
for h in range(3):
    cnt=0
    for w in range(3):
        cnt+=B[h][w]
    if cnt==3:
        F=1

for w in range(3):
    cnt=0
    for h in range(3):
        cnt+=B[h][w]
    if cnt==3:
        F=1

if B[0][0]+B[1][1]+B[2][2]==3:
    F=1
if B[2][0]+B[1][1]+B[0][2]==3:
    F=1
if F==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,mw,w,v,dp[100001]={};
    cin>>n>>mw;
    while(n--)
    {
        cin>>w>>v;
        for(int j=100000;j>=w;j--)
        {
            dp[j]=max(dp[j],dp[j-w]+v);
        }
    }
    cout<<dp[mw];
}


Measured memory_bytes: 1024
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <stdlib.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
signed main(){
int n,m;
cin >>n>>m;
vector<pair<int,bool>> a(n);
REP(i,n){
    int z;
    cin >>z;
a[i]=make_pair(z,true);
}
REP(i,m){
    int aa,b;
    cin >> aa >>b;
  aa--;
  b--;
if(a[aa].first>a[b].first){
if(a[aa].second){
  a[aa].second=true;
}
if(a[b].second){
  a[b].second=false;
}
}else if(a[b].first>a[aa].first){
if(a[b].second){
  a[b].second=true;
}
if(a[aa].second){
  a[aa].second=false;
}
}else if(a[b].first==a[aa].first){
if(a[b].second){
  a[b].second=false;
}
  if(a[aa].second){
a[aa].second=false;
  }
}
}
int ans=0;
REP(i,n){
  if(a[i].second==true){
    ans++;
    }
}
cout << ans;
}

Measured memory_bytes: 4704
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int a, b, c, d;
	while(~scanf("%d%d%d%d", &a, &b, &c, &d))
	{
		printf("%d\n", max(a * b, c * d));
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 1000001;
const int MOD =1000000007;
const int INV2 = (MOD+1)/2;



     signed main(){
   int n,a,b,c;
   cin>>n>>a>>b>>c;
  string s[n],x;
  string p[3];
  p[0]="AB";p[1]="BC";p[2]="AC";
  for(int i=0;i<n;i++)cin>>s[i];
  string ans;
  for(int i=0;i<n;i++){
    bool t=true;
    if(s[i]==p[0]){
      if(a>b&&t){
        ans.push_back('B');
        a--;b++;
        t=false;
      }
      if(a<b&&t){
        ans.push_back('A');
        a++;b--;
        t=false;
      }
      if(a==b&&t){
        if(i+1<n&&s[i+1]==p[1]){
          ans.push_back('B');
        a--;b++;
        }
        else{
           ans.push_back('A');
        a++;b--;
        }
       t=false;
      }
    }
    if(s[i]==p[1]){
      if(b>c){
        ans.push_back('C');
        b--;c++;
        t=false;
      }
      if(b<c&&t){
        ans.push_back('B');
        b++;c--;
        t=false;
      }
      if(b==c&&t){
        if(i+1<n&&s[i+1]==p[2]){
          ans.push_back('C');
        b--;c++;
        }
        else{
           ans.push_back('B');
        b++;c--;
        }
       
      }
    }
    if(s[i]==p[2]){
      if(c<a){
        ans.push_back('C');
        a--;c++;
        t=false;
      }
      if(c>a&&t){
        ans.push_back('A');
        a++;c--;
        t=false;
      }
      if(a==c&&t){
        if(i+1<n&&s[i+1]==p[0]){
          ans.push_back('A');
        c--;a++;
        }
        else{
          ans.push_back('C');
        a--;c++;
        }
       
      }
    }
    if(a<0||b<0||c<0){
     // cerr<<a<<' '<<b<<' '<<c<<endl;
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  for(int i=0;i<n;i++)cout<<ans[i]<<endl;






}


        


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

 
int main() {
   string s;
   cin>>s;
   rep(i,s.length()){
       if(i%2){//偶数の時
          if(s[i]=='R'){
              cout<<"No"<<endl;
              return 0;
          }
       }
       else{
           if(s[i]=='L'){
               cout<<"No"<<endl;
               return 0;
           }
       }
   }
   cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;

int main()
{
	//ifstream cin("input.txt");

	int N;
	string s, t;

	cin >> N;
	cin.ignore();
	getline(cin, s);
	getline(cin, t);

	int answer = N + N;
	for (int i = 0; i < N; ++i)
	{
		int countCommon = 0;
		for (int j = 0; i + j < N; ++j)
		{
			if (s[i + j] == t[j])
				++countCommon;
			else
				break;
		}

		if (2 * N - countCommon < answer)
			answer = 2 * N - countCommon;
	}

	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        N: usize,
        A: [usize; N-1],
    }

    let mut map :std::collections::HashMap<usize, usize> = std::collections::HashMap::new();
    for i in 0..N-1 {
        let count = map.entry(A[i]).or_insert(0);
        *count += 1;
    }
    for i in 1..N+1 {
        if map.contains_key(&i) {
            println!("{}", map[&i]);
        } else {
            println!("{}", 0)
        }
    }
}


Measured memory_bytes: 11504
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

int64 pw(int64 a, int64 b) {
  int64 res = 1;
  for (; b; b >>= 1) {
    if (b & 1) {
      res *= a;
      res %= mod;
    }
    a *= a;
    a %= mod;
  }
  return res;
}

int64 inv(int64 a) {
  return pw(a, mod - 2);
}

int64 C(int n, int a) {
  int64 res = n;
  for (int i = 2; i <= a; ++i) {
    res *= (n - i + 1);
    res %= mod;
    res *= inv(i);
    res %= mod;
  }
  return res;
}

void solve(int) {
  int a, b;
  cin >> n >> a >> b;
  int64 ans = pw(2, n) - 1 + mod;
  ans -= C(n, a);
  ans = (ans + mod) % mod;
  ans -= C(n , b);
  ans = (ans + mod) % mod;
  cout << ans << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    // static int INF = (1 << 30) - 1;
    // static long L_INF = (1L << 62) - 1;
    // static long MOD = (long) 1e9 + 7;

    static class Solver {
        long N, A, B;
        long[] X;

        // write your code
        void solve(InputReader in, PrintWriter out) {
            N = in.nextLong();
            A = in.nextLong();
            B = in.nextLong();
            X = new long[(int) N];
            for (int i = 0; i < N; i++) {
                X[i] = in.nextLong();
            }

            long ans = 0;
            for (int i = 1; i < N; i++) {
                long w = A * (X[i] - X[i - 1]);
                long j = B;
                ans += (w < j ? w : j);
            }
            out.println(ans);
        }

        void debug(Object... os) {
            System.err.println(Arrays.deepToString(os));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


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

using namespace std;

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

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

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

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
int a[252521],  b[252521];

int main(){
  cin>>n>>m;
  REP(i,n)cin>>a[i];
  REP(i,m)cin>>b[i];
  set<int> aa,oo;
  REP(i,n)oo.insert(a[i]);
  REP(i,m)oo.insert(b[i]);
  set<int> S;
  REP(i,m)S.insert(b[i]);
  REP(i,n){
    if(S.count(a[i]))aa.insert(a[i]);
  }
  printf("%d %d\n",(int)aa.size(), (int)oo.size());
  for(int x : aa){
    printf("%d\n",x);
  }
  for(int x : oo){
    printf("%d\n",x);
  }
  return 0;
}



Measured memory_bytes: 22296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+50;
ll n,k;
ll a[maxn];
ll log_number(int x,int mid)
{
    if(x%mid==0) return x/mid;
    else return x/mid+1;
}
bool check(int x)
{
    int ans=0;
    for(int i=0;i<n;++i)
    {
        ans+=log_number(a[i],x)-1;
    }
    if(ans>k) return false;
    return true;
}
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;++i) cin>>a[i];
    int l=1,r=1e9;
    int cnt=0;
    while(r-l>1)
    {
        int mid=(l+r)>>1;
        if(check(mid)) r=mid;
        else l=mid;
    }
    if(check(l)) cout<<l<<endl;
    else cout<<r<<endl;
    //cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 5152
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
 
using namespace std;
 
typedef long long ll;
const int maxn=1e5+7;
const ll mod= 998244353;

struct node
{
	ll x,y;
}a[1110];

bool cmp(node a,node b)
{
	return atan2(a.x,a.y)<atan2(b.x,b.y);
}
 
int main()
{
//	freopen("input.txt","r",stdin);
	
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++) cin>>a[i].x>>a[i].y;
	sort(a,a+n,cmp);
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		ll x=a[i].x,y=a[i].y;
		ans=max(ans,x*x+y*y);
		for(ll j=(i+1)%n;j!=i;j=(j+1)%n)
		{
			x+=a[j].x,y+=a[j].y;
			ans=max(ans,x*x+y*y);
		}
	}
	double res=sqrt(ans);
	printf("%.13f\n",res);
    
    return 0;
}

















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 10000000
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
using namespace std;
int main()
{
	int n;
	cin >> n;
	int ans = 0;
	int A[] = {500, 1000, 5000, 10000};
	int i = 3;
	while(1)
	{
		if(i < 0)
			break;
		if(n - A[i] < 0)
		{
			i--;
		}
		else
		{
			n -= A[i];
			ans += A[i];
		}
	}
	cout << ans << endl;
	return 0;
}



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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007

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

   string A;
   cin>>A;
   vector<vector<int> >c(A.size(),vector<int>(26,0));
   for(int i=0;i<A.size();i++){
      c[i][(int)A[i]-'a']++;
   }
   /*
   for(int i=0;i<A.size();i++){
      for(auto it:c[i]){
         cout<<it<<" ";
      }
      cout<<endl;
   }
   */

   for(int i=0;i<A.size()-1;i++){
      for(int j=0;j<26;j++){
         c[i+1][j] += c[i][j];
      }
   }

   /*
   for(int i=0;i<A.size();i++){
      for(auto it:c[i]){
         cout<<it<<" ";
      }
      cout<<endl;
   }
   */

   ll ans = 1;
   for(int i=0;i<A.size();i++){
      for(int j=0;j<26;j++){
         if(j==A[i]-'a')continue;
         ans+=c[i][j];
      }
   }

   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 27028
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <math.h> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int a,b;
    cin >> a >> b;

    int res;

    res = max(0, a - 2 * b);

    cout << res << endl;


    return 0;    

}



Measured memory_bytes: 384
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
int MOD=1000000000+7;
int INF=1e6;
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    ll int n,m;
    cin>>n>>m;
    ll int t=0,s=0;
    ll int pre,temp;
    cin>>temp;
    rep(i,n-1){
        pre=temp;
        cin>>temp;
        ll int a=((i+1)*(n-1-i))%MOD;
        a=(a*(temp-pre))%MOD;
        t+=a;
        t%=MOD;
    }
    cin>>temp;
    rep(i,m-1){
        pre=temp;
        cin>>temp;
        ll int a=((i+1)*(m-i-1))%MOD;
        a=(a*(temp-pre))%MOD;
        s+=a;
        s%=MOD;
    }
    cout<<((t*s)%MOD);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<int> a(3);
	rep(i, 3) cin >> a[i];

	sort(all(a));

	dunk(a[0] + a[1]);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
	double r1,r2,r3,rinf;
	int a[1000],b[1000],c[1000];
	int n;
	r1 = 0;
	r2 = 0;
	r3 = 0;
	rinf = 0;
	cin >>n ;
	for(int i = 0 ; i < n; i++){
		cin >>  a[i];
	}
	for (int i = 0 ; i < n ;i++){
		cin >> b[i];
	}
	for(int i = 0; i < n ; i++){
		c[i] = a[i]-b[i];
		r1 += abs(c[i]);
		r2 += c[i]*c[i];
		r3 += abs(c[i]*c[i]*c[i]);
		if(rinf<abs(c[i])){
			rinf = abs(c[i]);
		}
	}
	r2 = sqrt(r2);
	r3 = pow(r3,(double)1/(double)3);
	printf("%.8f\n%.8f\n%.8f\n%.8f\n",r1,r2,r3,rinf);
	return 0;
}

Measured memory_bytes: 1240
# DP
def main():
    N, W = map(int, input().split())

    dp = [-1] * (W + 1)
    dp[0] = 0
    for _ in range(N):
        w, v = map(int, input().split())
        for i in range(W - w, -1, -1):
            dpi = dp[i]
            if dpi == -1:
                continue
            if dp[i + w] < dpi + v:
                dp[i + w] = dpi + v
    print(max(dp))


main()


Measured memory_bytes: 9392
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final int MIN = 1;
        final int MAX = 1000000000;
        Scanner sc = new Scanner(System.in);
        String x = sc.next();
        String a = sc.next();
        String b = sc.next();
        int X;
        int A;
        int B;
        // 文字チェック
        try {
            X = Integer.parseInt(x);
            A = Integer.parseInt(a);
            B = Integer.parseInt(b);
        } catch (Exception e) {
            return;
        }

        // 範囲チェック
        if (X < MIN || MAX < X
                || A < MIN || MAX < A
                || B < MIN || MAX < B) {
            return;
        }

        // 食品チェック
        int days = A-B;
        int abs_num = Math.abs(days);
        if (days < 0 && X < abs_num) {
            System.out.println("dangerous");
        } else if (days < 0 && abs_num <= X) {
            System.out.println("safe");
        } else if (0 <= days) {
            System.out.println("delicious");
        }
    }
}


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

int main(void) {
  lint N;
  cin >> N;
  lint m = sqrt(N);
  for(; m > 0; m--) {
    if(N % m == 0) {
      cout << m + N / m - 2 << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
from math import ceil


def binary(N, LIST, num):  # 二分探索 # N:探索要素数
    l, r = -1, N
    while r - l > 1:
        if LIST[(l + r) // 2] > num:  # 条件式を代入
            r = (l + r) // 2
        else:
            l = (l + r) // 2
    return r + 1


n, d, a = map(int, input().split())
xh = sorted(list(map(int, input().split())) for _ in range(n))
x = [i for i, j in xh]
h = [j for i, j in xh]

bomb, bsum, ans = [0] * (n + 1), [0] * (n + 1), 0
for i in range(n):
    j = binary(n, x, x[i] + 2 * d) - 1
    bsum[i] += bsum[i - 1] + bomb[i]
    bnum = max(ceil(h[i] / a - bsum[i]), 0)
    bomb[i] += bnum
    bomb[j] -= bnum
    bsum[i] += bnum
    ans += bnum
print(ans)


Measured memory_bytes: 63496
D[13][3]={{1,0,0},{0,1,0},{0,0,1},{1,1,0},{1,0,1},{0,1,1},{1,-1,0},{1,0,-1},{0,1,-1},{1,1,1},{-1,1,1},{1,-1,1},{1,1,-1}};
M[9][9][9],q[2];main(n,m,p,I,x,y,z,j,c,d){for(;scanf("%d%d%d",&n,&m,&p),n;){
	for(memset(M,0,sizeof(M)),c=1,I=0;I++<p;c*=-1){
		scanf("%d%d",&x,&y);
		for(z=1;;z++)if(!M[x][y][z]){M[x][y][z]=c;break;}
		for(d=0;d<13;d++){
			for(j=0;j<2;j++)for(q[j]=0;q[j]<m;q[j]+=2*j-1)if(M[x+D[d][0]*q[j]][y+D[d][1]*q[j]][z+D[d][2]*q[j]]!=c)break;
			if(q[1]-q[0]-1>=m){printf("%s %d\n",c==1?"Black":"White",I);goto next;}
		}
	}
	puts("Draw");
next:
	for(;I++<p;)scanf("%d%d",&x,&y);
}exit(0);}

Measured memory_bytes: 612
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

#include <iostream>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

ll five_pow(ll a){
    return a*a*a*a*a;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <tgmath.h>
#include <time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007




int main() {
    long long int A,B;
    long long int X;
    scanf("%lld",&X);
    for(long long int i = -220; i <= 220;++i){
        A = five_pow(i);
        for(long long int j = -220; j <= 220; ++j){
            B = five_pow(j);
            if((A - B) == X){
                printf("%lld %lld",i,j);
                return 0;
            }
        }
    }
}

int D(){
    long long int A,B;
    long long int X;
    scanf("%lld",&X);
    for(long long int i = -1000; i <= 1000;++i){
        A = pow(i,5);
        for(long long int j = -1000; j <= 1000; ++j){

            B = pow(j,5);
            if(A-B == X){
                printf("%d %d",i,j);
                return 0;
            }
        }
    }

    printf("A");


}

int E(){
    long long int N;
    long long int X;
    long long int count = 0;
    scanf("%lld",&N);
    long long int A[300000];
    long long int counter_minus[300000];
    long long int counter_plus[300000];

    for(int i = 0; i < 300000; ++i){
        counter_minus[i] = 0;
        counter_plus[i] = 0;
        A[i] = 0;
    }

    for(int i = 1; i <= N; ++i) {
        scanf("%lld", &A[i]);
        if(abs(A[i] + i) < 300000 ) {
            counter_plus[A[i] + i]++;

        }
        if(i - A[i]  >= 0){
            counter_minus[i - A[i]]++;
        }
    }


    for(long long int i = 0; i < 300000; ++i){
        count += counter_minus[i]*counter_plus[i];
    }
    printf("%lld",count);

    return 0;
}



Measured memory_bytes: 3808
#include <iostream>
#include <vector>
int main(void){
  short i, j, n, sum = 0, ans = 0; scanf("%hd", &n);
  std::vector<short> A(n);
  for(i = 0; i < n; i++){
    scanf("\n%hd", &A[i]);
    sum += A[i];
  }
  std::vector<bool> KingCrimson(sum + 1, false);
  KingCrimson[0] = true;
  sum = 0;
  for(i = 0; i < n; i++){
    for(j = sum; j >= 0; j--){
      if(KingCrimson[j]) KingCrimson[j + A[i]] = true;
    }
    sum += A[i];
  }
  for(short i = 0; i <= sum; i++) if(KingCrimson[i] and i % 10 != 0) ans = i;
  printf("%hd\n", ans);
  return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;

#define show(x) cerr << #x << " = " << x << endl;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


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

  map<ll, ll> m;

  ll n, e, q, a, b;
  ll sum = 0;


  cin >> n;
  for(int i=0; i<n; i++){
    cin >> e;
    m[e]++;
    sum += e;
  }

  cin >> q;
  while(q--){
    cin >> a >> b;
    ll ca = m[a];
    ll sa = a*ca;
    m[b]+=m[a];
    m[a] = 0;
    ll cb = m[b];
    ll sb = b*ca - a*ca;
    sum+= sb;
    cout << sum << endl;
  }

  return 0;
}


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

using namespace std;

int n, a[100005][3], dp[100005][3];

int solve(int day, int p) {
    if (day >= n) return 0;
    if (dp[day][p] != -1) return dp[day][p];
    int ret = a[day][p];
    if (p == 0) ret += max(solve(day + 1, 1), solve(day + 1, 2));
    if (p == 1) ret += max(solve(day + 1, 0), solve(day + 1, 2));
    if (p == 2) ret += max(solve(day + 1, 0), solve(day + 1, 1));
    return dp[day][p] = ret;
}

int main() {
    for (int i = 0; i < 100005; ++i) {
        dp[i][0] = dp[i][1] = dp[i][2] = -1;
    }
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d %d %d", &a[i][0], &a[i][1], &a[i][2]);
    }
    printf("%d\n", max(solve(0, 0), max(solve(0, 1), solve(0, 2))));
    return 0;
}


Measured memory_bytes: 7296
#include <cstdio>
#include <map>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define ITR(c,it)  for(auto it = c.begin(); it != c.end(); it++)

const int MOD = 1000000007;
const int N_MAX = 1000;

//------------------------------------------------------------------------------
bool is_prime[N_MAX + 1];

map<int, int> factorial_prime_factor(int n) {
  fill(is_prime, is_prime + n + 1, true);
  is_prime[0] = is_prime[1] = false;
  map<int, int> res;
  for (int i = 2; i <= n; i++) {
    if (!is_prime[i]) continue;
    for (int j = i * 2; j <= n; j += i) is_prime[j] = false;
    int m = n;
    while ((m /= i) > 0) {
      res[i] += m;
    }
  }
  return res;
}

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

typedef long long ll;

int N;

void solve() {
  map<int, int> ff = factorial_prime_factor(N);
  ll ans = 1;
  ITR(ff, it) {
    ans = ans * (it->second + 1) % MOD;
  }
  printf("%lld\n", ans);
}

void input() {
  scanf("%d", &N);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        m_c: [Chars; h],
    }

    let m_c: Vec<Vec<char>> = m_c;

    let mut sum = 0;
    for hh in 0..2_usize.pow(h as u32) {
        let h_select = to_bin_vec(hh, h);
        for ww in 0..2_usize.pow(w as u32) {
            let w_select = to_bin_vec(ww, w);
            let count: usize = m_c.iter()
                .enumerate()
                .filter(|&(idx, _)| h_select[idx])
                .map(|(_, v_c)| v_c.iter()
                    .enumerate()
                    .filter(|&(idx, &c)| w_select[idx] && c == '#')
                    .count()
                    )
                .sum();
            if count == k {
                sum += 1;
            }
        }
    }

    println!("{}", sum);
}

fn to_bin_vec(i: usize, n: usize) -> Vec<bool> {
    let mut i = i;
    let mut v = vec![];
    for _ in 0..n {
        v.push(i % 2 == 1);
        i /= 2;
    }
    // v.reverse();
    v
}


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

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

  int N;
  cin >> N;

  vector<int> V(N);
  for (int i = 0; i < N; i++) {
    cin >> V.at(i);
  }

  vector<int> L(N);
  L.at(0) = V.at(0);
  L.at(1) = __gcd(V.at(0), V.at(1));
  for (int i = 2; i < N; i++) {
    L.at(i) = __gcd(L.at(i - 1), V.at(i));
  }

  vector<int> R(N);
  R.at(N - 1) = V.at(N - 1);
  R.at(N - 2) = __gcd(V.at(N - 2), V.at(N - 1));
  for (int i = N - 3; i >= 0; i--) {
    R.at(i) = __gcd(R.at(i + 1), V.at(i));
  }

  int ans = R.at(1);

  for (int i = 1; i < N - 1; i++) {
    ans = max(ans, __gcd(L.at(i - 1), R.at(i + 1)));
  }

  cout << max(ans, L.at(N - 2)) << endl;
}

Measured memory_bytes: 1408