akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  ll a,b,c; cin>>a>>b>>c;
  ll ans=b/c-a/c;
  if(a%c==0)
  ans++;

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


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) throws IOException {
        Scan sc = new Scan();
        int n = sc.scanInt();
        Sol sol = new Sol(n);
        for(int i = 0; i < n; ++i)
            sol.arr[i] = sc.scanInt();
        sol.sol();
    }
}

class Sol {
    int n;
    int[] arr, res;
    
    Sol(int n){
        this.n = n;
        arr = new int[n];
        res = new int[n];
    }
    
    void sol() {
        res[0] = 0;
        for(int i = 1; i < n; ++i){
            int prev = res[i-1] +  Math.abs(arr[i] - arr[i-1]);
            int pprev = i > 1 ? res[i-2] + Math.abs(arr[i] - arr[i-2]) : Integer.MAX_VALUE;
            res[i] = Math.min(prev, pprev);
        }
        System.out.println(res[n-1]);
    }
}

class Scan {
    private byte[] buf=new byte[1024];
    private int index;
    private InputStream in;
    private int total;
    public Scan()
    {
        in=System.in;
    }
    public int scan()throws IOException
    {
        if(total<0)
        throw new InputMismatchException();
        if(index>=total)
        {
            index=0;
            total=in.read(buf);
            if(total<=0)
            return -1;
        }
        return buf[index++];
    }
    public int scanInt()throws IOException
    {
        int integer=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n))
        {
            if(n>='0'&&n<='9')
            {
                integer*=10;
                integer+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        return neg*integer;
    }
    public double scanDouble()throws IOException
    {
        double doub=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n)&&n!='.')
        {
            if(n>='0'&&n<='9')
            {
                doub*=10;
                doub+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        if(n=='.')
        {
            n=scan();
            double temp=1;
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    temp/=10;
                    doub+=(n-'0')*temp;
                    n=scan();
                }
                else throw new InputMismatchException();
            }
        }
        return doub*neg;
    }
    public String scanString()throws IOException
    {
        StringBuilder sb=new StringBuilder();
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        while(!isWhiteSpace(n))
        {
            sb.append((char)n);
            n=scan();
        }
        return sb.toString();
    }
    private boolean isWhiteSpace(int n)
    {
        if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
        return true;
        return false;
    }
}

Measured memory_bytes: 22868
import java.util.*;
import java.math.*;

public class Main {

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

    for (int i = 0; i < n; i++) {
      x[i] = sc.nextInt();
    }

    int sum = 0;

    for (int i = 0; i < n; i++) {
      if (x[i] < Math.abs(k-x[i])) {
        sum += x[i]*2;
      } else {
        sum += Math.abs(k-x[i])*2;
      }
    }

    System.out.println(sum);

  }

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define EPS 1e-10
typedef pair<double,int> P;
struct Point{double x,y,r;};
int n;
Point p[100010];

double cl(int i,int j,double k=0.0){
  return sqrt(pow(p[i].x-p[j].x,2)+pow(p[i].y-p[j].y,2))-(p[i].r+p[j].r+k*2.0);
}

int solve(double k){
  
  vector<P> events;
  
  for(int i=0;i<n;i++){
    double x1=p[i].x-p[i].r-k;
    double x2=p[i].x+p[i].r+k;
    events.push_back(P(x1,i));
    events.push_back(P(x2,i+n));
  }
  sort(events.begin(),events.end());

  set<P> outers;
  for(int i=0;i<events.size();i++){
    int id=events[i].second%n;
    if(events[i].second<n){
      set<P>::iterator it = outers.lower_bound(P(p[id].y,id));
      if(it!=outers.end()&&cl(id,it->second,k)<=0)return 0;
      if(it!=outers.begin()&&cl(id,(--it)->second,k)<=0)return 0;
      outers.insert(P(p[id].y,id));
    }else{
      outers.erase(P(p[id].y,id));
    }
  }
  return 1;
}

int main(){
  
  while(cin>>n,n){

    for(int i=0;i<n;i++){
      cin>>p[i].r>>p[i].x>>p[i].y;
    }

    double ok=0,ng=cl(0,1),mid;
    while(ng-ok>EPS){
      mid=(ok+ng)/2.0;
      if(solve(mid))ok=mid;
      else ng=mid;
    }
  
    printf("%.10lf\n",ok*2.0);
  }
  return 0;
}



Measured memory_bytes: 14704
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

bool is_prime(int a) {
    bool ok = true;
    if (a == 1) return false;
    if (a == 2) return true;
    else {
        for (int i = 2; i * i <= a; i++) {
            if (a % i == 0) ok = false;
        }
        return ok;
    }
}

int main() {
    //エラストテネスの篩
    int mx = 55555;
    vector<bool> prime(mx+1,true);
    prime[1] = false;
    for (int i = 2; i <= mx; i++) {
        if (prime[i]) {
            for (int j = 2*i; j <= mx; j += i) prime[j] = false;
        }
    }
    int n; cin >> n;
    vint x;
    for (int i = 2; i <= mx; i++) {
        if (i % 5 != 1) continue;
        if (prime[i]) {
            x.push_back(i);
        }
    }
    rep(i,n) {
        if (i == n-1) cout << x[i] << endl;
        else cout << x[i] << " ";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000009
using namespace std;
signed main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int ans;
    int n,k;
    cin>>n>>k;
    int d = 2*k+1;
    if(n%d==0)
    ans = n/d;
    else
    ans=(n/d) + 1;
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int N,M;
    ll X;
    cin >> N >> M;
    cin >> X;
    int price;
    ll min_price = 10000000;
    int prices[20] = {0};//各値段が入っている
    int x;
    vector<ll> s[20]; // 理解度が入っている
    REP(i,N){
        cin>>prices[i];
        REP(i,M){
            cin >> x;
            s[i].push_back(x);
        }
    }
    REP(i,1 << N){ //すべての組み合わせを試す
        int mastery[20] = {0}; //理解度格納行列
        price = 0;
        //cout << bitset<8>(i) << endl;
        REP(k, N){//1~Nのk番目のものを買ったか確かめている
            if((i >> k)&1){ //もしk番目の物を購入したら
                price += prices[k];
                REP(l, M){ //すべての理解度を足す
                    mastery[l] += s[l][k];
                    //cout << s[l][k] << " ";
                }
                //cout << endl;
            }
            //cout << "合計" << endl;
            //REP(l,M) cout << mastery[l] << " ";
            //cout << endl;
        }
        bool flag = true;
        REP(k,M){//理解度が全て満たしたか確かめる
            if(mastery[k] < X){
                flag = false;
                break;
            }
        }
        if(flag){
            //cout << "この時理解度は条件を満たしており、price = " << price << endl;
            if(price < min_price){
                min_price = price;
            }
        }
        //cout << endl;
    }
    if (min_price == 10000000){
        fin(-1);
    }else{
        fin(min_price);
    }
    return 0;
}

Measured memory_bytes: 3196
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n, m = MAP()
arr = [-1 for _ in range(n)]
if n == 1:
    ans = -1
    for _ in range(m):
        s, c = MAP()
        if ans == -1 or ans == c:
            ans = c
        else:
            print(-1)
            exit()
    if ans == -1:
        ans = 0
    print(ans)
    exit()
for _ in range(m):
    s, c = MAP()
    if s == 1 and c == 0:
        print(-1)
        exit()
    if arr[s - 1] == -1 or arr[s - 1] == c:
        arr[s - 1] = c
    else:
        print(-1)
        exit()
for i in range(n):
    if arr[i] == -1 and i == 0:
        arr[i] = 1
    if arr[i] == -1 and i > 0:
        arr[i] = 0
    arr[i] = str(arr[i])
print(''.join(arr))

Measured memory_bytes: 59628
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef unsigned long long ull;

int main(){
	ios_base::sync_with_stdio(false);
	while(true){
		int n, m, q;
		cin >> n >> m >> q;
		if(n == 0 && m == 0 && q == 0){ break; }
		vector<ull> masks(m, (1ull << n) - 1);
		string state(m, '0');
		for(int i = 0; i < q; ++i){
			string s, t;
			cin >> s >> t;
			ull mask = 0ull;
			for(int j = 0; j < n; ++j){
				if(s[j] == '1'){ mask |= (1ull << j); }
			}
			for(int j = 0; j < m; ++j){
				if(state[j] == t[j]){
					masks[j] &= ~mask;
				}else{
					masks[j] &= mask;
				}
				state[j] = t[j];
			}
		}
		for(int i = 0; i < m; ++i){
			if(__builtin_popcountll(masks[i]) >= 2){
				cout << "?";
			}else{
				const int p = __builtin_ctzll(masks[i]);
				if(p < 10){
					cout << static_cast<char>(p + '0');
				}else{
					cout << static_cast<char>(p - 10 + 'A');
				}
			}
		}
		cout << endl;
	}
	return 0;
}

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

int main() {

  long long X;
  cin >> X;

  bool judge = true;
  while(true){
    for(long long i=2;i<X;i++){
      if(X%i == 0){
        judge = false;
        break;
      }
      if(i == X-1){
        judge = true;
      }
    }
    if(judge){
      cout << X << endl;
      return 0;
    }

    X++;

  }


}


Measured memory_bytes: 256
package main

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

func main() {
	scanInit()

	n := nextInt()
	t := nextInt()
	tl := make([]int, n)

	sum := 0
	tl[0] = nextInt()
	for i := 1; i < n; i++ {
		tl[i] = nextInt()
		sum += min(t, tl[i]-tl[i-1])
	}
	sum += t
	fmt.Println(sum)
}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define TCT template<class T>
TCT bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
TCT bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
#define INF (1000 * 1000 * 1000)
using namespace std;

int N, K;
int *h;
int *dp;

int abs(int a, int b){if(a>b) return a-b; else return b-a;} // for C++14 or earlier
void Solve()
{
	int i;
	for(i = 0; i < N - K; ++i){
		for (int j = 1; j <= K; ++j){
			chmin(dp[i + j], dp[i] + abs(h[i], h[i + j]));
		}
	}
	for (; i < N; ++i){
		for (int j = i + 1; j < N; ++j){
			chmin(dp[j], dp[i] + abs(h[i], h[j]));
		}
//		for( int d = 0; d < N; ++d)	cout << d << " = " << dp[d] << ", ";
	}
//	puts("");
	cout << dp[N - 1] << endl;
}

void Init()
{
	cin >> N >> K;
	h = new int[N];
	for (int i = 0; i < N; ++i) cin >> h[i];
	dp = new int[N];
	dp[0] = 0;
	for (int i = 1; i < N; ++i) dp[i] = INF;
}

void Clean(){delete[] dp; delete[] h;}

int main()
{
	Init();
	Solve();
	Clean();
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
  int main(void){
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    if(a >= b){
      printf("delicious\n");
    }else if(b-a <= x){
      printf("safe\n");
    }else{
      printf("dangerous\n");
    }
  }

Measured memory_bytes: 128
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define rev reverse
#define all(x) x.begin(), x.end()
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define endl '\n'
#define ull unsigned long long
#define sz(x) (int)x.size()

template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll inf = 1e9+7;
const ll N = 1e5+1;
const ll mod = 1e9+7;
const ll P = 31;

ll h[N];
bool used[N];
int main() {
    IOS
    ll n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    for(int i = 1; i <= m; i++) {
        ll x, y;
        cin >> x >> y;
        if(h[x] <= h[y]) {
            used[x] = 1;
        }
        if(h[x] >= h[y]) {
            used[y] = 1;
        }
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        if(used[i] == 0) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4572
fun main(args: Array<String>) = println(run {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val lr = (1..m).map { readLine()!!.split(" ").map { it.toInt() } }

    val imos = IntArray(n+2)
    lr.forEach {
        val (l, r) = it
        imos[l]++
        imos[r+1]--
    }
    imos.accumulated().count { it == m }
})

fun IntArray.accumulated(): List<Int> { var sum = 0; return this.map { sum += it; sum } }


Measured memory_bytes: 62840
#include <stdio.h>
     
    int main (void)
    {
      char s[3];
      int i;
      int cnt;
      
      scanf("%s",s);
      
     	for (i=0;i<3;i++)
        {if (s[i] == '1')
          cnt++;
        } 
   printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll N, W;
ll w[110], v[110];
ll dp[110][110][500];

int main() {
	cin >> N >> W;
	ll buf = 0;
	rep(i, N) {
		cin >> w[i] >> v[i];
		if (i == 0)buf = w[i];
		w[i] -= buf;
	}
	rep(i, N) {
		rep(j, 110) {
			rep(k, 500) {
				ll ww = buf*j + k;
				ww += buf + w[i];
				ll nj = ww / buf;
				ll nk = ww - nj*buf;
				if (ww <= W) {
					dp[i + 1][nj][nk]
						= max(dp[i + 1][nj][nk],
							dp[i][j][k] + v[i]);
				}
				dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
			}
		}
	}
	ll ans = 0;
	rep(i, 110) {
		rep(j, 500) {
			if (i*buf + j <= W) {
				ans = max(ans, dp[N][i][j]);
			}
		}
	}
	//rep(k, N + 1) {
	//	rep(i, 10) {
	//		rep(j, 3) {
	//			cout << dp[k][i][j] << " ";

	//		}
	//		cout << endl;
	//	}
	//	cout << endl;
	//}
	cout << ans << endl;
}

Measured memory_bytes: 45056
N, M = map(int,input().split())
graph = [[] for n in range(N+1)]
for _ in range(M):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
# 入力例 1の場合
# graph : [[], [2], [1, 3, 4], [2, 4], [3, 2]] graphのインデックスが部屋名
# graph[2] : 部屋2は、1,3,4と繋がっている
# graph[4] : 部屋4は、3,2と繋がっている

#次に探索をする部屋番号をストックしておく。まずは部屋番号1から探索を始めるので、１を入れておく
q = [1]
#ans[部屋番号]=道標が指す部屋番号とする。探索していない部屋を'No'として表す。
ans = ['No' for n in range(N+1)]
ans[0] = 1
ans[1] = 1 #ans[1]
while q: #qの中身がなくなったらbreak
    # 現在地を指定（キューの先頭）するとともに、qから先頭を削除する。　一番最初の現在地は1になる。
    now = q.pop(0)
    for edge in graph[now]:
        if ans[edge] != 'No':
            continue
        ans[edge] = now
        q.append(edge)

if not 'No' in ans:
    print('Yes')
    for n in range(2,N+1):
        print(ans[n])
else:
    print('No')





Measured memory_bytes: 33900
a = list(input())
b = []

for i in range(len(a)):
  if a[i] == "0":
    b.append("0")
  elif a[i] == "1":
    b.append("1")
  elif a[i] == "B":
    if b == []:
      b = []
    else:
      del b[-1]
    
print("".join(b))

Measured memory_bytes: 3060
def low_elements(n, arr):
    min = arr[0]
    count = 0
    for i in range(n):
        if min >= arr[i]:
            min = arr[i]
            count += 1
    return count

if __name__ == "__main__":
    n = int(input())
    arr = list(map(int, input().split(' ')))
    print(low_elements(n, arr))

Measured memory_bytes: 24744
def partial_max(L):
    n=len(L)
    max=-100000000000
    max_i=0
    for i in range(n):
       if max < sum(L[:i+1]):
           max=sum(L[:i+1])
           max_i=i
    max = -100000000000
    max_j=0
    for j in range(n):
       if max < sum(L[j:]):
           max=sum(L[j:])
           max_j=j

    if max_i >= max_j:
        return sum(L[max_j:max_i+1])
    elif sum(L[max_j:])>sum(L[:max_i+1]):
        return sum(L[max_j:])
    else:
        return sum(L[:max_i+1])
n=int(input())
A=[]
while n!=0:
    A.append([int(input()) for i in range(n)])
    n=int(input())
for i in range(len(A)):
    print(partial_max(A[i]))

Measured memory_bytes: 7820
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
long long n,m,i,j,f[5005][5005],sum;
int main(){
	scanf("%lld%lld",&n,&m);
	f[0][m]=1;
	for(i=1;i<=n;i++)
		for(sum=0,j=m;j>=1;j--){
			f[i][j]=(sum*j+f[i-1][j]*(j+1))%mo;
			sum=(sum*2+f[i-1][j])%mo;
		}
	for(i=1,sum=0;i<=m;i++)
		sum=(sum+f[n][i])%mo;
	printf("%lld\n",sum);
}

Measured memory_bytes: 199308
#include<iostream>

using namespace std;

int main(){
 int n;
  cin >> n;
  
  if(n<105) cout << 0 << endl;
  else if(n<135) cout << 1 << endl;
  else if(n<165) cout << 2 << endl;
  else if(n<189) cout << 3 << endl;
  else if(n<195) cout << 4 << endl;
  else cout << 5 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <queue>
using namespace std;

#define ll long long
typedef pair<ll, ll> P;

int main(){
    ll a, b, N, inf = 1000000000000000000LL;;
    cin >> N;
    vector<ll> dist1(N), dist2(N);
    vector< set<ll> > E(N);
    P p;
    queue<P> pairs;
    for(int i = 0; i < N-1; i++){
        cin >> a >> b;
        a--, b--;
        E[a].insert(b);
        E[b].insert(a);
    }
    for(int i = 0; i < N; i++){
        dist1[i] = inf;
        dist2[i] = inf;
    }
    dist1[0] = 0;
    dist2[N-1] = 0;

    //cul dist1
    for(auto i: E[0]){
        // cout << i << endl;
        pairs.push(make_pair(i,1));
    }
    while(pairs.size()){
        p = pairs.front();
        pairs.pop();
        int d = p.second;
        int n = p.first;
        if(dist1[n] == inf){
            dist1[n] = d;
            for(auto i: E[n]) pairs.push(make_pair(i, d+1));
        }
    }

    // cul dist2
    for(auto i: E[N-1]){
        pairs.push(make_pair(i,1));
    }
    while(pairs.size()){
        p = pairs.front();
        pairs.pop();
        int d = p.second;
        int n = p.first;
        if(dist2[n] == inf){
            dist2[n] = d;
            for(auto i: E[n]) pairs.push(make_pair(i,d+1));
        }
    }
    
    int f=0, s=0;
    for(int i = 0; i < N; i++){
        if(dist1[i] <= dist2[i]) f++;
        else s++;
    }
    if(f>s){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
}

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

#define int long long

using namespace std;

int n, m;
priority_queue<int> pq;
signed main() {
  cin >> n >> m;
  for(int i = 0; i < n; i++) {
    int manchukuo;
    cin >> manchukuo;
    pq.push(manchukuo);
  }
  for(int i = 0; i < m; i++) {
    int unit731 = pq.top();
    pq.pop();
    pq.push(unit731/2);
  }
  int nanjing1937 = 0;
  while(!pq.empty()) {
    nanjing1937 += pq.top();
    pq.pop();
  }
  cout << nanjing1937 << endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <cstring>

using namespace std;

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

    int n, k, q;
    cin >> n >> k >> q;
    int c[n];
    memset(c, 0, sizeof(c));
    for (int i = 0; i < q; i++) {
        int a;
        cin >> a;
        c[--a]++;
    }

    for (int i = 0; i < n; i++) {
        cout << (q - c[i] < k ? "Yes" : "No") << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
int ansH, ansW;
int H, W;
void solve() {
  int d = INF;
  ansH = 0, ansW = 0;
  for (int h = 1; h <= 150; h++) {
    for (int w = h+1; w <= 150; w++) {
      if ((h*h+w*w) == (H*H+W*W) && h>H) {
        ansH = h;
        ansW = w;
        return;
      } else if ((H*H+W*W) < (h*h+w*w) && (h*h+w*w) < d) {
        d = h*h+w*w;
        ansH = h;
        ansW = w;
      }
    }
  }
  return;
}

signed main() {
  while (cin>>H>>W, H+W!=0) {
    solve();
    cout << ansH << " " << ansW << endl;
  }
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>

#include <iomanip>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
// queue: first in first out
// stack: first in last out
typedef long long ll;

const long long int MOD = 1e9+7;
const ll INF = 1e17;
const ll NUM = 1e5+1;
// ll dp[100005][13];
ll dp[10005];

ll Query[NUM];

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

signed main(void) {
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << a[K-1] << endl;
}


Measured memory_bytes: 256
S = list(input())

Q = int(input())

state = 0
s = []
e = []

for loop in range(Q):

    T = input()

    if T == "1":
        state ^= 1
    else:

        t,F,C = T.split()
        F = int(F)
        

        if state == 0 and F == 1:
            s.append(C)
        elif state == 0 and F == 2:
            e.append(C)
        elif F == 1:
            e.append(C)
        else:
            s.append(C)

s.reverse()
ans = s+S+e
if state == 1:
    ans.reverse()

print ("".join(ans))
    


Measured memory_bytes: 79096
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : August 29, 2020 6:00 PM
 *    Problem Name  : D - Friends
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc177/tasks/abc177_d
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

int parent[200005], sz[200005];

void makeset(int n)
{
    for(int i=0; i<n; i++){
        parent[i] = i;
        sz[i] = 1;
    }
}

int find_par(int f)
{
    if( f == parent[f] )
        return f;
    return parent[f] = find_par(parent[f]);
}

void join(int a, int b)
{
    int x = find_par(a);
    int y = find_par(b);

    if(x != y){
        parent[y] = x;
        sz[x] += sz[y];
    }
}

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

    int n,m;
    cin >> n >> m;

    makeset(n);

    for(int i=0; i<m; i++){
        int u,v;
        cin >> u >> v;
        join(u,v);
    }

    cout << *max_element(sz,sz+n) << endl;

    return 0 ;
}


Measured memory_bytes: 5108
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string.h>
#include<queue>
#include<map>
#define maxn 3005
#define mod 1000000007
#define INF 0x3f3f3f3f
#define PI 3.1415926
using namespace std;
typedef long long ll;

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

int main(){
	//freopen("Test.txt", "r", stdin);
	int n, m;
	string s, t;
	scanf("%d %d", &n, &m);
	cin >> s >> t;
	int l = gcd(n, m);
	bool is = true;
	for(int i = 0, j = 0; i < n && j < m ; i += n / l, j += m / l){
		if(s[i] != t[j]){
			is= false;
			break;
		}
	}
	if(is) printf("%lld\n", (ll)n * m / l) ;
	else{
		printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 512
n = int(input())
A = list(map(int, input().split()))
# print(n)
# print(A)

dmax = 0
for i in range(n-1):
    for j in range(i+1,n):
        # print(i,j)
        d = abs(A[i]-A[j])
        dmax = max(dmax, d)
        # print('Ai',A[i],'Aj',A[j],'d',d,'dmax',dmax)
        # print('---')

print(dmax)


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

int main() {
    string s;
    cin>>s;
    int S=s.size(),ans=642;

    for(int i=0; i<S-2; i++){
        ans=min(abs(753-((s.at(i)-48)*100)-((s.at(i+1)-48)*10)-(s.at(i+2)-48)),ans);
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin >> s >> t;
  
  vector<int>A(s.size());
  for (int i = 0; i < s.size(); i++) {
    A.at(i) = s.at(i) - '0';
  }
  sort(A.begin(), A.end());
    
  vector<int>B(t.size());
  for (int i = 0; i < t.size(); i++) {
    B.at(i) = t.at(i) - '0';
  }
  sort(B.begin(), B.end());
  reverse(B.begin(), B.end());
  
  for (int i = 0; i < min(t.size(),s.size()); i++) {
    if (A.at(i) < B.at(i)){
      cout << "Yes" << endl;
      return 0;
    }
    else if (A.at(i) > B.at(i)){
      cout << "No" << endl;
      return 0;
    }
  }
  
  if (s.size() < t.size()){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

  

Measured memory_bytes: 3632
a,s[9999],t[9999];main(i,n){for(;n=~scanf("%d,%*d%*c%[\n]",&a,&n);n+2?i=0:0)i?s[a]++:s[a]&&t[a]++;for(;a=++i<9999;)t[i]&&printf("%d %d\n",i,s[i]+t[i]);}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<vector<int> >  vec2int;
typedef vector<ll >     vecll;
typedef vector<string > vecstr;
typedef vector<bool > vecbool;
typedef vector<bool > vecbool;
////////////////////////////////////////////////
int main()
{
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if(u == s){
    a --;
  }else{
    b --;
  }
  cout << a << " " << b << endl;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  if (A <= 8 && B <= 8) {
      cout << "Yay!" << endl;
  }
  else{
      cout << ":(" << endl;
  }
}


Measured memory_bytes: 256
class WeightedUnionFind:

    def __init__(self, n):
        self.parents = [i for i in range(n + 1)]
        self.weights = [0 for _ in range(n + 1)]
        self.ranks = [0 for _ in range(n + 1)]

    def find_root(self, node):
        parent_node = self.parents[node]
        if node == parent_node:
            return node
        else:
            root_node = self.find_root(parent_node)
            # reduction
            self.parents[node] = root_node
            self.weights[node] += self.weights[parent_node]
            return root_node

    def union(self, one, other, weight):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        if one_root == other_root:
            return
        one_rank = self.ranks[one_root]
        other_rank = self.ranks[other_root]
        diff_weight = weight + self.weights[one] - self.weights[other]
        if one_rank < other_rank:
            self.parents[one_root] = other_root
            # modify weight s.t. weight(one) + weight = weight(other)
            self.weights[one_root] -= diff_weight
        else:
            self.parents[other_root] = one_root
            # modify weight s.t. weight(one) + weight = weight(other)
            self.weights[other_root] += diff_weight
            if one_rank == other_rank:
                self.ranks[other_root] += 1

    def is_same_group(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        return one_root == other_root

    def diff(self, one, other):
        if not self.is_same_group(one, other):
            return None
        return self.weights[other] - self.weights[one]


def main():
    N, M = list(map(int, input().split(' ')))
    tree = WeightedUnionFind(N)
    for _ in range(M):
        L, R, D = list(map(int, input().split(' ')))
        d = tree.diff(L, R)
        if d is None:
            tree.union(L, R, D)
            continue
        # print(tree.parents)
        # print(tree.weights)
        if d != D:
            print('No')
            exit(0)
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9900
#include <iostream>
//#include <algorithm>
//#include <cmath>
//#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int n;
    double ans;

    cin >> n;
    ans = double(n - n/2)/(double)n;
    cout << ans << endl;
}

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

int main(){
	int N,i,j,k;
	cin >> N;
	int A[100];

	for(i = 0; i < N; i++)
		cin >> A[i];

	for(i = 0; i < N - 1; i++)
		cout << A[i] << " ";
	cout << A[i++] << endl;

	for(i = 1; i < N; i++){
		j = i - 1;
		int key = A[i];
		while(j >= 0 && A[j] > key){
			A[j + 1] = A[j];
			A[j] = key;
			j--;
		}
		for(k = 0; k < N - 1; k++)
			cout << A[k] << " ";
		cout << A[k++] << endl;
	}
}

Measured memory_bytes: 1160
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll   long long
#define ld long double
#define endl '\n'
#define INF 10000000000000000
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;
const ll N = 3005;
const ll MOD = 10e8+7;
ll dp[N][N];
ll a[N];
int main()
{
 //freopen("input.txt","r",stdin);
 //  freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    cin>>n;
    for(ll i =1;i<=n;i++) {
        cin>>a[i];
    }
    for(ll l = n;l>=1;l--) {
        for(ll r = l;r<=n;r++) {
            if(l==r)
                dp[l][r]=a[l];
            else
                dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
        }
    }
    cout<<dp[1][n];
    // ������ ������

}


Measured memory_bytes: 70016
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
int main(){
    int n,k; cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(),h.end(),greater<int>());
    if(k>=n){
        cout << 0 << endl;
        return 0;
    }
    ll ans=0;
    for(int i=k;i<n;i++){
        ans+=h[i];
    }
    cout << ans << endl;
}



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

int n;
string s[100005];

long long choose2(int i)
{
	return ((long long) i) * (i - 1) / 2;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	//	cout << s[i] << endl;
	}
	sort(s, s + n);
	long long ans = 0;
	int i = 0;
	while (i < n) {
		int j = i + 1;
		while (s[i] == s[j])
			j++;
		ans += choose2(j - i);
		i = j;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7296
N = gets.to_i
D = ["3","5","7"]
def r(s)
  return 0 if s.to_i > N
  k = D.all?{ |d| s.include?(d) }
  (k ? 1 : 0) + D.reduce(0){ |a,b| a + r(b+s) }
end

p D.reduce(0){ |a,b| a + r(b) }

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

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

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 55;
const int MAXS = 2505;
LL cnt[MAXS][MAXN];

int n, a;

vector<int> vx;

int main() {
    memset(cnt, 0, sizeof cnt); cnt[0][0] = 1;

    GI(n); GI(a);

    FORN(i, n) {
        int x; GI(x);
        vx.PB(x);
    }

    FORN(i, n) {
        FORD(j, MAXS) {
            FORN(k, MAXN) {
                if (j - vx[i] >= 0 && k > 0) {
                    cnt[j][k] += cnt[j - vx[i]][k-1];
                }
            }
        }
    }

    LL res = 0;

    FOR1(j, MAXS-1) FORN(k, MAXN) {
        if (a * k == j) {
            res += cnt[j][k];
        }
    }

    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    string s;
    cin >> n >> s;
    vi cntE(n+1), cntW(n+1);
    rep(i, n) {
        cntE[i+1] = cntE[i] + (s[i] == 'E');
        cntW[i+1] = cntW[i] + (s[i] == 'W');
    }
    int ans = 1001001001;
    rep(i, n) {
        int now = cntW[i] + (cntE[n] - cntE[i+1]);
        chmin(ans, now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3092
import copy
n, m = [ int(v) for v in input().split() ]
connect_matrix = [[ 0 for i in range(n)] for j in range(n)]

for i in range(m):
    a, b = [ int(v)-1 for v in input().split() ]
    connect_matrix[a][b] += 1
    connect_matrix[b][a] += 1


one_path_list = [[0]]
for i in range(n-1):
    next_path_list = []

    for j in range(len(one_path_list)):

        next_point_list = [ k for k in range(n) if connect_matrix[one_path_list[j][-1]][k] == 1 and k not in one_path_list[j]]

        for k in range(len(next_point_list)):
            next_path_list.append(copy.deepcopy(one_path_list[j])+[next_point_list[k]])

    one_path_list = next_path_list 

print(len(one_path_list))

Measured memory_bytes: 49880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    if((a - b) % 2){
        ll mn = min(a - 1, n - b);
        if(mn == a - 1){
            cout << (b - (1 - a)) / 2;
        }else{
            cout << (2 * n + 1 - b - a) / 2;
        }
    }else{
        cout << (b - a) / 2;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int N;
    cin >> N;
    vint a(N);
    REP(i,N){
        cin >> a[i];
    }
    int ans = 0;
    REP(i,N){
        if(i%2==0 && a[i]%2!=0){
            ans++;
        }
    }
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





int main() {
  string a,b,c;
  cin>>a>>b>>c;

  cout << a[0]<<b[0]<<c[0] << endl;

}

Measured memory_bytes: 256
<?php
	
	fscanf(STDIN, "%d",$n);
	$array = explode(" ",trim(fgets(STDIN)));
	
	for($i=0;$i<$n;$i++){
		$array[$i] -= ($i+1);
	}

	//	swap to be small order  
	sort($array);
	
	if($n%2!=0){
		$me=$array[$n/2];
	}else{
		$me=($array[($n-1)/2] + $array[$n/2])/2;
	}
	
	$ans = 0;
	for($i=0;$i<$n;$i++){
		$ans += abs($array[$i]-$me);
	}
	echo $ans."\n";
	
?>

Measured memory_bytes: 23028
import sys
sys.setrecursionlimit(4100000)
n = int(input())
d = [int(i) for i in input().split()]
d.sort()
half = n//2
ans = 0
if n%2 == 0:
    if d[half] == d[half-1]:
        ans = 0
    else:
        ans = d[half]-d[half-1]
else:
    ans = 0
print(ans)

Measured memory_bytes: 14396
#include<iostream>
#include<cstdio>;
#include<utility>
using namespace std;



int W,N;
int w[1010],v[1010];

int dp[1010];
void init(){
	for(int i=0;i<1010;i++){
		w[i]=0;
		v[i]=0;
		dp[i]=0;
	}
}


pair<int,int> solve(){
	for(int i=0;i<N;i++){
		for(int j=1010;j--;){
			if(j-w[i]>=0){
				dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
			}
		}
	}
	int res=W;
	for(int i=W;i--;){
		if(dp[i]!=dp[i+1]){
			break;
		}else{
			res=i;
		}
	}
	return make_pair(dp[W],res);
}

int main(){
	int c=0;
	while(cin>>W,W!=0){
		c++;
		init();
		cin>>N;
		for(int i=0;i<N;i++){
			scanf(" %d,%d",&v[i],&w[i]);
		}
		
		
		cout<<"Case "<<c<<":"<<endl;
		pair<int,int> ans=solve();
		cout<<ans.first<<endl;
		cout<<ans.second<<endl;
	}
}

Measured memory_bytes: 1256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
#include <iterator>
using namespace std;

namespace {

}

int main()
{
	string s, s1, s2, s3;

	cin >> s;

	int count1 = 0;
	for (int i = 0; i < 3; i++){
		if (s[i] == '1'){
			++count1;
		}
	}

	cout << count1;

	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a;
    cin >> a;
    string b;
    ll ab = 0;
    cin >> b;
    ab = (b[0]-'0')*100 + (b[2]-'0')*10 + (b[3]-'0'); 
    ll ans = (a*ab)/100;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
def solve(X, Y, p, q, r):
    red_apples = sorted(p, reverse=True)[: X]
    green_apples = sorted(q, reverse=True)[: Y]
    return sum(sorted(red_apples + green_apples + r, reverse=True)[: X + Y])

if __name__ == '__main__':
    X, Y, A, B, C = map(int, input().split())
    p = list(map(int, input().split()))
    q = list(map(int, input().split()))
    r = list(map(int, input().split()))
    print(solve(X, Y, p, q, r))

Measured memory_bytes: 114796
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        int z = Integer.parseInt(sc.next());
        if (x % (y + z) >= z) {
            System.out.println(x / (y + z));
        } else {
            System.out.println(x / (y + z) - 1);
        }

    }
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
 
int main() {
  int n,i,j,k,max,sum;
  while(1){
    int max=-100000;
    cin>>n;
    int a[n];
    if (n==0) break;
    for (i=0;i<n;i++){
      cin>>a[i];
    }
    for (i=0;i<n;i++){
      sum=0;
      for (j=0;j<n-i;j++){
        sum=sum+a[i+j];
        if (max<sum) max=sum;
      }
    }
    cout<<max<<endl;
  }
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

ll check[110000];

int main() {
  ll n, x, m;
  cin >> n >> x >> m;
  if(x==0) {
    cout << 0 << endl;
    return 0;
  }
  vll v;
  ll cnt = 0LL;
  ll a = x;
  rep(i,m*2) {
    v.push_back(a);
    cnt += a;
    check[a] = true;
    a *= a;
    a %= m;
    if(check[a]) break;
    if(a==0) {
      cout << cnt << endl;
      return 0;
    }
  }
  if(a==x) {
    ll s = v.size();
    ll ans = 0LL;
    ll c = n - n%s;
    ll b = c/s;
    ans += cnt*b;
    rep(i,n%s) ans += v[i];
    cout << ans << endl;
  }
  else {
    ll ans = 0LL;
    bool swi = true;
    vll vv;
    ll vs = v.size();
    rep(i,vs) {
      if(v[i]==a) swi = false;
      if(swi) {
        ans += v[i];
        n--;
      }
      else vv.push_back(v[i]);
    }
    ll s = vv.size();
    ll sum = 0LL;
    rep(i,s) sum += vv[i];
    ll c = n - n%s;
    ll b = c/s;
    ans += sum*b;
    rep(i,n%s) ans += vv[i];
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 5080
#include<iostream>
using namespace std;
int main(){
    int H,W,i,j;
    while(true){
        cin>>H>>W;
        if(H == 0)break;
        for(i=1;i<=H;i++){
            if(i==1 or i==H){
                for(j=1;j<=W;j++){
                    cout<<"#";
                }
                cout<<endl;
            }else{
                for(j=1;j<=W;j++){
                    if(j==1 or j==W){
                        cout<<"#";
                    }else{
                        cout<<".";
                    }
                }
                cout<<endl;    
            }
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3088