akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#define INF 9999999.9999999
using namespace std;

int n,m,a,b;
int id[1000];
double x[1000],y[1000];
double t[1000][1000];

void init();
void input();
void make_table();
void dijkstra(int,int);
int change(int);
int main(){
  while(cin>>n&&n){
    init();
    input();
    make_table();
    for(int i=0;i<m;i++){
      cin>>a>>b;
      
      dijkstra(change(a),change(b));
    }
  }
  return 0;
}

void init(){
  for(int i=0;i<1000;i++){
    for(int j=0;j<1000;j++){
      t[i][j]=INF;
    }
  }
}

void input(){
  for(int i=0;i<n;i++){
    cin>>id[i]>>x[i]>>y[i];
  }
  cin>>m;
}

void make_table(){
  double a;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i==j)continue;
      a=sqrt(pow(x[i]-x[j],2.0)+pow(y[i]-y[j],2.0));

      if(a<=50.0)t[i][j]=a;
    }
  }

  /*
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(t[i][j]==INF)cout<<"-- ";
      else{
	if((int)t[i][j]<10)cout<<' ';
	cout<<(int)t[i][j]<<' ';
      }
    }
    cout<<endl;
  }
  */
}

void dijkstra(int S,int T){
  //cout<<"S T "<<S<<' '<<T<<endl;
  int pi[1000];
  int mini_no;
  bool vd[1000];
  double u[1000];
  double mini;
  

  for(int i=0;i<n;i++){
    vd[i]=false;
    u[i]=INF;
  }

  u[S]=0.0;
  pi[S]=-1;

  while(1){
    mini=INF;
    for(int i=0;i<n;i++){
      if(mini>u[i]&&vd[i]==false){
	mini=u[i];
	mini_no=i;
      }
    }

    if(mini==INF)break;
    vd[mini_no]=true;

    for(int i=0;i<n;i++){
      if(t[mini_no][i]==INF)continue;
      if(u[i]>u[mini_no]+t[mini_no][i]){
	u[i]=u[mini_no]+t[mini_no][i];
	pi[i]=mini_no;
      }
    }
  }


  int ans[1000],cnt=0;
  
    
  if(u[T]==INF)cout<<"NA"<<endl;
  else {
    //cout<<vd[T]<<endl;
    for(;T!=-1;T=pi[T])ans[cnt++]=T;


    for(int i=cnt-1;i>=0;i--){
      if(i!=cnt-1)cout<<' ';
      cout<<id[ans[i]];
    }
    cout<<endl;
  }
}

int change(int x){
  for(int i=0;i<n;i++){
    if(id[i]==x)return i;
  }
}

Measured memory_bytes: 9072
lines = readlines.join.split.map(&:to_i)
a = lines.shift
b = lines.shift
c = lines.shift
k = lines.shift
xa = [a,k].min
k -= xa
xb = [b,k].min
k -= xb
xc = [c,k].min


ans = (xa*1)+(xc*-1)
p ans

Measured memory_bytes: 14236
# Aizu Problem ALDS_1_3_A: Stack
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


stack = []
for x in input().split():
    if x == '+':
        b = stack.pop()
        a = stack.pop()
        stack.append(a + b)
    elif x == '-':
        b = stack.pop()
        a = stack.pop()
        stack.append(a - b)
    elif x == '*':
        b = stack.pop()
        a = stack.pop()
        stack.append(a * b)
    else:
        stack.append(int(x))

print(stack[0])

Measured memory_bytes: 7720
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;

struct Cake {
    long x, y, z;
}

void solve() {
    int n, m;
    readf("%d %d\n", &n, &m);
    auto cakes = new Cake[n];
    foreach (ref c; cakes)
        readf("%d %d %d\n", &c.x, &c.y, &c.z);

    long res;
    foreach (k; 0..1<<3) {
        long[] a;
        foreach (cake; cakes) {
            long t;
            with (cake) {
                t += (k>>0 & 1 ? x : -x);
                t += (k>>1 & 1 ? y : -y);
                t += (k>>2 & 1 ? z : -z);
            }
            a ~= t;
        }
        sort!("a>b")(a);
        res = max(res, a[0..m].sum);
    }
    writeln(res);
}

void main() {
    solve();
}

Measured memory_bytes: 380
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


class Type(Enum):
    TRUE = 0
    FALSE = 1
    UNDEFINED = 2


MIN = 1
MAX = 13

dp = [[[None]*2 for _ in range(15)] for _ in range(15)]

def recursive(L,R,Sente,Gote,rest_Sente,rest_Gote,is_Sente):

    if dp[L][R][is_Sente] != Type.UNDEFINED:
        return dp[L][R][is_Sente] == Type.TRUE

    #終了判定
    if rest_Sente == 0:
        return True
    elif rest_Gote == 0:
        return  False

    if is_Sente == True:

        if (L < MIN or (L >= MIN and Sente[L] == False)) and (R > MAX or (R <= MAX and Sente[R] == False)): #パス

            return recursive(L,R,Sente,Gote,rest_Sente,rest_Gote,False)

        else:

            ret = False #先手に行動の選択権があるため、論理和を取る

            next_Sente = [None]*14
            for i in range(MIN,MAX+1):
                next_Sente[i] = Sente[i]

            if L >= MIN and Sente[L] == True:
                next_Sente[L] = False
                ret |= recursive(L-1,R,next_Sente,Gote,rest_Sente-1,rest_Gote,False)
                next_Sente[L] = True
            if R <= MAX and Sente[R] == True:
                next_Sente[R] = False
                ret |= recursive(L,R+1,next_Sente,Gote,rest_Sente-1,rest_Gote,False)

            if ret == True:
                dp[L][R][is_Sente] = Type.TRUE
            else:
                dp[L][R][is_Sente] = Type.FALSE

            return ret

    else: #is_Sente == False

        if (L < MIN or (L >= MIN and Gote[L] == False)) and (R > MAX or (R <= MAX and Gote[R] == False)): #パス

            return recursive(L,R,Sente,Gote,rest_Sente,rest_Gote,True)

        else:
            ret = True #後手に行動の選択権があるため、論理積を取る

            next_Gote = [None]*14
            for i in range(MIN,MAX+1):
                next_Gote[i] = Gote[i]

            if L >= MIN and Gote[L] == True:
                next_Gote[L] = False
                ret &= recursive(L-1,R,Sente,next_Gote,rest_Sente,rest_Gote-1,True)
                next_Gote[L] = True
            if R <= MAX and Gote[R] == True:
                next_Gote[R] = False
                ret &= recursive(L,R+1,Sente,next_Gote,rest_Sente,rest_Gote-1,True)

            if ret == True:
                dp[L][R][is_Sente] = Type.TRUE
            else:
                dp[L][R][is_Sente] = Type.FALSE

            return ret


N = int(input())

for _ in range(N):
    Sente = [False]*14
    Gote = [None]*14

    for L in range(0,7):
        for R in range(8,15):
            dp[L][R][True] = Type.UNDEFINED
            dp[L][R][False] = Type.UNDEFINED

    tmp_input = list(map(int,input().split()))

    for i in range(len(tmp_input)):
        Sente[tmp_input[i]] = True

    for i in range(MIN,MAX+1):
        Gote[i] = not Sente[i]

    if recursive(6,8,Sente,Gote,6,6,True) == True:
        print("yes")
    else:
        print("no")




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

int main(){
  int n,num;
  float t,a,ans=10000,temp,array[10000];
  cin>>n>>t>>a;
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  for(int i=0;i<n;i++){
    temp=t-array[i]*0.006;
    if(ans>abs(temp-a)){
      num=1+i;
      ans=abs(temp-a);
    }
  }
  cout<<num<<endl;
}


Measured memory_bytes: 256
import numpy as np

n, k = map(int, input().split())

ary = np.array([i for i in range(n+1)])
#print(ary)

def lr(l,r): # 等差数列の'l'から'r'の和_mean*number
    return (l+r)*(r-l+1)//2

ans = 0
for j in range(k,n+1):
    l = lr(0, j-1)
    r = lr(n+1-j, n)
    ans += r-l+1
    
ans += 1
ans %= 10**9+7

print(ans)


Measured memory_bytes: 36264
import fractions
import sys

n, k = map(int, input().split())
array = [int(x) for x in input().split()]

if n == 1:
    print("POSSIBLE" if max(array) == k else "IMPOSSIBLE")
    sys.exit()

res = fractions.gcd(array[0], array[1])

for i in array[2:]:
    res = fractions.gcd(res, i)
print("POSSIBLE" if k%res==0 and max(array) >= k else "IMPOSSIBLE")

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    int n,m;
    cin>>n;
    vector<int>a(n);
    vector<int>b(n);

    rep(i,n)cin>>a[i]>>b[i];
    rep(i,n){
        int r=n-i-1;
        if((a[r]+ans)%b[r] != 0)ans+=b[r] - (a[r]+ans)%b[r];
    }

    cout<<ans<<endl;
    //cout <<fixed<<setprecision(16)<< << endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  getline(cin, s);
  string t;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == ',') {
      cout << t << ' ';
      t = "";
      continue;
    }
    t += s[i];

  }
  cout << t << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int dist[N];
vector<pair<int,int>> G[N];
vector<int> newG[N], allG[N];
int was[N];
int x[N];
int ptr[N];

int main(void){
	int n,m;
	cin>>n>>m;
	rep(i,m){
		int p,q,c;
		cin>>p>>q>>c;
		p--;q--;
		G[p].push_back({c,q});
		G[q].push_back({c,p});
		allG[c].push_back(p);
		allG[c].push_back(q);
	}
	rep(i,n){
		sort(all(G[i]));
		ptr[i] = 0;
	}
	rep(i,n){
		was[i] = -1;
	}
	int new_n = n;
	rep(i,N){
		newG[i].clear();
	}
	rep(color, N){
		if(allG[color].empty()) continue;
		rep(it, allG[color].size()){
			int v = allG[color][it];
			if(was[v] == color){
				continue;
			}
			int b = 0, e = 1;
			x[0] = v;
			was[v] = color;
			while(b < e){
				while(ptr[x[b]] < (int) G[x[b]].size()){
					int c = G[x[b]][ptr[x[b]]].first;
					if(c != color){
						break;
					}
					int u = G[x[b]][ptr[x[b]]].second;
					if(was[u] != color){
						was[u] = color;
						x[e] = u;
						e++;
					}
					ptr[x[b]]++;

				}
				b++;
			}
			rep(i,e){
				newG[x[i]].push_back(new_n);
				newG[new_n].push_back(x[i]);
			}
			new_n++;
		}
	}
	rep(i,new_n){
		dist[i] = -2;
	}
	int b = 0, e = 1;
	x[0] = 0;
	dist[0] = 0;

	while(b < e){
		rep(j, newG[x[b]].size()){
			int u = newG[x[b]][j];
			if(dist[u] == -2){
				dist[u] = dist[x[b]] + 1;
				x[e] = u;
				e++;
			}
		}
		b++;
	}
	cout<<dist[n-1]/2<<endl;
	return 0;
}


Measured memory_bytes: 116096
#include <iostream>
using namespace std;
int main(){
  char a;
  cin >> a;
  if(a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o'){
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100
char a[N][N];
int rows,cols;

int dfs(int curX,int curY, char curChar){
	if(curX < 0 || curX >= rows)return 0;
	if(curY < 0 || curY >= cols)return 0;
	if(a[curX][curY] != curChar)return 0;

	a[curX][curY] = '0';
	dfs(curX-1,curY,curChar);
	dfs(curX+1,curY,curChar);
	dfs(curX,curY-1,curChar);
	dfs(curX,curY+1,curChar);
	return 0;
}

int main(){
	while(scanf("%d%d",&rows,&cols),rows || cols){
		int count = 0;
		int i,j;
		getchar();
		for(i = 0; i < rows; i++){
			for(j = 0; j < cols; j++)
				scanf("%c",&a[i][j]);
			getchar();
		}
		for( i = 0; i < rows; i++)
			for(j = 0; j < cols; j++)
				if(a[i][j] != '0'){dfs(i,j,a[i][j]);count++;}

		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 1352
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<long long, long long>> v;
  for(int i = 0; i < n; i++){
    long long a, b;
    cin >> a >> b;
    v.emplace_back(a, b);
  }
  sort(v.begin(), v.end());
  long long ans = v[0].first;
  for(int i = 0; i < n-1; i++){
    ans += min(abs(v[i].first - v[i+1].first), abs(v[i].second - v[i+1].second));
  }
  ans += v[n-1].second;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int dp[2][2][3009];

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

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

    rep(i, n + 1) dp[0][!i][i] = 1;

    int cur = 0;
    rep(_, m) {
        int nx = cur ^ 1;
        memset(dp[nx], 0, sizeof(dp[nx]));
        rep(k, 2) rep(i, n + 1) rep(j, 2) if(0 <= i - j && i - j < n) {
            int d = k | (i - j == 0);
            (dp[nx][d][i - j + 1] += dp[cur][k][i]) %= mod;
        }

        swap(nx, cur);
        memset(dp[nx], 0, sizeof(dp[nx]));
        rep(k, 2) rep(i, n + 1) rep(j, 2) if(0 <= i - j && i - j <= n) {
            int d = k | (i - j == 0);
            (dp[nx][d][i - j] += dp[cur][k][i]) %= mod;
        }
        swap(nx, cur);
    }

    int ans = 0;
    rep(i, n + 1)(ans += dp[cur][1][i]) %= mod;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3700
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stdlib.h>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
//using std::greater;
using std::max;
using std::min;

/*
using lli = long long int;
using ulli = unsigned long long int;
*/

#define INF 999999999;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int euclid(int a, int b){
	int swap, rt;
	if(a < b){
		swap = a;
		a = b;
		b = swap;
	}
	if(b == 1) return 1;
	rt = a % b;
	if(rt == 0) return b;
	euclid(b, rt);
}

int N, ans;
long long int A[100010];

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

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

	ans = euclid(A[0], A[1]);
	for(int i = 2; i < N; i++){
		ans = euclid(A[i], ans);
	}

	cout << ans;

#ifndef EVEL
	system("pause");
#endif

	return 0;
}

Measured memory_bytes: 1024
/*

*/
#include<bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,a,n) for(int i=(a);i<(n);i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int x,k=0,n=0;cin>>x;
  while(1){
    n+=x;
    k++;
    if(n>=360)n-=360;
    if(n==0){
      break;
    }
  }
  cout<<k<<endl;
}

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define int long long int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()

// typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
		
	int n,k;
	cin>>n>>k;
	int h[n+1], dp[n+1];
	h[0] = INT_MAX;
	for(int i=1;i<=n;cin>>h[i++]);
	for(int i=0;i<=n;i++) {
		dp[i] = INT_MAX;
	}
	dp[1] = 0;

	for(int i=2; i<=n; i++) {
		for(int j=i-1; j>=(max(1LL,i-k)); j--) {
			dp[i] = min(dp[i], dp[j] + abs(h[j]-h[i]));
		}
	}
	cout<<dp[n];

	return 0;
}

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

int nmax = 8;
vector<vector<bool>> graph(nmax, vector<bool>(nmax, false));

int dfs(int c, int N, vector<bool> visited){
    bool all_visited = true;
    rep(i, N){
        if(!visited[i]){
            all_visited = false;
        }
    }
    if(all_visited){
        return 1;
    }
    int count = 0;
    rep(i, N){
        if(!graph[c][i] || visited[i]){
            continue;
        }
        visited[i] = true;
        count += dfs(i, N, visited);
        visited[i] = false;
    }
    return count;
}

int main(){
    int N, M; cin >> N >> M;
    vector<bool> visited(N, false);
    rep(i, M){
        int a, b; cin >> a >> b;
        graph[a-1][b-1] = graph[b-1][a-1] = true;
    }
    visited[0] = true;
    int ans = dfs(0, N, visited);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.List             (sort)
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [a, b, c] <- getInts
  print $ solve a b c

solve :: Int -> Int -> Int -> Int
solve a b c
  | even s    = s `div` 2
  | otherwise = s `div` 2 + 2
  where s = c' - a' + c' - b'
        [a', b', c'] = sort [a, b, c]

readInts :: BC.ByteString -> [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words

getInts :: IO [Int]
getInts = readInts <$> BC.getLine


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  Int r,d,x;
  cin>>r>>d>>x;
  for(Int i=1;i<=10;i++){
    x=r*x-d;
    cout<<x<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
   ll n;cin>>n;
   ll dp[n+1][4];
   ll a,b,c;
   cin>>a>>b>>c;
   dp[1][1]=a;
   dp[1][2]=b;
   dp[1][3]=c;

   for(ll i=2;i<=n;i++)
   {
       cin>>a>>b>>c;
       dp[i][1]=max(dp[i-1][2]+a,dp[i-1][3]+a);
       dp[i][2]=max(dp[i-1][1]+b,dp[i-1][3]+b);
       dp[i][3]=max(dp[i-1][1]+c,dp[i-1][2]+c);
   }
   cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
}


Measured memory_bytes: 3328
/*
 * @author Raj Sharma
 * Date 20160306
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        long a,b;
 
 
        while((str=br.readLine()) != null){
            a = Long.parseLong(str.substring(0, str.indexOf(" ")));
            b = Long.parseLong(str.substring(str.indexOf(" ")+1, str.length()));
 
            System.out.println(gcd(a, b) + " " + lcm(a,b));
 
        }
    }
 
    static long gcd(long a,long b){
        return b == 0 ? a : gcd(b,a%b);
    }
 
    static long lcm(long a, long b){
        return b*a/gcd(a,b);
    }
}

Measured memory_bytes: 24224
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

ans = 1
if N == K:
    for a in A:
        ans *= a
        ans %= MOD
    print(ans)
    exit(0)

if N - A.count(0) < K:
    print(0)
    exit(0)

plus = []
minus = []
for a in A:
    if a > 0:
        plus.append(a)
    else:
        minus.append(a)

if K % 2 == 1 and len(plus) == 0:
    minus.sort(reverse=True)
    for i in range(K):
        ans *= minus[i]
        ans %= MOD
    print(ans)
    exit(0)

plus.sort(reverse=True)
minus.sort()

if len(minus) == 0:
    for k in range(K):
        ans *= plus[k]
        ans %= MOD
    print(ans)
    exit(0)

i = 0
j = 0

if K % 2 == 1:
    ans = plus[0]
    K -= 1
    plus = plus[1:]

for _ in range(K//2):
    if i+1 >= len(plus):
        ans *= (minus[j] * minus[j+1])
        ans %= MOD
        j += 2
        continue
    elif j+1 >= len(minus):
        ans *= (plus[i] * plus[i+1])
        ans %= MOD
        i += 2
        continue

    a = plus[i] * plus[i+1]
    b = minus[j] * minus[j+1]
    if a > b:
        ans *= a
        i += 2
    else:
        ans *= b
        j += 2
    ans %= MOD

print(ans)


Measured memory_bytes: 108936
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
long long n, p,cnt[1000001],temp, ans = 1;
int main()
{

	cin>>n>>p;
	if (n == 1) 
	{
		cout<<p;
	}
	else
	{
		temp = p;
		for (long long i = 2; i*i<=temp;i++)
		{
			while (temp % i == 0)
			{
				temp /= i;
				cnt[i]++;
			}
		}
		for (long long i = 2; i*i<=p; i++)
		{
			for (int j = 0; j < cnt[i]/n; j++)
			{
				ans *= i;
			}
				
		}
		cout<<ans;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    string s, t;
    cin >> s >> t;
    string ans = "Yes";
    rep(i,s.size()){
        if(s[i] != t[i]){
            ans = "No";
        }
    }

    cout << ans << endl;
    
    

}

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

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

template< typename T >
vector< T > convert_base(T x, T b) {
  vector< T > ret;
  T t = 1, k = abs(b);
  while(x) {
    ret.emplace_back((x * t) % k);
    if(ret.back() < 0) ret.back() += k;
    x -= ret.back() * t;
    x /= k;
    t *= b / k;
  }
  if(ret.empty()) ret.emplace_back(0);
  reverse(begin(ret), end(ret));
  return ret;
}

int main() {
  for(;;) {
    int X;
    cin >> X;
    if(X == 0) break;
    auto ret = convert_base(X, -10);
    for(auto &p : ret) cout << p;
    cout << endl;
  }
}



Measured memory_bytes: 3120
#include<stdio.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 2005;
const int MM = 924844033;

ll A[MX][MX][4];
int N, K;

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

	int b = 0;
	A[0][0][0] = 1;
	for(int i = 1; i <= K; i++){
		for(int k = 0; k <= N; k++){
			for(int l = 0; l < 4; l++) A[i][k][0] = (A[i][k][0] + A[b][k][l]) % MM;
		} b = i;
		for(int j = i+K; j <= N; j += K){
			for(int k = 0; k <= N; k++){
				A[j][k][0] = (A[j-K][k][0] + A[j-K][k][1] + A[j-K][k][2] + A[j-K][k][3]) % MM;
				if( k >= 1 ) A[j][k][1] = (A[j-K][k-1][0] + A[j-K][k-1][1]) % MM;
				if( k >= 1 ) A[j][k][2] = (A[j-K][k-1][0] + A[j-K][k-1][2]) % MM;
				if( k >= 2 ) A[j][k][3] = A[j-K][k-2][0] % MM;
			}
			b = j;
		}
	}
	ll B[MX];
	for(int k = 0; k <= N; k++){
		B[k] = 0;
		for(int l = 0; l < 4; l++) B[k] = (B[k] + A[b][k][l]) % MM;
	}

	ll fac = 1, ans = 0;
	for(int i = 0; i <= N; i++){
		if( (N-i+1)&1 ) ans = (ans + fac * B[N-i]) % MM;
		else ans = (ans - fac * B[N-i]%MM + MM) % MM;
		fac = fac * (i+1) % MM;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 125568
#include <stdio.h>

int main(){
    int a[3]={0,0,0};
    int min;
    int i, j;
    
    scanf("%d %d %d", &a[0], &a[1], &a[2]);
    
    min = a[0]+a[1];
    if(min>a[1]+a[2])min=a[1]+a[2];
    if(min>a[0]+a[2])min=a[0]+a[2];
    printf("%d", min);
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  string s;
  cin>>s;
  int n=s.length();
  REP(i,0,n){
    REP(j,i,n){
      stringstream a;
      a<<s.substr(0,i);
      a<<s.substr(j,n-1);
      //DUMP(i,j,a.str());
      if(a.str() == "keyence"){
        cout<<"YES";
        return 0;
      }
    }
  }
  cout<<"NO";

  return 0;
}


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

using namespace std;

vector<double> val;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  k--;
  double x = 0.0;
  for (int i = 1; i <= n; i++) {
    if (i <= k) {
      double tmp = i, c = 0;
      while (tmp <= k) {
        tmp *= 2.0;
        c++;
      }
      val.push_back(c);
    } else {
      x++;
    }
  }
  double ans = 0.0;
  for (auto i : val) {
    //cout << i << endl;
    double tmp = 1.0 / (double)n;
    double fmp = pow(0.5, i);
    double rmp = tmp * fmp;
    ans += rmp;
  }
  ans += (x * (1.0 / (double)n));
  cout << fixed << setprecision(15) << ans << '\n';
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

int main(){
  int N;
  std::cin >> N;
  std::vector<int> W(N);
  for(int i=0; i<N; ++i) std::cin >> W[i] ;
//  std::sort(W.begin(), W.end());
  int sum1 = 0, sum2 = 0;
  for(int i=0; i<N; ++i) { sum1 += W[i]; }
  int gap1 = 0, gap2 = 0;
  for(int i=0; i<N; ++i) {
    gap1 = gap2;
    sum1 -= W[i];
    sum2 += W[i];
    gap2 = sum1-sum2;
    if(gap2 < 0) break;
  }
  if(gap1 > -gap2) std::cout << -gap2 << std::endl;
  else std::cout << gap1 << std::endl;
  return 0;  
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s;
  std::cin >> s;
  int64_t k;
  std::cin >> k;

  std::vector<int64_t> dp1(k + 1, 0), dp2(k + 1, 0);
  dp1[0] = 1;
  for (const auto c : s) {
    int n = c - '0';
    std::vector<int64_t> dp1t(k + 1, 0), dp2t(k + 1, 0);

    for (int64_t i = 0; i < k + 1; i++) {
      dp2t[i] += dp2[i];
      if (i < k) {
        dp2t[i + 1] += 9 * dp2[i];
      }
    }
    for (int64_t i = 0; i < k + 1; i++) {
      if (n == 0) {
        dp1t[i] += dp1[i];
      } else {
        if (i < k) {
          dp1t[i + 1] += dp1[i];
          dp2t[i + 1] += (n - 1) * dp1[i];
        }
        dp2t[i] += dp1[i];
      }
    }
    std::swap(dp1, dp1t);
    std::swap(dp2, dp2t);
  }

  std::cout << dp1[k] + dp2[k] << std::endl;

  return 0;
}


Measured memory_bytes: 256
from sys import stdin

N, M = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(stdin.readline().rstrip()) for _ in range(M)]
fib = [1, 1]
for k in range(N):
    fib.append((fib[-1] + fib[-2]) % 1000000007)
if M == 0:
    print(fib[N])
    exit()
ans = fib[a[0] - 1]
for l in range(M - 1):
    if a[l + 1] - a[l] == 1:
        print(0)
        exit()
    ans = ans * fib[a[l + 1] - a[l] - 2]
ans = ans * fib[N - a[-1] - 1]
print(ans % 1000000007)


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            double ret = 1;
            for(int i = 1; i <= N;i++)
            {
                ret *= i%(Math.Pow(10,9)+7);
                ret = ret % (Math.Pow(10, 9) + 7);
            }

            Console.WriteLine(ret);
        }

    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define DEBUG if(0)
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	long int n;
	while(cin >> n) {
		int arr[n], freq[n + 1], vis[n + 1];
		long long dp[n + 1][2];
		memset(freq, 0, sizeof(freq));
		memset(vis, 0, sizeof(vis));
		memset(dp, 0, sizeof(dp));
		for(int i = 0; i < n; i++) {
			cin >> arr[i]; 
			freq[arr[i]]++;
		}
		long long sum = 0;
		for(int i = 0; i < n; i++) {
			if(!vis[arr[i]]) {
				vis[arr[i]] = 1;
				for(int d = 0; d < freq[arr[i]]; d++) {
					dp[arr[i]][0] += max(0, (freq[arr[i]] - d - 1));
					dp[arr[i]][1] += max(0, (freq[arr[i]] - 1 - d - 1));					
				}
				sum += dp[arr[i]][0];
				DEBUG cout << arr[i] << " " << freq[arr[i]] << " " << dp[arr[i]][0] << " " << dp[arr[i]][1] << endl;
			}
		}
		DEBUG cout << "-----------------" << endl;
		for(int i = 0; i < n; i++) {
			long long value = sum - dp[arr[i]][0] + dp[arr[i]][1];
			cout << value << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 8064
n = int(input())

a = []

for _ in range(n):
    a.append(int(input()))

a_max = max(a)
a_max_index = a.index(a_max)

a.sort(reverse=True)
a_second_max = a[1]

for i in range(n):
    if i == a_max_index:
        print(a_second_max)
    else:
        print(a_max)

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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

const int MAX=2e5+9;
const int MOD=998244353;
int n, lst[MAX];
ll dp[MAX];
vector<pi> v;
bool can[MAX];
int tree[(MAX<<2)], idx, l, r, val;

void upd(int low, int high, int pos) {
    if (low==high) {
        tree[pos]=val;
        return;
    }

    int mid=((low+high)>>1);
    if (idx<=mid) {
        upd(low, mid, (pos<<1|1));
    }
    else {
        upd(mid+1, high, (pos<<1)+2);
    }

    tree[pos]=max(tree[(pos<<1|1)], tree[(pos<<1)+2]);
}

int qwr(int low, int high, int pos) {
    if (l>high || r<low) {
        return 0;
    }

    if (l<=low && r>=high) {
        return tree[pos];
    }

    int mid=((low+high)>>1);
    return max(qwr(low, mid, (pos<<1|1)), qwr(mid+1, high, (pos<<1)+2));
}

int BSFindLast(int low, int high, int val) {
    int res=low;
    while (low<=high) {
        int mid=((low+high)>>1);

        if (v[mid].F<=val) {
            res=mid;
            low=mid+1;
        }
        else {
            high=mid-1;
        }
    }

    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for (int i=1; i<=n; ++i) {
        int a, d;
        cin >> a >> d;
        v.push_back({a, d});
    }

    sort(v.begin(), v.end());
    for (int i=n-1; i>=0; --i) {
        val=BSFindLast(i, n-1, v[i].F+v[i].S-1);
        idx=i;
        upd(0, n-1, 0);

        l=i; r=val;
        lst[i]=qwr(0, n-1, 0);

        idx=i;
        val=lst[i];
        upd(0, n-1, 0);
    }

    dp[n]=1;
    for (int i=n-1; i>=0; --i) {
        dp[i]=(dp[lst[i]+1]+dp[i+1])%MOD;
    }

    cout << dp[0];

    return 0;
}


Measured memory_bytes: 7664
// package app;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        // long N = sc.nextLong();
        // long K = sc.nextLong();
        int K = sc.nextInt();
        int X = sc.nextInt();

        StringJoiner sj = new StringJoiner(" ");

        for (int i = -(K - 1); i < K; i++) {
            sj.add(String.valueOf(i + X));
        }

        System.out.println(sj.toString());

    }
}

Measured memory_bytes: 23764
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
class SuffixArray(object):
    """
    construct:
        suffix array: O(N(logN)^2)
        lcp array: O(N)
        sparse table: O(NlogN)
    query:
        lcp: O(1)
    """
    def __init__(self,s):
        """
        s: str
        """
        self.__s=s
        self.__n=len(s)
        self.__suffix_array()
        self.__lcp_array()
        self.__sparse_table()

    # suffix array
    def __suffix_array(self):
        s=self.__s; n=self.__n
        # initialize
        sa=list(range(n))
        rank=[ord(s[i]) for i in range(n)]
        tmp=[0]*n
        k=1
        cmp_key=lambda i:(rank[i],rank[i+k] if i+k<n else -1)
        # iterate
        while(k<=n):
            sa.sort(key=cmp_key)
            tmp[sa[0]]=0
            for i in range(1,n):
                tmp[sa[i]]=tmp[sa[i-1]]+(cmp_key(sa[i-1])<cmp_key(sa[i]))
            rank=tmp[:]
            k<<=1
        self.__sa=sa
        self.__rank=rank

    # LCP array
    def __lcp_array(self):
        s=self.__s; n=self.__n
        sa=self.__sa; rank=self.__rank
        lcp=[0]*n
        h=0
        for i in range(n):
            if rank[i]==0: continue
            j=sa[rank[i]-1]
            if h>0: h-=1
            while j+h<n and i+h<n and s[j+h]==s[i+h]: h+=1
            lcp[rank[i]]=h
        self.__lcp=lcp

    # sparse table
    def __sparse_table(self):
        n=self.__n
        logn=max(0,(n-1).bit_length())
        table=[[0]*n for _ in range(logn)]
        table[0]=self.__lcp[:]
        # construct
        from itertools import product
        for i,k in product(range(1,logn),range(n)):
            if k+(1<<(i-1))>=n:
                table[i][k]=table[i-1][k]
            else:
                table[i][k]=min(table[i-1][k],table[i-1][k+(1<<(i-1))])
        self.__table=table

    def lcp(self,a,b):
        """
        a,b: int 0<=a,b<n
        return LCP length between s[a:] and s[b:]
        """
        if a==b: return self.__n-a
        l,r=self.__rank[a],self.__rank[b]
        l,r=min(l,r)+1,max(l,r)+1
        i=max(0,(r-l-1).bit_length()-1)
        table=self.__table
        return min(table[i][l],table[i][r-(1<<i)])
def resolve():
    n=int(input())
    s=input()
    sa=SuffixArray(s)
    ans=0
    for i in range(n):
        for j in range(i+1,n):
            ans=max(min(j-i,sa.lcp(i,j)),ans)
    print(ans)
resolve()

Measured memory_bytes: 53084
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int ans = 1;
  while(ans*ans<=n) ans++;

  cout << (ans-1)*(ans-1) <<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

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

    vector<bool> ok(M, true);
    for(int i=0; i<N; i++){
        int K;
        cin >> K;
        vector<bool> v(M, false);
        for(int j=0; j<K; j++){
            int A;
            cin >> A;
            v[A-1] = true;
        }
        for(int j=0; j<M; j++)
            if(!v[j])
                ok[j] = false;
    }
    int cnt = 0;
    for(int i=0; i<M; i++)
        if(ok[i])
            cnt++;
    cout << cnt << endl;

    return 0;
}


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

using namespace std;

const char nl = '\n';

int main(){
  string s, t;
    cin >> s >> t;
    int cnt = 1001;
    for(int i = 0; i + t.length() <= s.length(); ++i){
        string ans = s.substr(i, t.length());
        int res = 0;
        for(int j = 0; j < t.length(); ++j){
            if(t[j] != ans[j]){
                res++;
            }
        }
        cnt = min(cnt, res);
    }
    cout << cnt << nl;
}

Measured memory_bytes: 3624
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())

rem = pow(10,9)+7

n = ip()                                     #入力整数1つ
#x,y= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[input() for i in range(x)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
s = 0
for i in range(n):
    while a[i]%2==0:
        a[i]//=2
        s+=1
print(s)

Measured memory_bytes: 22972
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

		if ( n == 0 )
		{
			break;
		}

		VI dp( n + 1 );
		dp[0] = 1;

		REP( i, 1, dp.size() )
		{
			REP( j, 1, 4 )
			{
				if ( 0 <= i - j )
				{
					dp[i] += dp[ i - j ];
				}
			}
		}

		cout << dp.back() / 3650 + 1 << endl;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;

typedef pair<ll, ll> P;


ll merge(vector<ll> &a, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    vector<ll> l(n1 + 1, 0);
    vector<ll> r(n2 + 1, 0);

    for (int i = 0; i < n1; i++) {
        l[i] = a[left + i];
    }
    for (int i = 0; i < n2; i++) {
        r[i] = a[mid + i];
    }

    l[n1] = INF;
    r[n2] = INF;

    int i = 0, j = 0;
    ll compare = 0;
    for (int k = left; k < right; k++) {
        if (l[i] <= r[j]) {
            a[k] = l[i];
            i++;
        } else {
            a[k] = r[j];
            j++;
            compare += n1 - i;
        }
    }
    return compare;
}

ll merge_sort(vector<ll> &a, int left, int right) {
    ll compare = 0;
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        compare += merge_sort(a, left, mid);
        compare += merge_sort(a, mid, right);
        compare += merge(a, left, mid, right);
    }
    return compare;
}

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

    vector<ll> a(n);

    rep(i, n) cin >> a[i];

    ll compare = merge_sort(a, 0, n);
    cout << compare << endl;
}



Measured memory_bytes: 5892
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::ostream_iterator
#include <algorithm> // std::copy
#include <sstream>   // std::stringstream
//#include <iterator>  // std::back_inserter

using namespace std;

int main(int argc, char** argv) {
  vector<int> nums;

  string tmp;

  getline(cin, tmp); // drop 1st line
  getline(cin, tmp); // 2nd line

  stringstream ss(tmp);
  int ti;
  while (ss >> ti) {
    nums.push_back(ti);
  }

  //copy(istream_iterator<int>(cin), istream_iterator<int>(), back_inserter(nums));

  copy(nums.begin(), nums.end()-1, ostream_iterator<int>(cout, " "));
  cout << nums.back() << endl;

  for(int i = 1; i < (int)nums.size(); ++i) {
    int v = nums[i];
    int j = i - 1;
    while(j >= 0 && nums[j] > v) {
      nums[j+1] = nums[j];
      j--;
    }
    nums[j+1] = v;

    copy(nums.begin(), nums.end()-1, ostream_iterator<int>(cout, " "));
    cout << nums.back() << endl;
  }

  return 0;
}



Measured memory_bytes: 3168
int main(){
    int a,b;
    char n;
    
    while(1){
        scanf("%d %c %d",&a,&n,&b);
        if (n == '?') break;
        else if (n == '+') printf("%d\n", a + b);
        else if (n == '-') printf("%d\n", a - b);
        else if (n == '*') printf("%d\n", a * b);
        else if (n == '/') printf("%d\n", a / b);
        
    }
    return 0;
}


Measured memory_bytes: 2004
N = int(input())
B = [[] for i in range(N)]
C = []
for i in range(N):
  M = int(input())
  C.append(M)
  for j in range(M):
    B[i].append([int(s) for s in input().split()])
    
ans = 0
for i in range(2**N):
    array = bin(i)[2:]
    n = len(array)
    array = "0"*(N-n) + array  #give 0 in oreder to the length will be N
    array = [int(k) for k in list(array)]
    
    #check if the array is feasible or not, if feasible count the number of "1"
    flag = True
    for j in range(N):
        a = array[j]
        if a==1:
            for e,f in B[j]:
                if f != array[e-1]:
                    flag = False
    if flag==True:
        ans = max(ans, sum(array))
print(ans)                    

Measured memory_bytes: 3064
#include<stdio.h>

int main() {
	int a, b;

	//2????????´??°a,b?????\???
	scanf("%d %d",&a, &b);

	//2????????´??°?????§?°???????
	if (a > b) {
		printf("a > b\n");
	}
	else if (a < b) {
		printf("a < b\n");
	}
	else {
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580