akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            long N = Convert.ToInt64(input);
            long SN = 0;
            foreach (char c in input)
            {
                SN += (long)char.GetNumericValue(c);
            }
            if (N % SN == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 14292
//@author yash2040
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
//#define int long long
#define pb push_back
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	fast();
	int r;
	cin>>r;
	double ar=2*acos(-1.0)*r;
	cout<<ar<<endl;	
}




Measured memory_bytes: 3776
package main

import (
	. "fmt"
)

func Min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func main() {
	var n int
	Scan(&n)
	dp := make([]int, n + 1)
	for i := 0; i < n; i++ {
		dp[i + 1] = 1000000000
	}

	for i := 0; i < n; i++ {
		for j := 1; i + j <= n; j *= 6 {
			dp[i + j] = Min(dp[i + j], dp[i] + 1)
		}

		for j := 1; i + j <= n; j *= 9 {
			dp[i + j] = Min(dp[i + j], dp[i] + 1)
		}
	}

	Println(dp[n])
}

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

int main(){
    string S;
    cin >> S;
    int minval = 1000;
    for(int i=0; i<(S.size()-2); i++){
        int x = 100 * (S[i] -'0') + 10 * (S[i+1] - '0') + (S[i+2] - '0');
        minval = min(minval, abs(x - 753));
    }
    cout << minval << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {

        static void Main(string[] args)
        {
          //入力を受け取る
          var N = long.Parse(Console.ReadLine());
          var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
          var youso = A.Max();
          var ans = new long[youso+2];
          
          for(long i = 0; i < N ; i++){
            var num = A[i];
            ans[num]++;
          }
          
          var B = new long[youso+1];
          for(long i = 0; i < B.Length ; i++){
            B[i] = 0;
          }
          var max = 0L;
          for(long i = 1; i <= youso;i++){
            B[i] = ans[i-1]+ans[i]+ans[i+1];
            if(B[i] > max){
              max = B[i];
            }
          }
          if(max < ans[0]){
            max = ans[0];
          }
          Console.WriteLine(max);
        }
  
}


Measured memory_bytes: 20960
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <utility>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
using ll = long long;
constexpr int MOD = 1e9 + 7;

long long fac[4040], inv[4040], finv[4040];
void CombInit(){
    fac[0] = inv[0] = finv[0] = 1;
    fac[1] = inv[1] = finv[1] = 1;
    for(int i=2; i<4040; ++i){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

long long Comb(int n,int k){
    if(n < 0 || k < 0 || n < k) return 0;
    return (fac[n] * finv[n-k] % MOD) * finv[k] % MOD;
}


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,K;cin>>N>>K;

    CombInit();
    for(int i=1; i <= K ;++i){
        cout << (Comb(N-K+1,i) * Comb(K-1, i-1))%MOD << '\n';
    }

    return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <cstdio>
#include <utility>
#include <bitset>
#include <complex>
#include <stack>
#include <tuple>

using namespace std;
typedef long long ll;
typedef tuple<ll,ll,ll> T;


int main(){
	ll ans=0;
	ll K,S;
	cin >> K >> S;
	for(ll X=0;X<=K;X++){
		for(ll Y=0;Y<=K;Y++){
			ll Z=S-X-Y;
			if(0<=Z && Z<=K)
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
answer = 0
penalty = 0
ans = [0] * n
pen = [0] * n
 
for x in range(m):
  p, s = input().split()
  pi = int(p) - 1
  if ans[pi] == 1:
    continue
 
  if s == 'AC':
    answer += 1
    ans[pi] = 1
    penalty += pen[pi]
  elif s == 'WA':
    pen[pi] += 1
 
print(f'{answer} {penalty}')

Measured memory_bytes: 10360
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>

int f(int n)
{
    if(n%2==0) return n/2;
    else return 3*n+1;
}

int main()
{
    // std::cout << std::fixed << std::setprecision(5);
    int s; std::cin >> s;
    std::vector<int> a;
    a.push_back(s);
    
    for (int i = 0;;i++)
    {
        int temp = f(a[i]);
        a.push_back(temp);
        for(int j = 0; j<a.size() - 1; j++)
        {
            if(a[j]==temp)
            {
                std::cout << i+2 << std::endl;
                return 0;
            }
        }
    }    
    return 0;
}

Measured memory_bytes: 256
# encoding: utf-8

def runStep(candidates,n,p):
    mayor = 0
    decidedFlg = False
    if p > n:
        for i in range(0,n):
            candidates[i] += 1
        p -= n
    else:
        for i in range(0,n):
            if p == 0:
                result,mayor = checkEmpty(candidates,n)
                if result:
                    result = mayor
                    decidedFlg = True
                    break
                else:
                    p = candidates[i]
                    candidates[i] = 0
            else:
                candidates[i] += 1
                p -= 1
    return candidates,p,mayor,decidedFlg

def checkEmpty(candidates,n):
    result = True
    count = 0
    mayor = 0
    for i in range(0,n):
        if candidates[i] != 0:
            count += 1
            mayor = i
            if count > 1:
                result = False
                break
    return result,mayor

while True:
    data = input().split()
    n, p = int(data[0]),int(data[1])
    if n == 0 and p == 0: break
    candidates = [0] * n
    while True:
        candidates,p,mayor,decidedFlg = runStep(candidates,n,p)
        if decidedFlg:
            print(mayor)
            break

    


Measured memory_bytes: 5604
p = 1000000007
n = int(input())
A = list(map(int, input().split()))

ans = 1
cnt = [3 if i == 0 else 0 for i in range(n+1)]

for a in A:
    ans *= cnt[a]
    ans %= p
    if ans == 0:
        break
    cnt[a] -= 1
    cnt[a+1] += 1
print(ans)

Measured memory_bytes: 13964
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

n = 0
0.upto(a) do |aa|
    0.upto(b) do |bb|
        0.upto(c) do |cc|
            if (500 * aa + 100 * bb + 50 * cc) == x
                n += 1 
            end
        end
    end
end

print(n)

Measured memory_bytes: 3836
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#define SENTINEL INT_MAX

int A[500000],c=0;
int L[300000], R[300000];

void Merge(int left, int mid, int right){
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;


	for (i = 0; i < n1;i++){
		L[i] = A[left + i];
	}
	for (i = 0; i < n2;i++){
		R[i] = A[mid + i];
	}
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;
	i = 0;
	j = 0;
	for (k = left; k < right;k++){
		c++;
		if (L[i] <= R[j]){
			A[k] = L[i];
			i = i + 1;
		}else{
			A[k] = R[j];
			j = j + 1;
		}
	}
}

void Merge_Sort(int left, int right){
	int mid;
	if (left + 1 < right){
		mid = (left + right) / 2;
		Merge_Sort(left, mid);
		Merge_Sort(mid, right);
		Merge(left, mid, right);
	}
}

int main(){
	int i, j, k;
	scanf("%d",&i);
	for (j = 0; j < i;j++){
		scanf("%d",&A[j]);
	}

	Merge_Sort(0,j);

	
	for (i = 0; i < j; i++){
		printf("%d", A[i]);
		if (i < j - 1){
			printf(" ");
		}
	}
printf("\n%d\n",c);
return 0;
}

Measured memory_bytes: 4708
#林檎が A 個、林檎の欠片が P 個あります。林檎 1 個は、砕くことで林檎の欠片 3 個になります。
#また、林檎の欠片 2 個を鍋で煮込むことで、アップルパイが 1 個作れます。
#今ある材料で作れるアップルパイの最大数を求めてください。
A, P = map(int, input().split())
print((A*3+P)//2) #//で切り捨て、/は商

Measured memory_bytes: 38384
import java.util.*;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext())
	    for(int cs = sc.nextInt(); cs > 0; cs--){
		int n = sc.nextInt(), s = sc.nextInt(), t;
		Vector<Integer> v1, v2;
		v1 = new Vector<Integer>();
		v2 = new Vector<Integer>();
		v1.add(new Integer(0));
		v2.add(new Integer(0));

		for(int i = 1; i < n; i++){
		    t = sc.nextInt();
		    if(s < t) v1.add(new Integer(t-s));
		    if(s > t) v2.add(new Integer(s-t));
		    s = t;
		}
		Collections.sort(v1);
		Collections.sort(v2);

		System.out.println(Integer.toString(v1.get(v1.size()-1))+" "+Integer.toString(v2.get(v2.size()-1)));
	    }
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 12000
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "ctime"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> H >> W;
	vector<int>h(H);
	vector<int>w(W);
	for (auto &i : h)cin >> i;
	for (auto &i : w)cin >> i;
	vector<int>vh(H*W + 1);
	vector<int>vw(H*W + 1);
	for (auto i : h)vh[i]++;
	for (auto i : w)vw[i]++;
	for (auto i : vh) {
		if (i > 1) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (auto i : vw){
		if (i > 1) {
			cout << 0 << endl;
			return 0;
		}
	}
	long long int hh = 0, ww = 0;
	long long int used = 0;
	long long int ans = 1;
	for (int i = H * W; i >= 1; i--) {
		hh += vh[i];
		ww += vw[i];
		if (vh[i] && vw[i]) {
			used++;
	//		cout << ans << endl;
			continue;
		}
		else if (vh[i]) {
			ans *= ww;
		}
		else if (vw[i]) {
			ans *= hh;
		}
		else {
			ans *= ww * hh - used;
		}
	//	cout << ans << endl;
		ans %= MOD;
		used++;
	}
	cout << ans << endl;
	return 0;
}

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

int main(void) {
    int n,m;
    cin >> n >> m;

    vector<pair<long, long>> ba(m);
    for(auto &x: ba)
        cin >> x.second >> x.first;

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

    long last = -1, res = 0;
    for(auto &x: ba) {
        if(last < x.second) {
            res++;
            last = x.first-1;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 1792
// Minimun Spanning Tree
#include <stdio.h>

#define INF 999999999
#define NIL -1
#define MAX 100

// 以下の3色でvの訪問状態を示す
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;           // Gの頂点の数
int color[MAX];  // 訪問状態を記録する
int G[MAX][MAX]; // 隣接行列
int d[MAX];      // 重みが最小の辺の重みを記録する
int p[MAX];      // MSTにおける頂点vの親を記録する

// プリムのアルゴリズムを実施 //
void prim(){
  int i, u, mincost, sum=0;
  
  // 初期化 //
  for(i=0; i < n; i++){
    d[i] = INF;
    p[i] = NIL;
    color[i] = WHITE;
  }
  d[0] = 0;
  //p[0] = NIL;
  color[0] = GRAY;
  while(1){
    mincost = INF;
    // 候補を探し、確定していく //
    for(i=0; i < n; i++){
      // MSTのルートとしてMSTの集合として追加するための重みが最小である頂点iを探す //
      if(color[i] != BLACK && d[i] < mincost){
        mincost = d[i];
        u = i;
      }
    }
    if(mincost == INF) break; // colorがすべてBLACKのとき(すべて確定したとき)

    color[u] = BLACK; // 親を確定する(候補を確定していく)

    for(i=0; i < n; i++){
      // 重みが最小のものに更新する //
      if(color[i] != BLACK && G[u][i] != NIL){
        if(d[i] > G[u][i]){  // ここ注意!!
          d[i] = G[u][i];
          p[i] = u;
          color[i] = GRAY;
        }
      }
    }
  }
  for(i=0; i < n; i++){
    sum += d[i];
  }
  printf("%d\n", sum);
}

int main(){
  int i, j;

  scanf("%d", &n);

  for(i=0; i < n; i++){
    for(j=0; j < n; j++){
      scanf("%d", &G[i][j]);
    }
  }
  
  prim();
  
  return 0;
}


Measured memory_bytes: 2112
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <string.h>

int main(int argc, char** argv)
{
	std::string w;
	std::getline(std::cin, w);

	std::string tmp;
	std::vector<std::string> t;
	while (std::getline(std::cin, tmp))
	{
		if ("END_OF_TEXT" == tmp)
		{
			break;
		}

		for (size_t i = 0; i < tmp.size(); ++i)
		{
			if (tmp[i] >= 'A' && tmp[i] <= 'Z')
			{
				tmp[i] += 'a' - 'A';
			}
		}

		std::istringstream stream(tmp);

		std::string field;
		std::vector<std::string> split;
		while (std::getline(stream, field, ' '))
		{
			t.push_back(field);
		}
	}

	int count = 0;
	for (std::string s : t)
	{
		if (s == w)
		{
			++count;
		}
	}

	std::cout << count << std::endl;

	return 0;
}


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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							 \
			cout.tie(0);
#define PI 3.141592654

using namespace std;

using ll = long long;
const int MOD = 1e9 + 7;
const ll INF = 1e18 + 9;

ll powmod(ll base, ll exp, const ll MOD) { ll ans = 1; while (exp) { if (exp & 1)	ans = (ans * base) % MOD; base = (base * base) % MOD; exp >>= 1; } return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
void add(ll& x, ll v) { x = (x + v) % MOD; if (x < 0) x += MOD; }
//ll f[500005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }

void test_case() {

}

const int mxN = 1e5 + 1;


int main() {
	fastio;
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		ll j = n / i;
		ans += i * (j * (j + 1) / 2);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <tuple>

using namespace std;

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

    bool beautiful = true;
    for(char s='a'; s<'z'; ++s){
        int count = 0;
        for(int i=0; i<w.length(); ++i){
            if(s == w[i]){
                count++;
            }
        }
        if(count % 2 != 0){
            beautiful = false;
            break;
        }
    }
    
    if(beautiful) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
n,k = map(int, input().split())
h = []
count = 0

for i in map(int, input().split()):
  h.append(i)

hr = sorted(h, reverse=True)

for l in range(n):
  if l >= k:
    count += hr[l]
print(count)
    

Measured memory_bytes: 25872
#include<bits/stdc++.h>
using namespace std;
int ab[50000],ac[50000],bc[50000];
bool check(char  i,char j){
	if(i=='?'||j=='?'||i==j) return 1;
	return 0;
}
int main(){
	 string a,b,c;
	 cin>>a>>b>>c;
	 int la=a.size(),lb=b.size(),lc=c.size();
	 for(int i=0;i<la;i++){
	 	for(int j=0;j<lb;j++){
		 if(!check(a[i],b[j]))ab[i-j+10000]=1;
	  }
	  for(int j=0;j<lc;j++){
	  	if(!check(a[i],c[j])) ac[i-j+10000]=1;
	  }
	}
	for(int i=0;i<lb;i++){
		for(int j=0;j<lc;j++){
			if(!check(b[i],c[j])) bc[i-j+10000]=1;
		}
	}
	int ans=1e9;
	for(int i=-4000;i<=4000;i++){
		for(int j=-4000;j<=4000;j++){
			if(!ab[10000+i]&&!ac[10000+j]&&!bc[j-i+10000]){
			int l=min(0,min(i,j));
			int r=max(la,max(lb+i,lc+j));
			ans=min(r-l,ans);
		}
	}
 }
	cout<<ans<<'\n';
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  while(true){
    int n, p;
    cin >> n >> p;
    int num = p;
  
    if(n == 0 && p == 0) break;

    vector<int> v(n);
    REP(i,n){
      v[i] = 0;
    }

    bool is_end = false;
    while(!is_end){
      REP(i,n){
        if(p > 0){
          v[i]++;
          p--;
          if(p == 0){ 
            if(v[i] == num){
              cout << i << endl;
              is_end = true;
              break;
            }
          }
        }else{
          p += v[i];
          v[i] = 0;
        }
      }  
    }

  }
  return 0;
}




Measured memory_bytes: 3008
#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<int> p(n);
  rep(i, n)
  {
    cin >> p[i];
    p[i]--;
  }
  vector<int> idx(n);
  rep(i, n)
    idx[p[i]] = i;
  multiset<int> s;
  s.insert(-1);
  s.insert(-1);
  s.insert(n);
  s.insert(n);
  ll ans = 0;
  for (int i = n - 1; i >= 0; i--)
  {
    int id = idx[i];
    ll l1, l2, r1, r2;
    s.insert(id);
    auto itr = s.find(id);
    r1 = *++itr;
    r2 = *++itr - r1;
    r1 -= id;
    itr--;
    itr--;
    l1 = *--itr;
    l2 = *--itr;
    l2 = l1 - l2;
    l1 = id - l1;
    ll c = r1 * l2 + r2 * l1;
    ans += (r1 * l2 + r2 * l1) * (i + 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5760
import heapq
INFTY = 10**6
N,M = map(int,input().split())
G = {i:[] for i in range(1,N+1)}
for _ in range(M):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
dist = [INFTY for _ in range(N+1)]
hist = [0 for _ in range(N+1)]
heap = [(0,1)]
dist[1] = 0
hist[1] = 1
while heap:
    d,x = heapq.heappop(heap)
    if dist[x]<d:continue
    hist[x]=1
    for y in G[x]:
        if hist[y]==0 and dist[y]>d+1:
            dist[y] = d+1
            heapq.heappush(heap,(d+1,y))
if dist[N]==2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

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

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

#define ALL(v) (v).begin(), (v).end()

#define MOD 1000000007

int main(){
	int n,t;
	cin>>n>>t;
	int cost = 1e9;
	while(n--){
		int c,tt;
		cin>>c>>tt;
		if(tt>t)continue;
		CHMIN(cost, c);
	}
	if(cost == 1e9){
		puts("TLE");
	}else{
		cout<<cost<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
from time import time
start = time()

import sys
import random


def solve(c_list, days, now):
    r = sum(c_list[i]*(now-days[i]) for i in range(26))
    return r


d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _i in range(d)]


last_days = [-1 for _i in range(26)]
result = []
score = 0
for today in range(d):
    checker = [c[j]*(today-last_days[j]) for j in range(26)]
    y = sum(checker)

    finder = [s[today][j]-(y-checker[j]) for j in range(26)]
    x = finder.index(max(finder))

    last_days[x] = today
    result.append(x+1)
    score += s[today][x] - solve(c, last_days, today)


def change(problems, days):
    last_days = [-1 for _i in range(26)]
    score = 0
    for i in range(d):
        score += s[i][problems[i]-1]
        last_days[problems[i]-1] = i
        score -= sum([c[j]*(i-last_days[j]) for j in range(26)])
    return score

change_list = result.copy()
while time()-start < 1.9:
    if random.randrange(2)<1:
        x, y = random.randrange(0, d), random.randrange(0, d)
        while x == y:
            y = random.randrange(0, d)
        change_list[x], change_list[y] = change_list[y], change_list[x]
        next_score = change(change_list, d)
        if next_score >= score:
            score = next_score
            result[x], result[y] = result[y], result[x]
        else:
            change_list[x], change_list[y] = change_list[y], change_list[x]
    else:
        x = random.randrange(0, d)
        y = random.randrange(1, 27)
        while change_list[x] == y:
            x = random.randrange(0, d)
            y = random.randrange(1, 27)    
        change_list[x], z = y, change_list[x]
        next_score = change(change_list, d)
        if next_score >= score:
            score = next_score
            result[x] = y
        else:
            change_list[x] = z

for i in result:
    print(i)

Measured memory_bytes: 93428
/////////////////////////////////TEST CASES////////////////////////////////////
/*
*/
/////////////////////////////////////CODE//////////////////////////////////////		
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define vl vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define FR(i,a) for(auto &i:a)
#define rvl(a,n) vl a;FOR(i,0,n){IN(in); a.pb(in);}
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 100000000000;
ll MOD = 1000000007;
void solve()
{
	IN(n);
	ll cnt = 0;
	FOR(i, 1, n)
	{
		if (n % i != 0)
			cnt += n / i;
		else
			cnt+=n / i - 1;
	}
	cout << cnt << endl;
}
int main()
{
	fastio
		//freopen("input.txt", "rt", stdin);
		//freopen("output.txt", "wt", stdout);
	ll test = 1;
	//cin >> test;
	while (test--)
	{
		solve();
	}
}

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

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF INT_MIN 
#define INF INT_MAX 
#define MP make_pair
#define int ll int

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef map<int,int>MII;
typedef vector<int> VI;
const int MAX = 1e4 + 5;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 
//int root(int x){return x==f[x]?x:f[x]=root(f[x]);}


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{
 int h,n;
 cin>>h>>n;
 int sum=0;
 for(int i=0;i<n;i++){int x;cin>>x;sum+=x;}
 if(sum>=h)cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
}


return 0;
}





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

const int N = 105, W = 1000000005, V = 1005, INF = 1000000009;

int n, w;
int dp[N][N*V];

int main(){
    cin >> n >> w;
    fill(dp[0],dp[0]+N*V,INF);
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++){
        int a, c;
        cin >> a >> c;
        for(int j = 0; j < c; j++){
            dp[i][j] = dp[i-1][j];
        }
        for(int j = c; j < N*V; j++){
            dp[i][j] = min(dp[i-1][j-c]+a, dp[i-1][j]);
        }
    }
    int ans = 0;
    for(int i = N*V-1; i >= 0; i--){
        if(dp[n][i] <= w){
            cout << i << "\n";
            break;
        }
    }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

vector<ll> gr(102020);
vector<ll> G[102020];

void merge(ll x, ll y){
	if(G[gr[x]].size() < G[gr[y]].size()){
		swap(x, y);
	}
	ll gx = gr[x];
	ll gy = gr[y];
	REP(i, G[gy].size()){
		gr[G[gy][i]] = gx;
		G[gx].push_back(G[gy][i]);
	}
	return;
}

int main(){
	ll N, M;
	cin >> N >> M;
	vector<pll> list(M);
	REP(i, M){
		cin >> list[i].first >> list[i].second;
	}
	vector<ll> result(M);
	ll tmp = N*(N-1)/2;
	result[0] = tmp;
	REP(i, N+1){
		G[i].push_back(i);
		gr[i] = i;
	}
	REP(i, M-1){
		ll x = list[M-1-i].first;
		ll y = list[M-1-i].second;
		if(gr[x]!=gr[y]){
			tmp -= (G[gr[x]].size() * G[gr[y]].size());
			merge(x, y);
		}
		result[i+1] = tmp;
	}
	REP(i, M){
		cout << result[M-1-i] << endl;
	}
    return 0;
}

Measured memory_bytes: 17516
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
const int mx = 2002;
int n, k, t, h[mx];
vector < int > ad[mx];
vector < pair < int , int > > e;
bool mark[mx];
void dfs(int v){
	mark[v] = true;
	for(auto u : ad[v])
		if(!mark[u]){
			h[u] = h[v] + 1;
			if(h[u] > k / 2)
				t++;
			dfs(u);
		}
	return;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int u, v, ans = 2002;
	cin >> n >> k;
	for(int i = 0; i < n - 1; i++){
		cin >> u >> v;
		u--, v--;
		ad[u].pb(v);
		ad[v].pb(u);
		e.pb({u , v});
	}
	if(!(k % 2)){
		for(int i = 0; i < n; i++){
			memset(mark , 0 , sizeof mark);
			h[i] = 0;
			t = 0;
			dfs(i);
			ans = min(ans , t);
		//	cout << i << " " << t << endl;
		}
	}
	else{
		for(int i = 0; i < n - 1; i++){
			memset(mark , 0 , sizeof mark);
			h[e[i].f] = h[e[i].s] = 0;
			mark[e[i].f] = mark[e[i].s] = true;
			t = 0;
			dfs(e[i].f); dfs(e[i].s);
		//	cout << e[i].f << " " << dfs(e[i].f) << endl;
			ans = min(ans , t);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
import itertools

N=int(input())

nums=[7,5,3]
l=len(str(N))

def solve(n):
  res=0
  for SFT in itertools.product(nums, repeat=n):
    if len(set(SFT)) == 3:
      SFT=list(SFT)
      cnt=0
      for i in range(len(SFT)):
        cnt+=SFT[i]*(10**i)
      if cnt <= N:
        res+=1
  return res

if l < 3:
  print(0)
else:
  ans=0
  for i in range(3,l+1):
    ans+=solve(i)
  print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;
bool compare(pair<pair<int,int>,int> a,pair<pair<int,int>,int> b){
    return a.second < b.second;
}

int main(){
  int m;cin >> m;
  int n;cin >> n;cin.ignore();
  string s;    
  for(int i = 0;i<m;i++){
      getline(cin,s);
      cout << s << endl;
      cout << s << endl;
  }
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n, k, d, tmp, num = 0;
    bool snuke[100] = {};

    cin >> n >> k;
    for(int i = 0; i < k; i++){
        cin >> d;
        for(int j = 0; j < d; j++){
            cin >> tmp;
            snuke[tmp - 1] = true;
        }
    }

    for(int i = 0; i < n; i++){
        if(!snuke[i]){
            num++;
        }
    }

    cout << num << endl;

    return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> T& chmin(T &a, const U &b){return a = (a<=b?a:b);}
template <typename T, typename U> T& chmax(T &a, const U &b){return a = (a>=b?a:b);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

bool is_included_in(int a, int b){
  return (a&(~b)) == 0;
}
vector<LLI> a;

using pii = pair<int,int>;
pii g(pii &x, pii &y){
  vector<int> temp = {x.fst, y.fst};
  if(x.snd != -1) temp.push_back(x.snd);
  if(y.snd != -1) temp.push_back(y.snd);

  sort(ALL(temp), [&](int p, int q){return a[p] > a[q];});
  temp.erase(unique(ALL(temp)), temp.end());

  if(temp.size() == 1) return make_pair(temp[0], -1);
  return make_pair(temp[0], temp[1]);
}

template <typename T> void fast_zeta_transform_subset(vector<T> &f){
  for(int i=0; (1<<i) < f.size(); ++i){
    REP(j,f.size()){
      if(j & (1<<i)) f[j] = g(f[j], f[j ^ (1<<i)]);
    }
  }
}


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

  int N;
  while(cin >> N){
    a = vector<LLI>(1<<N); cin >> a;

    vector<pair<int,int>> dp(1<<N);
    REP(i,1<<N) dp[i] = make_pair(i,-1);
    fast_zeta_transform_subset(dp);

    dump(dp);
    
    LLI ans = 0;
    FOR(k,1,1<<N){
      chmax(ans, a[dp[k].fst] + a[dp[k].snd]);
      cout << ans << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 7168
// 

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
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 int INF = (1 << 29);
const long long INFL = 1LL<<60;

void dump(const vector<pair<int, int>>& a)
{
  for (auto v : a) {
    cerr << v.first << " " << v.second << endl;
  }
}

void dump(const vector<int>& a)
{
  for (auto v : a) {
    cerr << v << " ";
  }
  cerr << endl;
}

////////////////////////////////////////////////////

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

  priority_queue<ll> q;

  rep(i, n) {
    ll a;
    cin >> a;
    q.push(a);
  }

  rep(i, m) {
    ll val = q.top(); q.pop();
    q.push(val / 2);
  }

  ll ans = 0;
  rep(i, n) {
    ans += q.top(); q.pop();
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1400
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, acos, asin, atan, sqrt, tan, cos, pi
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
plus = []
minus = []
for _ in range(n):
    s = S()
    ret = 0
    ret2 = 0
    for i in s:
        if ret and i == ')':
            ret -= 1
        elif i == '(':
            ret += 1
        else:
            ret2 += 1
    if ret2 > ret:
        plus += [(ret, ret2)]
    else:
        minus += [(ret, ret2)]


plus.sort()
minus.sort(key=lambda x:x[1], reverse=True)
L = plus + minus

now = 0
for x, y in L:
    now -= x
    if now < 0:
        print("No")
        exit()
    now += y

if now:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 207144
import math
import fractions
n=int(input())
a=list(map(int,input().split()))
left=[0]*(n+1)
right=[0]*(n+1)
left[1]=a[0]
right[1]=a[n-1]
for i in range(2,n+1):
    left[i]=fractions.gcd(left[i-1],a[i-1])
    right[i]=fractions.gcd(right[i-1],a[n-i])
ans=0
for i in range(1,n-1):
    ans=max(ans,fractions.gcd(left[i],right[n-1-i]))
print(max(ans,right[n-1],left[n-1]))


Measured memory_bytes: 89580
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	Map<Long, Long> shop = new HashMap<>();
    	for (int i = 0; i < N; i++) {
    		long cost = sc.nextInt();
    		long count = sc.nextInt();
    		if (shop.containsKey(cost)) {
    			shop.put(cost, shop.get(cost) + count);
    		} else {
    			shop.put(cost, count);
    		}
    	}
    	List<Long> key = new ArrayList<>(shop.keySet());
    	Collections.sort(key);
    	long rem = M;
    	long totalCost = 0;
    	for (int i = 0; i < key.size(); i++) {
    		long cost = key.get(i);
    		long count = shop.get(cost);
    		if (count < rem) {
    			rem -= count;
    			totalCost += count * cost;
    		} else {
    			totalCost += rem * cost;
    			break;
    		}
    	}
    	System.out.println(totalCost);
    }
}

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

int main(int argc, const char * argv[]) {
    int A, B;
    
    cin >> A >> B;
    if (A >= 13) {
        cout << B << endl;
    } else if (A <= 12 && A >= 6) {
        cout << (B / 2) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
using namespace std;
int main()
{
	int a;
	int b;
	int c;
	cin >> a >> b >> c;
	int t;
	int ans;
	if (c < b){
		t = b;
		b = c;
		c = t;
	}
	if (b < a){
		t = a;
		a = b;
		b = t;
	}
	if (c < b){
		t = b;
		b = c;
		c = t;
	}
	ans += (c - a) / 2 + (c - b) / 2;
	if ((a % 2 == b % 2) && (a % 2 != c % 2)){
		ans += 1;
	}
	if ((a % 2 != b % 2)){
		ans += 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import math

N,M = map(int,input().split())
A = M//N
L = []
for i in range(1,int(math.sqrt(M))+1):
  if (M%i == 0 and i <= A):
    L.append(i)
    if (M//i <= A):
      L.append(M//i)
print(max(L))

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

const int INF = 1001001001;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> C(n);
    vector<vector<int>> vec(n, vector<int>(m));
    rep(i, n)
    {
        cin >> C[i];
        rep(j, m) cin >> vec[i][j];
    }

    int ans = INF;
    rep(bit, 1 << n)
    {
        vector<int> d(m, 0);
        int cost = 0;
        rep(i, n)
        {
            if ((bit >> i) & 1)
            {
                cost += C[i];
                rep(j, m) d[j] += vec[i][j];
            }
        }
        bool ok = true;
        rep(i, m)
        {
            if (d[i] < x)
                ok = false;
        }
        if (ok)
            ans = min(ans, cost);
    }
    if(ans==INF){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N, x;
    cin >> N >> x;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    ll ans = 0;
    for (int i = 1; i < N; i++) {
        ll sum = a[i] + a[i - 1];
        if (sum > x) {
            ll d = min(sum - x, a[i]);
            a[i] -= d;
            ans += d;

            ll sum2 = a[i] + a[i - 1];
            if (sum2 > x) {
                d = sum2 - x;
                a[i - 1] -= d;
                ans += d;
            }
        }
    }

//    ll sum = a[N - 1] + a[N - 2];
//    if(sum > x) {
//        ll d = sum - x;
//        a[N-1] -= d;
//        ans += d;
//    }

    cout << ans << endl;
}

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

using namespace std;

#define int long long

struct UF {
  vector<int> data;
  UF(int n):data(n, -1){}
  int find(int x) {
    if(data[x] < 0) return x;
    return data[x] = find(data[x]);
  }
  int size(int x) {
    return -data[find(x)];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }
};

struct edge {
  int u, v, w;
  edge(){}
  edge(int u, int v, int w):u(u), v(v), w(w){}
  bool operator < (const edge& e) const {
    return w < e.w;
  }
};

signed main() {
  int n;
  cin >> n;
  vector<edge> es;
  for(int i = 0; i < n-1; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    es.emplace_back(a, b, c);
  }
  sort(es.begin(), es.end());
  UF uf(n);
  int ans = 0;
  for(edge& e : es) {
    int x = uf.find(e.u), y = uf.find(e.v);
    if(x == y) continue;
    ans += e.w*uf.size(x)*uf.size(y);
    uf.unite(x, y);
  }
  
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 9120
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
int main()
{
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a,b;
   cin>>n>>m;
   k=MAX;
   for(i=0;i<n;i++)
   {
       cin>>p>>q;
       if(q<=m)
       {
           k=min(p,k);
       }
   }
if(k==1000000000000000000)
{
    cout<<"TLE"<<endl;
}
   else{cout<<k<<endl;}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long D[5005];

int main() {

    ios::sync_with_stdio(false);

    int n, p;
    cin >> n >> p;

    D[0] = 1;
    long long ans = 0;

    if (p == 0) ++ans;

    int x;

    for (int i = 1; i <= n; ++i) {
        cin >> x;

        for (int j = 5000; j >= 0; --j) {
            if (D[j] && j + x <= 5000) {
                D[j + x] += D[j];
                if ((j + x) % 2 == p) {
                    ans += D[j];
                }
            }
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
/*
  * author: said_v15
  * created with web_programmer
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char s;
    cin>>s;
    if(s=='A') cout<<"T";
    if(s=='T') cout<<"A";
    if(s=='C') cout<<"G";
    if(s=='G') cout<<"C";
    return 0;
    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<P, int> PP;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			if (mod <= ans * x) ans = ans * x % mod;
			else ans *= x;
		}
		if (mod <= x * x) x = x * x % mod;
		else x *= x;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
	}
	fact_memo[n] = (ans + mod) % mod;
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

int gcd(int a, int b) {
	while (b != 0) {
		int c = b;
		b = a % b;
		a = c;
	}
	return a;
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

int n;
int a[114514], l[114514], r[114514];
int ans = 0;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	l[0] = a[0];
	r[n - 1] = a[n - 1];
	rep(i, n - 1) {
		l[i + 1] = gcd(l[i], a[i + 1]);
	}
	Rep(i, n - 1) {
		r[i] = gcd(r[i + 1], a[i]);
	}
	rep(i, n) {
		if (i == 0) {
			ans = r[i + 1];
		}
		else if (i == n - 1) {
			ans = max(ans, l[i - 1]);
		}
		else {
			ans = max(ans, gcd(l[i - 1], r[i + 1]));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main()
{
    int h, w;
    char s[50][50];

    cin >> h >> w;

    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            cin >> s[i][j];

    bool ans = true;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] == '#')
            {
                bool tmp = false;
                //左
                if (i >= 0 && s[i - 1][j] == '#')
                    tmp = true;

                //上
                if (j >= 0 && s[i][j - 1] == '#')
                    tmp = true;

                //右
                if (i < h - 1 && s[i + 1][j] == '#')
                    tmp = true;

                //下
                if (j < w - 1 && s[i][j + 1] == '#')
                    tmp = true;

                if (!tmp)
                {
                    ans = false;
                    break;
                }
            }
        }

    if (ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

ll Max(ll *a){
    ll maxi=-1;
    rep(i,0,2){
        maxi=max(maxi,a[i]);
    }
    return maxi;
}
ll Min(ll *a){
    ll mini=inf;
    rep(i,0,2){
        mini=min(mini,a[i]);
    }
    return mini;
}


int main(){
    ll h,w,i,j;cin>>h>>w;
    if(h%3==0 || w%3==0){
        cout<<0<<endl;
        return 0;
    }
    ll ans=min(h,w);
    j=w/2;
    ll s[3];
    rep(i,0,h){
        s[0]=i*w;
        s[1]=(h-i)*j;
        s[2]=(h-i)*(w-j);
        ans=min(ans,Max(s)-Min(s));
    }
    i=h/2;
    rep(j,0,w){
        s[0]=h*j;
        s[1]=(w-j)*i;
        s[2]=(w-j)*(h-i);
        ans=min(ans,Max(s)-Min(s));
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int num, i, min, max = 0, n;
	long sum = 0;

	scanf("%d", &num);
	scanf("%d", &n);
	
	min = max = sum = n;
	
	for (i = 0; i < num - 1; i++) {
		scanf("%d", &n);
		sum += n;
		if (min > n) {
			min = n;
		}
		if (max < n) {
			max = n;
		}
	}

	printf("%d %d %ld\n", min, max, sum);
	
	return(0);
}


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

int main() {
   string s; cin >> s;
   if (s.size() == 2)
        cout << s << endl;
    else {
        reverse(s.begin(), s.end());
        cout << s << endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int (i)=0,i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(x) cout << x << endl
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

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

    int a = N / (D * 2 + 1);
    if(N % (D * 2 + 1)) a += 1;

    cout << a << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int R = stdIn.nextInt();
		int ans = 0;
		if(N >= 10){
			System.out.println(R);
		}
		else{
			ans = 100 * (10 - N);
			System.out.println(R + ans);
		}
		stdIn.close();
	}
}

Measured memory_bytes: 35676
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>

using namespace std;

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

vector<pair<int, int>> make_set(string &s, int i){
	vector<pair<int, int>> ret;
	auto pos = make_pair(0, 0);

	ret.push_back(pos);
	for (auto c : s){
		pos.first += dx[(c - 'a' + i) % 6];
		pos.second += dy[(c - 'a' + i) % 6];
		ret.push_back(pos);
	}
	sort(ret.begin(), ret.end());
	return ret;
}

bool check(string &s, string &t){
	vector<pair<int, int>> s1 = make_set(s, 0);
	vector<vector<pair<int, int>>> s2(6);
	for (int i = 0; i < 6; ++i) s2[i] = make_set(t, i);

	for (auto p : s1){
		for (int i = 0; i < 6; ++i){
			bool ok = true;
			for (int j = 0; j < s1.size(); ++j){
				int x = s1[j].first - p.first;
				int y = s1[j].second - p.second;
				if (make_pair(x, y) != s2[i][j]) ok = false;
			}

			if (ok) return true;
		}
	}
	return false;
}

int main(){
	int n;
	cin >> n;
	cin.ignore();
	for (int i = 0; i < n; ++i){
		string s, t, u;
		getline(cin, s);
		getline(cin, t);
		getline(cin, u);
		if (s.size() == t.size() && check(s, t)) cout << "true" << '\n';
		else cout << "false" << '\n';
	}

	return 0;
}

Measured memory_bytes: 1208