akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

struct data{
    char name;
    int win;
    int lose;
};

int main(){
    int n;
    struct data data[15];
    while(cin >> n, n){
        rep(i,n){
            cin >> data[i].name;
            data[i].win = data[i].lose = 0;
            rep(j,n - 1){
                int inp;
                cin >> inp;
                if(inp == 0)
                    data[i].win++;
                else if(inp == 1)
                    data[i].lose++;
            }
        }
        rep(i,n){
            rep(j,n - 1){
                if(data[j].win < data[j + 1].win){
                    struct data g = data[j];
                    data[j] = data[j + 1];
                    data[j + 1] = g;
                }
                if(data[j].win == data[j + 1].win){
                    if(data[j].lose > data[j + 1].lose){
                        struct data g = data[j];
                        data[j] = data[j + 1];
                        data[j + 1] = g;
                    }
                }
            }
        }
        rep(i,n){
            cout << data[i].name << endl;
        }
    }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;

#define Pb push_back
const int maxn =3e5+10;
struct Edge{
	int to,corlor,w;
};
vector<Edge> G[maxn];

int depth[maxn],vs[maxn],ID[maxn],dis[maxn];
int n;
int f[maxn][20];
void dfs(int node,int fa,int d,int &k){
   	ID[node] = k;
   	vs[k] = node;
 	depth[k++] = d;
 	// dis[node] = distance;
 	for(int i = 0;i < G[node].size(); ++i){
 		Edge &t = G[node][i];
 		if(t.to == fa) continue;
 		dis[t.to] = dis[node]+t.w;
 		dfs(t.to,node,d+1,k);
        vs[k] = node;
        depth[k++] = d;
 	}
}



void init_rmq(int n){
	
	for(int i = 1;i <= n ; ++i) f[i][0] = i;
    for(int j = 1;(1<<j) <= n; ++j){
    	for(int i = 1;i + (1<<j)-1 <= n; ++i){
    		if(depth[f[i][j-1]]< depth[f[i+(1<<(j-1))][j-1]])
    			f[i][j] = f[i][j-1];
    		else
    			f[i][j] = f[i+(1<<(j-1))][j-1];

    	}
    }
}
int rmq_query(int l,int r){
	int x = 0;
	while((1<<(x+1)) <= r-l+1) x++;
	if(depth[f[l][x]] < depth[f[r-(1<<x)+1][x]])
		return f[l][x];
	else
		return f[r-(1<<x)+1][x];
}
void init_lca(){
	int k = 1;
	dfs(1,-1,0,k);
	init_rmq(2*n-1);
}
int lca(int u,int v){
	// cout<<rmq_query(ID[u],ID[v])<<endl;
	return vs[rmq_query(min(ID[u],ID[v]),max(ID[u],ID[v]))];
}
struct que{
	int corlor,w,coe,id;
};
vector<que> Query[maxn];
int ans[maxn],num[maxn],value[maxn];// num[i] 个数，value 值
void dfs(int u,int fa){
	for(auto qu:Query[u]){
		// cout<<dis[u]<<endl;
		ans[qu.id] +=(dis[u]+num[qu.corlor]*qu.w-value[qu.corlor])*qu.coe;
	}
	for(auto p: G[u]){
		int to = p.to;
		if(to == fa) continue;
		num[p.corlor]++;
		value[p.corlor] += p.w;
		dfs(to,u);
		num[p.corlor]--;
		value[p.corlor] -= p.w;
	}
}
int main(void)
{
	int q;
    cin>>n>>q;
    for(int i = 1;i < n;++i){
    	int u,v,c,w;
    	scanf("%d%d%d%d",&u,&v,&c,&w);
    	G[u].Pb(Edge{v,c,w});
    	G[v].Pb(Edge{u,c,w});
    }
    init_lca();
    for(int i = 1;i <= q; ++i){
    	int x,y,u,v;
    	scanf("%d%d%d%d",&x,&y,&u,&v);
    	int fa = lca(u,v);

    	Query[u].Pb(que{x,y,1,i});
    	Query[v].Pb(que{x,y,1,i});
    	Query[fa].Pb(que{x,y,-2,i});
    }
    dfs(1,-1);
    for(int i  = 1;i <= q; ++i){
    	printf("%d\n",ans[i]);
    }

   return 0;
}


Measured memory_bytes: 56180
#include<stdio.h>

int main(){
	int a;
	int b;
	scanf("%d %d",&a,&b);
	
	int c;
	c = a + b;
	
	if(c==3){
		printf("3");
	}
	if(c==4){
		printf("2");
	}
	if(c==5){
		printf("1");
	}
	
	
	
	
	return 0;
}

Measured memory_bytes: 1632
X,K,D=map(int,input().split())
count=X//D
ans=0
if abs(count)>=K and X>0:
    ans=abs(X-D*K)
elif abs(count)>=K and X<0:
    ans=abs(X+D*K)
else:
    if K%2==count%2:
        ans=abs(X-D*count)
    else:
        ans=abs(X-D*(count+1))
print(ans)

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

const long long mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  long long dp[2001][2001];
  for (int i = 0; i <= n; i++) dp[0][i] = 1;
  for (int i = 1; i <= n / 3; i++) {
    dp[i][n] = dp[i-1][n];
    for (int j = 3; j <= n; j++) {
      for (int k = 3; k <= j - 3; k++) {
        dp[i][j] += dp[i-1][k] % mod;
      } 
    } 
  }
  cout << dp[(n/3)-1][n] % mod;
}

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

int main(){

    int x,a,b;
    cin >> x >> a >> b;
    int distance_A = x>=a ? x-a : a-x;
    int distance_B = x>=b ? x-b : b-x;
    if(distance_A > distance_B){
        cout << 'B' << endl;
    }else{
        cout << 'A' << endl;
    }


    return 0;
}

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

const int p = 73;
const int mod = (int)1e9 + 9;
const int p2 = 53;
const int mod2 = (int)1e9 + 7;

int n;

char s[5005];

long long pw[5005],h[5005],pw2[5005],h2[5005];
                                   	
long long get(int l,int r){
	return (h[r] - h[l - 1] + mod) % mod;
}

long long get2(int l,int r){
	return (h2[r] - h2[l - 1] + mod2) % mod2;
}

bool can(int x){
	if(x == 0) return 1;
	for(int i = x; i <= n - x; i++){
		for(int j = i + 1; j <= n - x + 1; j++){
			long long a = (get(i - x + 1,i) * pw[j + x - 1 - i]) % mod;
			long long b = get(j,j + x - 1);
			long long a2 = (get2(i - x + 1,i) * pw2[j + x - 1 - i]) % mod2;
			long long b2 = get2(j,j + x - 1);	
			if(a == b && a2 == b2) return 1;
		} 			
	}
	return 0;
}

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
    	cin >> n;
    	for(int i = 1; i <= n; i++){
    		cin >> s[i];
    	}
    	pw[0] = 1;
    	pw2[0] = 1;
    	for(int i = 1; i <= n; i++){
    		pw[i] = pw[i - 1] * p;
    		pw[i] %= mod;
    		pw2[i] = pw2[i - 1] * p2;
    		pw2[i] %= mod2;	
    	}
    	for(int i = 1; i <= n; i++){
    		h[i] = h[i - 1] + (s[i] * pw[i]);
    		h[i] %= mod;		
    		h2[i] = h2[i - 1] + (s[i] * pw2[i]);
    		h2[i] %= mod2;
    	}
    	int l = 0,r = n,ans = 0;
    	while(l <= r){
    		int mid = (r + l) / 2;
    		if(can(mid)){
    			ans = mid;
    			l = mid + 1;
    		}
    		else r = mid - 1;
    	}
    	cout << ans;
	return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

N,M = map(int,input().split())
S = input()
T = input()
g = gcd(N,M)
N1 = N//g
M1 = M//g

bl = True
for i,s in enumerate(S[::N1]):
    if s != T[M1*i]:
        bl = False
        break

answer = N * M1 if bl else -1
print(answer)


Measured memory_bytes: 3316
l=list(map(int,input().split()))
n=l[0]
m=l[1]
x=l[2]
y=l[3]

l1=max(list(map(int,input().split())))
l2=min(list(map(int,input().split())))
q=0
if l1<l2:
    if l1<y:
        if x<l2:
            print("No War")
            q=1
if q==0:
    print("War")

Measured memory_bytes: 3064
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>

#define in std::cin
#define out std::cout

int32_t N;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	bool count_odd = false;
	in >> N;
	for (int32_t i = 0; i < N; ++i)
	{
		int a;
		in >> a;
		if (a & 1) { count_odd = !count_odd; }
	}
	if (count_odd) {
		out << "NO";
	}
	else {
		out << "YES";
	}
	out << endl;

	return 0;
}
#endif


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> 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);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    vector<pair<double, int>> v;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        v.push_back(make_pair(atan2(x[i], y[i]), i));
    }
    sort(all(v));
    double ans = 0;
    for (int id = 0; id < n; id++) {
        int i = v[id].second;
        double sx = x[i], sy = y[i];
        chmax(ans, sqrt(sx * sx + sy * sy));
        for (int k = 1; k < n; k++) {
            int j = v[(id + k) % n].second;
            sx += x[j];
            sy += y[j];
            chmax(ans, sqrt(sx * sx + sy * sy));
        }
    }
    cout << fixed << setprecision(15) << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
vector<ll> v;
vector<ll> v1;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/


int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	if(a[a.length()-1]==b[0]&&b[b.length()-1]==c[0]) {
		cout << "YES" << endl;
	}else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    E=[[] for _ in range(n)]
    for v in range(1,n):
        u=int(input())-1
        E[u].append(v)
        E[v].append(u)

    dp=[None]*n
    def dfs(v,p=-1)->int:
        if(dp[v] is not None): return dp[v]
        if(E[v]==[p]):
            dp[v]=0
            return 0
        res=[]
        for nv in E[v]:
            if(nv==p): continue
            res.append(dfs(nv,v))
        dp[v]=max(1+i+x for i,x in enumerate(sorted(res,reverse=1)))
        return dp[v]

    print(dfs(0))
resolve()


Measured memory_bytes: 142640
Sa = input()
Sb = input()
Sc = input()

turn = 'a'

while 1:
    if turn == 'a':
        if not Sa:
            print('A')
            exit()
        turn = Sa[0]
        Sa = Sa[1:]
    elif turn == 'b':
        if not Sb:
            print('B')
            exit()
        turn = Sb[0]
        Sb = Sb[1:]
    else:
        if not Sc:
            print('C')
            exit()
        turn = Sc[0]
        Sc = Sc[1:]

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
INF = 10**10
MOD = 10**9 + 7
sys.setrecursionlimit(100000000)
from functools import lru_cache
from itertools import permutations

def main():
    n = int(input())
    l = list(map(int,input().split()))
    
    tot = sum(l)
    m = max(l)
    if m < tot - m:
        print('Yes')
    else:
        print('No')

if __name__=='__main__':
    main() 

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<char,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;


int main(){
    int n;cin >> n;
    int ans = 0;
    vector<int> x(n),y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> y[i];
    }
    for (int i = 0; i < n; i++) {
        if(x[i]>y[i]) ans+=x[i]-y[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
	int n,hist[6]={0};
	double height;
	
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>height;
		if(height<165.0) hist[0]++;
		else if(height>=165.0 && height<170.0) hist[1]++;
		else if(height>=170.0 && height<175.0) hist[2]++;
		else if(height>=175.0 && height<180.0) hist[3]++;
		else if(height>=180.0 && height<185.0) hist[4]++;
		else if(height>=185.0) hist[5]++;
	}
	for(int i=0;i<6;i++){
		cout<<i+1<<":";
		for(int j=0;j<hist[i];j++){
			cout<<"*";
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>

using namespace std;

int main(){
	int a, b,ret;
	string op;
	while (cin >> a >> op >> b,op != "?"){
		if (op == "-") cout << (a - b) << endl;
		if (op == "+") cout << (a + b) << endl;
		if (op == "*") cout << (a * b) << endl;
		if (op == "/") cout << (int)(a / b) << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	int x;
	for (int i = 1;; i++) {
		cin >> x;
		if (x == 0)break;
		cout << "Case " << i << ": " << x << endl;
	}

	return 0;
}

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


int main() {
  vector<Int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(A.begin(), A.end());
  
  Int x,y;
  x = A[2] * 10 + A[1];
  y = A[0];
  
  cout << x + y << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

bool check(int x,int y,vector<string> a,vector<string> b ){
    for(auto i = 0; i<b.size();i++){
        for(auto j =0; j<b.size();j++){
            if(a[x+i][y+j]!= b[i][j]) return false;
        }
    }
    return true;
}

int dist(pii a, pii b){
    return abs(a.first-b.first) + abs(a.second-b.second);
}

int main() {
    double a,b;cin>>a>>b;
    
    if(a>b)cout<<"GREATER"<<endl;
    else if(a<b) cout<<"LESS"<<endl;
    else cout<<"EQUAL"<<endl;
    
    return 0;
}







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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  if(s[0] == '0' || s[n-1]  == '1'){
    cout << -1<< endl;
    return 0;
  }
  s = s.substr(0, n-1);
  string t = s;
  reverse(t.begin(), t.end());
  if (s!=t){
    cout<<-1<<endl;
    return 0;
  }
  s=s+"1";
  vector<int> p(n, -1);
  for (int i = 1; i<n; ++i){
    if(s[i] != '1'){
      continue;
    }
    for(int j=i-1;j>=0 &&p[j] < 0; --j){
      p[j]=i;
      cout<<i+1<<" "<<j+1<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <map>
#include <stdlib.h>
#define llint long long
#define inf 1e18

using namespace std;

llint N, M, W, T;
map<string, int> mp;
llint V[10], P[10];
llint X[10], Y[10];
llint Q[10][10];

llint dist[10][10];
llint cost[150];
llint dp[150][10];
llint dp2[10][10005];
llint gain[150];
llint dp3[10005];


int main(void)
{
	cin >> N >> M >> W >> T;
	string s;
	for(int i = 1; i <= M; i++){
		cin >> s >> V[i] >> P[i];
		mp[s] = i;
	}
	int L, q;
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= M; j++){
			Q[i][j] = inf;
		}
	}
	for(int i = 1; i <= N; i++){
		cin >> L >> X[i] >> Y[i];
		for(int j = 1; j <= L; j++){
			cin >> s >> q;
			Q[i][mp[s]] = q;
		}
	}
	
	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= N; j++){
			dist[i][j] = abs(X[i]-X[j]) + abs(Y[i]-Y[j]);
		}
	}
	
	llint S = 1 << N;
	for(int i = 0; i < S; i++){
		for(int j = 0; j <= N; j++){
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for(int i = 0; i < S; i++){
		for(int j = 0; j <= N; j++){
			for(int k = 1; k <= N; k++){
				if(i & (1<<(k-1))) continue;
				dp[i|(1<<(k-1))][k] = min(dp[i|(1<<(k-1))][k], dp[i][j] + dist[j][k]);
			}
		}
	}
	for(int i = 0; i < S; i++){
		cost[i] = inf;
		for(int j = 0; j <= N; j++){
			cost[i] = min(cost[i], dp[i][j] + dist[0][j]);
		}
	}
	
	llint profit[10];
	for(int s = 0; s < S; s++){
		for(int i = 1; i <= M; i++) profit[i] = 0;
		for(int i = 1; i <= N; i++){
			if( (s & (1<<(i-1))) == 0 ) continue;
			for(int j = 1; j <= M; j++){
				profit[j] = max(profit[j], P[j] - Q[i][j]);
			}
		}
		
		for(int i = 0; i <= N; i++){
			for(int j = 0; j <= W; j++){
				dp2[i][j] = -inf;
			}
		}
		dp2[0][0] = 0;
		for(int i = 1; i <= M; i++){
			for(int j = 0; j <= W; j++){
				dp2[i][j] = dp2[i-1][j];
				if(j >= V[i]) dp2[i][j] = max(dp2[i][j], dp2[i][j-V[i]] + profit[i]) ; 
			}
		}
		
		gain[s] = 0;
		for(int j = 0; j <= W; j++){
			gain[s] = max(gain[s], dp2[M][j]);
		}
	}
	
	for(int i = 0; i <= T; i++){
		for(int j = 0; j < S; j++){
			if(i+cost[j] > T) continue;
			dp3[i+cost[j]] = max(dp3[i+cost[j]], dp3[i] + gain[j]);
		}
	}
	
	llint ans = 0;
	for(int i = 0; i <= T; i++) ans = max(ans, dp3[i]);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3876
// 🐋💭 Next Prime
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}



func main() {
    var x = readInt()
    var count = 0
    var isNotPrime = true
    
    while isNotPrime {
        for i in 1..<x {
            count += x % i == 0 ? 1: 0
            if count > 1 {
                break
            }
            
        }
        if count > 1 {
            count = 0
            x += 1
        } else {
            isNotPrime = false
        }
        
    }
    print(x)
}
main()


Measured memory_bytes: 13124
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    int P[N];
    REP(i,N) cin >> P[i];
    int mi = N+1;
    int ans = 0;
    REP(i,N){
        if(P[i] <= mi){
            ans++;
            mi = P[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4376
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[] = {-1,0,1,0,-1,-1,1,1};
const int dy[] = {0,-1,0,1,1,-1,1,-1};

int main(){
  int n,m; cin>>n>>m;
  int c[m]; rep(i,m) cin>>c[i];
  int dp[101010];
  rep(i,101010) dp[i]=-1;
  dp[0]=0;
  rep(i,n+1){
    rep(j,m){
      int x=c[j];
      if(dp[i+x]!=-1) dp[i+x]=min(dp[i+x],dp[i]+1);
      else dp[i+x]=dp[i]+1;
    }
  }
  //rep(i,n+1) cout<<dp[i]<<endl;
  cout<<dp[n]<<endl;
}



Measured memory_bytes: 3520
#include<bits/stdc++.h>							
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;
const ll maxsize = 100000009;

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

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

void solve() {
	ll a, b;
	cin >> a >> b;
	cout << lcm(a, b) << endl;
	return;
}


int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
}
 
 
 



Measured memory_bytes: 3648
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include "bits/stdc++.h"
using namespace std;
#define int int32_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = numeric_limits <int>::max())
{return uniform_int_distribution<int> (l, r)(rng);}

template <typename T, typename G>
ostream& operator << (ostream& out, const pair <T, G> &a) 
{return out << "( " << a.x << ", " << a.y << ")";}

template <typename T>
ostream& operator << (ostream& out, const vector <T> &a) 
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

template <typename T>
ostream& operator << (ostream& out, const set <T> &a) 
{out << "{ "; for(const auto &i: a) out << i << ", "; return out << "}" << endl;}

template <typename T, typename G>
ostream& operator << (ostream& out, const map <T, G> &a) 
{out << "< "; for(const auto &i: a) out << i << ", "; return out << ">" << endl;}

template <typename T, size_t N>
typename enable_if<!is_same <typename remove_cv <T>::type, char>::value,
ostream&>::type operator << (ostream& out, T (&a)[N])
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

void debug_out(){cerr << endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr << (H) << ' '; debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr << '#' << #__VA_ARGS__ << ":\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	vector <string> a(n);
	for (int i = 0; i < n; ++i) 
		cin >> a[i];
	int ans = 0;
	for (int mask_i = 0; mask_i < (1 << n); ++mask_i) {
		for (int mask_j = 0; mask_j < (1 << m); ++mask_j) {
			int count = 0;
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < m; ++j) {
					if ((mask_i & (1 << i)) || (mask_j & (1 << j)))
						continue;
					count += (a[i][j] == '#');
				}
			}
			ans += (count == k);
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;

int memo[200][200];

int dfs(int x,int y){
  if(memo[x][y] != 0) return memo[x][y];
  if(x<=1&&y<=1) return memo[x][y] = -1;
  for(int i=1;i*2<=x;i++){
    int a = dfs(x-2*i,y+i);
    if(a==-1){
      return memo[x][y] = 1;
    }
  }
  for(int i=1;i*2<=y;i++){
    int a = dfs(x+i,y-2*i);
    if(a==-1)
    return memo[x][y] = 1;
  }
  return memo[x][y] = -1;
}

int main() {
  /*
  repeat(i,100){
    repeat(j,100){
      cout << i << " " << j << " " << dfs(i,j) << endl;
    }
  }
  */
  ll X,Y;cin >> X >> Y;
  cout << (abs(X-Y)<=1? "Brown":"Alice") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long N, K;
    cin >> N >> K;
    long long cnt = 0;
    for(long long b = K+1; b <= N; b++) {
        for(long long a = 0; a <= N; a += b) {
            long long c = a + K;
            long long d = a + b - 1;
            if (c == 0) c = 1;
            if (c > N) break;
            if (d > N) d = N;
            cnt += d-c+1;
        }
    }

    cout << cnt << endl;
    return 0;
}

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

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;
 
int main() {
  int n;
  cin >> n;
  
  vector<mint> a(n);
  int b = 0;
  for (int i = 0; i < n; i++) {
    cin >> b; 
    a.at(i) = b;
  }
  
  mint sum = 0;
  for(mint i : a){
    sum += i;
  }
  
  mint total = 0;
  mint left = 0;
  for(int i=0; i<n; i++){
    left += a.at(i);
    total += a.at(i)*(sum - left);    
  }
  
  cout << total << endl;

  return 0; 
}

Measured memory_bytes: 4824
import heapq
N , M = map(int ,input().split())
a = list(map(int ,input().split()))

heapq.heapify(a)
lst = []
for i in range(M):
    b , c = map(int ,input().split())
    lst.append([b, c])
lst.sort(reverse = True , key = lambda x: x[1])
#print(lst)
for i in range(M):
    for _ in range(lst[i][0]):
        if lst[i][1] <= a[0]:
            break
        heapq.heappop(a)
        heapq.heappush(a,lst[i][1])
print(sum(a))

Measured memory_bytes: 25656
#include<iostream>
using namespace std;
int main(){
    int a, b, c, x, y = 0; ;
    cin >> a >> b >> c;
    for ( x = a; x <= b; x++ ){
        if ( c % x == 0 ){
            y = y + 1;
        }
    }
    cout << y << endl;
    return 0;
}



Measured memory_bytes: 3112
MOD = 1000000007

s = [-1 if x == '?' else int(x) for x in input()]
n = len(s) + 1

dp = [0] * 13
dp[0] = 1

r = [[(j-i)*4%13 for i in range(10)]for j in range(13)]

for i, x in enumerate(s):
    next_dp = [0] * 13
    if x == -1:
        next_dp = [sum(dp[i] for i in j) for j in r]
    else:
        next_dp = [dp[j[x]] for j in r]
    dp = [k % MOD for k in next_dp]

print(dp[5])

Measured memory_bytes: 3956
import copy

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

S=[]
for _ in range(N-K+1):
    S.append(0)

for i in range(K):
    S[0]+=P[i]

for j in range(1,N-K+1):
    S[j]=S[j-1]-P[j-1]+P[j+K-1]

ans=(max(S)+K)/2

print(ans)

Measured memory_bytes: 25572
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, k; readV(n, k);
  writeln(n%k == 0 ? 0 : 1);
}


Measured memory_bytes: 256
#include <stdio.h> 
#include <math.h>
int main(void)
{
	double x1, x2, y1, y2;
	double kyori;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	kyori = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
	printf("%f\n", kyori);

	return 0;
}

Measured memory_bytes: 652
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int n = sc.nextInt();
				int m = sc.nextInt();
				if(n + m == 0) break;
				
				int[] ds = new int[11];
				while(n-- != 0) {
					int d = sc.nextInt();
					int p = sc.nextInt();
					ds[p] += d;
				}
				int P = 0;
				for(int p=10; p>=0; p--) {
					if(m >= ds[p]) {
						m -= ds[p];
					}
					else {
						P += (ds[p] - m) * p;
						m = 0;
					}
				}
				System.out.println(P);
			}
		}
	}
}


Measured memory_bytes: 67116
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
const ll MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};
 
int main() {
	ll X,Y;
  	cin >> X >> Y;
  	ll count=0;
  	while(X<=Y){
    	X*=2;
      	count++;
    }
  	cout << count << endl;
}

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

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

  int r = (2*D+1);
  cout << (N+r-1)/r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <complex>
#include <vector>
using namespace std;
typedef complex<double> P;
const double PI=3.141592653589793238462643383279;

inline bool inC(P p, P c, double r){return abs(p-c)<r+1e-9;}

inline P getE(P p){return p/abs(p);}

inline double sq(double x){ return  x*x;}

int main(){
    int n,i,j,k,ans,cnt;
    double x, y;
    while(scanf("%d",&n)){
        if(n==0) break;
        ans=0;
        vector<P> ps(n);
        for(i=0; i<n; i++){
            scanf("%lf%lf",&x,&y);
            ps[i] = P(x,y);
        }
        for(i=0;i<n;i++)
            for(j=i+1;j<n;j++)if(abs(ps[i]-ps[j])<2){
                double d=sqrt(1-sq(abs(ps[j]-ps[i])*0.5));
                P c1=0.5*(ps[i]+ps[j])+getE(getE(ps[j]-ps[i]))*polar(d,PI/2);
                P c2=0.5*(ps[i]+ps[j])+getE(getE(ps[j]-ps[i]))*polar(d,-PI/2);
                cnt=0;
                for(k=0;k<n;k++)if(inC(ps[k],c1,1.0))cnt++;
                if(cnt>ans)ans=cnt;
                cnt=0;
                for(k=0;k<n;k++)if(inC(ps[k],c2,1.0))cnt++;
                if(cnt>ans)ans=cnt;
            }
        if(ans==0) ans++;
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1076
odd = ['R','U','D']
even = ['L','U','D']
yesno = 'Yes'
S = list(input())
for i in range(len(S)):
  if i%2 == 0 and S[i] in odd:
    continue
  elif i%2 == 1 and S[i] in even:
    continue
  else:
    yesno = 'No'
    break
print(yesno)
  
  

Measured memory_bytes: 3060
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] abc = scanner.nextLine().split(" ", 3);
        int a = Integer.parseInt(abc[0]);
        int b = Integer.parseInt(abc[1]);
        int c = Integer.parseInt(abc[2]);
        if (c >= a && c <= b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<iostream>
using namespace std;

long long int buks[11];
long long int N;
long long int F[200][20];
long long int P[200][20];
long long int many[200];
long long int maxs, prof;
bool first;

void bruteforce(int a, int b)
{
	if(a == 10)
	{
		bool ok = false;
		for(int i=0; i<N; i++) 
		{
			if(buks[i] == 1) {ok = true;
			break;	
			}
		}
		if(ok == true)
		{
		
			for(int i=0; i<N; i++) many[i] = 0;
			
			for(int i=0; i<10; i++)
			{
				if(buks[i] ==0) continue;
				for(int j=0; j<N; j++)
				{
					if(F[j][i] == 1) many[j]++;
				}
			}
			
			int totbuk = 0;
			
			prof = 0;
			for(int i =0; i<N; i++)
			{
				prof+= P[i][many[i]];
			}
			
			if(first == false)
			{
				first = true;
				maxs = prof;
			}
			else if(prof>maxs) maxs = prof;
		}
				
	} 
	else
	{
		for(int i=0; i<=1; i++)
		{
			buks[a] = i;
			bruteforce(a+1, i);
		}
	}
}

int main()
{
	
	scanf("%lld",&N);
	for(int i=0; i<N; i++)
	{
		for(int j=0; j<10 ;j++) scanf("%lld",&F[i][j]);
	}
	for(int i=0; i<N; i++)
	{
		for(int j=0; j<11 ;j++) scanf("%lld",&P[i][j]);
	}
	first = false;
	bruteforce(0,0);
	
	printf("%lld\n",maxs);
}

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

int main() {
	int a,b;
	cin>>a>>b;
	if(a>b) {
		if(b==1) cout<<"Bob";
		else cout<<"Alice";
	}
	else if(a<b) {
		if(a==1) cout<<"Alice";
		else cout<<"Bob";
	}
	else cout<<"Draw";
	cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int i, j;
    int n, m;

    int mat[100][100];
    int vec[100];
    int result[100] = {};

    scanf("%d %d", &n, &m);

    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            scanf("%d", &mat[i][j]);
        }
    }
    for (i = 0; i < m; i++) {
        scanf("%d", &vec[i]);
    }

    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            result[i] += mat[i][j] * vec[j];
        }
    }

    for (i = 0; i < n; i++) {
        printf("%d\n", result[i]);
    }

    return 0;
}


Measured memory_bytes: 2104
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := make([]int, n)
	ans := 0
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	var tmpSum int
	for i := 0; i < n; i++ {
		if a[i] == 0 {
			ans += tmpSum / 2
			tmpSum = 0
		} else {
			tmpSum += a[i]
		}
	}
	ans += tmpSum / 2
	fmt.Println(ans)
}


Measured memory_bytes: 4224
import java.util.*

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toLong() }
    val a = readLine()!!.split(" ").map { -it.toLong()}

    var q = PriorityQueue(a)
    for (i in 0 until m){
        q.add(q.poll()/2)
    }
    println(-q.sum())
}



Measured memory_bytes: 69940
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)
#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0)

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

int calc_need(int i, int k) {
    int ret = 0;
    while (true) {
        if (i >= k) {
            return ret;
        }
        ret++;
        i *= 2;
    }
}

// --- notice ---
// intの和はllにしろ

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

    vector<int> need(n, 0);
    rep(i, n) {
        need[i] = calc_need(i + 1, k);
    }

    double prob = 0.0;
    rep(i, n) {
        prob += (1.0 / pow(2.0, (double) need[i]));
    }

    cout << fixed << setprecision(10) << prob / (double) n << endl;
    
    return 0;
}

Measured memory_bytes: 640
local mfl, mce = math.floor, math.ceil
local n, a, b = io.read("*n", "*n", "*n")
local c = a - b
local h = {}
for i = 1, n do
  h[i] = io.read("*n")
end
table.sort(h)

local function solve(x)
  local cnt = 0
  for i = 1, n do
    if x * b < h[i] then
      cnt = cnt + mce((h[i] - x * b) / c)
    end
  end
  return cnt <= x
end

local min = 0
local max = mce(h[n] / b)
while 1 < max - min do
  local mid = mfl((min + max) / 2)
  if solve(mid) then
    max = mid
  else
    min = mid
  end
end
print(max)


Measured memory_bytes: 1408
n,m=map(int,input().split())
broken=[False for i in range(n+1)]
for i in range(m):
    a=int(input())
    broken[a]=True
ans=[1]
if broken[1]:
    ans.append(0)
else:
    ans.append(1)
for i in range(2,n+1):
    if broken[i]:
        ans.append(0)
    else:
        ans.append((ans[i-1]+ans[i-2])%1000000007)
print(ans[n])


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

using T = tuple<double, double, double>;
double d(T a, T b) {
    double x, y, z, xx, yy, zz;
    tie(x, y, z) = a;
    tie(xx, yy, zz) = b;
    return sqrt(pow(x - xx, 2) + pow(y - yy, 2) + pow(z - zz, 2));
}

struct star {
    double x, y, z;
    double vx, vy, vz;
    double r, vr;
    double t;
    void get() {
        cin >> x >> y >> z >> vx >> vy >> vz >> r >> vr;
        t = r / vr;
    }
    T p(double s) { return T{x + s * vx, y + s * vy, z + s * vz}; }
};

main() {
    cout << setprecision(15) << fixed;
    while(1) {
        int n;
        cin >> n;
        if(!n) return 0;
        vector<star> s(n);
        rep(i, n) s[i].get();
        vector<pair<double, pair<int, int>>> v;
        using pii = pair<int, int>;
        rep(i, n) { v.emplace_back(s[i].t, pii(i, -1)); }
        rep(i, n) {
            rep2(j, i + 1, n - 1) {
                double l = 0, r = min(s[i].t, s[j].t);
                auto f = [&](double t) {
                    return d(s[i].p(t), s[j].p(t)) - (s[i].r - s[i].vr * t) -
                           (s[j].r - s[j].vr * t);
                };
                rep(_, 70) {
                    double tl = (l * 2 + r) / 3, tr = (l + r * 2) / 3;
                    if(f(tl) > f(tr))
                        l = tl;
                    else
                        r = tr;
                }
                if(f(l) > 0) continue;
                double low = 0, high = l;
                rep(_, 70) {
                    double mid = (low + high) / 2;
                    if(f(mid) < 0)
                        high = mid;
                    else
                        low = mid;
                }
                v.emplace_back(low, pii(i, j));
            }
        }
        sort(v.begin(),v.end());
        vector<double> ans(n,-100);
        for(auto e:v){
            int i = e.second.first;
            int j = e.second.second;
            if(j == -1) {
                if(ans[i] < 0) ans[i] = e.first;
            } else {
                if(!(ans[i] > 0 or ans[j] > 0)){
                    ans[i] = e.first;
                    ans[j] = e.first;
                }
            }
        }
        rep(i, n) cout << ans[i] << endl;
    }
}



Measured memory_bytes: 3288
import sys
sys.setrecursionlimit(10**7)
N,M=map(int,input().split())
E=[[]for _ in'_'*-~N]
for _ in'_'*M:
	a,b=map(int,input().split())
	E[a]+=[b]
	E[b]+=[a]
V=[0]*-~N
def f(i,x):
	if V[i]:
		return V[i]==x
	V[i]=x
	r=1
	for j in E[i]:
		r*=f(j,-x)
	return r
if f(1,1):
	print(V.count(1)*V.count(-1)-M)
else:
	print(N*~-N//2-M)

Measured memory_bytes: 43952
#include <stdio.h>
int main(void){
  int A,B,C,K,max,i,sum;
  scanf("%d %d %d",&A,&B,&C);
  scanf("%d",&K);
  
  if(A>=B&&A>=C){
    max=A;
    sum=B+C;}
  else if(B>=A&&B>=C){
    max=B;
    sum=A+C;}
  else{
    max=C;
    sum=A+B;}
  
  for(i=0;i<K;i++)
    max=max*2;
    
  sum=sum+max;
  printf("%d",sum);

}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
using namespace std;
const int MAXN = 1e5+10, INF = 0x3f3f3f3f;
int A[MAXN], dp[MAXN], N;

int main()
{
	scanf("%d", &N);
	int i;
	for(i=1;i<=N;i++) scanf("%d", &A[i]), dp[i] = INF;
	dp[1] = 0;
	dp[2] = abs(A[1]-A[2]);
	for(i=3;i<=N;i++) {
		dp[i] = Min(dp[i], Min(dp[i-1]+abs(A[i]-A[i-1]), dp[i-2]+abs(A[i]-A[i-2])));
	}
	printf("%d\n", dp[N]);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

void solve(){
    ll n, k;
    cin>>n>>k;
    n = n%k;
    print(min(n, k-n));
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
   
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    string s;
    cin >> s;
    string s1 = s;
    string s2 = s;
    int ans1 = 0, ans2 = 0;
    for(int i = 0; i < s.size(); i++){
        if(i&1){
            s1[i] = '1';
            s2[i] = '0';
        }
        else{
            s1[i] = '0';
            s2[i] = '1';
        }
        if(s[i] != s1[i])ans1++;
        if(s[i] != s2[i])ans2++;
    }
    cout << min(ans1, ans2) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n;
ll a[300005];
ll d[300005];

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < (1 << n); i++)
    {
        scanf("%lld", &a[i]);
    }
    for(ll i = 1; i < (1 << n); i++)
    {
        ll t = i;
        d[i] = d[i - 1];
        ll mx1 = a[0], mx2 = 0;
        for(ll j = t; j > 0; j = ((j - 1) & i))
        {
            if(mx1 < a[j]) mx2 = mx1, mx1 = a[j];
            else if(mx2 < a[j]) mx2 = a[j];
        }
        d[i] = max(d[i - 1], mx1 + mx2);
        printf("%lld\n", d[i]);
    }
    return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
vector<vector<int>> dp;
vector<int> a;
int dfs(int x, int turn) {
    if(dp[x][turn] != -1) {
        return dp[x][turn];
    } else {
        int tmp = 1;
        for(auto e : a) {
            if(x - e >= 0) {
                tmp = min(tmp, dfs(x - e, 1 - turn));
            }
        }
        if(tmp == 0) {
            dp[x][turn] = 1;
            return 1;
        } else {
            dp[x][turn] = 0;
            return 0;
        }
    }
}
int main() {
    int n, k;
    cin >> n >> k;
    a.resize(n);
    int m = INT_MAX;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        m = min(m, a[i]);
    }
    dp.resize(k + 1, vector<int>(2, -1));
    for(int i = 0; i < m; i++) {
        dp[i][0] = 0;
        dp[i][1] = 0;
    }
    cout << (dfs(k, 0) ? "First" : "Second") << endl;
}

Measured memory_bytes: 16340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int ac=0,wa=0,tle=0,re=0;
    int n;
    cin>>n;
    while(n--){
        string s;
        cin>>s;
        if(s=="AC")ac++;
        else if(s=="WA")wa++;
        else if(s=="TLE")tle++;
        else re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}

Measured memory_bytes: 3556