akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
//#define int long long 
#define LL long long 
#define ull unsigned long long 
using namespace std;
const int MAXN = 4001, mod = 1e9 + 7, INF = 1e9 + 10;
const double eps = 1e-9;
template <typename A, typename B> inline bool chmin(A &a, B b){if(a > b) {a = b; return 1;} return 0;}
template <typename A, typename B> inline bool chmax(A &a, B b){if(a < b) {a = b; return 1;} return 0;}
template <typename A, typename B> inline LL add(A x, B y) {if(x + y < 0) return x + y + mod; return x + y >= mod ? x + y - mod : x + y;}
template <typename A, typename B> inline void add2(A &x, B y) {if(x + y < 0) x = x + y + mod; else x = (x + y >= mod ? x + y - mod : x + y);}
template <typename A, typename B> inline LL mul(A x, B y) {return 1ll * x * y % mod;}
template <typename A, typename B> inline void mul2(A &x, B y) {x = (1ll * x * y % mod + mod) % mod;}
template <typename A> inline void debug(A a){cout << a << '\n';}
template <typename A> inline LL sqr(A x){return 1ll * x * x;}
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int N, M;
char s1[MAXN], s2[MAXN];
map<ull, bool> mp;
ull base = 29;
int num[27];
ull get() {
	ull now = 0;
	for(int i = 0; i < 26; i++) 
		now = now * base + num[i];
	return now;
}
signed main() {
	scanf("%s", s1 + 1);
	scanf("%s", s2 + 1);
	N = strlen(s1 + 1); M = strlen(s2 + 1);
	for(int len = min(N, M); len >= 1; len--) {
		mp.clear();
		memset(num, 0, sizeof(num));
		for(int i = 1; i <= N; i++) {
			num[s1[i] - 'a']++;
			if(i > len) num[s1[i - len] - 'a']--;
			if(i >= len) mp[get()] = 1;
		}
		memset(num, 0, sizeof(num));
		for(int i = 1; i <= M; i++) {
			num[s2[i] - 'a']++;
			if(i > len) num[s2[i - len] - 'a']--;
			if(i >= len && mp[get()]) {
				cout << len << '\n';
				return 0;
			}
		}
	}
	puts("0");
    return 0;
}
/*
aaaaa
aaaaaaaa
*/


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;

int main(){

    string s;
    cin >> s;

    if (s=="ABC")
    {
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }
    return 0;
}



Measured memory_bytes: 3628
#include<stdio.h>

int gcd(int x,int y);

int main()
{
  int x,y;

  scanf("%d%d",&x,&y);
  
  printf("%d\n",gcd(x,y));

  return 0;
}

int gcd(int x, int y)
{
  int tmp;

  if(x < y) {
    tmp = x;
    x = y;
    y = tmp;
  }
  while(y>0) {
    tmp = x%y;
    x = y;
    y = tmp;
  }
  return x;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#include<map>
#include<string>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pll         pair<ll,ll>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep1(i,a,b) for(ll i=a;i<= b;i++)
#define PI          3.14159
#define MAX         1000001
#define left (2*i+1)
#define right (2*i+2)
#define fast_io ios_base::sync_with_stdio(false);  cin.tie(0);  cout.tie(0);
using namespace std;
vector<ll> track;
int main()
{
  fast_io
  ll n;
  cin >> n;
  cout << (n - 1)*(n)/2;
  return 0;
}

Measured memory_bytes: 256
using System;

class _049C
{
    static void Main()
    {
        string S;

        S = Console.ReadLine();

        NewMethod(S);
    }

    private static void NewMethod(string S)
    {
        S = S.Replace("eraser", " ");
        S = S.Replace("erase", " ");
        S = S.Replace("dreamer", " ");
        S = S.Replace("dream", " ");
        S = S.Replace(" ", "");

        if (S.Length == 0)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 14304
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll target;

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

    ll maxi=0,f=0,mini=INF,sum=0;
    string stra,str2;
    ll h,w;
    ll n,x,m;
    ll a,b,d,c;
    multiset<ll> s;
    cin>>n>>m;
    rep(i,m){
        cin>>a>>b;
        s.insert(a);
        s.insert(b);
    }
    for(ll i=1;i<=n;i++){
        cout<<s.count(i)<<endl;
    }
    


    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  ll s = 0;
  REP(i, n) s^= a[i];
  REP(i, n){
    ll ans = s^a[i];
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 4684
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double



////////////////////////////////////////////////////////////////////
template<typename T>
struct edge {
  int to, from;T cost;
  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T>
using edges = vector<edge<T>>;
template<typename T>
using graph = vector<edges<T>>;
template<typename T>
using matrix = vector<vector<T>>;

template<typename T>
bool compByCost(const edge<T>& left, const edge<T>& right){
  return left.cost < right.cost; 
}

template<typename T>
vector<T> dijkstra(int s, graph<T> &g){
  vector<T> dist(g.size()+10, INF);dist[s] = 0;
  priority_queue<P, vector<P>, greater<P>> que;que.push(P(0,s));
  while(!que.empty()){
    P p = que.top();que.pop();
    int v = p.second;
    if(dist[v] < p.first)continue;
    rep(i, g[v].size()){
      edge<T> e = g[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        que.push(P(dist[e.to], e.to));
      }
    }
  }
  return dist;
}

#define dijkstra dijkstra<int>

////////////////////////////////////////////////////////////////////
int n;graph<int> g(1100000);
int ans,h[1100000];
signed main(){
  cin>>n;int v = n*2;
  rep(i,1100000)h[i] = 0;
  rep(i,n){
    int pre;cin>>pre;pre--;
    rep(j,n-2){
      int mx = max(i, pre), mm = min(i, pre);
      int a;cin>>a;a--;
      int mmx = max(i, a), mmm = min(i, a);
      g[mx*n+mm].push_back(edge<int>(mmx*n+mmm, 1));
      h[mmx*n+mmm]++;
      pre = a;
    }
  }
  //cout << "///////////" << endl;
  ///rep(i,20)cout << i/n+1 << " " << i%n+1 << " " << h[i] << endl;
  //cout << "/////////" << endl;
  queue<int> st;
  rep(i,1100000){
    if(h[i] == 0 && i%n < i/n && i/n < n)st.push(i);
  }
  st.push(-1);
  int ans = 0, cnt = 0;
  while(!st.empty()){
    int i = st.front();st.pop();
    //if(i == -1)cout << "-1!!!!!  " << st.size() << endl;
    //else cout << i/n+1 << " " << i%n+1 << endl;
    if(i == -1){
      ans++;st.push(-1);
      if(st.front() == -1){
        break;
      }else continue;
    }
    cnt++;
    rep(j,g[i].size()){
      int jj = g[i][j].to;
      //if(i == 4)cout << jj << endl;
      h[jj]--;
      if(h[jj] == 0)st.push(jj);
    }
  }
  if(cnt != n*(n-1)/2){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
}


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


int main() {
    ios::sync_with_stdio(false);
    long long int a,b,c;
    cin >> a >> b >> c;
    //4 12 20
    //2 6 10
    //
    long long int ta,tb,tc;
    long long int oa=a,ob=b,oc=c;
    int cn=0;
    while(a%2==0 && b%2 ==0 && c%2==0){
        ta = b/2+c/2;
        tb = a/2+c/2;
        tc = a/2+b/2;
        a = ta;
        b = tb;
        c = tc;
        cn++;
        if(oa==a && ob==b && oc==c){
            cout << "-1" << endl;
            return 0;
        }
    }
    cout << cn << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = [_ for _ in input()]

left, right = 0, S[1:].count('E')
ans = left + right
for i in range(N-1):
    if S[i] == 'W':
        left += 1
    if S[i+1] == 'E':
        right -= 1

    ans = min(ans, left + right)

print(ans)


Measured memory_bytes: 15136
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int a, b;

signed main() {
    cin >> a >> b;
    if (a + b == 15) {
        cout << "+" << endl;
    } else if (a * b == 15) {
        cout << "*" << endl;
    } else {
        cout << "x" << endl;
    }
    return 0;
}
//A


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

struct MaximumHeap {
    MaximumHeap(const vector < int >& dat) : size(dat.size())
    {
        data = dat;
        for ( int i = (size - 2) / 2; i >= 0; i-- ) {
            maxHeapify(i);
        }
    }
    
    void print()
    {
        for ( int i = 0; i < size; i++ ) {
            cout << " " << data[i];
        }
        cout << endl;
    }

private:
    vector < int > data;
    int size;
    
    void maxHeapify(int node)
    {
        int l = node * 2 + 1, r = node * 2 + 2;
        int largest = node;
        if ( l < size && data[l] > data[node] ) largest = l;
        if ( r < size && data[r] > data[largest] ) largest = r;
        if ( largest != node ) {
            swap(data[largest], data[node]);
            maxHeapify(largest);
        }
    }
};

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

    vector < int > data(H);
    
    for ( int i = 0; i < H; i++ ) {
        cin >> data[i];
    }

    MaximumHeap tree(data);

    tree.print();
    
    return ( 0 );
}



Measured memory_bytes: 6744
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n < 105) {
			System.out.println(0);
		} else if(n < 135) {
			System.out.println(1);
		} else if(n < 165) {
			System.out.println(2);
		} else if(n < 189) {
			System.out.println(3);
		} else if(n < 195){
			System.out.println(4);
		} else {
			System.out.println(5);
		}
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int dp[20][3][3];
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
int main(){
	while(true){
		int n;	cin>>n;
		if(n==0)	return 0;
		char s,t,b;	cin>>s>>t>>b;
		int sx,sy,tx,ty,bx,by;
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				int num=3*i+j;
				if(num==s-'A'){
					sy=i;	sx=j;
				}
				if(num==t-'A'){
					ty=i;	tx=j;
				}
				if(num==b-'A'){
					by=i;	bx=j;
				}
			}
		}
		for(int i=0;i<20;i++)
			for(int j=0;j<3;j++)
				for(int k=0;k<3;k++)
					dp[i][j][k]=0;
		dp[0][sy][sx]=1;
		for(int i=0;i<n;i++){
			for(int y=0;y<3;y++){
				for(int x=0;x<3;x++){
					if(dp[i][y][x]==0)	continue;
					for(int l=0;l<4;l++){
						int ny=y+dy[l];
						int nx=x+dx[l];
						if(ny<0||3<=ny||nx<0||3<=nx){
							dp[i+1][y][x]+=dp[i][y][x];
						}
						else if(bx==nx&&by==ny){
							dp[i+1][y][x]+=dp[i][y][x];
						}
						else{
							dp[i+1][ny][nx]+=dp[i][y][x];
						}
					}
				}
			}
		}
		printf("%.15lf\n",(double)dp[n][ty][tx]/pow(4,n));
	}
}

Measured memory_bytes: 1228
#include<iostream>
using namespace std;
int main()
{
    int i,a,b,n,m,l=0;
    cin>>a>>b;
    for(i=1;i<=2000;i++)
    {
        m=(i*(0.08));
        n=(i*(0.1));
        if(m==a&&n==b)
        {
            l++;
            cout<<i<<endl;
            break;
        }
    }
    if(l==0)
    {
        cout<<"-1"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a);i<=(b);i++)
#define ROF(i,a,b) for(int i = (a);i>=(b);i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 100005
#define M 51
#define INF 500
#define MOD 924844033
#define MOD2 1000000009
#define eps 1e-7
using namespace std;
inline int Max(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^b;
}
inline int Min(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^a;
}

string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin>>s)
    {
        int x = 0;
        int ans = 0;
        for(auto c:s)
        {
            if(c == 'g')
            {
                if(x>0)ans++,x--;
                else x++;
            }
            else
            {
                if(x>0)x--;
                else ans--,x++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
from operator import itemgetter

#配列のソート
def protect(N,M):
    DP = []
    for i in range(N):
        DP.append(list(map(int, input().split())))

    DP.sort(key=itemgetter(1))
    nokori = 0

    for i in range(N):
        if M > DP[N - i - 1][0]:
            M -= DP[N - i - 1][0]
            DP.pop()
        elif M <= DP[N - i - 1][0]:
            nokori = (DP[N - i - 1][0] - M) * DP[N - i - 1][1]
            M = 0
            DP.pop()
            break

    for i in range(len(DP)):
        nokori += DP[i][0] * DP[i][1]

    print(nokori)


#データの入力

while True:
    NM = input().split()
    N = int(NM[0])
    M = int(NM[1])
    if N==0:
        break
    protect(N,M)





Measured memory_bytes: 7200
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

const int MAX_N = 1000;

int par[MAX_N];
int Rank[MAX_N];
int size;

void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        Rank[i] = 0;
    }
    size = n;
}

int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    size--;
    if (Rank[x] < Rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (Rank[x] == Rank[y]) {
            Rank[x]++;
        }
    }
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int V, M;
    cin >> V >> M;
    int a[M], b[M];
    int ans = 0;
    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    rep(i, M) {
        init(V);
        rep(j, M) {
            if(i != j) unite(a[j], b[j]);
        }
        if (size != 1) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
local mmi, mma = math.min, math.max
local mab = math.abs
local n, k = io.read("*n", "*n")
local h = {}
local cost = {}
for i = 1, n do
  h[i] = io.read("*n")
  cost[i] = 1000000007 * 100
end
cost[1] = 0
for i = 1, n - 1 do
  local lim = mmi(k, n - i)
  for j = 1, lim do
    cost[i + j] = mmi(cost[i + j], cost[i] + mab(h[i + j] - h[i]))
  end
end
print(cost[n])


Measured memory_bytes: 6392
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;
#include<vector>
template<typename T>
class UnionFind
{
	public:
	vector<T> parent;
	
	UnionFind(T n):parent(n)
	{
		for(int i=0;i<n;i++)
			parent[i]=i;
	}
	
	void unite(T a,T b)
	{
		a=root(a);
		b=root(b);
		if(a==b)return;
		if(a>b)swap(a,b);
		parent[b]=a;
		return;
	}
	
	T root(T n)
	{
		if(parent[n]==n)
			return n;
		else
		{
			T ret=root(parent[n]);
			parent[n]=ret;
			return ret;
		}
	}
};

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

	int X[100010]={};
	int Y[100010]={};
	int Z[100010]={};
	
	UnionFind<int> uf(N);
	for(int i=0;i<M;i++)
	{
		cin >> X[i];
		cin >> Y[i];
		cin >> Z[i];
		X[i]--;
		Y[i]--;
		if(uf.root(X[i])!=uf.root(Y[i]))
			uf.unite(X[i],Y[i]);
	}

	int ans=0;
	for(int i=0;i<N;i++)
		if(i==uf.root(i))
			ans++;

	cout << ans << endl;

	return 0;
}



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

bool IsPrime(int);
int main()
{
    long long x;
    cin >> x;
    for (long long i = x;i>0;i++){
        if(IsPrime(i)==true){
            cout << i << endl;
            return 0;
        }
    }
}

bool IsPrime(int num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String[] judgeResult = new String[] { "AC", "WA", "TLE", "RE" };
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < 4; i++) {
            map.put(judgeResult[i], 0);
        }
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            map.put(s, map.get(s) + 1);
        }
        sc.close();

        // 主処理
        List<String> list = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            list.add(judgeResult[i] + " x " + map.get(judgeResult[i]));
        }
        String result = String.join("\r\n", list);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 58760
#include<stdio.h>
int table[55000];
 
int main(){
    for(int i=2;i<1000;i++){
        if(table[i]==0){
            for(int j=i*2;j<=55000;j+=i){
                table[j]=1;
            }
        }
    }
    int a;
    while(~scanf("%d",&a)){
        int i;
        for(i=a-1;table[i]==1;i--);
        printf("%d ",i);
        for(i=a+1;table[i]==1;i++);
        printf("%d\n",i);
    }
}


Measured memory_bytes: 2904
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  string n[N],m[M];
  for(int i=0;i<N;i++)
    cin>>n[i];
  for(int i=0;i<M;i++)
    cin>>m[i];
  if(M==N){
    bool p=true;
    for(int i=0;i<M;i++)
      for(int j=0;j<M;j++)
        if(n[i][j]!=m[i][j])
          p=false;
    if(p==true)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
    return 0;
  }
  for(int i=0;i<N-M;i++)
    for(int j=0;j<N-M;j++){
      bool present=true;
      for(int p=i;p<i+M;p++)
        for(int q=j;q<j+M;q++)
          if(n[p][q]!=m[p-i][q-j])
            present=false;
      if(present==true){
        cout<<"Yes";
        return 0;
      }
    }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long X){
    long long n = 100;
    int count = 0;
    for (int i = 1; i < 4000; i++) {
        n *= 1.01;
        count++;
        if (n >= X) break ;
    }
    cout << count << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


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

using namespace std;
using ll = long long int;

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

    vector<vector<ll>> tel(n, vector<ll>(100));
    for(ll i=0; i<n; i++)
        cin >> tel[i][0], tel[i][0]--;

    for(ll k=1; k<100; k++)
        for(ll i=0; i<n; i++)
            tel[i][k] = tel[tel[i][k-1]][k-1];

    ll v = 0;
    for(ll t=63; t>=0; t--)
        if((k>>t)&1)
            v = tel[v][t];
    cout << v + 1 << endl;
}


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    int SUM = A + B + C;
    if(SUM == 17){
        if(10 == A+B || 10 == A+C || 10 == B+C){
            cout << "YES" << endl;            
        }
    }
    else{
        cout << "NO" << endl;
    }
}


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

const int INF = 1001001001;

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

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

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



    return 0;

}


Measured memory_bytes: 256
import java.io.*; 
public class Main{
  public static void main(String[] args) throws java.io.IOException{
    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br= new BufferedReader(isr);
    String buf =br.readLine();
    //int[] x = s2i(buf);
    int x=Integer.parseInt(buf);
    int h=x/3600;
    int m = (x-h*3600)/60;
    int s = x%60; 
    System.out.println(h+":"+m+":"+s);
  }

  static int[] s2i(String s){
    String[] res = s. split(" ",0);
    int[] x= new int[res.length];
    for(int i=0;i<res.length;i++){
      x[i]= Integer.parseInt(res[i]);
    }
    return x;
  }
}

Measured memory_bytes: 24084
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
long long n,m;
long long solve(long long x,long long y)
{
	if(x%y==0){
		return x+x-y;
	}
	long long t=x/y;
	return t*2*y+solve(y,x-t*y);
}
int main()
{
	cin>>n>>m;cout<<n+solve(m,n-m)<<endl;
	return 0;
}

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




 
public class Main 
{
	
	public static void main(String[] args) throws IOException 
	{ 
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		long k=s.nextLong();
		
		int ar[]=new int[n];
		for(int i=0;i<n;i++) {
			int u=s.nextInt();
			u--;
			ar[i]=u;
		}
		if(k<n) {
			int count=0;
			int next=0;
			while(count<k) {
				int val=ar[next];
				count++;
				next=val;
			}
			System.out.println(next+1);
		}else {
			int pos=0;
			int next=0;
			int noofnode=-1;
			HashMap<Integer,Integer>hm=new HashMap<>();
			hm.put(next, pos);
			while(true ) {
				pos++;
				int val=ar[next];
				if(hm.containsKey(val)) {
					noofnode=hm.get(val);
					break;
				}
				hm.put(val, pos);
				next=val;
			}
//				System.out.println(hm.size());
//				System.out.println(noofnode);
				k-=noofnode;
				int nodeincycle=hm.size()-noofnode;
				k%=nodeincycle;
				if(k==0) 
					k=nodeincycle;
				next=ar[next];
				int count=0;
				while(count<k) {
					int val=ar[next];
					count++;
					next=val;
				}
				System.out.println(next+1);
			
			
			
		}
	}

	
}




Measured memory_bytes: 67788
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n);
    REP(i,n){
        cin>>v[i];
    }
    sort(ALL(v));
    ll sum=0;
    REP(i,k){
        sum+=v[i];
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
typedef long long ll;

ll l, r, i, mn = 1e9;
int main()
{
    cin >> l >> r;
    for(ll i = l; i < min(l + 2018, r); i++){
        for(ll j = i + 1; j <= min(l + 2018, r); j++){
            mn = min(mn, i * j % 2019);
        }
    }
    cout << mn << endl;
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
const ll inf=0x3f3f3f3f;
using namespace std;
int main()
{
    ll s;
    cin>>s;
    int lim=1e9;
    int x=s/lim;if(s%lim) x++;
    int b=s/x;if(s%x) b++;

    int y=1ll*x*b-s;
    printf("%d %d %d %d %d %d",0,0,x,y,1,b);
    return 0;
}


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

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

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

    int d, n;
    cin >> d >> n;
    if (n == 100) n =101;
    int ans = 1;
    for (int i = 0; i < d; ++i) ans *= 100;
    cout << ans * n << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static long calc(long A, long B, long X) {
	long A_count = (A - 1) / X;
	long B_count = B / X;

	return B - A + 1 - (B_count - A_count);
    }

    public static long lcm(long a, long b) {
	long temp;
	long c = a;
	c *= b;
	while((temp = a % b) != 0) {
		a = b;
		b = temp;
	}

	return (long)(c / b);
    }
    
    public static void main(String[] args)  {
	Scanner sc = new Scanner(System.in);

	long A, B, C, D;
	A = sc.nextLong();
	B = sc.nextLong();
	C = sc.nextLong();
	D = sc.nextLong();

	long C_count = calc(A, B, C);
	long D_count = calc(A, B, D);
	long CD_count = calc(A, B, lcm(C, D));

	System.out.println(C_count + D_count - CD_count);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

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

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

int main() {
    
    int N, M;
    cin >> N >> M;
    
    int s = std::pow(2, N);
    vector<ll> dp(s, MOD_BIG);
    dp[0] = 0;
    
    for (int i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        std::bitset<12> op;
        for (int j = 0; j < b; j++) {
            int c;
            cin >> c;
            op.flip(c-1);
        }
        for (ll now = 0; now < s; now++) {
            ll next = now | op.to_ulong();
            dp[next] = std::min(dp[next], dp[now] + a);
        }
    }
    if (dp[s-1] == MOD_BIG) {
        cout << -1 << endl;
        return 0;
    }
    
    cout << dp[s-1] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef complex <double> point;
vector <point> pol;

bool eq(double a,double b){
  return (abs(a-b)<=(1e-9));
}

bool on_segment(point a,point b,point c){
  return eq(abs(b-a),abs(a-c)+abs(b-c));
}

double get_r(point a,point b,point c){
  b-=a,c-=a;
  b*=conj(c);
  return arg(b);
}

int solve(point a){
  for(int i=0;i<pol.size();i++)
    if(on_segment(pol[i],pol[(i+1)%pol.size()],a)) return 1;
 
  double sum=0;
  for(int i=0;i<pol.size();i++)
    sum+=get_r(a,pol[i],pol[(i+1)%pol.size()]);
  
  if(eq(sum,0))return 0;
  return 2;
}


int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++) {
    double a,b;
    cin>>a>>b;
    pol.push_back(point(a,b));
  }

  int q;
  cin>>q;
  while(q--){
    double a,b;
    cin>>a>>b;
    cout<<solve(point(a,b))<<endl;
  }
  return 0;
}

Measured memory_bytes: 1336
require 'matrix'
loop do
  s = gets.chomp.chop
  break if s == ''
  #lookahead(?!  )
  s.gsub!(/([A-Z\)])(?![a-z\d])/, '\11')
  s.gsub!(/([A-Z][a-z])(?!\d)/, '\11')
  s.gsub!(/\((.+?)\)(\d*)/){
    as, n = $1, $2
    as.gsub(/([a-zA-Z])(\d+)/){"#{$1}#{$2.to_i * n.to_i}"}
  }
  atoms = s.scan(/[A-Z][a-z]?/)
  atoms.uniq!
  molecules = s.split('->').map{|ms| ms.split('+')}
  l = molecules[0].size
  molecules.flatten!
  m = molecules.size - 1
  n = atoms.size

  a = Matrix.build(n, m){|y, x|
    molecules[x].scan(/#{atoms[y]}(\d+)/).reduce(0){ |sum, a|
      x < l ? sum + a[0].to_i : sum - a[0].to_i
    }.to_r
  }.to_a

  b = [0] * n
  atoms.each do |atom|
    molecules[-1].scan(/(#{atom})(\d+)/).each{|a, k|
      b[atoms.index(a)] = k.to_r
    }
  end

  # Gauss-Jordan elimination
  (0...[n,m].min).each do |i|
    pv = (i...n).max{|k| a[k][i].abs}
    a[i], a[pv] = a[pv], a[i]
    b[i], b[pv] = b[pv], b[i]
    (0...n).each do |j|
      next if i == j
      r = a[j][i] / a[i][i]
      (i...m).each do |k|
        a[j][k] -= r * a[i][k]
      end
      b[j] -= r * b[i]
    end
  end

  ans = (Matrix[*a[0,m]].inv * Vector[*b[0,m]]).to_a + [1.to_r]
  lcm = ans.map(&:denominator).reduce(&:lcm)
  puts ans.map{|x| (x * lcm).to_i} * ' '
end

Measured memory_bytes: 9920
def main():
    n = int(input())
    A = input().split()
    ans = list(reversed(A[1::2])) + A[::2]
    if n % 2 == 0:
        print(' '.join(ans))
    else:
        print(' '.join(list(reversed(ans))))


if __name__ == '__main__':
    main()


Measured memory_bytes: 99800
x = int(input())

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return table

table = sieve(10**5 + 100)

for i in table:
    if i >= x:
        print(i)
        exit()


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

int main()
{
  string s, t;
  cin >> s >> t;
  int res = (int)t.size();
  for (int base = 0; base + (int)t.size() <= (int)s.size(); base++) {
    int cnt = 0;
    for (int i = 0; base+i < (int)s.size() && i < (int)t.size(); i++) {
      if (s.at(base+i) == t.at(i)) {
        cnt++;
      }
    }
    cnt = (int)t.size() - cnt;
    res = min(res, cnt);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>

struct GROUP{
    int B;
    long long int C;

    GROUP(int _B, long long int _C){
        B = _B;
        C = _C;
    }
};

int main(){
    int N, M;
    int idx=0;
    std::cin >> N >> M;

    std::vector<long long int> A(N);
    std::vector<GROUP> X;

    for(int i=0;i<N;i++){
        int _A;
        std::cin >> _A;
        A[i] = _A;
    }
    for(int i=0;i<M;i++){
        int _B;
        long long int _C;
        std::cin >> _B >> _C;
        X.emplace_back(GROUP(_B, _C));
    }

    std::sort(X.begin(), X.end(), [](const GROUP &l, const GROUP &r){
        return l.C > r.C;
    });
    std::sort(A.begin(), A.end());

    for(int i=0;i<M;i++){
        int cnt = 0;
        while(cnt<X[i].B && A[idx]<X[i].C){
            A[idx]=X[i].C;
            idx++;
            cnt++;
        }
    }

    long long int sum=0;
    for(auto a : A){
        sum+=a;
    }
    std::cout << sum << std::endl;

    return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
#include <queue>
long long MOD=1e9+7;
using namespace std;
long long fib[10];

int main() {
  fib[0]=0;
  fib[1]=1;
  for(int i=2;i<=10;i++)fib[i]=fib[i-1]+fib[i-2];
  int h,w,k,i,j;
  cin >> h >> w >> k;
  long long dp[h+2][w+2];
  for(i=0;i<=h;i++){
    for(j=0;j<=w;j++){
      dp[i][j]=0;
    }
  }
  dp[0][1]=1;
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      long long l,c,r;
      l = c = r = 0;
      if(j>1)l = (dp[i-1][j-1]*fib[j-1]*fib[w-j+1])%MOD;
      c = (dp[i-1][j]*fib[j]*fib[w-j+1])%MOD;
      if(j<w)r = (dp[i-1][j+1]*fib[j]*fib[w-j])%MOD;
      dp[i][j]=(l+c+r)%MOD;
    }
  }
  cout << dp[h][k] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long ;

int A,B,h[100010]={};
int N;


bool judge(int X){
	ll T=0;
	for(int i=0;i<N;i++){
		int a=h[i]-B*X;
		if(a>0){
			if(a%(A-B)!=0){
				T+=a/(A-B)+1;
			}else{
				T+=a/(A-B);
			}
		}
	}
	if(T>X){
		return false;
	}else{
		return true;
	}
}
int main(){
	cin >> N >> A >> B;
	int Max=0;
	for(int i=0;i<N;i++){
		cin >> h[i];
		Max=max(Max,h[i]);
	}
	int top=1,bottom=Max/B;
	int mid=(top+bottom)/2;
	
	while(true){
		mid=(top+bottom)/2;
		if(judge(mid)){
			bottom=mid;
		}else{
			top=mid+1;
		}
		
		if(top==bottom){
			if(top==bottom&&mid==bottom){
				break;
			}
		}else{
			if(abs(top-bottom)==1){
				if(judge(min(top,bottom))){
					mid=min(top,bottom);
				}else{
					mid=max(top,bottom);
				}
				break;
			}
		}
	}
	cout << mid << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 220000
inline char gc(){
    static char now[1<<16],*S,*T;
    if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
    return *S++;
}
#define S 1<<19
inline int read(){
    int x=0,f=1;char ch=gc();
    while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=gc();}
    while (ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=gc();}
    return x*f;
}
int f1[S],f2[S],n,num,bin[20],st[N],a[N],right[N][20],left[N][20],v;
int main(){
    n=read();v=read();int Log=0;
    for (int i=1;i<=n;++i) a[i]=read();
    while ((1<<Log)<=v) Log++;Log++;
    for (int i=0;i<=Log+1;++i) bin[i]=1<<i;
    num=1;for (int i=2;i<=n;++i) if (a[i]-a[i-1]>v) num++;
    for (int j=0;j<Log;++j){
        left[1][j]=1;right[n][j]=n;
        for (int i=2;i<=n;++i) if (a[i]-a[i-1]>(v>>j)) left[i][j]=i;else left[i][j]=left[i-1][j];
        for (int i=n-1;i>=1;--i) if (a[i+1]-a[i]>(v>>j)) right[i][j]=i;else right[i][j]=right[i+1][j];
    }   
    if (num>Log){
        for (int i=1;i<=n;++i) printf("Impossible\n");return 0;
    }
    for (int s=0;s<=bin[Log]-1;++s) {f1[s]=0,f2[s]=n+1;}
    for (int s=0;s<=bin[Log]-1;++s){
        for (int i=0;i<Log;++i){
            if (s&bin[i])continue;
            if (f1[s]==n) f1[s|bin[i]]=n;else f1[s|bin[i]]=max(f1[s|bin[i]],right[f1[s]+1][Log-i-1]);
            if (f2[s]==1) f2[s|bin[i]]=1;else f2[s|bin[i]]=min(f2[s|bin[i]],left[f2[s]-1][Log-i-1]);
        }
    }for (int i=0;i<=n;++i) st[i]=n+2;
    for (int s=0;s<=bin[Log-1]-1;++s){
        int s1=(bin[Log-1]-1)^s;
        st[f1[s]]=min(st[f1[s]],f2[s1]);
    } for (int i=n-1;i>=0;--i) st[i]=min(st[i],st[i+1]);
    for (int i=1;i<=n;++i){
        int l=left[i][0],r=right[i][0];
        if (st[l-1]<=r+1) printf("Possible\n");else printf("Impossible\n");
    }
    return 0;
}

Measured memory_bytes: 42496
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


int main(){
    int N;cin>>N;
    FOR(n,1,N+1){
        int cnt=0;
        for(int x=1;x*x<=n;x++){
            for(int y=1;x*x+y*y+x*y<=n;y++){
                for(int z=1;x*x+y*y+z*z+x*y+y*z+x*z<=n;z++){
                    if(x*x+y*y+z*z+x*y+y*z+x*z==n){
                        cnt++;break;
                    }
                }
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A;
    cin >> N >> A;
    rep(i, A+1){
        if ((N - i) % 500 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int a, b;
  cin >> a >> b;
  if (b % a == 0) {
    cout << a + b << endl;
  } else {
    cout << b - a << endl;
  }
}


Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split(" "))
if x < y:
    a,b = b,a
    x,y = y,x
ans1 = a*x + b*y
ans2 = 2*c*max(x,y)
ans3 = 2*c*min(x,y)+(x-y)*a
print(min(ans1,ans2,ans3))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
  int n;
  cin >> n;
  ll a[n],sum=0,cnt=0,cnt1=0;
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++){//奇数が正
    sum+=a[i];
    if(i%2!=0){
      if(sum<=0){
          cnt+=abs(1-sum);
          sum=1;
      }
    }
    else{
      if(sum>=0){
          cnt+=abs(sum+1);
          sum=-1;
      }
    }
  }
  sum=0;
  for(int i=0;i<n;i++){//偶数が正
    sum+=a[i];
    if(i%2==0){
      if(sum<=0){
          cnt1+=abs(1-sum);
          sum=1;
      }
    }
    else{
      if(sum>=0){
          cnt1+=abs(sum+1);
          sum=-1;
      }
    }
  }
cout <<min(cnt,cnt1)<<endl;
}


Measured memory_bytes: 1024
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int A , B , C;
vector<tuple<int,int,int> > V;

int main(){
    cin >> A >> B >> C;
    int times = 0;
    while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
        if(find(all(V) , make_tuple(A,B,C)) != V.end()){
            cout << -1 << endl;
            return 0;
        }
        V.pb(make_tuple(A,B,C));
        tie(A , B , C) = make_tuple((B+C)>>1,(A+C)>>1,(A+B)>>1);
        times++;
    }
    cout << times << endl;
    return 0;
}


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

#define For(i, x, y) for (int i = x; i <= (int)(y); ++i)
#define Rep(i, x, y) for (int i = y; i >= (int)(x); --i)
#define While while
#define mem memset

const int mod = 1e9 + 7;
const int mask = (1 << 17);

int n, x, y, z, f[47][mask + 7];

int Ins(int S, int x) {
	return ((S << x) | (1 << (x - 1))) & (mask - 1);
}

int main() {
	scanf("%d%d%d%d", &n, &x, &y, &z);
	
	int S = 0; S = Ins(S, x); S = Ins(S, y); S = Ins(S, z);
	
	f[0][0] = 1;
	For(i, 1, n)
		For(j, 0, mask - 1) {
			For(k, 1, 10) {
				int now = Ins(j, k);
				if ((now & S) == S) continue;
				f[i][now] = (f[i][now] + f[i - 1][j]) % mod; 
			}
		}
	
	ll ans = 1;
	For(i, 1, n) ans = (ans * 10LL) % mod;
	For(i, 0, mask - 1) ans = (ans - f[n][i]) % mod;
	
	printf("%lld\n", (ans + mod) % mod);
	 
	return 0;
}


Measured memory_bytes: 22272
class BellmanFord:
    def __init__(self,v,start):
        self.inf = float('inf')
        self.dist = [self.inf]*v
        self.dist[start] = 0
        self.edge = []
        self.v = v
    
    def add(self,f,t,cost):
        self.edge.append((f,t,cost))
    
    def build(self):
        for _ in range(self.v - 1):
            for f,t,cost in self.edge:
                if self.dist[t] > self.dist[f] + cost:
                    self.dist[t] = self.dist[f] + cost
        self.ans = self.dist[n-1]
        for f,t,cost in self.edge:
            if self.dist[t] > self.dist[f] + cost:
                self.dist[t] = self.dist[f] + cost
        return self.ans == self.dist[n-1]

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

bf = BellmanFord(n,0)

for i in range(m):
    a,b,c = map(int,input().split())
    bf.add(a - 1,b - 1,- c)

if bf.build():
    print(- bf.ans)
else:
    print('inf')


Measured memory_bytes: 46184
#include<stdio.h>
int main(void)
{
	int a,b,c,tmp=0;
	
	scanf("%d %d %d",&a,&b,&c);
		if(a>c){
		tmp=c;
		c=a;
		a=tmp;
	}
	if(a>b){
		tmp=a;
		a=b;
		b=tmp;
	}
	if(b>c){
		tmp=b;
		b=c;
		c=tmp;
	}

	
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define F  first
#define S  second
#define ff(i,n) for(i=0;i<n;i++)
ll bg = 1000000000000000000;
ll power(ll x,ll y)
{
	if(y==0)
		return 1;
	ll h=power(x,y/2)%bg;	
	h=(h*h)%bg;
	if(y%2==1)
	  return (x*h)%bg;
	else
	  return h%bg;  
}
ll modinv(ll m)
{
	return power(m,bg-2)%bg;
}
ll sum(ll i)
{
	ll s = (i*(i+1))/2;
	return s;
}
ll g(char d)
{
	return (d-'0');
}
int main()
{ 
	ll t;
	t=1;
	while(t--)
	{
		ll i,n,m;
		cin>>n;
		string f;
		cin>>f;
		ll a1 =g(f[0]);
		ll a2 = g(f[2]);
		ll a3 = g(f[3]); 
		ll d = a1*100 + a2*10 + a3;
		ll dd = d*n;
		dd = dd/100;
		cout<<dd; 
	}
	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;
class Main{
    public static void main(String arg[]){
        Scanner scn=new Scanner(System.in);
        int n = scn.nextInt();
        int k = scn.nextInt();
        int ex = n%k;
        if(ex==0){
            System.out.println(0);
        }else{
            System.out.println(1);
        }
    }
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> C(N - 1), S(N - 1), F(N - 1);
    for (int i = 0; i < N - 1; i++)
    {
        cin >> C.at(i) >> S.at(i) >> F.at(i);
    }

    for (int i = 0; i < N; i++)
    {
        int t = 0;
        for (int j = i; j < N - 1; j++)
        {
            int Cj = C.at(j), Sj = S.at(j), Fj = F.at(j);
            if (t < Sj)
            {
                t = Sj;
            }
            else if (t % Fj != 0)
            {
                t += Fj - (t % Fj);
            }
            t += Cj;
        }
        cout << t << endl;
    }
}

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


int main(void) {
	int a[4], b[4];
	int hit, blow;
	int i, j;
	
	while (1) {
		if( scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) == EOF)
			break;
		if( scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]) == EOF)
			break;
		hit = blow = 0;
		for (i = 0; i < 4; i++)
			for (j = 0; j < 4; j++)
				if( a[i] == b[j])
					if( i == j) {
						hit++;
						break;
					} else {
						blow++;
						break;
					}
		printf("%d %d\n", hit, blow);
	}
	
	return 0;
}

Measured memory_bytes: 596