akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <map>
#include <cstring>

using namespace std;

int main(){
	int n, m;
	string str[2];
	int dist[500][500];
	while(cin >> n >> m, n){
		map<string, int> mp;
		for(int i=0;i<3;i++){
			cin >> str[0];
			mp[str[0]] = i;
		}
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				dist[i][j] = i == j ? 0 : 1000000007;
		int size = 3;
		for(int i=0;i<m;i++){
			int a, b;
			cin >> str[0] >> str[1];
			if(mp.count(str[0])) a = mp[str[0]];
			else                 a = mp[str[0]] = size++;
			if(mp.count(str[1])) b = mp[str[1]];
			else                 b = mp[str[1]] = size++;
			int d, t; cin >> d >> t;
			dist[a][b] = dist[b][a] = d/40+t;
		}
		for(int k=0;k<n;k++){
			for(int i=0;i<n;i++)
				for(int j=0;j<n;j++)
					dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
		}
		cout << dist[0][1] + dist[1][2] << endl;
	}
	return 0;
}

Measured memory_bytes: 1932
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
#define PB push_back
#define MP make_pair
const int maxn = 200009;
const int MOD = 1e9 + 7;
int cnt[10009];
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  for(int a1=1;a1<=100;++a1){
    for(int a2=1;a2<=100;++a2){
      for(int a3=1;a3<=100;++a3){
        if(a1*a1+a2*a2+a3*a3+a1*a2+a2*a3+a1*a3<=10000){
          cnt[a1*a1+a2*a2+a3*a3+a1*a2+a2*a3+a1*a3]++;
        }
      }
    }
  }
  int n;cin>>n;
  for(int i=1;i<=n;++i)cout<<cnt[i]<<'\n';
  
  return 0;
}
//2020.07.11 20:04:04


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv){
    int h, w;
    cin >> h >> w;
    vector<vector<int>> path(h, vector<int>(w));
    vector<vector<int>> dp(h, vector<int>(w));
    for(int i = 0; i < h; ++i){
        for(int j = 0;j < w;++j){
            char c;
            cin >> c;
            path[i][j] = c == '.' ? 1 : 0;
        }
    }
    for(int i = 0; i < h - 1; ++i){
        if(path[i+1][0]){
            dp[i+1][0] = 1;
        } else break;
    }
    for(int j = 0; j < w - 1; ++j){
        if(path[0][j+1]){
            dp[0][j+1] = 1;
        } else break;
    }
    for(int i = 1; i < h ; ++i){
        for(int j = 1;j < w ;++j){
            if(path[i][j]){
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]);
                dp[i][j] %= int(1e9 + 7);

            }
        }
    }
/*
    for(int i = 0; i < h; ++i){
        for(int j = 0;j < w;++j){
            cout << dp[i][j] << " ";
        }
        cout << "\n";
    }
*/
    cout << dp[h-1][w-1] << "\n";
    return 0;
}

Measured memory_bytes: 8192
x1,y1,x2,y2 = list(map(int,input().split()))

a = x2-x1
b = y2-y1
y3 = y2 + a
x3 = x2 - b
y4 = y3 -b
x4 = x3 -a

print(x3,y3,x4,y4)


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

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

    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;

    int sum_a, sum_b, sum_c;
    int count = 0;

    for (int i = 0; i <= c; i++) {
        sum_a = 50 * i;
        if (sum_a == x) {
            count++;
            break;
        }
        for (int j = 0; j <= b; j++) {
            sum_b = sum_a + 100 * j;
            if (sum_b == x) {
                count++;
                break;
            }
            for (int k = 0; k <= a; k++) {
                sum_c = sum_b + 500 * k;
                if (sum_c == x) {
                    count++;
                    break;
                }
            }
        }
    } 

    cout << count << endl;
}

Measured memory_bytes: 256
open String
let f s=let r=ref[]and j=ref(length s)in for i=length s-1downto 0do if s.[i]=' 'then(r:=sub s(i+1)(!j-i-1)::!r;j:=i)done;sub s 0!j::!r
and g n k a=let rec($)l r=if r<l then l else if h(0,0,0,(l+r)/2)<n then((l+r)/2+1)$r else l$((l+r)/2-1)and h=function(i,j,x,p)->if i=n||j=k then i else if x+a.(i)<=p then h(i+1,j,x+a.(i),p)else h(i,j+1,0,p)in 0$1000000000;;match List.map int_of_string(f(read_line()))with[n;k]->Printf.printf"%d
"(g n k(Array.init n(fun _->read_int())))|_->()

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか) */

  int n;

  int a,b,c;


  while(1){
    cin>>n;

    if(n==0){
      break;
    }
    for(int i=0;i<n;i++){
      cin>>a>>b>>c;
    

      if(a==100||b==100||c==100){
	cout<<'A'<<endl;
      }else if((a+b)/2>=90){
	cout<<'A'<<endl;
      }else if((a+b+c)/3>=80){
	cout<<'A'<<endl;
      }else if((a+b+c)/3>=70){
	cout<<'B'<<endl;
      }else if((a+b+c)/3>=50&&(a>=80||b>=80)){
	cout<<'B'<<endl;
      }else{
	cout<<'C'<<endl;
      }
    }

  }
    return 0;

  }



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

int main()
{
	int N;
	cin >> N;
	vector<long long> a( N );
	long long all = 0;
	for( int i = 0; i < N; i++ ) {
		cin >> a[i];
		all ^= a[i];
	}

	for( int i = 0; i < N; i++ ) {
		if( i ) cout << " ";
		cout << (all ^ a[i]);
	}
	cout << endl;
}


Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;



int main()
{
  int a,b;cin>>a>>b;
  cout<<(a+b-3)/(a-1)<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


public class Test
{	
    public static void Main()
	{
	    int num = int.Parse(Console.ReadLine());
        double a = Math.Pow(num,2);
        num = int.Parse(Console.ReadLine());
        Console.WriteLine(a-num);        
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;




int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double sm = 360*(m / 60)*(3.14159265359/180);
    double sh = 360*(h / 12)*(3.14159265359/180);

    double hosei =(30*m/60)* (3.14159265359 / 180);

    double hy = a * cos(sh+hosei);
    double hx = a * sin(sh+hosei);
    double my = b*cos(sm);
    double mx = b*sin(sm);
    
    double xx = pow(hx - mx,2);
    double yy = pow(hy - my,2);
    double ans = sqrt(xx+yy);

    cout << fixed << setprecision(15)<< ans << endl;
}

Measured memory_bytes: 4100
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

def fib(n):
    if n == 1:
        return 1
    else:
        return fib(n - 1) + n

a, b = map(int, input().split())

l = b - a - 1
print(fib(l) - a)


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll a,b,n;
cin >> a >> b >> n;
ll x = min(n, b - 1);
cout << a * x / b - a * (x / b) << endl;
}


Measured memory_bytes: 3540
#include <iostream>
#include <algorithm>
#include <tuple>
//#include <string>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;

int c[100];
int t[100];
vector<int> v;

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

	rep(i, N) {
		cin >> c[i] >> t[i];
	}

	rep(i, N) {
		if (t[i] <= T) v.push_back(c[i]);
	}
	if (v.size() == 0) cout << "TLE" << endl;

	else {
	sort(v.begin(), v.end());
	cout << v.at(0) << endl;
	}

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  bool flag = false;
  
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
    if( a.at(i) == 1 ) flag = true;
  }
    
  if(!flag){
    cout << -1 << endl;
    return 0;
  }
  
  int count = 1;
  int ans = 0;
  
  for(int i = 0; i < N; i++){
    if(count == a.at(i)) count++;
    else ans++;
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> dif(n, -1);
	long long a_sum = 0, b_sum = 0;
	for ( int i = 0; i < n; i++ ) {
		cin >> a[i];
		a_sum += a[i];
	}
	for ( int i = 0; i < n; i++ ) {
		cin >> b[i];
		b_sum += b[i];
		if ( a[i] >= b[i] ) dif[i] = a[i] - b[i];
	}

	long long extra = a_sum - b_sum;
	int cnt = 0;
	sort(dif.begin(), dif.end());

	if ( extra < 0 ) {
		cout << -1 << endl;
		return 0;
	}

	for ( int i = 0; i < n; i++ ) {
		if ( dif[i] == -1 ) continue;
		extra -= dif[i];
		cnt++;
		if ( extra < 0 ) {
			cnt--;
			break;
		}
		if ( extra == 0 ) {
			break;
		}
	}

	cout << n - cnt << endl;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000
struct mat {
	long long a, b, c, d;
};

mat bas[70];

mat prod(mat x, mat y) {
	mat re;
	re.a = ((x.a*y.a) + (x.b*y.c)) % MOD;
	re.b = ((x.a*y.b) + (x.b*y.d)) % MOD;
	re.c = ((x.c*y.a) + (x.d*y.c)) % MOD;
	re.d = ((x.c*y.b) + (x.d*y.d)) % MOD;
	return re;
}

void pre(void) {
	bas[0] = { 0,1,1,1 };
	f(i, 69)bas[i + 1] = prod(bas[i], bas[i]);
	return;
}


long long fib(long long k) {
	mat re = { 1,0,0,1 };
	f(i, 70) {
		if (k % 2 == 1)re = prod(re, bas[i]);
		k = k / 2;
		if (k == 0)break;
	}
	return re.d;
}

int main() {
  pre();
	long long n, k, m;
	long long x, y, z;
	long long l, r;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%lld", &n);
	l = 0;
	r = 1000000010;
	while (l + 1 < r) {
		m = (l + r) / 2;
		m--;
		x = m * (m + 1);
		if (n <= x)r = m + 1;
		else l = m + 1;
	}
	k = l;
	x = l * (l - 1);
	y = n - x;//1-2k
	if (y <= k)z= 2 * k;
	else {
		z = (2 * k) + 1;
		y -= k;
	}
	if (y <= (k + 1) / 2)x = 2 * y - 1;
	else x = 2 * (k - y + 1);
	y = z - x;
	x = fib(x);
	y = fib(y);
	ans = (x*y) % MOD;
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 2756
#include <stdio.h>
#include <stdlib.h>

void sort(int *a,int n);

int main(void)
{
	int n;
	int *a;
	
	scanf("%d",&n);
	a=(int *)malloc(sizeof(int)*n);
	int i;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	
	
	int check;
	int count=0;
	int j,k;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(a[i]==a[j])
			{
				;
			}
			else
			{
				for(k=j+1;k<n;k++)
				{
					if(a[j]==a[k])
					{
						;
					}
					else if(a[i]==a[k])
					{
						;
					}
					else
					{
						check=0;
						if(a[i]+a[j]>a[k])
						{
							check++;
						}
						if(a[j]+a[k]>a[i])
						{
							check++;
						}
						if(a[k]+a[i]>a[j])
						{
							check++;
						}
						if(check==3)
						{
							count++;
						}
					}
				}
			}
		}
	}
	printf("%d",count);
	return 0;
}

void sort(int *a,int n)
{
	int i,j;
	int tmp;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(a[i]>a[j])
			{
				tmp=a[i];
				a[i]=a[j];
				a[j]=tmp;
			}
		}
	}
}

Measured memory_bytes: 1736
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, A, B;
	cin >> N >> A >> B;
	int maxv = min(A, B);
	int minv = max(0, -N + A + B);
	cout << maxv << " " << minv << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
// C++ includes
#include <bits/stdc++.h>
// 俳句
using namespace std;

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

ll counts = 0;
ll k;

void dp(ll last,ll cur_digit,ll all_digits,string num){
    //printf("dp(%llu,%llu,%s)\n",last,cur_digit,num);
    if(cur_digit==all_digits){
        counts++;
        if(counts==k){
            cout << num << endl;
        }
        return;
    }
    switch(last){
        case -1:
            FOR(i,1,9){
                dp(i,cur_digit+1,all_digits,num+to_string(i));
            }
            break;
        case 0:
            dp(0,cur_digit+1,all_digits,num+"0");
            dp(1,cur_digit+1,all_digits,num+"1");
            break;
        case 9:
            dp(8,cur_digit+1,all_digits,num+"8");
            dp(9,cur_digit+1,all_digits,num+"9");
            break;
        default:
            dp(last-1,cur_digit+1,all_digits,num+to_string(last-1));
            dp(last  ,cur_digit+1,all_digits,num+to_string(last  ));
            dp(last+1,cur_digit+1,all_digits,num+to_string(last+1));
            break;
    }

}

int main(void){
    cin >> k;
    FOR(i,1,10){
        dp(-1,0,i,"");
    }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
num = [0] * (N+1)
for i in range(M):
    a, b = map(int, input().split())
    num[a] += 1
    num[b] += 1

flag = 1
for i in num:
    if i % 2 != 0:
        flag = 0

if flag == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3828
#include <iostream>
#include<bits/stdc++.h>
#define  ll long long
 using namespace std;
priority_queue<double,vector<double>,greater<double> >q;
int main()
{
   int n;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
       double x;
       cin>>x;
       q.push(x);
   }
    while(q.size()>1)
    {
        double x,y;
        x=q.top();q.pop();
        y=q.top();q.pop();
        q.push((x+y)/2);
    }printf("%.6f\n",q.top());
return 0;
}

Measured memory_bytes: 256
n, k, s = map(int, input().split())
ans = [s] * k
if s // 2 + 1 == s:
    ss = s // 2 + 10
else:
    ss = s // 2 + 1
ex = [ss] * (n-k)
ans.extend(ex)

for e in ans:
    print(e, end=' ')
print()

Measured memory_bytes: 5728
#include<iostream>
using namespace std;
int main(){
  int a,b;
  while(cin >> a >> b&&a||b){
    int cnt=0;
    for(int i=1;i<=a;i++){
      for(int j=i+1;j<=a;j++){
    for(int k=j+1;k<=a;k++){
      if(i+j+k==b)cnt++;
    }
      }
    }
    cout << cnt << endl;
  }
}


Measured memory_bytes: 3108
""" AtCoder"""

N, M = map(int, input().split())
KA = [list(map(int, input().split())) for _ in range(N)]

l = []
for i in range(M+1):
    l.append(0)

for i in range(N):
    for j in range(1, KA[i][0]+1):
        l[KA[i][j]] += 1

ans = 0
for i in range(1, M+1):
    if l[i] == N:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  int sx,sy,tx,ty,i;

  scanf("%d%d%d%d",&sx,&sy,&tx,&ty);

  int xdif=tx-sx;
  int ydif=ty-sy;

  for(i=0;i<ydif;i++){
    printf("U");
  }
  for(i=0;i<xdif;i++){
    printf("R");
  }
  for(i=0;i<ydif;i++){
    printf("D");
  }
  for(i=0;i<xdif;i++){
    printf("L");
  }
  printf("L");
  for(i=0;i<ydif+1;i++){
    printf("U");
  }
  for(i=0;i<xdif+1;i++){
    printf("R");
  }
  printf("D");
  printf("R");
  for(i=0;i<ydif+1;i++){
    printf("D");
  }
  for(i=0;i<xdif+1;i++){
    printf("L");
  }
  printf("U");

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  if(s == "AAA" || s == "BBB") cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str1 = sc.next();
		String str2 = sc.next();
		int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		String str3 = sc.next();
		if(str3.equals(str1)) {
			System.out.println((num1-1) + " " + num2);
		}else {
			System.out.println(num1 + " " + (num2-1));
		}
	}

}


Measured memory_bytes: 21588
n,K = map(int,input().split())
X, Y = [], []
dots = []
for _ in range(n):
    x,y = map(int,input().split())
    dots.append((x,y))
    X.append(x)
    Y.append(y)
X.sort()
Y.sort()
ans = float('inf')
for i in range(n):
    for j in range(i+1, n):
        for k in range(n):
            for l in range(k+1, n):
                x1,x2 = X[i], X[j]
                y1,y2 = Y[k], Y[l]
                cnt = 0
                for dot in dots:
                    if x1<=dot[0]<=x2 and y1<=dot[1]<=y2:
                        cnt += 1
                if cnt >= K:
                    ans = min(ans, (x2-x1)*(y2-y1))
print(ans)

Measured memory_bytes: 48348
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CG031A3
{
    class Program
    {
        static void Main(string[] args)
        {
            // 文字の長さ
            int N = int.Parse(Console.ReadLine());
            // 文字列
            string S = Console.ReadLine();
            //使われているアルファベットの個数を記録する
            Dictionary<string, int> dict = new Dictionary<string, int>();
            for (int i = 0; i < S.Length; i++)
            {
                string alpha = S.Substring(i, 1);
                if (dict.ContainsKey(alpha))
                {
                    dict[alpha]++;
                }
                else
                {
                    dict.Add(alpha, 1);
                }
            }
            ulong ans = 1;
            ulong seed = (ulong)Math.Pow(10, 9) + 7;
            foreach(KeyValuePair<string,int> member in dict)
            {
                ans = ans%seed *(ulong) (member.Value + 1)%seed;
            }
            Console.WriteLine((ans-1)%seed);
        }
    }
}


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

int main() {
	vector<int> ans;
	int a,b,co=0;
	char s;
	while(1)
	{
		cin>>a>>s>>b;
		if(s=='?')break;
		co++;
		if(s=='+')ans.push_back(a+b);
		else if(s=='-')ans.push_back(a-b);
		else if(s=='*')ans.push_back(a*b);
		else ans.push_back(a/b);
	}
	for(a=0;a<co;a++)cout<<ans[a]<<endl;
	return 0;
}

Measured memory_bytes: 3088
# B - Algae
# https://atcoder.jp/contests/abc127/tasks/abc127_b

r, d, x = list(map(int, input().split()))

num_list = [r * x - d]

for i in range(9):
    num_list.append(r * num_list[i] - d)
    
for i in num_list:
    print(i)

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

def main():
    N = int(input())
    H = list(map(int,input().split()))

    if N == 1:
        print(0)
    else:
        ans_list = []
        count = 0
        for i in range(N-1):
            if H[i+1] <= H[i]:
                count += 1
            else:
                ans_list.append(count)
                count = 0
        ans_list.append(count)
        print(max(ans_list))

if __name__ == "__main__":
    main()

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    string a,b,c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;

    return 0;
}

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

using namespace std;

int main() {
    int N, M, a, t = 0;
    vector<int> V;

    scanf("%d %d", &N, &M);
    for (int i = 0; i < N; i++) {
        scanf("%d", &a);
        V.push_back(a);
        t += a;
    }
    sort(V.rbegin(), V.rend());

    int e = V[M - 1];

    if (e * 4 * M >= t) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 256
mod = 998244353
primitive_root = 3
roots = [pow(primitive_root, (mod-1)>>i, mod) for i in range(24)]
inv_roots = [pow(root, mod-2, mod) for root in roots]

def ntt(A, n):
    for i in range(n):
        m = 1<<(n-i-1)
        for s in range(1<<i):
            w = 1
            s *= m*2
            for j in range(m):
                A[s+j], A[s+j+m] = (A[s+j]+A[s+j+m])%mod, (A[s+j]-A[s+j+m])*w%mod
                w *= roots[n-i]
                w %= mod

def intt(A, n):
    for i in range(n):
        m = 1<<i
        for s in range(1<<(n-i-1)):
            w = 1
            s *= m*2
            for j in range(m):
                A[s+j], A[s+j+m] = (A[s+j]+A[s+j+m]*w)%mod, (A[s+j]-A[s+j+m]*w)%mod
                w *= inv_roots[i+1]
                w %= mod
    inv = pow((mod+1)//2, n, mod)
    for i in range(1<<n):
        A[i] *= inv
        A[i] %= mod

def convolution(A, B):
    la = len(A)
    lb = len(B)
    deg = la + lb - 2
    n = deg.bit_length()
    N = 1<<n
    A += [0]*(N-la)
    B += [0]*(N-lb)
    ntt(A, n)
    ntt(B, n)
    A = [a*b%mod for a, b in zip(A, B)]
    intt(A, n)
    return A[:deg+1]


import sys
input = sys.stdin.readline
n, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = convolution(A, B)
print(*C)

Measured memory_bytes: 213032
#include <iostream>
#include <vector>
using namespace std;
int a[60],b[60],c[60],d[60],ans = 0,n,m,q;
void dfs(vector<int> v){
    int i;
    if(v.size()<n){
        int k = v.back();
        for(i=k;i<=m;i++){
            v.push_back(i);
            dfs(v);
            v.pop_back();
        }
    }else{
        int val = 0;
        for(i=0;i<q;i++){
            if(v[b[i]] - v[a[i]]==c[i]) val += d[i]; 
        }
        ans = max(ans,val);
    }
}
vector<int> v;
int main(){
    int i;
    cin >> n >> m >> q;
    for(i=0;i<q;i++){
        cin >> a[i] >>  b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    v.push_back(1);
    dfs(v);
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
typedef pair<int, int> PII;

const double PI = 3.1415926535897932384626433832795;

// whether x is in v or not
template <class T>
bool inVector(const T &x, const std::vector<T> &v) {
  auto iter = std::find(v.begin(), v.end(), x);
  if(iter != v.end()) {
    return true;
  }
  else {
    return false;
  }
}

vector<vector<int>> edges;
vector<PII> vp;

void explore(int p, vector<vector<int>> &tmp_edges, vector<bool> &visited) {
  REP(i, visited.size()) {
    if(tmp_edges[p][i] == 1 && visited[i] == false) {
      visited[i] = true;
      explore(i, tmp_edges, visited);
    }
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  edges.resize(n);
  REP(i, n) {
    edges[i] = vector<int>(n, 0);
  }
  REP(i, m) {
    PII p;
    cin >> p.first >> p.second;
    p.first--; p.second--;
    edges[p.first][p.second] = 1;
    edges[p.second][p.first] = 1;
    vp.push_back(p);
  }

  /*
  REP(y, n) {
    REP(x, n) {
      cout << edges[y][x];
    }
    cout << endl;
  }
  */

  int ans = 0;
  REP(i, m) {
    PII e = vp.back();
    vp.pop_back();
    vector<vector<int>>tmp_edges = edges;
    tmp_edges[e.first][e.second] = 0;
    tmp_edges[e.second][e.first] = 0;
    vector<bool> visited(n, false);
    explore(e.first, tmp_edges, visited);
    if(inVector(false, visited)) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip> // setprecision
#include <complex>
#include <cmath>
using namespace std;

typedef complex<double> point;

double inner_product(point x, point y) {
  return (conj(x) * y).real();
}

double outer_product(point x, point y) {
  return (conj(x) * y).imag();
}

point normalize(point a) {
  return a * (1/abs(a)); // normはabsの2乗、absは本来のノルム。
}

point projection(point a, point b) {
  point e = normalize(b);
  return e * inner_product(a, e);
}

int main() {
  point P[30];
  double x, y;
  int n = 0;
  while (scanf("%lf,%lf", &x, &y) != EOF) {
    P[n++] = point(x, y);
  }
  double S = 0;
  for (int i=1; i<n-1; i++) {
    S += outer_product(P[i]-P[0], P[i+1]-P[0])/2;
  }
  cout << fixed << setprecision(10) << abs(S) << endl;
}

Measured memory_bytes: 1280
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    pair<double,double>   pd;
typedef    vector<pd>   vpd;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define all(x) x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}



int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{
int n;
cin>>n;
int a[n-1];
for(int i=0;i<n-1;i++)
cin>>a[i];
int b[n+1]={0};
for(int i=0;i<n-1;i++)
b[a[i]]++;

for(int i=1;i<=n;i++)
cout<<b[i]<<"\n";










}return 0;}

Measured memory_bytes: 5212
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 string s;cin>>s;
	  int n=s.length();
	  bool f=true;
	  for(int i=0;i<n/2;i++)
	  {
	  	if(s[i]!=s[n-i-1])f=false;
	  }
	 string s1=s.substr(0,(n-1)/2);
	 string s2=s.substr((n+3)/2-1);
	 int len1=s1.length();int len2=s2.length();
	 for(int i=0;i<len1;i++)
	 {
	 	if(s1[i]!=s1[len1-i-1])f=false;
	 }
	 for(int i=0;i<len2;i++)
	 {
	 	if(s2[i]!=s2[len2-i-1])f=false;
	 }
	 if(!f)cout<<"No"<<endl;
	 else
	 cout<<"Yes"<<endl;
	// cout<<s2;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n ;
int a[10005];
int  f[1000005];
int z[1000005];
int cnt[1000005];
int now;
long long L=1;
int INF=1e9 +7;
int b[10005];

void find(int x)
{
	while(x!=1)
	{
		int d = z[f[x]], k=0;
		int dd = f[x];
		while (x%d == 0)
			x/=d, ++k;
		cnt[dd]=max(cnt[dd],k);
	}
}

long long pow_mod(long long x, long long y, long long k)
{
	if(y==0) return 1%k;
	if(y%2) return pow_mod(x,y-1,k)*x%k;
	return pow_mod(x*x%k,y/2,k);
}

int main()
{
	scanf("%d",&n);
	for(int i=2;i<=1000005;++i)
	{
		if(f[i]) continue;
		z[++now]=i;
		f[i]=now;
		for(int j=i+i;j<=1000005;j+=i)
		    f[j]=now;
	}
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
	    find(a[i]);
	}
	for(int i=1;i<=now;++i)
	{
		for(int j=1;j<=cnt[i];++j)
		    L*=z[i],L%=INF;
	}
	long long ans=0;
	for(int i=1;i<=n;++i)
	{
		b[i]=pow_mod(a[i],INF-2,INF);
		ans+=L*b[i]%INF;
		ans%=INF;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8208
#include<bits/stdc++.h>
using namespace std;
char str[1005];
bool check(int L,int R){
	if((R-L+1)%2!=0)return 0;
	int len=(R-L+1)/2;
	for(int i=0;i<len;i++)
		if(str[L+i]!=str[L+len+i])return 0;
	return 1;
}
int main() {
	scanf("%s",str);
	int n=strlen(str);
	for(int i=1; i<n; i++) {
		if(check(0,n-i-1)) {
			printf("%d\n",n-i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

typedef unsigned long long int ull;

int N;

const int MAXN=502;

struct info_t{
    ull targets[MAXN];
    int opcat[MAXN];
    int zeroCount[64][MAXN];
}row,col;

ull matrix[MAXN][MAXN];

bool check(){
    //
    for(int r=1;r<=N;r++){
        ull androw=-1,orrow=0ull,andcol=androw,orcol=orrow;
        for(int c=1;c<=N;c++){
            androw&=matrix[r][c];
            orrow|=matrix[r][c];
            andcol&=matrix[c][r];
            orcol|=matrix[c][r];
        }

        if (row.opcat[r]&&orrow!=row.targets[r]) return false;
        if (!row.opcat[r]&&androw!=row.targets[r]) return false;
        if (col.opcat[r]&&orcol!=col.targets[r]) return false;
        if (!col.opcat[r]&&andcol!=col.targets[r]) return false;
    }

    return true;
}

void simpleInference(int pos){
    for(int r=1;r<=N;r++){
        for(int c=1;c<=N;c++){
            //目標値の対応ビットを取り出す
            auto colBit=(col.targets[c]>>pos)&1;
            auto rowBit=(row.targets[r]>>pos)&1;

            if (colBit^col.opcat[c]) matrix[r][c]|=(colBit<<pos);

            if (rowBit^row.opcat[r]) matrix[r][c]|=(rowBit<<pos);

            if (rowBit==colBit) matrix[r][c]|=(rowBit<<pos);
        }
    }
}

void SpecialInference(info_t& one,info_t& another,bool isRow,int pos){
    ull mask=(ull)1<<(ull)pos;
    for(int r=1;r<=N;r++){
        //今の桁を何にするかを表す
        auto bitTarget=(one.targets[r]>>pos)&one.opcat[r];
        if (!bitTarget||one.zeroCount[pos][r]<N) continue;
        
        int c=1;
        while(c<=N){
            if (another.opcat[c]==0&&(another.targets[c]&mask)==0&&another.zeroCount[pos][c]>1) break;
            c++;
        }
        if (c>N) continue;
        if (isRow)
            matrix[r][c]|=mask;
        else 
            matrix[c][r]|=mask;
        another.zeroCount[pos][c]--;
        one.zeroCount[pos][r]--;
    }
}

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

    for(int i=1;i<=N;i++) scanf("%d",row.opcat+i);
    for(int i=1;i<=N;i++) scanf("%d",col.opcat+i);
    for(int i=1;i<=N;i++) scanf("%llu",row.targets+i);
    for(int i=1;i<=N;i++) scanf("%llu",col.targets+i);

    for(int bit=0;bit<64;bit++){
        simpleInference(bit);

        memset(row.zeroCount,0,sizeof(row.zeroCount));
        memset(col.zeroCount,0,sizeof(col.zeroCount));
        for(int r=1;r<=N;r++)
            for(int w=1;w<=N;w++)
                if (((matrix[r][w]>>bit)&1)==0) row.zeroCount[bit][r]++,col.zeroCount[bit][w]++;

        SpecialInference(row,col,true,bit);
        SpecialInference(col,row,false,bit);
    }

    if (!check()){
        puts("-1");
        return 0;
    }

    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++)
            printf("%llu ",matrix[i][j]);
            putchar('\n');
    }

    return 0;
}

Measured memory_bytes: 7668
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<ll,ll> P;
int N,M;

int main(void){
  cin >> N >> M;
  vector < P > X(N);
  int i,n=0;
  ll cost=0;
  FOR(i,N) cin >> X[i].first >> X[i].second;
  sort(X.begin(),X.end());
  FOR(i,N){
    if(n+X[i].second < M){
      n += X[i].second;
      cost += (ll)X[i].first*X[i].second;
    }else{
      cost += (ll)X[i].first*(M-n);
      break;
    }
  }
  cout << cost << endl;
  return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int N = cin.nextInt();
		int K = cin.nextInt();
		boolean[] num = new boolean[10];
		Arrays.fill(num, true);
		for(int i=0;i<K;i++){
			num[cin.nextInt()] = false;//这些数字是不可用的 
		}
		while (true) {
			int dummpN = N;
			boolean flag = false;
			while (dummpN != 0) {
				int temp = dummpN%10;
				dummpN /=10;
				if (!num[temp]) {
					flag = true;
					break;
				}
			}
			if (flag == false) {
				System.out.println(N);
				return;
			}
			N++;
		}
		
	} 
	
}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    string s;
    cin>>s;
    
    ll A = (s[0]-'0')*10 + (s[1]-'0');
    ll B = (s[2]-'0')*10 + (s[3]-'0');
    
    bool YYMM = (1<=B && B<=12);
    bool MMYY = (1<= A && A<=12);

    if(YYMM){
        if(MMYY)puts("AMBIGUOUS");
        else puts("YYMM");
    }else{
        if (MMYY) puts("MMYY");
        else puts("NA");
    }
    return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#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>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< "\n"


int main(){
    int n,k;
    cin >> n >> k;
    int ans = k;
    for(int i=1;i<n;i++){
        ans *= k-1;
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n, c;
	cin >> n >> c;
	int d[30][30];
	for(int i = 0; i < c; i++){
		for(int j = 0; j < c; j++){
			cin >> d[i][j];
		}
	}
	int cnt[3][30] = {};
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			int tmp;
			cin >> tmp;
			tmp--;
			cnt[(i + j) % 3][tmp]++;
		}
	}
	int ans = mod;
	for(int i = 0; i < c; i++){
		for(int j = 0; j < c; j++){
			if(i == j) continue;
			for(int k = 0; k < c; k++){
				if(i == k || j == k) continue;
				int res = 0;
				for(int p = 0; p < 3; p++){
					for(int q = 0; q < c; q++){
						res += cnt[p][q] * d[q][(p == 0) ? i : ((p == 1) ? j : k)];
					}
				}
				ans = min(ans, res);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dI = { 0, 1, 0, -1 };
        static readonly int[] dJ = { 1, 0, -1, 0 };
        //static List<List<int>> G = new List<List<int>>();
        //static List<List<Edge>>G = new List<List<Edge>>();
        //static List<Edge> E = new List<Edge>();
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            int N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            int ans = 0;
            for(var i = 0; i < N - 2; i++)
            {
                if (S.Substring(i, 3) == "ABC") { ans++; }
            }
            Console.WriteLine(ans);

            //Console.Out.Flush();
        }
        struct Edge
        {
            public int from;

            public int to;
            public long dist;
            public Edge(int t, long c)
            {
                from = -1;
                to = t;
                dist = c;
            }
            public Edge(int f, int t, long c)
            {
                from = f;
                to = t;
                dist = c;
            }

        }
    }
    public class Scanner
    {
        public int[] ReadSplitInt()
        {
            return ConvertAll(Console.ReadLine().Split(), int.Parse);
        }
        public long[] ReadSplitLong()
        {
            return ConvertAll(Console.ReadLine().Split(), long.Parse);
        }
        public double[] ReadSplit_Double()
        {
            return ConvertAll(Console.ReadLine().Split(), double.Parse);
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public void Swap<T>(ref T a, ref T b)
        {
            T keep = a;
            a = b;
            b = keep;
        }

        static public void Display<T>(T[,] array2d, int n, int m)
        {
            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < m; j++)
                {
                    Console.Write($"{array2d[i, j]} ");
                }
                Console.WriteLine();
            }
        }

        static public long LPow(int a, int b)
        {
            return (long)Pow(a, b);
        }
    }
}


Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static int[] w;
        static int[] v;
        static long[] dp;

        static void Main(string[] args)
        {
            //[summary]D - Knapsack 2
            var line = ReadLine();
            int N = line[0];
            int W = line[1];

            //品物ごとの重さ,価値を取得する
            GetGoods(N);

            dp = new long[v.Sum() + 1];
            var copy = new long[dp.Length];

            for(int i = 0; i < N; i++)
            {
                if (IsUpdate(v[i], w[i]))
                {
                    copy[v[i]] = w[i];
                }

                for(int j = 0; j < dp.Length; j++)
                {
                    if (dp[j] > 0)
                    {
                        if (v[i] + j < dp.Length)
                        {
                            if (IsUpdate(v[i] + j, w[i] + dp[j]))
                            {
                                copy[v[i] + j] = w[i] + dp[j];
                            }
                        }
                    }
                }

                Array.Copy(copy, dp, dp.Length);
            }

            /*for(int i = 0; i < dp.Length; i++)
            {
                if (dp[i] > 0)
                {
                    Console.WriteLine("{0} {1}", i, dp[i]);
                }
            }*/

            Console.WriteLine(GetMaxValue(W));
        }

        static bool IsUpdate(int vi, long wi)
        {
            if (dp[vi] == 0 | dp[vi] > wi)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        static int GetMaxValue(int W)
        {
            for(int i = dp.Length - 1; i >= 0; i--)
            {
                if (dp[i] <= W && dp[i] > 0)
                {
                    return i;
                }
            }

            return 0;
        }

        static void GetGoods(int N)
        {
            w = new int[N];
            v = new int[N];

            for(int i = 0; i < N; i++)
            {
                var line = ReadLine();
                w[i] = line[0];
                v[i] = line[1];
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 14688
s = gets.chomp

N = 13

mod = 10**9 + 7

dp = Array.new(13, 0)

dp[0] = 1

s.chars.each do |c|
  nextdp = Array.new(13, 0)

  dp.each_with_index do |b, num|
    if c == '?'
      10.times do |i|
        nextdp[(num * 10 + i) % N] += b
      end
    else
      nextdp[(num * 10 + c.to_i) % N] += b
    end
  end

  13.times do |n|
    nextdp[n] = nextdp[n] % mod
  end

  dp = nextdp
end

puts dp[5]


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

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>

struct Op {
    int r1, c1, r2, c2;
};


int main() {
    std::ios_base::sync_with_stdio(false);
    int nRows, nCols;
    std::cin >> nRows >> nCols;
    std::vector<std::vector<int>> field(nRows, std::vector<int>(nCols));
    std::vector<Op> answ;
    for (int r = 0; r < nRows; ++r) {
        for (int c = 0; c < nCols; ++c) {
            std::cin >> field[r][c];
        }
    }
    for (int r = 0; r < nRows; ++r) {
        for (int c = 0; c < nCols; ++c) {
            if (field[r][c] % 2 == 1) {
                bool flag = false;
                for (int dr = -1; dr <= 1; ++dr) {
                    for (int dc = -1; dc <= 1; ++dc) {
                        if (dr*dr + dc*dc != 1) continue;
                        int nr = r + dr, nc = c + dc;
                        if (nr < 0 || nr >= nRows || nc < 0 || nc >= nCols) continue;
                        if (field[nr][nc] % 2 == 1) {
                            flag = true;
                            answ.push_back({r+1, c+1, nr+1, nc+1});
                            field[nr][nc]++;
                            field[r][c]--;
                            break;
                        }
                    }
                    if (flag) break;
                }
                if (!flag) {
                    if (c+1 < nCols) {
                        field[r][c+1]++;
                        field[r][c]--;
                        answ.push_back({r+1, c+1, r+1, c+2});
                    } else if (r+1 < nRows) {
                        field[r+1][c]++;
                        field[r][c]--;
                        answ.push_back({r+1, c+1, r+2, c+1});
                    }
                }
            }
        }
    }
    std::cout << (int)answ.size() << "\n";
    for (auto& t : answ) {
        std::cout << t.r1 << " " << t.c1 << " " << t.r2 << " " << t.c2 << "\n";
    }
    return 0;
}

Measured memory_bytes: 5236
//Addition and Multiplication
//https://atcoder.jp/contests/abc076/tasks/abc076_b

#include <cstdio>

int main()
{
  int N, K;
  int min = 1;

  scanf("%d", &N);
  scanf("%d", &K);
  for (int i = 0; i < N; i++)
  {
    int add, mul;
    add = min + K;
    mul = min * 2;
    if (add < mul)
    {
      min = add;
    }
    else
    {
      min = mul;
    }
  }
  printf("%d\n", min);
}


Measured memory_bytes: 128
from collections import deque
print("Yes")

N,M=map(int,input().split())
lst=[[] for _ in range(N)]
for _ in range(M):
    a,b=map(int,input().split())
    lst[a-1].append(b-1)
    lst[b-1].append(a-1)
q=deque(lst[0])
go=[None]*N
for i in lst[0]:
    go[i]=0
while q:
    v=q.popleft()
    for new in lst[v]:
        if go[new]==None:
            go[new]=v
            q.append(new)
for i in go[1:]:
    print(i+1)

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

void printNodeInfo(int* array, int index, int num_elem)
{
    cout << "node " << index+1 << ": key = " << array[index] << ", ";
    if(index != 0)
    {
        cout << "parent key = " << array[(index - 1) / 2] << ", ";
    }
    if(2 * index + 1 < num_elem)
    {
        cout << "left key = " << array[2 * index + 1] << ", ";
    }
    if(2 * index + 2 < num_elem)
    {
        cout << "right key = " << array[2 * index + 2] << ", ";
    }
    cout << endl;
}

int main()
{
    int n, array[250];
    cin >> n;
    for(int i=0;i<n;++i)
    {
        cin >> array[i];
    }

    for(int i=0;i<n;++i) printNodeInfo(array, i, n);
}



Measured memory_bytes: 3100
#include <iostream>
using namespace std;
int le,ri;
string s;
int main(){
	cin>>s;
	for(int i=0;i<s.length()&&le==0;++i){
		if(s[i]=='A') le=i+1;
	}
	for(int i=s.length()-1;i>=0&&ri==0;--i){
		if(s[i]=='Z') ri=i+1;
	}
	if(le<ri) cout<<ri-le+1<<endl;
}

Measured memory_bytes: 832
#include<stdio.h>
#define MAX 2000000
#define INFTY 999999999
int H,A[MAX+1];

void maxHeapify(int );
int extract();
void increaseKey(int , int );
void insert(int );

int main()
{
  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[0]=='e' && com[1]=='n')break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else printf("%d\n",extract());
  }

 
  return 0;
}

void maxHeapify(int i)
{
  int l,r,largest,x;

  l=2*i;
  r=2*i+1;
  if(l<=H && A[l]>A[i])largest=l;
  else largest=i;
  if(r<=H && A[r]>A[largest])largest=r;

  if(largest!=i)
    {
      x=A[i];
      A[i]=A[largest];
      A[largest]=x;
      maxHeapify(largest);
    }
  
}

int extract(){
  int maxv;
  if(H<1)return -INFTY;
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key){
  int x;
  
  if(key<A[i])return;
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    x=A[i];
    A[i]=A[i/2];
    A[i/2]=x;
    i=i/2;
  }
}


void insert(int key){
  H++;
  A[H]=-INFTY;
  increaseKey(H,key);
}



Measured memory_bytes: 5692
ans ([0,0,0]:_) = []
ans ([n,m,p]:as) =
  let x = concat $ take n as
      r = drop n as
      a = if x!!(m-1) == 0
          then 0
          else (sum x) * (100-p) `div` (x!!(m-1))
  in
    a:(ans r)

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  mapM_ print o



Measured memory_bytes: 5408
#include<iostream>

using namespace std;

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

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

int main(){
  int n;
  cin >> n;
  int a;
  int ans = 0;
  for (int i = 0; i < n; i++){
    cin >> a;
    ans+= a - 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main(){
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];	
	int min=arr[0],ans=1;
	for(int i=1;i<n;i++){
		if(arr[i]<min)
		{
			ans++;
			min=arr[i];
		}
	}
	cout<<ans;
  	return 0;
}

Measured memory_bytes: 1024
M=10**9+7
n,m=gets.split.map &:to_i
x=gets.split.map(&:to_i).each.with_index.map{|x,i|i*x-(n-1-i)*x}.inject(:+)
y=gets.split.map(&:to_i).each.with_index.map{|y,i|i*y-(m-1-i)*y}.inject(:+)
p x*y%M

Measured memory_bytes: 17160