akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
       {
  scanf("%d %d", &a, &b);
  if(a == 0 && b == 0)
  break;
 
  for(i = 1; i <= a; i++)
    {
      for(j = 1; j <= b; j++)
    {
      if(i > 1 && i < a && j < b && j > 1)printf(".");
      else printf("#");
    }
      printf("\n");
    }
  printf("\n");
     
       }
  return 0;
}


Measured memory_bytes: 1980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
int a[5][5];

int main() {
	//Sum矩阵 = 3 * (a1 + a2 + a3) + 3 * (b1 + b2 + b3);
	//Sum对角线 = (a1 + a2 + a3) + (b1 + b2 + b3);
	//Sum矩阵 = 3 * Sum对角线
	int sum = 0;
	for(int i = 1; i <= 3; i++) {
		for(int j = 1; j <= 3; j++) {
			cin >> a[i][j];
			sum += a[i][j];
		}
	}
	int tt = a[1][1] + a[2][2] + a[3][3];
	if(sum % 3) puts("No");
	else {
		if(!tt) {
			bool flg = 1;
			for(int i = 1; i <= 3; i++) {
				for(int j = 1; j <= 3; j++) {
					if(a[i][j]) {
						flg = 0;
						break;
					}
				}
			}
			if(flg) puts("Yes");
			else puts("No");
		}
		else {
		if(sum % tt) puts("No");
		else {
			if(sum / tt != 3) puts("No");
			else puts("Yes");
		}
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer n = Integer.parseInt(scanner.next());
        Integer m = Integer.parseInt(scanner.next());
        Integer[] h =  new Integer[n];
        Integer[] a =  new Integer[m];
        Integer[] b =  new Integer[m];
        boolean[] total = new boolean[n];

        for(int i =0; i<total.length; i++) total[i] = true;

        for(int i =0; i <h.length; i++) {
            h[i] = Integer.parseInt(scanner.next());
        }

        for(int i = 0; i < m; i++) {
            a[i] =  Integer.parseInt(scanner.next());
            b[i] =  Integer.parseInt(scanner.next());
        }

        for(int i = 0; i < m; i++) {
            if(h[a[i]-1] > h[b[i]-1]) {
                total[b[i]-1] = false;
            } else if(h[b[i]-1] > h[a[i]-1]) {
                total[a[i]-1] = false;
            } else {
                total[b[i]-1] = false;
                total[a[i]-1] = false;
            }
        }
        int count = 0;

        for(int i =0; i < total.length; i++){
            if(total[i]) count++;
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 66020
/*  ex4_1
    potter0723sw  */

#include <stdio.h>
#include <math.h>

int main(void) {
	float num,d;//小数点以下も考えたいのでfloat型
	int answer;
	scanf("%f %f",&num ,&d);
	answer = ceil(num/(d * 2 + 1));
	//監視員が見れるのは自分がいる木と周囲d本だから2d+1本見れる。
	//監視範囲が被ってもいいことを考慮し小数以下切り上げ
	printf("%d\n", answer);
	return 0;
}


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

int main(){
  long long N,L;
  cin>>N>>L;
  int long long a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  int temp=-1;
  for(int i=0;i<N-1;i++){
    if(a[i]+a[i+1]>=L){
      temp=i;
    }
  }
  if(temp==-1){
    cout<<"Impossible"<<endl;
    return 0;
  }
  cout<<"Possible"<<endl;
  for(int i=0;i<temp;i++){
    cout<<i+1<<endl;
  }
  for(int i=N-2;i>temp;i--){
    cout<<i+1<<endl;
  }
  cout<<temp+1<<endl;
  return 0;
}



Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back 
#define mp make_pair
typedef long long ll;



int main(){
	int a,b; cin>>a>>b;
	
	for(int i=0;i<max(a,b);i++)
		cout<<min(a,b);
			
	
	return 0;
}


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

int main() {
  string s,t;
  cin >> s >> t;
  if ((s.at(0) == t.at(2)) && (s.at(1)==t.at(1)) && (s.at(2) == t.at(0))) {
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(N+M-1),B(N+M-1);
  vector<vector<int>> G(N);
  vector<int> in(N,0);
  rep(i,N+M-1){
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
    G[A[i]].push_back(B[i]);
    in[B[i]]++;
  }
  int p = -1;
  rep(i,N) if(!in[i]) p = i;
  queue<int> que;
  que.push(p);
  vector<int> dist(N,-1);
  dist[p] = 0;
  while(que.size()){
    int v = que.front();
    que.pop();
    for(int nv: G[v]){
      chmax(dist[nv],dist[v]+1);
      in[nv]--;
      if(in[nv] == 0) que.push(nv);
    }
  }
  vector<int> par(N);
  par[p] = -1;
  rep(i,N+M-1){
    if(dist[B[i]]-dist[A[i]] == 1){
      par[B[i]] = A[i];
    }
  }
  rep(i,N){
    cout << par[i]+1 << endl;
  }
  return 0;
}

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

using namespace std;

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

//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    map<string, int> mp;

    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }

    cout << "AC x " << mp["AC"] << '\n';
    cout << "WA x " << mp["WA"] << '\n';
    cout << "TLE x " << mp["TLE"] << '\n';
    cout << "RE x " << mp["RE"] << '\n';

    return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>
int main(){
  int x,y,z,k,s,ans=0;
  scanf("%d %d\n",&k,&s);
  for(x=0;x<=k;x++){
    for(y=0;y<=k;y++){
      z=s-x-y;
      if(z>=0 && z<=k){
        ans++;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String ans = s.replace('?','D');
		System.out.println(ans);
	 }
}


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

int main()
{
    string s;
    cin >> s;
    if ( s [0]== s [1]&& s [1]== s [2]) puts (" Yes ");
    else if ( s [1]== s [2]&& s [2]== s [3]) puts (" Yes ");
    else puts (" No ");
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
int A[100100], B[100100];
pii C[100100];

signed main() {
    cin >> N;
    rep(i, N) {
        cin >> A[i] >> B[i];
        C[i] = pii(A[i] + B[i], i);
    }
    sort(C, C + N);
    int taka = 0;
    int aoki = 0;
    int s = 1;
    for (int i = N - 1; i >= 0; --i) {
        if (s == 1) {
            taka += A[C[i].second];
        } else {
            aoki += B[C[i].second];
        }
        s *= -1;
    }
    cout << taka - aoki << endl;
    return 0;
}


Measured memory_bytes: 3328
x,y = map(int,input().split())
flags = False
for i in range(0,x+1):
    for j in range(0,x+1):
        #print("i:{},j:{}".format(i,j))
        if i + j == x and i*2 + j*4 == y:
            flags = True

if flags == True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9080
package main

import "fmt"

func main() {
    var n int
    fmt.Scan(&n)
    if (n % 2) == 1 {
        fmt.Printf("%f", ((float32(n) - 1.0) / 2.0 + 1.0) / float32(n))
    } else {
        fmt.Printf("%f", 1.0 / 2.0)
    }
}

Measured memory_bytes: 512
S = input()
s2 = ['+' for i in range(2*len(S)-1)]
for i in range(2*len(S)-1):
    if i%2 == 0:
        s2[i] = S[i//2]
ans = []
for i in range(2**(len(S)-1)):
    s3 = s2.copy()
    for j in range(len(S)-1):
        if (i >> j) & 1 == 1:
            s3[2*j+1] = '+'
        else:
            s3[2*j+1] = ''
    s3 = ''.join(s3)
    ans.append(s3)
suma = 0
for i in ans:
    suma += eval(i)
print(suma)

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

lis = list(map(int, input().split()))
target = sorted(lis, reverse=True)
diff = (target[0] - target[1]) + (target[0] - target[2])
if diff % 2 == 0:
    print(int(diff / 2))
else:
    target[0] += 1
    target[1] += 1
    diff = (target[0] - target[1]) + (target[0] - target[2])
    print(int(diff / 2) + 1)

Measured memory_bytes: 3064
import sys
import re
s = input()
x, y = [int(i) for i in sys.stdin.readline().split()]
s = [len(i) for i in re.split("T", s)]
v_ls = s[1::2]
h_ls = s[::2]
x -= h_ls[0]
h_ls.pop(0)
v_sum = sum(v_ls)
h_sum = sum(h_ls)
# memo_v_ls[i][j] : i番目まででj - v_sumができるか
width = max(abs(y), v_sum)
memo_v_ls = [[0 for i in range(width * 2 + 1)] for j in range(len(v_ls) + 1)]
memo_v_ls[0][width] = 1
for j, v in enumerate(v_ls, 1):
    for i in range(width * 2 + 1):
        if i >= v and i <= 2 * width - v:
            memo_v_ls[j][i] = max(memo_v_ls[j - 1][i - v], memo_v_ls[j - 1][i + v])
        elif i >= v:
            memo_v_ls[j][i] = memo_v_ls[j - 1][i - v]
        else:
            memo_v_ls[j][i] = memo_v_ls[j - 1][i + v]

flg = memo_v_ls[-1][y + width] == 1

width = max(abs(x), h_sum)
memo_h_ls = [[0 for i in range(width * 2 + 1)] for j in range(len(h_ls) + 1)]
memo_h_ls[0][width] = 1
for j, h in enumerate(h_ls, 1):
    for i in range(width * 2 + 1):
        if i >= h and i <= 2 * width - h:
            memo_h_ls[j][i] = max(memo_h_ls[j - 1][i - h], memo_h_ls[j - 1][i + h])
        elif i >= h:
            memo_h_ls[j][i] = memo_h_ls[j - 1][i - h]
        else:
            memo_h_ls[j][i] = memo_h_ls[j - 1][i + h]

flg &= memo_h_ls[-1][x + width] == 1
if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 379272
#include<cstdio>
#include<algorithm>
using namespace std;

int l, r;

int main() {
	scanf("%d%d", &l, &r);
	
	if(r-l>=2019) puts("0");
	else {
		int ans = 2018;
		for(int i=l;i<=r;i++)
			for(int j=i+1;j<=r;j++)
				ans = min(ans, int(1LL*i*j%2019));
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l=sc.nextInt();
		int r=sc.nextInt();

		if(r-l>=2019)
			System.out.print(0);
		else {
			System.out.print(full(r,l));
		}

	}
	
	public static int full(int r, int l) {
		int saishou = 2018;
		for(int i=l;i<r;i++) {
			for(int j=i+1;j<=r;j++) {
				if(((i%2019)*(j%2019))%2019 < saishou)
					saishou = ((i%2019)*(j%2019))%2019;
			}
		}
		return saishou;
	}

}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            String s = scanner.next();
            byte[] bytes = s.getBytes();
            if (bytes[0] == bytes[1] || bytes[1] == bytes[2] || bytes[2] == bytes[3]) {
                System.out.println("Bad");
            } else {
                System.out.println("Good");
            }
        }
    }

}


Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	int n, i, flag = 0, a;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a;
		if (a % 2 == 1)
			flag++;
	}
	if (flag > 0)
		cout << "first" << endl;
	else
		cout << "second" << endl;
}


Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main()
{
   int A1,A2,A3,b;
   cin>>A1>>A2>>A3;
   b=A1+A2+A3;
   if(b>=22)
   {
       cout<<"bust";
   }
   else
   {
       cout<<"win";
   }
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll n, m;
	cin >> n >> m;

	ll t = 1900 * m + 100 * (n - m);
	cout << pow(2, m) * t << endl;
}


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

int main()
{
    int n;
    cin >> n;
    vector<double> a(n);
    rep(i, n) cin >> a[i];
    double sum = 0;
    int len = a.size();
    while (len > 1)
    {
        sort(a.begin(), a.end());
        sum = (a[0] + a[1]) / 2;
        rep(i, 2)
        {
            a.erase(a.begin());
        }
        a.insert(a.begin(), sum);
        len--;
    }
    cout << a[0] << endl;

    return 0;
}


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

int main(){
    char s[3];
    
    for(int i=0;i<3;i++){
        cin>>s[i];
    }
    if(s[1]=='B'){
        cout<<"ARC\n";
    }else{
        cout<<"ABC\n";     
    }
    return 0;
}            

Measured memory_bytes: 3540
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int a[n+1];
    rep(i,n)cin>>a[i+1];
    vector<int> b(n+1);
    rep(i,n){
        int cur = n-i;
        for(int j = cur ; j <= n; j+=cur){
            a[cur]^=b[j];
        }
        b[cur]=a[cur];
    }
    vector<int> ans;
    rep(i,n+1)if(b[i])ans.push_back(i);
    cout<<ans.size()<<endl;
    for(auto i : ans)cout<<i<<" ";
    cout<<endl;
    return 0;
}

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

#include <cmath>
#include <map>
#include <cstdlib>

using namespace std;

int main(int argc, char *argv[]){

  string S;
  cin >> S;
  int len = S.length();

  string S1, S2;
  for(int i = 0; i < len; i++){
    if(i%2 == 0){
      S1 += "0";
      S2 += "1";
    }else{
      S1 += "1";
      S2 += "0";
    }
  }

  int diff1 = 0;
  int diff2 = 0;
  for(int i = 0; i < len; i++){
    if(S[i] != S1[i]) diff1++;
    if(S[i] != S2[i]) diff2++;
  }

  cout << (diff1<diff2?diff1:diff2) << endl;


  return 0;
}


Measured memory_bytes: 768
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx - sx, ty - sy
m1 = 'R' * dx + 'U' * dy
m2 = 'L' * dx + 'D' * dy
m3 = 'D' + 'R' * (dx + 1) + 'U' * (dy + 1) + 'L'
m4 = 'U' + 'L' * (dx + 1) + 'D' * (dy + 1) + 'R'
print(m1 + m2 + m3 + m4)


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <utility>

using namespace std;

struct Card{ char suit, value; };

//???????????????????????¢??° write ?????????

void write( struct Card A[], int N ){

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

        if( i > 0 ){

            printf(" ");
            
        }

        cout << A[i].suit << A[i].value;

    }

    printf("\n");

}

//bubble_sort ?????????

void bubble_sort( struct Card A[], int N ){

    int i, j;

    for( i = 0 ;  i < N ; i++ ){

        for( j = N-1 ; j > i ; j-- ){

            if( A[j].value < A[j-1].value ){

                swap( A[j], A[j-1] );

            }

        }

    }

}



//?????????????????? selection_sort ??????????????????

void selection_sort( struct Card A[], int N ){

    int i, j, minj;

    for( i = 0 ; i < N ; i++ ){

        minj = i;

        for( j = i ; j < N ; j++ ){
        
            if( A[j].value < A[minj].value ){

                minj = j;

            }

        }

        swap( A[i], A[minj] );

    }    

}



//??¬???

int main(){

    int i, n;
    bool test;

    test = true;

    scanf("%d", &n);
 
    Card C1[n], C2[n];
 
    for( i = 0 ; i < n ; i++ ){
 
        cin >> C1[i].suit >> C1[i].value;

        C2[i] = C1[i];

    }

    bubble_sort( C1, n);
    write( C1, n);
    printf("Stable\n");

    selection_sort( C2, n);
    write( C2, n);
    
    for( i = 0 ; i < n ; i++ ){

        if( C1[i].suit != C2[i].suit ){

            test = false;

        }

    }

    if(test == true){

        printf("Stable\n");

    } else {

        printf("Not stable\n");

    }

    return 0;

}

Measured memory_bytes: 3144
n = int(input())
arr = [int(input()) for i in range(n)]

m = 1 - 10**9
minv = arr[0]
for i in range(1,len(arr)):
    if arr[i] - minv > m:
        m = arr[i] - minv
    minv = min(minv, arr[i])
print(m)    

Measured memory_bytes: 15680
// luogu-judger-enable-o2
#include<iostream>
#include<cstring>
#include<cstdio>
#define ll long long
using namespace std;
const int maxn=2005;
const int mod=1e9+7;
int n,k;
ll dp[maxn][maxn],f[maxn];
ll kuai(ll a,int k)
{
	ll ans=1;
	while(k)
	{
		if(k&1)(ans*=a)%=mod;
		(a*=a)%=mod;k>>=1;
	}
	return ans%mod;
} 
int main()
{
//	freopen("forget.in","r",stdin);
//	freopen("forget.out","w",stdout);
	cin>>n>>k;
	dp[0][n+1]=1;ll ans=0;
	for(int i=1;i<=k;i++)
	{
		f[n+1]=dp[i-1][n+1];
		for(int j=n;j>=1;j--)f[j]=(f[j+1]+dp[i-1][j])%mod;
		for(int j=1;j<=n-i+1;j++)
			dp[i][j]=f[j];
	}
	dp[k][1]=(dp[k][1]-dp[k-1][1]+mod)%mod;
	if(n==k)ans=dp[k][1];
	else ans=dp[k][1]*kuai(2,n-k-1)%mod;
	cout<<ans<<endl;
}

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

void    DoHinge(int i, vector<bool> &HingeDone, vector<vector<int>> &Hinge1, vector<vector<int>> &Hinge2, vector<long> &S) {
        for (int j=0; j<Hinge1.at(i).size(); j++) {
                int ii=Hinge1.at(i).at(j);
                if (!HingeDone.at(ii)) {
                        S.at(ii)+=S.at(i);
                        HingeDone.at(ii)=true;
                        DoHinge(ii, HingeDone, Hinge1, Hinge2, S);
                }
        }
        for (int j=0; j<Hinge2.at(i).size(); j++) {
                int ii=Hinge2.at(i).at(j);
                if (!HingeDone.at(ii)) {
                        S.at(ii)+=S.at(i);
                        HingeDone.at(ii)=true;
                        DoHinge(ii, HingeDone, Hinge1, Hinge2, S);
                }
        }
}

int     main() {
        int N, Q;
        cin >>N >>Q;
        vector<vector<int>> Hinge1(N+1, vector<int> (0));
        vector<vector<int>> Hinge2(N+1, vector<int> (0));
        for (int i=0; i<N-1; i++) {
                int a, b;
                cin >>a >>b;
                Hinge1.at(a).push_back(b);
                Hinge2.at(b).push_back(a);
        }
        vector<long> S(N+1, 0);
        for (int i=0; i<Q; i++) {
                int p, x;
                cin >>p >>x;
                S.at(p) +=x;
        }
        vector<bool> HingeDone(N+1, false);
        HingeDone.at(1)=true;
        DoHinge(1, HingeDone, Hinge1, Hinge2, S);
        for (int i=1; i<=N; i++) {
                cout <<S.at(i)<<" ";
        }
        cout <<endl;
        return 0;
};

Measured memory_bytes: 44544
from itertools import combinations, count
 
n = int(input())
r = range(n)
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(input())):
    x, y = map(int, input().split())
    a[i][y].add(x - 1)
r = next(i for i in count(n, -1) for x in combinations(r, i)
         if all(a[j][0].isdisjoint(x) and a[j][1].issubset(x) for j in x))
print(r)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N,T;
    cin>>N>>T;
    vector<P> ct(N);
    rep(i,N){
        cin>>ct.at(i).first>>ct.at(i).second;
    }
    int ans=10000;
    rep(i,N){
        if(ct.at(i).second<=T){
            chmin(ans,ct.at(i).first);
        }
    }
    if(ans==10000){
        cout<<"TLE"<<endl;
        return 0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 * <br>ÛèCÌvO
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int max=0,sum=0,
			n,k;
		int[] list;
		while(true){
			n = scan.nextInt();		//¢
			k = scan.nextInt();
			if(n==0 && k==0){
				break;
			}
			
			list = new int[n];
			for(int i=0; i<n; i++){
				list[i] = scan.nextInt();
				if(k==i+1){			//ñÌZbg
					max = 0;
					sum = 0;
					for(int j=0; j<k; j++){
						sum += list[j];
					}
				}else if(k<=i){
					sum += list[i];
					sum -= list[i-k];
				}
				
				if(max<sum){
					max = sum;
				}
			}
			
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 13000
n = int(input())
a_list = list(map(int, input().split()))

n_divided = 0

def list_contains_odd(list):
    r = False
    for idx in range(len(list)):
            if list[idx] % 2 != 0:
                r = True
    return r

# 1回も割れない場合
if list_contains_odd(a_list):
    print("0")
else: # 最低1回は割れる場合
    while 1:
        a_list = [x/2 for x in a_list]
        n_divided += 1
        if list_contains_odd(a_list):
            print(n_divided)
            exit()

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

int main()
{
	int n ;
	map<string, int> cnt ;

	cin >> n ;
	for(int i = 0 ; i < n ; ++i)
	{
		string s ;
		cin >> s ;
		cnt[s]++ ;
	}

	int mx_cnt = 0 ;
	for(const auto &p : cnt)
		mx_cnt = max(mx_cnt, p.second) ;

	vector<string> ans ;
	for(const auto &p : cnt)
	{
		if(p.second == mx_cnt)
			ans.push_back(p.first) ;
	}

	sort(ans.begin(), ans.end()) ;
	for(const string &s : ans)
		cout << s << '\n' ;

	return 0 ;
}


Measured memory_bytes: 27248
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	d := nextInt()

	c := make([]int, 26)
	for i := 0; i < 26; i++ {
		c[i] = nextInt()
	}

	s := make([][]int, d)
	for i := 0; i < d; i++ {
		s[i] = make([]int, 26)
		for j := 0; j < 26; j++ {
			s[i][j] = nextInt()
		}
	}

	var t []int
	for i := 0; i < d; i++ {
		t = append(t, 1)
		var max int
		for j := 1; j <= 26; j++ {
			tmp := t[i]
			t[i] = j
			suti := cal(s, c, t)
			if suti > max {
				max = suti
			} else {
				t[i] = tmp
			}
		}
	}

	for _, v := range t {
		fmt.Println(v)
	}

}

func cal(s [][]int, c []int, t []int) int {
	tmp := make([]int, 26)
	d := len(t)
	var satis int
	for i := 0; i < d; i++ {
		tk := t[i] - 1
		satis += s[i][tk]

		var nega int
		for k, _ := range tmp {
			if k == tk {
				tmp[k] = 0
			} else {
				tmp[k]++
				nega += tmp[k] * c[k]
			}
		}
		satis -= nega
	}
	return satis
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 1964
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    rep(i, 0, 1001) {
        int rest = X - 100 * i;
        if (rest < 0) {
            continue;
        } else if (rest <= 5 * i) {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
s1 = gets.chomp!
s2 = gets.chomp!
mod = 10 ** 9 + 7

pattern = {"nil,tate" => 3, "nil,yoko" => 6, "tate,tate" => 2,
            "tate,yoko" => 2, "yoko,tate" => 1, "yoko,yoko" => 3}
pre = "nil"

i = 0
ans = 1
while i < n do
    if s1[i] == s2[i]
        i += 1
        ans = ans * pattern[pre + ",tate"] % mod
        pre = "tate"
    else
        i += 2
        ans = ans * pattern[pre + ",yoko"] % mod
        pre = "yoko"
    end
end

puts ans

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define vvi vector<vi>
#define Q queue<ll>
#define DQ deque<ll> 
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back
#define mp make_pair
#define mt make_tuple
#define f first
#define s second
#define ub upper_bound
#define lb lower_bound
#define loop(x,y,z) for(ll i=x; i<=y; i+=z)
#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)
#define all(x) x.begin(), x.end()
#define sum(x) accumulate(all(x),0LL)
#define minE(x) *min_element(all(x))
#define maxE(x) *max_element(all(x))
#define watch(x) cout<<(#x)<<" is "<<x
#define endl "\n"

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

void display(vi &v,string c){
	for(auto x:v) cout<<x<<c;
}

int main(){
	IOS
	ll t;
	cin>>t;
	vi v(t),dp(t);
	loop(0,t-1,1) cin>>v[i];
	dp[0]=0;
	dp[1]=abs(v[1]-v[0]);
	loop(2,t-1,1){
		dp[i]=min((dp[i-1]+abs(v[i]-v[i-1])),(dp[i-2]+abs(v[i]-v[i-2])));
	}
	cout<<dp[t-1];
	return 0;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

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

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

    ll m = 0;
    ll a = 0;
    ll r = 0;
    ll c = 0;
    ll h = 0;

    rep(i, n) {
        string s;
        cin >> s;
        if (s[0] == 'M') m++;
        else if (s[0] == 'A') a++;
        else if (s[0] == 'R') r++;
        else if (s[0] == 'C') c++;
        else if (s[0] == 'H') h++;
    }

    ll p = 0;

    p += m * a*r;
    p += m * a*c;
    p += m * a*h;
    p += m * r*c;
    p += m * r*h;
    p += m * c*h;
    p += a * r*c;
    p += a * r*h;
    p += a * c*h;
    p += r * c * h;

    cout << p << endl;


    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

		if(a%2==0) {
			System.out.println(a);
		}
		else {
			System.out.println(a*2);
		}
	}
}

Measured memory_bytes: 23764
n = list(map(int, input()))+[0]
ans = 0
for i in range(len(n)):
    if n[i] < 5 or (n[i]==5 and n[i+1]<5):
        ans += n[i]
    else:
        ans += 10 - n[i]
        n[i+1] += 1
print(ans)


Measured memory_bytes: 20336
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

bool s[105][105];

int main(){
	const int N=100;
	int p,q;
	int i,j,k;
	int a,b,c;
	cin>>p>>q;
	p--,q--;
	for(i=0;i<N/2;i++){
		for(j=0;j<N;j++)s[i][j]=true;
	}
	for(i=0;i<p;i++){
		a=(i/(N/4))*2,b=(i%(N/4))*2;
		s[a][b]=false;
	}
	for(i=0;i<q;i++){
		a=(i/(N/4))*2+N/2+1,b=(i%(N/4))*2;
		s[a][b]=true;
	}
	cout<<N<<" "<<N<<endl;
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			if(s[i][j])cout<<'#';
			else cout<<'.';
		}
		cout<<endl;
	}
	
		
}


Measured memory_bytes: 256
while 1:
    n = int(input())
    if n == 0:
        break

    ports = []
    for _ in range(n):
        tmp = list(input())
        port = tmp[0]
        for i in range(len(tmp)):
            if i != len(tmp) - 1 and tmp[i] in list("aiueo"):
                port += tmp[i+1]
        ports.append(port)

    for i in range(1, 51):
        ext = []
        for p in ports:
            tmp = p[:i]
            if tmp in ext:
                break
            else:
                ext.append(tmp)
        else:
            print(i)
            break
    else:
        print(-1)



Measured memory_bytes: 5616
/* BABA JAGAAAAAA  */  

#include<bits/stdc++.h>
#define pb push_back
#define un unordered_map
#define us unordered_set
#define ll long long
#define PI 3.1415926535897932384626
#define fast ios:: sync_with_stdio(false);cin.tie(NULL)
#define l long 
using namespace std;
const int  mod= 1e9+7;
const int inf=1e9+3;
 int main()
 {
     fast;  
    ll a, b, c,d;
     cin>>a>>b>>c>>d;
     cout<<max({(a*c), (a*d), (b*c), (b*d)});
    
     
 }
  

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

int main() {
	string s,t;
	cin>>s>>t;
	int flag=1;
	for(int i=0;i<s.size();i++) {
        if (s[i] != t[i]){
            flag = 0;
            break;
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
int main(){
  char alp[26],retu[1200];
  int i,count[26]={0};
  int size,n;

  while(scanf("%s",retu) == 1){
    size = strlen(retu);
    for(i=0;i<size;i++){
      if(retu[i] <='z' && retu[i] >='a'){
        n = retu[i] - 'a';
        count[n]++;
      }
      else if('A' <= retu[i] && retu[i] <= 'Z'){
        n = retu[i] - 'A';
        count[n]++;
      }
      else continue;
    }
  }
  for(i=0;i<26;i++){
    printf("%c : %d\n",'a'+i,count[i]);
  }
  return 0;
}



Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;
 
int main(){
  int n;cin>>n;
  ll x[n],y[n];
  rep(i,n)cin>>x[i]>>y[i];
  vector<tuple<long double,ll,ll>> v(n);
  rep(i,n){
    v[i]=make_tuple(atan2(y[i],x[i]),x[i],y[i]);
  }
  sort(all(v));
  vector<ll> sx(2*n),sy(2*n);
  rep(i,n){
    sx[i]=get<1>(v[i]);sy[i]=get<2>(v[i]);
    sx[n+i]=get<1>(v[i]);sy[n+i]=get<2>(v[i]);
  }
  long double ans=0;
  rep(i,n){
    long double vx=0;long double vy=0;
    rep(j,n){
      vx+=sx[i+j];vy+=sy[i+j];
      chmax(ans,sqrtl(vx*vx+vy*vy));
    }
  }
  cout<<setprecision(25)<<ans<<endl;
}
      
  


Measured memory_bytes: 384
// AOJ - Lesson ALDS1
// ALDS1_1_C - Prime Numbers
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/1/ALDS1_1_C

// 問題：
// n個の整数を読み込み、それらに含まれる素数の数を出力するプログラムを作成してください
// 制約：
// 1 <= n <= 10000
// 2 <= 与えられる整数 <= 10^8

// 方針：
// 整数1つ毎に素数かどうか判定する。ある数mが素数かどうか判定するには√mまでの数で割り切れるかどうか試せばよいので、高速に判定可能
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
/*
// エラトステネスの篩 - 計算量はO(NloglogN)なので、10^8だと間に合わないかも
var nprimes [int(1e8) + 1]bool

func initPrimes() {
	nprimes[0] = true
	nprimes[1] = true
	for i := 2; i*i <= int(1e8); i++ {
		for j := i * 2; j <= int(1e8); j += i {
			if !nprimes[j] {
				nprimes[j] = true
			}
		}
	}
}
*/
func isPrime(n int) bool {
	if n <= 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	// initPrimes()
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	ans := 0

	for i := 0; i < n; i++ {
		v := nextInt(sc)
     // if !nprimes[v] {
		if isPrime(v) {
			ans++
		}
	}
	fmt.Println(ans)
}
func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}



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

int main(){
	int k,s,x,y,z,cont=0;
	cin>>k>>s;
	for(x=0;x<=k;x++){
		for(y=0;y<=k;y++){
			z=s-x-y;
			if(x+y+z==s&&z<=k&&z>=0){
				cont++;
			} 
		}
	}
	cout<<cont;
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
class program{
  static void Main(){
    int n = int.Parse(Console.ReadLine());
    long[] a = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long ans = 1;
    Array.Sort(a);
    if(a[0] == 0){
      Console.Write(0);
      return;
    }
    for(int i = 0;i<n;i++){
      if(ans > 1000000000000000000/a[i]){
        Console.Write(-1);
      	return;
      }
      ans *= a[i];
    }
    Console.Write(ans);
  }
}

Measured memory_bytes: 40560
#include<bits/stdc++.h>
#define ll long long int
#define l(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int a[n];
	l(i,0,n){
		cin>>a[i];
	}
	sort(a,a+n);
	int sum=0;
	l(i,0,k){
		sum+=a[i];
	}
  cout<<sum<<"\n";
}

Measured memory_bytes: 3592
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
x = I()
ans = 2*(x//11)+1
x %= 11
if x == 0:
    ans -= 1
if x > 6:
    ans += 1
print(ans)
"""

#D
n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
l = list(d.keys())
k = 0
for i in l:
    k ^= ~(d[i]%2)
    d[i] = 1
ans = sum(list(d.values()))
ans -= 1 if k%2 else 0
print(ans)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


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

using ll = long long;
using ld = long double;

const int N = 2e5 + 69;

int n;
int ar[N];

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

  cin >> n;
  for(int i = 1; i <= n; i++)
    cin >> ar[i];
  for(int i = n; i >= 1; i -= 2)
    cout << ar[i] << ' ';
  int cur = 1 + (n & 1);
  for(int i = cur; i <= n; i += 2)
    cout << ar[i] << ' ';
  
  return 0;
}

Measured memory_bytes: 4436
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		List<Integer> value = new ArrayList<>();
		int num = scn.nextInt();
		int min = 1000000;int max = -1000000;long sum = 0;
		for (int i = 0; i < num; i++) {
			value.add(scn.nextInt());
			if (value.get(i) > max) {
				max = value.get(i);
			}
			if (value.get(i) < min) {
				min = value.get(i);
			}
			sum += value.get(i);
		}
		System.out.println(min + " " + max + " "+sum);
	}
}



Measured memory_bytes: 41244
#include <stdio.h>

int main(void)
{
	int n = 0, n2 = 0;
	double odd = 0;
	scanf("%d", &n);
	n2 = n;
	while (n >= 0) {
		if (n % 2 != 0) {
			odd++;
		}
		n--;
	}
	printf("%lf", odd / n2);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    vector<ll>index(100100);
    int dp[100100][13];
    index[0]=1;
    REP(i,100100-1){
        index[i+1] = index[i]*10%13;
    }
    REP(i,100100){
        REP(j,13){
            dp[i][j]=0;
        }
    }
    reverse(ALL(s));
    if(s[0]=='?'){
        REP(i,10){
            dp[0][i]=1;
        }
    }
    else{
        dp[0][(int)(s[0]-'0')]=1;
    }

    FOR(i,1,s.length()){
        ll now_dig=index[i];
        if(s[i]=='?'){
            REP(j,10){
                REP(k,13){
                    if(dp[i-1][k]==0)continue;
                    ll n = (now_dig*(j)+k)%13;
                    dp[i][n]=(dp[i][n]+dp[i-1][k])%MOD;
                }
            }

        }else{
            REP(j,13){
                if(dp[i-1][j]==0)continue;
                ll n = (now_dig*((int)(s[i]-'0'))+j)%13;
                dp[i][n]=(dp[i][n]+dp[i-1][j])%MOD;
            }
        }
    }

    cout << dp[s.length()-1][5] << endl;
    return 0;
}

Measured memory_bytes: 9308
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	public static String S;
	boolean flg = false;

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int max = Math.max(A + B, A - B);
		max = Math.max(max, A * B);
		System.out.print(max);
	}

	public static int[] judgeEven(int Num) {
		int ret[] = new int[2];
		ret[0] = Num / 2;
		ret[1] = ret[0];
		int amari = Num % 2;
		if (amari != 0) {
			ret[1]++;
		}
		return ret;

	}

	public static List<String[]> getRunLength(String str) {
		List<String[]> list = new ArrayList<String[]>();
		char back = 'm';
		for (int i = 0; i < str.length(); i++) {
			if (back != str.charAt(i)) {
				String[] hairetu = new String[2];
				hairetu[0] = String.valueOf(str.charAt(i));
				hairetu[1] = "1";
				list.add(hairetu);
				back = str.charAt(i);
			} else {
				String[] hairetu = list.get(list.size() - 1);
				hairetu[1] = String.valueOf(Integer.parseInt(hairetu[1]) + 1);
				list.set(list.size() - 1, hairetu);
			}
		}
		return list;
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
using namespace std;

int H,W;
char maze[55][55];
int dist[55][55];
signed main(){
    cin>>H>>W;
    int black=0;
    rep(i,H){
        rep(j,W){
            cin>>maze[i][j];
            if(maze[i][j]=='#')black++;
            dist[i][j]=INF;
        }
    }
    dist[0][0]=0;
    queue<P> que;
    que.push(P(0,0));
    while(que.size()){
        P p=que.front(); que.pop();
        int x=p.F,y=p.S;
        rep(i,4){
            int nx=x+dx[i],ny=y+dy[i];
            if(nx>=0 and nx<H and ny>=0 and ny<W and dist[nx][ny]==INF and maze[nx][ny]!='#'){
                dist[nx][ny]=dist[x][y]+1;
                que.push(P(nx,ny));
            }
        }
    }
    if(dist[H-1][W-1]==INF){
        cout<<-1<<endl;
        return 0;
    }
    cout<<H*W-(dist[H-1][W-1]+1)-black<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)

ll M = 1e9 + 7;
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll max3(ll a,ll b,ll c){ return max( max(a,b),c ); }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}


int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	ll a,b,n;
	cin>>a>>b>>n;
	if(a%b!=0)
	{
	    if( n < b )
	    {
	        cout<<((a*n)/b);
	        return 0;
	    }
	    cout<<((a*(b-1))/b);
	    return 0;
	}
	ll k = a/b;
	if( n < b )
	{
	    cout<<k*n;
	    return 0;
	}
	cout<<k*(b-1);
	
	
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
struct wtf {
  int u, v, w;
  char choice;
};
string op[100007];
int dp[100007][8][8][8];
wtf bt[100007][8][8][8];
int main() {
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  for (int i = 1; i <= n; i++)
    cin >> op[i];
  for (int i = 0; i <= min(7, a); i++) {
    for (int j = 0; j <= min(7, b); j++) {
      for (int k = 0; k <= min(7, c); k++) {
        dp[0][i][j][k] = 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 7; j++) {
      for (int k = 0; k <= 7; k++) {
        for (int l = 0; l <= 7; l++) {
          if (!dp[i - 1][j][k][l])
            continue;
          if (op[i] == "AB") {
            if (j - 1 >= 0)
              dp[i][j - 1][min(7, k + 1)][l] = 1,
                                      bt[i][j - 1][min(7, k + 1)][l] = {j, k, l,
                                                                        'B'};
            if (k - 1 >= 0)
              dp[i][min(7, j + 1)][k - 1][l] = 1,
                                       bt[i][min(7, j + 1)][k - 1][l] = {
                                           j, k, l, 'A'};
          } else if (op[i] == "AC") {
            if (j - 1 >= 0)
              dp[i][j - 1][k][min(7, l + 1)] = 1,
                                         bt[i][j - 1][k][min(7, l + 1)] = {
                                             j, k, l, 'C'};
            if (l - 1 >= 0)
              dp[i][min(7, j + 1)][k][l - 1] = 1,
                                          bt[i][min(7, j + 1)][k][l - 1] = {
                                              j, k, l, 'A'};
          } else if (op[i] == "BC") {
            if (k - 1 >= 0)
              dp[i][j][k - 1][min(7, l + 1)] = 1,
                                         bt[i][j][k - 1][min(7, l + 1)] = {
                                             j, k, l, 'C'};
            if (l - 1 >= 0)
              dp[i][j][min(7, k + 1)][l - 1] = 1,
                                          bt[i][j][min(7, k + 1)][l - 1] = {
                                              j, k, l, 'B'};
          }
        }
      }
    }
  }
  deque<char> seq;
  for (int i = 0; i <= 7; i++) {
    for (int j = 0; j <= 7; j++) {
      for (int k = 0; k <= 7; k++) {
        if (dp[n][i][j][k]) {
          int x = i, y = j, z = k;
          for (int l = n; l > 0; l--) {
            // cout << i << ' ' << j << ' ' << k << endl;
            // cout << bt[n][i][j][k].choice << endl;
            seq.push_front(bt[l][x][y][z].choice);
            int nx = bt[l][x][y][z].u;
            int ny = bt[l][x][y][z].v;
            int nz = bt[l][x][y][z].w;
            x = nx;
            y = ny;
            z = nz;
          }
          if (seq.size() != n) {
            seq.clear();
            continue;
          }
          cout << "Yes" << endl;
          for (char c : seq)
            cout << c << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 1006848
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    K, X = map(int, readline().split())
    res = [x for x in range(X - K + 1, X + K)]
    print(*res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62288