akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N,K,R,S,P,score;
  string T;
  cin>>N>>K>>R>>S>>P>>T;
  score=0;
  for(int i=0;i<N;i++)
  {
    if(i>=K)
    {
      if(T.at(i)==T.at(i-K)) T.at(i)='z';
    }
    if(T.at(i)=='r') score+=P;
    else if(T.at(i)=='s') score+=R;
    else if(T.at(i)=='p') score+=S;
  }
  cout<<score<<endl;
}

Measured memory_bytes: 512
load = []
for i in range(3):
	tmp = input().split();
	load.append([int(tmp[0]),int(tmp[1])])
count = [0]*5
for i in range(len(load)):
	count[load[i][0]]+=1
	count[load[i][1]]+=1

ans = True

for i in range(1,5):
	if(count[i] == 3):
		ans = False

if(ans):
	print("YES")
else:
	print("NO")

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = new List<int>();
            for (int i = 0; i < 28; i++)
            {
                list.Add(ReadInt());
            }

            var anslist = new List<int>();
            for (int i = 1; i <= 30; i++)
            {
                if (!list.Contains(i))
                {
                    anslist.Add(i);
                }
            }
            anslist.Sort();
            foreach (var item in anslist)
            {
                WriteLine(item);
            }
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 15896
def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res

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

MOD = 1000000007

ANS1 = modpow(2, n, MOD)

ANS2 = 1
for i in range(a):
    ANS2 = ANS2 * (n-i) * modpow(i+1, MOD-2, MOD) % MOD

ANS3 = 1
for i in range(b):
    ANS3 = ANS3 * (n-i) * modpow(i+1, MOD-2, MOD) % MOD

if (ANS1 - 1 - ANS2 - ANS3) % MOD < 0:
    print((ANS1 - 1 - ANS2 - ANS3) % MOD + MOD)
else:
    print((ANS1 - 1 - ANS2 - ANS3) % MOD)

Measured memory_bytes: 41580
N = int(input())
S = [list(input()) for _ in range(2)]

DIVIDER = 1000000007

c_type = []
i = 0
while i < N:
    if S[0][i] == S[1][i]:
        c_type.append(0)
        i += 1
    else:
        c_type.append(1)
        i += 2

for i in range(len(c_type)):
    if i == 0:
        ans = 3 if c_type[i] == 0 else 6
    elif c_type[i] == 0:
        if c_type[i - 1] == 0:
            ans = (ans * 2) % DIVIDER
        else:
            ans = (ans * 1) % DIVIDER
    else:
        if c_type[i - 1] == 0:
            ans = (ans * 2) % DIVIDER
        else:
            ans = (ans * 3) % DIVIDER

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int d[210][210];

int main()
{
    for(int i = 0; i < 210; i++) for(int j = 0; j < 210; j++) d[i][j] = INF;
    int n,m,R;
    cin >> n >> m >> R;
    vector<int> r(R);
    for(int i = 0; i < R; i++) cin >> r[i];
    for(int i = 0; i < m; i++){
        int a,b,c;
        cin >> a >> b >> c;
        d[a][b] = d[b][a] = c;
    }

    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }

    int res = INF;
    sort(r.begin(),r.end());
    do{
        int sub = 0;
        for(auto x = r.begin(); x != r.end(); x++){
            if(x != r.begin()) sub += d[*(x-1)][*x];
        }
        res = min(res,sub);
    }while(next_permutation(r.begin(),r.end()));

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17

int dp[1010][10010];
int main(){
    ll h,n;cin>>h>>n;
    int a[MAX],b[MAX];
    rep(i,n)cin>>a[i]>>b[i];
    rep(i,1010)rep(j,10010)dp[i][j]=INF;
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=h;j++){ 
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            chmin(dp[i+1][min(j+a[i],(int)h)],dp[i+1][j]+b[i]);
        }
    }
    cout<<dp[n][h]<<endl;
}

Measured memory_bytes: 43120
n=int(input())
A=[1]
for i in range(15):
  A.append(A[-1]+4**(i+1))
B=[-2,-1]
for i in range(15):
  B.append(A[i]+1)
  B.append(A[i+1])
  B.append(-2*A[i+1])
  B.append(-2*A[i]-1)
C=[1]
for i in range(32):
  C.append(C[-1]*-2)
if n==0:
  print(0)
  exit()
if n==1:
  print(1)
  exit()
a=0
i=0
while a==0:
  if B[2*i]<=n and n<=B[2*i+1]:
    a=1
  else:
    i=i+1
ans=""
while i>=0:
  if B[2*i]<=n and n<=B[2*i+1]:
    ans=ans+"1"
    n=n-C[i+1]
    i=i-1
  else:
    ans=ans+"0"
    i=i-1
if n==0:
  ans=ans+"0"
else:
  ans=ans+"1"
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
struct _data{
	char n[10];
	int r;
	int g;
	int b;
}typedef _data;
_data list[8]={
		{"black",0,0,0},
		{"blue",0,0,255},
		{"lime",0,255,0},
		{"aqua",0,255,255},
		{"red",255,0,0},
		{"fuchsia",255,0,255},
		{"yellow",255,255,0},
		{"white",255,255,255}
};
int getDigit(char s1,char s2){
	int sum1=0,sum2=0;
	if(s1>='a'&&s1<='f')sum1 += 10 + s1-'a';
	else sum1 += s1-'0';
	if(s2>='a'&&s2<='f')sum2 += 10+ s2-'a';
	else sum2 += s1-'0';
	return sum1*16+sum2;
}
int main(){
	int i,j,n,r,g,b,dMinN;
	char str[10];
	double d,dMin;
	for(;scanf("%s",str)&&str[0]!='0';){
		dMin=100000;
		r=getDigit(str[1],str[2]);
		g=getDigit(str[3],str[4]);
		b=getDigit(str[5],str[6]);
		for(i=0;i<8;i++){
			d=sqrt((double)((list[i].r-r)*(list[i].r-r)
					+(list[i].g-g)*(list[i].g-g)
					+(list[i].b-b)*(list[i].b-b)));
			if(d<dMin){
				dMin=d;
				dMinN=i;}}printf("%s\n",list[dMinN].n);}return 0;}

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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc086/tasks/abc086_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            string result = "";

            if (inputLongArray[0]*inputLongArray[1] % 2 == 0)
            {
                result = "Even";
            }
            else
            {
                result = "Odd";
            }


            //if (inputLongArray[0] % 2 == 0 || inputLongArray[1] % 2 == 0)
            //{
            //    result = "Even";
            //}
            //else
            //{
            //    result = "Odd";
            //}

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
//k-stones
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <bool> vb;
typedef vector <double> vd;
typedef vector <ll> vll;
typedef vector <vector <int>> vvi;
typedef vector <vector <long long>> vvll;
typedef vector <vd> vvd;
typedef vector <long long> vll;
typedef pair <int, int> pii;
typedef pair<ll , ll> pll;
typedef vector <pair <int, int>> vpii;

int main()
{
    int n, k; cin >> n >> k;
    vi a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    vb state(k+1, 0);
    for(int i = 0; i < k + 1; i++){
        for(auto j: a) {
                if(i >= j && !state[i-j]){
                    state[i] = 1;
                }
        }
    }
    cout << (state[k]?"First":"Second") <<endl;
}

Measured memory_bytes: 256
def dfs(n,a,b,c):
    if n == N:
        return abs(A-a)+abs(B-b)+abs(C-c) - 30 if min(a,b,c) > 0 else float('inf')

    ret1 = dfs(n+1,a+l[n],b,c) + 10
    ret2 = dfs(n+1,a,b+l[n],c) + 10
    ret3 = dfs(n+1,a,b,c+l[n]) + 10
    ret4 = dfs(n+1,a,b,c)

    return min(ret1,ret2,ret3,ret4)



if __name__ == "__main__":
    N,A,B,C = map(int,input().split())
    l = [int(input()) for _ in range(N)]
    print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

//using
using VI = vector<int>;
using VVI = vector<VI>;
using VS = vector<string>;
using PII = pair<int, int>;
using LL = long long;

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  for(int i=0;i<(n);i++)

//constant
const int INF = 1 << 29;
const double EPS = 1e-10;
const double PI = acos(-1.0);

//debug
#define dump(x)  cout << #x << " = " << (x) << endl;

int main() {
  int N;
  cin >> N;
  VI a(N);
  REP(i, N) cin >> a[i];
  sort(a.begin(), a.end());
  int cost = INF;
  FOR(n, a[0], a[N-1]+1) {
    int cost_tmp = 0;
    REP(i, N) cost_tmp += pow(a[i] - n,2);
    cost = min(cost, cost_tmp);
  }
  cout << cost << endl;
  return 0;
}

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

ll l,r;

int main(){
  cin >> l >> r;
  if(r-l>=2019){
   cout << 0;
   return 0;
  }
  ll mn=2019;
  for(ll i=l;i<r;++i){
    for(ll j=i+1;j<=r;++j){

        mn=min(mn,(i*j)%2019);

    }
  }
  cout << mn;
  return 0;
}


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

int main(void)
{
	int X = 0;
	int ureshi = 0;
	int temp = 0;

	cin >> X;

	if (X < 500) ureshi = X / 5 * 5;
	else {
		temp = X / 500;
		X = X - (500 * temp);
		ureshi = temp * 1000 + X / 5 * 5;
	}

	cout << ureshi << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <tuple>
using namespace std;
typedef long long ll;

int par[200010];
int rnk[200010];
ll sze[200010];
 
// 初期化
void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        rnk[i] = 0;
        sze[i] = 1;
    }
}
 
// 親探し
int find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
}
 
// 併合
void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rnk[x] < rnk[y]) {
        sze[y] = sze[x] + sze[y];
        par[x] = y;
    }
    else {
        sze[x] = sze[x] + sze[y];
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
    
}
 
// 同じ木にあるか
bool same(int x, int y) {
    return find(x) == find(y);
}

int main() {
    int n, k, l;
    cin >> n >> k >> l;

    init(n);
    for (int i = 0; i < k; i++) {
        int p, q;
        cin >> p >> q;
        unite(p - 1, q - 1);
    }

    int road[200010];
    for (int i = 0; i < n; i++) {
        road[i] = find(i);
    }

    init(n);
    for (int i = 0; i < l; i++) {
        int p, q;
        cin >> p >> q;
        unite(p - 1, q - 1);
    }

    int train[200010];
    for (int i = 0; i < n; i++) {
        train[i] = find(i);
    }

    int ans[200010] = {};
    vector<tuple<int, int, int>> v;
    for (int i = 0; i < n; i++) {
        v.emplace_back(road[i], train[i], i);
    }
    sort(v.begin(), v.end());

    int idx = 0;
    while (idx < n) {
        if (ans[get<2>(v[idx])] == 0) {
            int sub = 0;
            vector<int> w;
            while (get<0>(v[idx]) == get<0>(v[idx + sub]) 
            && get<1>(v[idx]) == get<1>(v[idx + sub]) 
            && idx + sub < n) {
                w.push_back(get<2>(v[idx + sub]));
                sub++;
            }
            for (int i = 0; i < w.size(); i++) {
                ans[w[i]] = sub;
            }
            idx += sub;
        }
        else idx++;
    }

    for (int i = 0; i < n; i++) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;


}


Measured memory_bytes: 10100
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	static final int INF = 1001001001;
	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int m = sc.nextInt();
			if (m == 0) break;
			int n = 16;
			int[][] d = new int[n][n];
			for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) d[i][j] = INF;
			for (int i = 0; i < n; i++) d[i][i] = 0;
			for (int i = 0; i < m; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				int c = sc.nextInt();
				if (d[a][b] > c) {
					d[a][b] = c;
					d[b][a] = c;
				}
			}
			
			for (int k = 0; k < n; k++) for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) {
				d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
			}
			
			int bp = 0;
			int best = INF;
			for (int p = 0; p < n; p++) if (d[0][p] < INF) {
				int here = 0;
				for (int i = 0; i < n; i++) if (d[i][p] < INF) here += d[i][p];
				if (best > here) {
					best = here;
					bp = p;
				}
			}
			System.out.println((bp) + " " + best);
		}
	}
}

Measured memory_bytes: 20184
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);

		int n=sc.nextInt();		//くじn回引く

		ArrayList<String>array=new ArrayList<String>();

		for(int i=0;i<n;i++) {		//くじの回数分回す
			array.add(sc.next());
		}
		
		HashSet<String>keihin=new HashSet<String>(array);
		
		System.out.println(keihin.size());
		sc.close();
	}

}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//main code

int main(int argc, char const* argv[])
{
	int n,k;
	cin >> n >> k;
	cout << n - k + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
x = tonumber(io.read())
t = {}
for i = 100, 105 do
  t[i] = true
end
for i = 1, x do
  for j = 100, 105 do
    if t[i - j] then
      t[i] = true
    end
  end
end
print(t[x] and 1 or 0)

Measured memory_bytes: 2424
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
ll n, m, x;
priority_queue<ll>pq;
int  main()
{
    cin >> n >> m;
    while(n--)
        cin >> x, pq.push(x);
    while(m--){
        x = pq.top();
        pq.pop();
        pq.push(x / 2);
    }
    x = 0;
    while(!pq.empty())
        x += pq.top(), pq.pop();
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 1400
n = int(input())
A = list(map(int, input().split()))

def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

idx = partition(A, 0, len(A)-1)
A[idx] = [A[idx]]
print(*A)


Measured memory_bytes: 16388
#include <stdio.h>
#include <math.h>

bool prime(int x)
{
    for(int i = 2; i <= sqrt(x); i++)
        if (!(x%i))
            return false;
    return true;
}

int main()
{
    int N, x, count = 0;
    scanf("%d", &N);
    while (N--)
    {
        scanf("%d", &x);
        if(prime(x)) count++;
    }
    printf("%d\n", count);
    return 0;
}



Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<string> str(3);
  for(int i = 0; i < 3; i++){
    cin >> str.at(i);
    transform(str.at(i).begin(), str.at(i).end(), str.at(i).begin(), ::toupper);
  }
  for(int i = 0; i < 3; i++){
    cout << str.at(i).at(0);
  }
  cout << endl;
}

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

void i_sort(int N,int *A);

int main(){
	int N;
	int A[100];
	cin >> N;
	for(int i = 0;i < N;i++){
		cin >> A[i];
		}
	i_sort(N,A);
}

void i_sort(int N,int *A){
	int temp = 0;
	int j = 0;
	for(int i = 0;i < N;i++){
		cout << A[i];
		
		if(i != N-1){
			 cout << " ";
			}else{
				cout << endl;
			}
	}
	for(int i = 1;i < N;i++){
		temp = A[i];
		j = i-1;
		while(j >= 0 && A[j] > temp){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = temp;
		for(int i = 0;i < N;i++){
			cout << A[i];
			if(i != N-1){
				 cout << " ";
				}else{
					cout << endl;
				}
		}
	}
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

#define MOD 1000000007

int main()
{
    int n = get<int>();
    int m = get<int>();
    vector<int> s(n);
    for (int i = 0; i < n; i++)
        s[i] = get<int>();
    vector<int> t(m);
    for (int i = 0; i < m; i++)
        t[i] = get<int>();

    vector<vector<int>> sum(n+1);
    for (int i = 0; i < n+1; i++)
        sum[i].resize(m+1, 0);

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (i == 0 || j == 0) {
                sum[i][j] = 1;
            } else {
                long tmp = (long) sum[i-1][j] + sum[i][j-1] + MOD - sum[i-1][j-1];
                if (s[i-1] == t[j-1])
                    tmp += sum[i-1][j-1];
                sum[i][j] = tmp % MOD;
            }
        }
    }
    cout << sum[n][m] << endl;
    return 0;
}

Measured memory_bytes: 16000
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin>>s;
	int out=inf;
	rep(i,s.size()-2)cmin(out,abs(stoi(s.substr(i,3))-753));
	cout<<out<<endl;
}






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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

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

    if (S[S.size()-1] == 's') {
        S += "es";
    }
    else {
        S += "s";
    }
    cout << S << endl;
}


Measured memory_bytes: 3628
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

N = int(input())
#N, M = map(int, input().split())
A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
#ABC = [list(map(int, input().split())) for _ in range(N)]
#S = input()
#S = [input() for _ in range(N)]

acum_A = 0
for a in A:
    acum_A += a

answer = 0
for a in A:
    acum_A -= a
    answer = (answer + a * (acum_A)) % MOD

print(answer)

Measured memory_bytes: 93588
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


typedef set<int> SI;
string cmd, sl, sr;
SI L, R;

void init() {
    L.clear();
    R.clear();
}

int parse( string s, int k, int d, SI& T ) {
    int n = s.size();
    int lr = 1; 
    T.insert(d);
    for ( int i = k+1; i < n; ) {
        if ( s[i] == '(' ) {
            i = parse( s, i, 2*d+lr, T );
        } else if ( s[i] == ',' ) {
            lr = 2;
            i ++;
        } else if ( s[i] == ')' ) {
            return i+1;
        }
    }
    return n;
}

string rec( SI& T, int d ) {
    string res;
    res += '(';
    if ( T.count(2*d+1) ) {
        res += rec( T, 2*d+1 );
    }
    res += ',';
    if ( T.count(2*d+2) ) {
        res += rec( T, 2*d+2 );
    }
    res += ')';
    return res;
}

string toString( SI& T ) {
    return rec( T, 0 );
}

string solve() {
    parse( sl, 0, 0, L );
    parse( sr, 0, 0, R );
    SI T;
    if ( cmd == "i" ) {
        set_intersection( L.begin(), L.end(), R.begin(), R.end(), inserter( T, T.end() ) );
    } else if ( cmd == "u" ) {
        set_union( L.begin(), L.end(), R.begin(), R.end(), inserter( T, T.end() ) );
    }
    return toString(T);
}

int main() {
    while ( cin >> cmd >> sl >> sr ) {
        init();
        cout << solve() << endl;
    }
    return 0;
}

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

int main(void) {
  string S;
  cin >> S;
  for (int i = 2, len = S.length(); i < len; i += 2) {
    string a, b;
    a = S.substr(0, (S.length() - i) / 2);
    b = S.substr((S.length() - i) / 2, (S.length() - i) / 2);
    if (a == b) {
      cout << S.length() - i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
sum = [0]*(N+1)

for i in range(N):
    sum[i+1] = (sum[i] + A[i])%M
    

C = Counter(sum)
ans = 0
for k,v in C.items():
    ans += v*(v-1)//2

print(ans)

Measured memory_bytes: 16516
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>
#include <queue>

using namespace std;
int64_t n, m, s, t;
using P = pair<int, int>;
struct Edge {
    int64_t to, cost;
};
constexpr int64_t INF = 100000000000000000;

constexpr int MAX_V = 1000000;
vector<Edge> G[MAX_V];
int64_t d[MAX_V];
vector<Edge> G2[MAX_V];
int64_t d2[MAX_V];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + n, INF);
    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(const auto& e : G[v]){
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

void dijkstra2(int s){
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d2, d2 + n, INF);
    d2[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d2[v] < p.first) continue;
        for(const auto& e : G2[v]){
            if(d2[e.to] > d2[v] + e.cost){
                d2[e.to] = d2[v] + e.cost;
                que.push(P(d2[e.to], e.to));
            }
        }
    }
}

int main(){
    cin >> n >> m >> s >> t;
    --s, --t;

    int64_t X = 1000000000000000;
    for(int i = 0; i < m; ++i){
        int64_t u, v, a, b;
        cin >> u >> v >> a >> b;
        --u, --v;
        G[u].push_back(Edge{v, a});
        G[v].push_back(Edge{u, a});
        G2[u].push_back(Edge{v, b});
        G2[v].push_back(Edge{u, b});
    }

    dijkstra(s);
    dijkstra2(t);

    vector<int64_t> ans(n);
    ans[n-1] = d[n-1] + d2[n-1];
    int64_t mi = ans[n-1];
    for(int i = n-2; i >= 0; --i){
        mi = min(mi, d[i] + d2[i]);
        ans[i] = mi;
    }
    for(int i = 0; i < n; ++i){
        cout << X - ans[i] << endl;
    }
}

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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int c11, c12, c13, c21, c22, c23, c31, c32, c33;
	int a1, a2, a3, b1, b2, b3;
	string ans = "No";
	
	cin >> c11 >> c12 >> c13 >> c21 >> c22 >> c23 >> c31 >> c32 >> c33;
	for(int i = 0; i <= max({c11, c12, c13, c21, c22, c23, c31, c32, c33}); i++){
		b1 = i;
		a1 = c11 - b1;
		a2 = c21 - b1;
		a3 = c31 - b1;
		b2 = c12 - a1;
		b3 = c13 - a1;
		if(a2+b2 == c22 && a2+b3 == c23 && a3+b2 == c32 && a3+b3 == c33){
			ans = "Yes";
			break;
		}
	}
	cout << ans;
		

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2000+10;
ll n,x,ans=1e15,a[maxn],dp[maxn][maxn];

int main()
{
    scanf("%lld%lld",&n,&x);
    for(ll i=1;i<=n;i++){
    	scanf("%lld",&a[i]);
    	dp[i][0]=a[i];
	}
	ll t;
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<n;j++){
			t=i-j;
			if(t<=0) t+=n;
			dp[i][j]=min(dp[i][j-1],a[t]);
		}
	}
	ll sum;
	for(ll i=0;i<n;i++){
		sum=0;
		for(ll j=1;j<=n;j++){
			sum+=dp[j][i];
		}
		ans=min(ans,sum+i*x);
	}
	printf("%lld\n",ans);
    return 0;
}

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

S = input()

wa = 0

if S[0] == "A":
    pass
else:
    wa = 1

n = 0
for i in S[2:-1]:
    if i == "C":
        n = n + 1
if n == 1:
    pass
else:
    wa = 1 


n = 0
for i in S:
    if i.isupper() == True:
        n = n + 1

if n == 2:
    pass
else:
    wa = 1        

if wa == 1:
    print("WA")
else:
    print("AC")

Measured memory_bytes: 3064
import heapq

N,K=map(int,input().split())
inl = list(map(int,input().split()))

pq = []
max_score = 0
# 左からi個
for i in range(min(N,K)+1):
    # 右からj個
    for j in range(min(N-i, K-i)+1):
        tmp_score = 0
        pq = []
        for lef in range(i):
            if inl[lef] < 0:
                heapq.heappush(pq, inl[lef])
            tmp_score += inl[lef]
        for rg in range(j):
            if inl[N-1-rg] < 0:
                heapq.heappush(pq, inl[N-1-rg])
            tmp_score += inl[N-1-rg]
        for _ in range(K-i-j):
            if len(pq):
                minus = heapq.heappop(pq)
                tmp_score -= minus
        # print(pq)
        # print("i:{} j:{} nokori:{} tmp_score:{}".format(i,j,K-i-j, tmp_score))
        max_score = max(tmp_score, max_score)

print(max_score)


Measured memory_bytes: 56924
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

int N;
int V[20];
int C[20];
int DIFF[20];

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

    cin >> N;
    for (int i = 0; i < N; ++i)
        cin >> V[i];
    for (int i = 0; i < N; ++i)
    {
        cin >> C[i];
        DIFF[i] = V[i] - C[i];
    }

    sort(DIFF, DIFF + N, greater<int>());
    int result = 0;
    for (int i = 0; i < N; ++i)
    {
        if (DIFF[i] < 0)
            break;
        result += DIFF[i];
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 888
#include<iostream>
using namespace std;
int main(){
	int a;
	cin>>a;
	int cek=0;
	for(int i=1;i<=a;i++){
		int d1,d2;
		cin>>d1>>d2;
		if(d1==d2){
			cek++;
		}else cek=0;
		if(cek==3){
			cout<<"Yes"<<"\n";
			 return 0;
		}
	}
	cout<<"No"<<"\n";
}

Measured memory_bytes: 3580
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.nextLine();
      	int count=0;
      	for(int i=0;i<s.length();i+=2){
          if(i+1==s.length()){
          	count+=Integer.parseInt(s)-Math.pow(10,i)+1;
          }else{
          count+=Math.pow(10,i)*9;
          }
        }
		System.out.println(count);
		
	}
}

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

long long q, h, s, d, n;

int main(){
    cin >> q >> h >> s >> d >> n;
    int tot = min(q*4, min(h*2, s));
    if(d < 2*tot) cout << d*(n-n%2)/2+(n%2)*tot << endl;
    else cout << tot*n << endl;
    return 0;
}


Measured memory_bytes: 256
// Lec11-A Dice I
#include<iostream>
class Dice{
private:
  int d[6], tmp;
public:
  Dice(int *in){
    for(int i=0; i<6; i++) d[i] = in[i];
  }
  int Rolling(std::string str){
    for(int i=0; i<str.length(); i++){
      switch(str[i]){
        case 'N':
        tmp=d[0],d[0]=d[1],d[1]=d[5],d[5]=d[4],d[4]=tmp;
        break;
        case 'S':
        tmp=d[0],d[0]=d[4],d[4]=d[5],d[5]=d[1],d[1]=tmp;
        break;
        case 'E':
        tmp=d[0],d[0]=d[3],d[3]=d[5],d[5]=d[2],d[2]=tmp;
        break;
        case 'W':
        tmp=d[0],d[0]=d[2],d[2]=d[5],d[5]=d[3],d[3]=tmp;
        break;
      }
    }
    return d[0];
  }
};
int main(){
  int in[6];
  std::string str;
  for(int i=0; i<6; i++) std::cin >> in[i];
  std::cin >> str;
  Dice sample(in);
  std::cout << sample.Rolling(str) << std::endl;
  return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> arr(n, 0);
    for(auto& val: arr) {
        cin >> val;
    }
    while(k--) {
        vector<int> var(n+1, 0);
        for(int i = 0; i < n; i++) {
            var[max(i - arr[i], 0)] += 1;
            var[min(n, i + arr[i]+1)] -= 1;
        }
        vector<int> new_arr(n);
        int cur = 0;
        ll acc = 0;
        for(int i = 0; i < n; i++) {
            cur += var[i];
            new_arr[i] = cur;
            // cout << cur << " ";
            acc += cur;
        }
        arr = new_arr;
        if (acc == ll(n)*ll(n))
            break;
    }
    for(int i = 0; i < n; i++)
        cout << arr[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 5580
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char b; cin >> b;
    map<char, char> M = {{'A', 'T'}, {'T', 'A'}, {'C', 'G'}, {'G', 'C'}};
    cout << M[b] << endl;
    return 0;
}


Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han Elmuzaffer Daima
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define FOR1 for(int i=1;i<=m;i++)
#define mid (start+end)/2
#define ort (bas+son)/2

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

lo n,m,cev,b,a[li],k,vis[11];
string s;
vector<string> v;

inline lo solve(){
	scanf("%lld %lld",&n,&m);
	for(lo i=1;i<=m;i++){
		scanf("%lld",&b);
		vis[b]=1;
	}
	for(lo i=n;i<=100000000;i++){
		lo at=i,flag=0;;
		while(at){
			if(vis[at%10]){flag=1;break;}
			at/=10;
		}
		if(!flag){
			printf("%lld\n",i);
			return 0;
		}
	}
	return 0;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int tot=0;
int nxt[100001];
int to[100001];
int head[100001];
int degree[100001];
int f[100001];
void addedge(int u,int v)
{
	tot++;
	nxt[tot]=head[u];
	to[tot]=v;
	head[u]=tot;
}
int dfs(int ind)
{
	int i,v;
	if(head[ind]==0)
		f[ind]=0;
	if(f[ind]>=0)
		return f[ind];
	for(i=head[ind];i;i=nxt[i])
	{
		v=to[i];
		f[ind]=max(f[ind],dfs(v)+1);
	}
}
int main()
{
	memset(f,0xff,sizeof(f));
	int u,v,n,m,i,maxn;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d %d",&u,&v);
		addedge(u,v);
		degree[v]++;
	}
	for(i=1;i<=n;i++)
	{
		//if(degree[i]==0)
			dfs(i);
	}
	maxn=0;
	for(i=1;i<=n;i++)
		maxn=max(maxn,f[i]);
	printf("%d",maxn);
	return 0;
}

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

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n) {
        while(1) {
            if ( a[i] % 2 == 1 ) break;
            a[i] /= 2;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main () {

	


	while(1){
		int x[200]={};
	int y[200]={};

	int input_x = 0;
	int input_y = 0;

	int present_x = 0;
	int present_y = 0;

	int max_x_r=0;
	int max_x_l=0;
	int max_y_u =0;
	int max_y_d=0;

	int result_x=0;
	int result_y=0;

	int der_x=0;
	int der_y=0;

	int left =0;
	int down =1;
	int right = 2;
	int up =3;
	int i=0;

	int dataset = 0;
		scanf("%d",&dataset);

		if ( dataset == 0){
			break;
		}
		//???????????¨???
		x[0] = 0;
		y[0] = 0;

		
		
			for ( i =1; i < dataset; i++){
				scanf("%d %d",&input_x,&input_y);

				//?????¨??????
				present_x = x[input_x];
				present_y = y[input_x];

				if( input_y == 0){
					der_x = -1;
				}
				else if ( input_y == 1){
					der_y = -1;
				}
				else if ( input_y == 2){
					der_x = 1;
				}
				else if ( input_y == 3){
					der_y = 1;
				}

				//??´??°
				x[i] = der_x + present_x;
				y[i] = der_y + present_y;
				der_x = 0;
				der_y = 0;

				//printf("xi:%d yi:%d\n",x[i],y[i] );

				if ( max_x_r < x[i]){
					max_x_r = x[i];
				}
				if(max_x_l > x[i]){
					max_x_l = x[i];
				}
				if ( max_y_u < y[i]){
					max_y_u = y[i];
				}
				if ( max_y_d > y[i]){
					max_y_d = y[i];
				}
			}
			result_x = max_x_r - (max_x_l) + 1;
			result_y = max_y_u - (max_y_d) + 1;
			printf("%d %d\n",result_x,result_y );
			result_x=0;
			result_y=0;

	}

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cctype>
#include <ctime>
#include <bitset>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define eps 1e-9

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

const int INF = 0x7fffffff;
int n, m, k;
bool flag = false;

int main() {
#ifdef __AiR_H
    freopen("B.in", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif // __AiR_H
    scanf("%d %d %d", &n, &m, &k);
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            if (i * m + n * j - i * j * 2 == k) { flag = true; break; }
        }
        if (flag) { break; }
    }
    if (flag) { printf("Yes\n"); } else { printf("No\n"); }
#ifdef __AiR_H
    printf("Time used = %.2fs\n", (double)clock() / CLOCKS_PER_SEC);
#endif // __AiR_H
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const int INFI = 1000000000;
 const ll INFL = (1LL << 60);

 int main() {
   int N, K; cin >> N >> K;
   ll ans = 0;

   for (int b = 1; b <= N; b++) {
     int p = N / b, r = N % b;
     ans += p * max(0, b - K) + max(0, r - K + 1);
   }
   if (K == 0) ans -= N;
   
   cout << ans << endl;
 }


Measured memory_bytes: 256
using System;
class program{
  static void Main(){
    string s = Console.ReadLine();
    string h = Console.ReadLine();
    int ct = 0;
   	for(int i = 0 ;i < s.Length;i++){
      if(s[i] != h[i]) ct++;
    }
    Console.WriteLine(ct);
  }
}

Measured memory_bytes: 27520
#include<bits/stdc++.h>
using namespace std;
static const int base=700000000;
int main(){
  int N;cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    int x;cin>>x;x--;
    A.at(x)=base+i;
  }vector<int>a(N);
  vector<int>b(N);
  for(int i=0;i<N;i++){
  a.at(i)=30000*i+1;
    b.at(i)=A.at(i)-a.at(i);
  }for(int i=0;i<N-1;i++)
    cout<<a.at(i)<<" ";cout<<a.at(N-1)<<endl;
  for(int i=0;i<N-1;i++)
    cout<<b.at(i)<<" ";cout<<b.at(N-1)<<endl;
  return 0;
}

Measured memory_bytes: 3800
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    while(true){
        int n,m;
        cin >> n >> m;
        if(n==0&&m==0)break;
        int a[1000];
        for(int i=0; i<n; i++){
            cin >> a[i];
        }
        int ans = -1;
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                if(a[i]+a[j]<=m)
                    ans=max(ans,a[i]+a[j]);
            }
        }
        if(ans==-1)
            cout << "NONE" << endl;
        else 
            cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
package main

import "fmt"

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

func sum(x int) int {
	s := 0
	for x > 0 {
		s += x % 10
		x /= 10
	}
	return s
}

func main() {
	var n int
	fmt.Scan(&n)
	ans := 1000000000
	for i := 1; i <= n/2; i++ {
		j := n - i
		s := sum(i) + sum(j)
		ans = min(ans, s)
	}
	fmt.Println(ans)
}


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

#define PI acosl(-1)
using namespace std;

int main() {
  double ans,rad,deg,A,B;
  double H,M;
  cin >> A >> B >> H >> M;
  H = 30*H + 0.5*M;
  M *= 6;
  if(H > M){
    deg = H - M;
  }
  else{
    deg = M - H;
  }
  /*
  rad = cos((deg*PI)/180.0);
  ans = A*A + B*B - rad*2*A*B;
  cout << setprecision(20) << sqrt(ans) << endl;
  */
  rad = cos((deg*M_PI)/180.0);
  ans = A*A + B*B - rad*2*A*B;
  cout << setprecision(10) << sqrt(ans) << endl;
  return 0;
}


Measured memory_bytes: 4048
h,w=map(int,input().split())
if w%2==0:
    if h>1:
        print(h*w//2)
    else:
        print(1)
else:
    if h%2==0:
        if w>1:
            print((h*w)//2)
        else:
            print(1)
    elif h%2!=0:
        if w>=2 and h>=2:
            print((h*w+1)//2)
        else:
            print(1)

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

#define mx 105
#define ll long long

int ar[mx][mx];
char ch[mx][mx];

int n,m,k,ii;

void solve()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%s",ch[i]+1);

    if(ch[1][1]=='#')ar[1][1]=1;

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(i==1 && j==1)continue;
            ar[i][j]=100005;
           // cout<<ar[i][j]<<" "<<ch[i][j]<<endl;
            if(i>1)
            {
                int val=0;
                if(ch[i-1][j]!=ch[i][j] && ch[i][j]=='#')val++;
                ar[i][j]=ar[i-1][j]+val;
            }
           // cout<<ar[i][j]<<endl;
            if(j>1)
            {
                int val=0;
                if(ch[i][j-1]!=ch[i][j] && ch[i][j]=='#')val++;

                ar[i][j]=min(ar[i][j],ar[i][j-1]+val);
            }
            //if(j>1)cout<<(ch[i][j]=='#')<<" "<<ar[i][j-1]<<endl;
           // cout<<ar[i][j]<<endl;
        }
    }
    printf("%d\n",ar[n][m]);
}

int main()
{
   //freopen("in.txt","r",stdin);
   //freopen("out.txt","w",stdout);
   int t=1;
  // scanf("%d",&t);
   while(t--)solve();
   return 0;
}


Measured memory_bytes: 3784
import scala.io.{StdIn => in}

object Main extends App {
  var Array(a, b) = in.readLine.split(" ").map(_.toInt)
  val res = if(a > b) a else b
  if(res == a) a -= 1 else b -= 1
  val ans = res + (if(a > b) a else b)
  println(ans)
}

Measured memory_bytes: 25536
#include<cstdio>
#include<cmath>
using  namespace  std;
typedef  long  long  LL;
LL  top;
bool  pd1(LL  x)
{
	if(x==1)return  true;
	for(LL  i=sqrt(x);i>=2;i--)
	{
		if(x%i==0)return  false;
	}
	return  true;
}
void  pd2(LL  x,LL  y)
{
	x>y?x^=y^=x^=y:0;
	LL  ed=sqrt(x);
	for(LL  i=1;i<=ed;i++)
	{
		if(x%i==0)
		{
			if(y%i==0  &&  pd1(i)==1)top++;
			if(y%(x/i)==0  &&  i*i!=x  &&  pd1(x/i)==1)top++;
		}
	}
}
LL  n,m;
int  main()
{
	scanf("%lld%lld",&n,&m);
	pd2(n,m);
	printf("%lld\n",top);
	return  0;
}

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

int main()
{
	int r, c;
	cin >> r >> c;
	vector<vector<int>> m(r, vector<int>(c));
	for (auto &v : m)
		for (auto &x : v)
			cin >> x;
	for (auto &v : m)
		v.push_back(accumulate(v.begin(), v.end(), 0));
	m.push_back(vector<int>(c + 1));
	for (int j = 0; j <= c; j++)
		m.back()[j] = accumulate(m.begin(), m.end(), 0, [j](int s, auto v) {return s + v[j]; });
	for (int i = 0; i <= r; i++)
		for (int j = 0; j <= c; j++)
			cout << m[i][j] << (j == c ? '\n' : ' ');
}


Measured memory_bytes: 3216
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		if(S.equals("SUN")) {
			System.out.println('7');
		}else if(S.equals("MON")) {
			System.out.println(6);
		}else if(S.equals("TUE")) {
			System.out.println(5);
		}else if(S.equals("WED")) {
			System.out.println(4);
		}else if(S.equals("THU")) {
			System.out.println(3);
		}else if(S.equals("FRI")) {
			System.out.println(2);
		}else if(S.equals("SAT")) {
			System.out.println(1);
		}else {
			System.out.println(S);
		}
		sc.close();
	}
}


Measured memory_bytes: 21716
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }

        static int[] A;
        static long[,] dp;
        static readonly long Mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            A = Sarray();
            dp = new long[N + 1, N + 1];
            for (var i = 1; i < N; ++i)
            {
                for (var j = 0; j < N - i; ++j)
                {
                    long sum = 0;
                    long min = long.MaxValue;
                    for (var k = j; k <= i + j; ++k)
                        sum += A[k];
                    for (var k = j; k < i + j; ++k)
                        min = Min(min, dp[j, k] + dp[k + 1, i + j]);
                    dp[j, i + j] = min + sum;
                }
            }
            WriteLine(dp[0, N - 1]);
        }
    }
}

Measured memory_bytes: 14656
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int x = sc.nextInt();
		
		int d = 0;
		int cnt = 1;
		
		for (int i = 1; i <= n; i++) {
			int l = sc.nextInt();
			d += l;
			if (d <= x) {
				cnt++;
			} else {
				break;
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	}

}


Measured memory_bytes: 23764
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli a, b;
    cin >> a >> b;
    Yes((a * b) % 2 != 0);
}

Measured memory_bytes: 3616