akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int s;
    cin >> s;
    vector<int> a = {s};
    
    for(int i = 1; i <= 1000000; i++){
        int v;
        if(a[i-1] % 2 == 0){
            v = a[i-1] / 2;
        }else{
            v = 3 * a[i-1] + 1;
        }
        for(int j = 0; j < a.size(); j++){
            if(a[j] == v){
                cout << i + 1 << endl;
                return 0;
            }
        }

        a.push_back(v);
    }
}

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

int main(void){
  int size;
  vector<ll> v(200);
  for(ll i=1;;i++){
    if((i*(i+1)*(i+2))/6 > 1000000) break;
    v[i-1] = (i*(i+1)*(i+2))/6;
    size = i-1;
  }
  int dp1[1000000]; // dp[i] := number of tetrahedron with value i
  int dp2[1000000]; // dp[i] := number of tetrahedron with value i
  fill(dp1, dp1+1000000+1, INT_MAX);
  fill(dp2, dp2+1000000+1, INT_MAX);
  dp1[0] = dp2[0] = 0;

  for(int i = 0; i <= 1000000; i++){
    for(int j = 0; j < size; j++){
      if(i+v[j] > 1000000) continue;
      dp1[i + v[j]] = min(dp1[i+v[j]], dp1[i]+1);
    }
  }


  for(int i = 0; i <= 1000000; i++){
    for(int j = 0; j < size; j++){
      if(i+v[j] > 1000000) continue;
      if(v[j] % 2 == 0) continue;
      dp2[i + v[j]] = min(dp2[i+v[j]], dp2[i]+1);
    }
  }

  while(1){
    int x; cin >> x;
    if(x == 0) break;
    int ans = 0;
    cout << dp1[x] << " ";
    cout << dp2[x] << endl;
  }
  return 0;
}

Measured memory_bytes: 9008
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(ll, X);
    CIN(ll, Y);

    int ans = 0;
    while (Y >= X) {
        ans++;
        X *= 2;
    }

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

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

using namespace std;

int main()
{
	int a;
	int b;
	string x;
	string y;
	cin >> x;
	cin >> y;
	if (x == "A")
		a = 10;
	if (x == "B")
		a = 11;
	if (x == "C")
		a = 12;
	if (x == "D")
		a = 13;
	if (x == "E")
		a = 14;
	if (x == "F")
		a = 15;
	if (y == "A")
		b = 10;
	if (y == "B")
		b = 11;
	if (y == "C")
		b = 12;
	if (y == "D")
		b = 13;
	if (y == "E")
		b = 14;
	if (y == "F")
		b = 15;
	if (a < b)
		cout << "<" << endl;
	if (a == b)
		cout << "=" << endl;
	if (a > b)
		cout << ">" << endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(int[]);
    AS = [0] ~ AS ~ 0;
    int s;
    foreach (i; 0..N+1) s += abs(AS[i] - AS[i+1]);
    foreach (i; 1..N+1) {
        writeln(s - abs(AS[i-1] - AS[i]) - abs(AS[i] - AS[i+1]) + abs(AS[i-1] - AS[i+1]));
    }
}

Measured memory_bytes: 5240
a = b = o = ab = 0
while query = gets
  break if query == "\n"
  no, type = query.chomp.split(",")
  
  case type
  when "A" then a += 1
  when "B" then b += 1
  when "O" then o += 1
  when "AB" then ab += 1
  end
end
puts a,b,ab,o

Measured memory_bytes: 8612
import java.io.*;
import java.util.*;
public class Main {
    static boolean check(String s){
        if (s.length()<=1)
            return true;
        for (int i =0;i<s.length()/2;i++){
            if (s.charAt(i)!=s.charAt(s.length()-i-1))
                return false;
        }
        return true;
    }
    static long nc2(int n){
        return 1l*n*(n-1)/2;
    }
    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int[]a = new int[n];
        int[] c= new int[n+1];
        long ans=0;
        for (int i =0;i<n;i++){
            a[i]=sc.nextInt();
            c[a[i]]++;
        }
        for (int i =1;i<=n;i++){
            ans+=nc2(c[i]);
        }
        for (int i =0;i<n;i++){
            pw.println((ans-nc2(c[a[i]])+nc2(c[a[i]]-1)));
        }
        pw.flush();
    }
    static int gcd(int x,int y){
        if (x==0)
            return y;
        return gcd(y%x,x);
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }

}

Measured memory_bytes: 51452
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
//const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){cout << a << " " << b << " " << c << endl;}
#define INT_MAX 1<<30;
const int MAX = 1020000;
const double EPS = 1e-6;
const int mod = 1e9+7;

ll check(ll n, ll b){
    ll ret = 0;
    ll t = 1;
    while(n>0){
        ret += n % b;
        n /= b;
    }
    return ret;
}

int main(){
    ll n,s; cin >> n >> s;
    ll p = sqrt(n)+1;
    REP(i,2,p+1){
        if(check(n,i)==s){
            cout << i << endl;
            return 0;
        }
    }
    ll t = min(n/p,s);
    for(ll i=t; i>=1; i--){
        ll q = (n-(s-i))/i;
        if((n-(s-i))%i==0 && q>i && q>(s-i)){
            cout << q << endl;
            return 0;
        }
    }
    if(n==s) cout << n+1 << endl;
    else puts("-1");
}


Measured memory_bytes: 256
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int f(int x) {
  int y = 1;
  for (int i = 1; i <= x; i++) {
    y *= i;
  }
  return y;
}

int main() {
  ll N, p = 0, q = 0;
  cin >> N;
  vector<ll> P(N), Q(N), pu(N, 0), qu(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> P.at(i);
    P[i]--;
    pu[P[i]] = 1;
    for (int j = 0; j < P[i]; j++) {
      if (pu[j] == 0) p += f(N - 1 - i);
    }
  }
  for (int i = 0; i < N; i++) {
    cin >> Q.at(i);
    Q[i]--;
    qu[Q[i]] = 1;
    for (int j = 0; j < Q[i]; j++) {
      if (qu[j] == 0) q += f(N - 1 - i);
    }
  }

  cout << abs(q - p) << endl;
}


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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

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

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int A,B, T;
    cin >> A >> B >> T;

    cout << T/A*B << endl;
  
  
    return 0;
}



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

int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int ans=min(A,B)+min(C,D);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

x = int(input())
# print(x)

def is_prime(num):
    if num > 1:
        for i in range(2, num):
            if (num % i) == 0:
                return False
        return True
    else:
        # 1 is not prime
        return False

num = x
while True:
    if is_prime(num):
        print(num)
        break
    num += 1


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

int main() {
    int X;
    cin >> X;
    if(X >= 400 && X <= 599) cout << '8' << endl;
    else if(X >= 600 && X <= 799) cout << '7' << endl;
    else if(X >= 800 && X <= 999) cout << '6' << endl;
    else if(X >= 1000 && X <= 1199) cout << '5' << endl;
    else if(X >= 1200 && X <= 1399) cout << '4' << endl;
    else if(X >= 1400 && X <= 1599) cout << '3' << endl;
    else if(X >= 1600 && X <= 1799) cout << '2' << endl;
    else if(X >= 1800 && X <= 1999) cout << '1' << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
using namespace std;
typedef long long ll;
const int N=100005;
const int MAXN=100005;
int n,k;
const int mod=1e9+7;
int a[105];
ll ft[MAXN+1]; // for more dimensions, make ft multi-dimensional
void upd(int i0, ll v){ // add v to i0th element (0-based)
	for(int i=i0+1;i<=MAXN;i+=i&-i){
		ft[i]+=v;
		if(ft[i]>=mod)ft[i]-=mod;
	}
}
ll get(int i0){ // get sum of range [0,i0)
	ll r=0;
	for(int i=i0;i;i-=i&-i){
		r+=ft[i];
		if(r>=mod)r-=mod;
	}
	return r;
}
ll get_sum(int i0, int i1){ // get sum of range [i0,i1) (0-based)
	ll r=get(i1)-get(i0);
	if(r<0)r+=mod;
	return r;
}

int main(){//FIN;
	cin>>n>>k;
	fore(i,0,n)cin>>a[i];
	fore(i,0,a[n-1]+1)upd(i,1);
	for(int i=n-2;i>=0;i--){
		vector<ll> v;
		fore(j,0,k+1){
			int x=max(0,j-a[i]);
			int y=j;
			v.pb(get_sum(x,y+1));
		}
		memset(ft,0,sizeof ft);
		fore(j,0,k+1)upd(j,v[j]);
	}
	ll r=get_sum(k,k+1)%mod;
	if(r<0)r+=mod;
	cout<<r<<"\n";
}

Measured memory_bytes: 2888
str = input()
question = int(input())
for q in range(question):
    line = input()
    if line.find("print") != -1:
        order, a, b = (x for x in line.split())
        print(str[int(a):int(b)+1])
    elif line.find("reverse") != -1:
        order, a, b = (x for x in line.split())
        if(a == 0): str = str[int(a):int(b)+1][::-1] + str[int(b)+1:len(str)]
        else: str = str[:int(a)] + str[int(a):int(b)+1][::-1] + str[int(b)+1:len(str)]
    elif line.find("replace") != -1:
        order, a, b, word = (x for x in line.split())
        str = str[:int(a)] + word + str[int(b)+1:len(str)]



Measured memory_bytes: 5628
#include <stdio.h>

int main(){
    long    n, y;
    
    scanf("%ld %ld", &n, &y);

    //i:10k札の枚数
    for(int i=0; i<=n; i++){

        //j:5k札の枚数
        for(int j=0; j<=n; j++){

            //k:1k札の枚数
            int k = n-i-j;
            if( k>=0 && (10000*i + 5000*j + 1000*k)==y ){
                printf("%d %d %d\n", i, j, k);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");

    return 0;
}

Measured memory_bytes: 1728
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){
  long long int A, B, C;

  scanf("%lld%lld%lld", &A, &B, &C);

  if(A==B && A!= C){
    std::cout << "Yes" << std::endl;
  }
  else if(A==C && B!= C){
    std::cout << "Yes" << std::endl;
  }
  else if(C==B && A!= C){
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }

  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        for (int i = 1; ; ++i) {
            int x = in.nextInt();
            if (x == 0) break;
            System.out.println("Case " + i + ": " + x);
        }
    }
}

Measured memory_bytes: 32992
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>
 
using namespace std;
 
int main() {
    
 
    
    string s;
    cin >> s;
    int c = 0;
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] == 'o')
        {
            c++;
        }
    }
    
    cout << 700 + c * 100 << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		long N = sc.nextLong();
		long M = sc.nextLong();
		long m = M - N - N;
		if (m < 0) {
			System.out.println(M / 2);
		}else {
			System.out.println(N + m / 4);
		}
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
#define int ll
 
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
 
using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;
 
template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}
 
template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}
 
int read(){
	int i;
	scanf("%lld",&i);
	return i;
}
 
void printSpace(){
	printf(" ");
}
 
void printEoln(){
	printf("\n");
}
 
void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}
 
string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}
 
char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}
 
template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}
 
template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}
 
template<class T>
T Sq(const T& t){
	return t*t;
}
 
const int inf=LLONG_MAX/3;

const int mod=998244353;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

struct Pos{
	int x,y;
};
int cross(const Pos&a,const Pos&b){
	return a.x*b.y-a.y*b.x;
}

signed main(){
	int n=read(),dp[4]{1,0,0,0};
	REP(_,n){
		int k=dp[3];
		for(int i=3;i>=1;i--)
			add(dp[i],dp[i-1]);
		add(dp[3],k);
	}
	vector<Pos> ps;
	REP(i,n){
		int x=read(),y=read();
		ps.PB(Pos{x,y});
	}
	sort(ALL(ps),[&](const Pos&a,const Pos&b){
		return a.x!=b.x?(a.x<b.x):(a.y<b.y);
	});
	REP(_,n){
		vector<Pos> cur;
		REP(i,_)
			cur.PB(Pos{ps[i].x-ps[_].x,ps[i].y-ps[_].y});
		sort(ALL(cur),[&](const Pos&a,const Pos&b){
			return cross(a,b)>0;
		});
		int num=0;
		REP(i,cur.size()){
			//cerr<<_<<" "<<num<<endl;
			sub(dp[3],modPow(2,num++)-1);
			if(i+1==int(cur.size())||cross(cur[i],cur[i+1])!=0)
				num=0;
		}
	}
	cout<<dp[3]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(int argc, char* argv[])
{
	char S[6];
	int flag = 0;

	scanf("%s", S);

	if(S[2] == S[3]){
		flag += 1;
	}
	if(S[4] == S[5]){
		flag += 1;
	}

	if(flag==2){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}





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

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

  int N; cin >> N;
  priority_queue<int> que;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    que.push(a);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (i & 1) ans -= que.top();
    else ans += que.top();
    que.pop();
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );

vector<ll> dp;

/*
ll f(string s){
  char c=s[0];
  if(s.size()==1){
    if(c=='0') return dp[0];
    else return dp[1];
  }
  else{
    if(c=='0') return ( dp[s.size()-1 ] + f(s.substr(1)) )%mod;
    else return ( dp[ s.size()-1 ] + 2LL*f(s.substr(1)) )%mod;
  }
}
*/

int main(void){

  string l;
  cin>>l;

  string l_r=l;
  reverse(begin(l_r),end(l_r));

  dp.resize(100002,0);
  dp[0]=1;
  dp[1]=3;

  for(ll i=2;i<100002;i++){
    dp[i]=dp[i-1]*3LL % mod;
  }
  ll ans=0;
  for(ll i=0;i<l_r.size();i++){
    auto c=l_r[i];
    if(i==0){
      if(c=='0') ans=1;
      else ans=3;
    }
    else{
      if(c=='0') ans=(ans)%mod;
      else ans=(2LL*ans+dp[ i ])%mod;
    }
  }  

  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define len length
#define mp make_pair
#define pq priority_queue
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define take(v) for(int i=0;i<(int)v.size();i++){cin>>v[i];}
#define printvec(v) for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define printds(x) while(!x.empty()){cout<<x.top()<<" ";x.pop();}
#define input(n) int n;cin>>n;
#define PI 3.141592653589793238463
#define lnput(n) long long int n;cin>>n;
#define fr(i,s,e) for(int i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
vector<int> v;
int main()
{
  speed;
  input(n);
  input(k);
  v.resize(n);
  fr(i,0,n) {
    cin>>v[i];
  }
  vector<int> dp(n,INT_MAX);
  dp[0] = 0;
  dp[1] = abs(v[1]-v[0]);
  for(int i = 2;i<n;i++) {
    for(int j = max(0,i-k);j<i;j++) {
      dp[i] = min(dp[i],(dp[j]+abs(v[i]-v[j])));
    }
  }
  cout<<dp[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 3992
#include <stdio.h>
     
    int main() {
      int N,M;
      int gcd = 1;
      int m;
      int i;
      scanf("%d %d", &N, &M);
      m = (int) M / N;
      
      for(i = m;i > 1;i--) {
            if(M % i == 0) {
            gcd = i;
            break;
        }
      }
     
      printf("%d", i);
      
    return 0;
    }

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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1e9;
const int MOD = 1000000007;
const int N = 202055;
const int M = 1211;

void solve() {
    ll a,b;
    cin >> a >> b;

    cout << LCM(a,b);


}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  ll N;
  cin>>N;
  string s;
  cin>>s;
  ll ans = 0;
  for(ll i = 0;i<1000;i++){
    ll p = i/100;
    ll q = (i/10)%10;
    ll r = i%10;
    ll keta[3] = {p,q,r};
    ll kazu = 0;
    for(ll k = 0;k<s.size();k++){
      ll ppp = s.at(k) - '0';
      if(keta[kazu] == ppp){
        kazu++;
      }
      if(kazu == 3){
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

int main()
{
  int cnt;
  int K, X;
  int i;
  int low, high;

  cnt = scanf("%d %d", &K, &X);

  // oooxxxooo
  //    012

  for(i=(X-K+1); i<(X+K); i++) {
    printf("%d ", i);
  }

  return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include <vector>


using namespace std;

int length;
string str;

inline bool IsB(int index)
{
	if (index < 0)
	{
		return false;
	}

	if (length <= index)
	{
		return false;
	}

	return 'B' == str[index];
}

int main()
{
	vector<int> r, g, b;

	cin >> length;
	str.reserve(length);
	r.reserve(length);
	g.reserve(length);
	b.reserve(length);

	cin >> str;

	for (int i = 0; i < length; i++)
	{
		switch (str[i])
		{
		case 'R':
			r.push_back(i);
			break;
		case 'G':
			g.push_back(i);
			break;
		case 'B':
			b.push_back(i);
			break;
		default:
			break;
		}
	}


	long long cnt = b.size() * r.size() * g.size();

	for (int i : r)
	{
		for (int j : g)
		{
			int c = i + j;

			cnt -= IsB(2 * j - i) + IsB(2 * i - j) + (c % 2 == 0 && IsB(c / 2));

		}
	}

	cout << cnt;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <ctype.h> 

int main(void) {
    //code goes 
	int a,b,i; 
	char code[12];
	scanf("%d %d %s",&a,&b,&code);  
	if(code[a]!='-'){
	    printf("No");
	    return 0; 
	}               
	for(i=0;code[i];++i){
	    if(i!=a){
	        if(!isdigit(code[i])){
	            printf("No");
	            return 0;
	        }
	    }
	}
	printf("Yes");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{	
	int N, M;
	cin >> N >> M;
	vector<bool> broken(N, false);
	vector<ll> dp(N+2);
	REP(i, M) {
		int tmp;
		cin >> tmp;
		broken[tmp] = true;
	}

	dp[N] = 1;
	REPR(i, N-1){
		if(broken[i]){
			dp[i] = 0;
			continue;
		}
		dp[i] = (dp[i+1]+dp[i+2]) % 1000000007;
	}

	cout << dp[0] << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define SIZE 100000

int counter = 0;

typedef struct process{
    char name[10];
    int t;
} process;

typedef struct Node{
    process P;
    struct Node* next;
} Node;

Node* head = NULL;
Node* tail = NULL;

bool isEmpty(){
    return counter == 0; 
}

bool isFull(){
    return counter == SIZE;
}

void Enqueue(Node* tmp){
    if(!isFull()){
        tmp -> next = NULL;

        if(isEmpty())
            tail = head = tmp;    
        else{
            tail -> next = tmp;
            tail = tmp;
        }
        counter++;
    }else
        printf("Queue is full!\n");
}

Node* Dequeue(){
    if(!isEmpty()){
        Node* tmp = head;
        if(tail == head) 
            tail = head -> next;
        head = head -> next;
        counter--;
        return tmp;
    }else
        printf("Queue is empty!\n");
}

int main(){
    // Number of process n 
    unsigned int n;
    // Time slot assigned for each process
    int q;
    scanf("%d %d",&n,&q);

    for(int i=1; i<=n; i++){
        Node* newNode = (Node*) malloc(sizeof(Node));
        scanf("%s %d",newNode->P.name,&newNode->P.t);
        Enqueue(newNode);
    }
    
    unsigned int period = 0;
    while(!isEmpty()){
        if(head->P.t <= q){
            period = period + head->P.t;
            printf("%s %d\n",head->P.name,period);
            Dequeue();
        }else{
            period = period + q;
            head->P.t = head->P.t - q;
            Enqueue(Dequeue());
        }
    }
    
    return 0;
}


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

"""
参考：https://img.atcoder.jp/abc054/editorial.pdf
・3次元DP
・送るDP
"""
 
import sys
def input(): return sys.stdin.readline().strip()
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
 
N, Ma, Mb = map(int, input().split())
l = [[0] * 3 for i in range(N)]
for i in range(N):
    l[i][0], l[i][1], l[i][2] = map(int, input().split())

# 不可能な組み合わせは0とは区別するのでINF初期化
dp = [[[INF] * 401  for i in range(401)] for i in range(N+1)]
dp[0][0][0] = 0
for i in range(N):
    for j in range(401):
        for k in range(401):
            # あり得ない組み合わせの時は送らない
            if dp[i][j][k] == INF: continue
            dp[i+1][j][k] = min(dp[i][j][k], dp[i+1][j][k])
            dp[i+1][j+l[i][0]][k+l[i][1]] = min(dp[i][j][k] + l[i][2], dp[i+1][j+l[i][0]][k+l[i][1]])

ans = INF
for j in range(1, 401):
    for k in range(1, 401):
        # j/k == Ma/Mb だと分母0が心配なので
        if j * Mb == k * Ma:
            ans = min(dp[N][j][k], ans)

if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 141532
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
 
#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
 int d,n; cin >> d >> n;
 int f = pow(100, d);
 int g = pow(100, d+1);
 
 int cnt =0; 
 for(int i=1;;i++){
   if(i%f == 0 && i%g != 0){
     cnt++;
     if (cnt == n){
       cout << i;
       exit(0);
     }
   }
 }
 return 0;
}

Measured memory_bytes: 256
#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
#define NDEBUG
#endif
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int N=605,P=1e9+7;
int n,a[N],ia[N],f[2][N][N];
bool skip[N];
int main(){
	scanf("%d",&n);
	rep(i,1,n*2){
		scanf("%d",&a[i]);
		if(a[i]!=-1)ia[a[i]]=i;
	}
	int cnt=0,fac=1;
	for(int i=1;i<=n*2;i+=2){
		if(a[i]!=-1&&a[i+1]!=-1){
			skip[a[i]]=skip[a[i+1]]=1;
		}
		if(a[i]==-1&&a[i+1]==-1){
			fac=1LL*fac*(++cnt)%P;
		}
	}
	
	int cur=0;
	f[0][0][0]=1;
	per(i,n*2,1)if(!skip[i]){
		cur^=1;
		memset(f[cur],0,sizeof(f[cur]));
		if(!ia[i]){
			rep(j,0,n*2)rep(k,0,n*2){
				f[cur][j][k]=(f[cur^1][j][k+1]+1LL*(j+1)*f[cur^1][j+1][k]+(k?f[cur^1][j][k-1]:0))%P;
				if(f[cur][j][k]){
					D("%d %d %d\n",i,j,k);
				}
			}
		}else{
			rep(j,0,n*2)rep(k,0,n*2){
				f[cur][j][k]=(f[cur^1][j][k+1]+(j?f[cur^1][j-1][k]:0))%P;
				if(f[cur][j][k]){
					D("%d %d %d\n",i,j,k);
				}
			}
		}
	}
	printf("%lld\n",1LL*f[cur][0][0]*fac%P);
	return 0;
}

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

Measured memory_bytes: 22612
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, long long P, string S0){
    vll S(N);
    REP(i, N) S[i] = S0[i]-'0';
    reverse(ALL(S));
    if(P == 2 || P == 5){
        ll ans = 0;
        REP(i, N){
            if(S[i] % P == 0) ans += N-i;
        }
        cout<<ans<<endl; return;
    }

    vll sum(N, 0);
    ll base = 1;
    REP(i, N){
        sum[i] = (S[i] *base) % P ;
        if(i > 0) sum[i] = (sum[i] +sum[i-1]) % P;
        base = (base*10) %P;
    }
    map<ll, ll> rec;
    REP(i, N){
        rec[sum[i]]++;
    }
    ll ans = 0;
    for(auto x: rec){
        ans += x.second*(x.second-1)/2;
    }
    if(rec.count(0)) ans += rec[0];
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long P;
    scanf("%lld",&P);
    string S;
    cin >> S;
    solve(N, P, move(S));
    return 0;
}


Measured memory_bytes: 4100
#include <stdio.h>
#include <string.h>

int main(void){
	int i,n,d,x,a[100],j,c;
	scanf("%d %d %d",&n,&d,&x);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++){
		j=0;
		c=0;
		while(c<=d){
			x++;
			c=1+a[i]*j;
			j++;
			//printf("%d\n",c);
		}
		//printf("%d\n",x);
	}
	printf("%d\n",x-n);
	return 0;
}

Measured memory_bytes: 128
def insertionSort(A, N):
  print(' '.join(map(str, A)))
  for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
      A[j + 1] = A[j]
      j -= 1
    A[j + 1] = v
    print(' '.join(map(str, A)))

N = int(input())
A = list(map(int, input().split()))
insertionSort(A,N)


Measured memory_bytes: 5600
//stl
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>

//std
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ls(o) ((o)<<1  )
#define rs(o) ((o)<<1|1)

//macro
typedef long long LL;
using namespace  std;
//-----------------------------------------------------
char str[20][20];
//-----------------------------------------------------
int  main()
{

	//( "xx.in"  , "r" , stdin  );
	//freopen( "xx.out" , "w" , stdout );

	//--0 init
	
	//--1 read
	int n,m; scanf("%d%d",&n,&m);
	for (int i=1; i<=n; i++) scanf(" %s",str[i]+1);
	
	bool can=(str[1][1]=='#');
	str[1][1]='.';
	int x=1,y=1;
	for (; x<n||y<m; ) {
		int road=0;
		//printf("%d %d\n",x,y);
		//fflush(stdout);
		
		if (str[x+1][y]=='#') road+=1;
		if (str[x][y+1]=='#') road+=2;
		if (road>3||road==0) { 
			can=false;
			break;
		}
		if (road==1) x++;
			else y++;
		str[x][y]='.';
	}
	for (int i=1; i<=n; i++)
	for (int j=1; j<=m; j++) if (str[i][j]=='#') can=false;
	printf(can?"Possible":"Impossible");
}









Measured memory_bytes: 764
package main

import (
	"fmt"
)

// go run ./main.go < in
var num int

func main() {
	fmt.Scan(&num)

	sum := 0
	for i := 1; i <= num; i++ {
		for j := 1; j <= num; j++ {
			init := gcd(i, j)
			for k := 1; k <= num; k++ {
				sum += gcd(init, k)
			}
		}
	}
	fmt.Println(sum)
}

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

Measured memory_bytes: 1780
import java.util.Scanner;

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

        int A = scanner.nextInt();
        int B = scanner.nextInt();

        if (A < 10 && B < 10) {
            System.out.println(A * B);
        } else {
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 35664
#include <iostream>
//#include <fstream>

#define NA cout << "NA" << endl; goto LABEL

using namespace std;

int main() {
	//ifstream fin("in.txt");

	int snakeCount;
	cin >> snakeCount;

	for(int loopCount = 0; loopCount < snakeCount; loopCount++) {
		char arr[202];
		cin >> arr;
		int i = 0;

		if(arr[i]!='>') {
			NA;
		}
		i++;

		if(arr[i]=='\'') {
			int equalCount = 0;
			bool mode = false;
			for(int j = i+1; j < 202; j++) {
				if(arr[j]=='=') {
					if(!mode) {
						equalCount++;
					}else {
						equalCount--;
					}
				}else if(arr[j]=='#') {
					if(!mode && equalCount>0) {
						mode = !mode;
					}else {
						NA;
					}
				}else if(arr[j]=='~') {
					if(arr[j+1]=='\0'&&equalCount==0&&mode) {
						cout << "A" << endl;
						goto LABEL;
					}else {
						NA;
					}
				}else {
					NA;
				}
			}
		}else if(arr[i]=='^') {
			int count = 0;
			for(int j = i+1; j < 202; j++) {
				if(arr[j]=='Q'&&arr[j+1]=='=') {
					j++;
					count++;
					continue;
				}else if(arr[j]=='~'&&arr[j+1]=='~'&&arr[j+2]=='\0'&&count>0) {
					cout<< "B" << endl;
					goto LABEL;
				}else {
					NA;
				}
			}
		}else {
			NA;
		}
		LABEL:;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
	int a,b,c,N,i,j;
	int *data,(*result)[4];

	while(1){
		scanf("%d %d %d",&a,&b,&c);
		if(!a && !b && !c){
			break;
		}
		data = (int *)malloc(sizeof(int)*(a+b+c+1));

		scanf("%d",&N);
		result = (int (*)[4])malloc(sizeof(int[4])*N);
	
		for(i = 1;i <= a+b+c;i++){
			data[i] = 2;
		}

		for(i = 0;i < N;i++){
			for(j = 0;j < 4;j++){
				scanf("%d",&result[i][j]);
			}
			if(result[i][3]){
				for(j = 0;j < 3;j++){
					data[result[i][j]] = 1;
				}
			}
		}

		for(i = 0;i < N;i++){
			if(!result[i][3]){
				if(data[result[i][0]] == 1 && data[result[i][1]] == 1){
					data[result[i][2]] = 0;
				}else if(data[result[i][1]] == 1 && data[result[i][2]] == 1){
					data[result[i][0]] = 0;
				}else if(data[result[i][2]] == 1 && data[result[i][0]] == 1){
					data[result[i][1]] = 0;
				}
			}
		}

		for(i = 1;i <= a+b+c;i++){
			printf("%d\n",data[i]);
		}
	}

	return 0;
}

Measured memory_bytes: 628
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long a, N, s, A = (LLONG_MAX), l = 0, r = 0, S[100002] = { 0 }; cin >> N >> s;
	for (int i = 1; i <= N;i++) { cin >> a;S[i] += S[i - 1] + a; }
	for(;;){
		if (S[r] - S[l] >= s) { A = min(A, r - l); l++; }else r++;
		if (r > N || l > N) { if (A == (LLONG_MAX))A = 0; cout << A << endl; return 0; }
	}
}

Measured memory_bytes: 3948
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<int> > mat;

int main()
{
  string S;
  cin >> S;
  int size = S.size();
  bool n = false, e = false, w = false, s = false;
  for (int i = 0; i < size; i++)
  {
    if (S[i] == 'N')
    {
      n = true;
    }
    if (S[i] == 'E')
    {
      e = true;
    }
    if (S[i] == 'W')
    {
      w = true;
    }
    if (S[i] == 'S')
    {
      s = true;
    }
  }
  cout << (!(n ^ s) && !(w ^ e) ? "Yes" : "No") << "\n";
}

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

using namespace std;

const int MAXN = 200005;

int a[MAXN], b[MAXN];

int n;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i], b[i] = a[i];
	sort(a + 1, a + n + 1);
	int x = a[n / 2], y = a[n / 2 + 1];
	for (int i = 1; i <= n; i++)
	{
		if (b[i] <= x)
			cout << y << endl;
		else
			cout << x << endl;
	}
	return 0;	
}


Measured memory_bytes: 3712
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
	long int N;
	scanf("%ld",&N);
	long int **A=malloc(N*sizeof(long int*));
	long int **B=malloc(N*sizeof(long int*));
	int error=0;
	long int sum=0;
	int i,j,k;

	for (i=0;i<N;i++){
		A[i]=malloc(N*sizeof(long int));
		B[i]=malloc(N*sizeof(long int));

		for (j=0;j<N;j++){
			scanf("%ld",&A[i][j]);
			B[i][j]=1;
		}
	}

	for (i=0;i<N;i++){
		for (j=0;j<i;j++){
			for (k=0;k<N;k++){

				if (A[i][j]>A[i][k]+A[k][j]){
					error=-1;
				}

				if (i!=k && j!=k && A[i][j]==A[i][k]+A[k][j]){
					B[i][j]=B[j][i]=0;
				}
			}
		}
	}

	if (error==-1){
		printf("-1\n");
	}

	if (error==0){
		for (i=0;i<N;i++){
			for (j=0;j<i;j++){
				if (B[i][j]==1){
					sum+=A[i][j];
				}
			}
		}
		printf("%ld\n",sum);
	}
	return 0;	
}

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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll ans = x / 11 * 2;
    if (x % 11 > 0) ans++;
    if (x % 11 > 6) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;
int main(){
    int N,L,ma=0,ans=0;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> L;
        ans+=L;
        if(ma<L)
        ma=L;
    }
    if(ma<ans-ma) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#define ll long long
#define ffor(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 (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

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

	int n,m;
	int a[100],b[100];

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

	int count[100];
	rep(i,100) count[i] = 0;

	rep(i,m){
		count[a[i]]++;
		count[b[i]]++;
	}

	for(int i=1; i<n+1; i++) cout << count[i] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  char arr[5];
  int n, k, ans=1;

  fgets(arr, sizeof(arr), stdin);
  sscanf(arr, "%d", &n);

  fgets(arr, sizeof(arr), stdin);
  sscanf(arr, "%d", &k);
  
  for (int i = 0; i < n; ++i) {

    if (ans << 1 < ans+k) {
      ans <<= 1;
    } else {
      ans += k;
    }

  }

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


Measured memory_bytes: 128
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	string SA, SB, SC;
	cin >> SA >> SB >> SC;

	int turn = 0;
	char ans;

  	while(1){ 
		if(turn == 0){ // A's turn
          	if(SA.size() == 0){
          		ans = 'A';
            break;
          	}
 			turn = SA[0]-'a';
 			SA = SA.substr(1);
          	//cout << "A's turn: " << SA << endl;
		}
		else if(turn == 1){ // B's turn
            if(SB.size() == 0){
          		ans = 'B';
            break;
            }
 			turn = SB[0]-'a';
 			SB = SB.substr(1);
          	//cout << "B's turn: " << SB << endl;
		}
		else if(turn == 2){ // C's turn
			if(SC.size() == 0){
          		ans = 'C';
            break;
            }
          	turn = SC[0]-'a';
 			SC = SC.substr(1);
          	//cout << "C's turn: " << SC << endl;
        }
	}

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())

    pair_str = input().split()
    pair_int = [int(s) for s in pair_str]

    min_value = min(pair_int)
    max_value = max(pair_int)
    sum = 0
    for value in pair_int:
        sum = sum+ value

    print("{} {} {}".format(min_value, max_value, sum))

main()



Measured memory_bytes: 6604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		
		int a = in.nextInt(), b = in.nextInt();
		
		int max = Math.max(a, b);
		
		int k = 0;
		
		for(int i = 1;i<=max;i++) {
			if(Math.abs(a-i) == Math.abs(b-i)) {
				k = i;
			}
		}
		
		if(k == 0) {
			System.out.println("IMPOSSIBLE");
		}
		else {
			System.out.println(k);
		}

	}

}


Measured memory_bytes: 27140