akhauriyash/Code-Regression huggingface dataset:
// 25/05/2020  @ 10:47:49
// *****************************************************************
// *****************************************************************
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <stack>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
// *****************************************************************
// *****************************************************************
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fr(i,n) for(llu i=0;i<n;i++)
#define fl(j,a,b) for(llu j=a;j<=b;j++)
#define pi 3.14159265
#define mod 1e9+7
#define MID(a,b) ((a + b) >> 1)
#define MAX(a,b) ((a) > (b) ? (a): (b))
#define MIN(a,b) ((a) < (b) ? (a) :(b))
// *****************************************************************
// *****************************************************************
typedef long long unsigned int llu;
typedef long long int ll;
// *****************************************************************
// *****************************************************************
using namespace std;
// *****************************************************************
// *****************************************************************

                   // Dream it. Wish it. Do it.

                         // tannatsri //

              // Without tact you can learn nothing.

// *****************************************************************
// *****************************************************************
template< class Iterator,  class T>
// template<typename TT>
// *****************************************************************
// *****************************************************************
Iterator search(Iterator start, Iterator end, T key) {
    while(start != end) {
        if(*start == key){
            return start;
        }
        ++start;
    }
    return end;
}
bool rev(int a, int b) {
    return a > b;
}






// *****************************************************************
// *****************************************************************
int main() {
    IOS;
    int n;
    cin >> n;
    ll a[n + 1];
    fl(i,1,  n) cin >> a[i];
    ll dp[n + 1] = {0};
    dp[1] = 0;
    dp[2] = abs(a[1] - a[2]);
    fl(i, 3, n) {
        dp[i] = MIN(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n] <<"\n";

    return 0;
}

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

using namespace std;

int main(void){
	int N;
	cin >> N;
	vector<ll> a(N),b(N);
	rep(i,N)cin >> a[i] >> b[i];
	ll ans = 0;
	ll cnt = 0;
	for(int i=N-1;i>=0;i--){
		a[i] += cnt;
		if(a[i]%b[i]==0)continue;
		else {
			ans += b[i] - a[i]%b[i];
			cnt += b[i] - a[i]%b[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.*;

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

        long n = sc.nextLong();
        long sum = 0;

        List<Long> list = divisor(n);
        for(long i : list){
            i--;
            if(i == 0){
                continue;
            }
            if(n / i == n % i){
                sum += i;
            }
        }

        System.out.println(sum);

    }

    public static ArrayList<Long> divisor(long n){
        ArrayList<Long> result = new ArrayList<>();
        for(long i = 1; i * i <= n; i++){
            if(n % i == 0){
                result.add(i);
                if(i != n / i){
                    result.add(n / i);
                }
            }
        }
        return result;
    }

}


Measured memory_bytes: 23892
#include<stdio.h>
#include<stdlib.h>

int main() {
  int n, i, j;
  int c = 0;
  int temp, min;
  int *A;

  scanf("%d", &n);
  A = malloc(n*sizeof(int));
  for(i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  for(i = 0; i < n; i++) {
    min = i;
    for(j = i; j < n; j++) {
      if(A[j] < A[min]) {
	min = j;
      }
    }
    if(min != i) {
	temp = A[i];
	A[i] = A[min];
	A[min] = temp;
	c++;
    }
  }

  for(i = 0; i < n; i++) {
    printf("%d", A[i]);
    if(i != n-1) {
      printf(" ");
    }
  }
  printf("\n%d\n", c);

  return 0;
}

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

int main() {
    int a[5];
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }

    int ans = 0;
    int p = 0;
    for (int i = 0; i < 5; i++) {
        int r = (a[i] + 9)/10;
        int b = 10*r;
        p = max(p, b - a[i]);
        ans += b;
    }
    
    cout << ans - p << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  double a[100];
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  for(int i=0;i<n-1;i++)
    a[i+1]=(a[i]+a[i+1])/2;
 	cout<<a[n-1]<<endl;
  return(0);
}

Measured memory_bytes: 256
if __name__ == "__main__":
    while True:
        h, w = map(lambda x: int(x), input().split())

        if (w == 0 & h == 0):
            break

        for i in range(h):
            for k in range(w):
                if (i + k) % 2 == 0:
                    print("#", end="")
                else:
                    print(".", end="")
            print()

        print()



Measured memory_bytes: 7004
#include<stack>
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<string>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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;
int main(){
int a[3][3];
int n;
rep(i,3){
  rep(j,3) cin >> a[i][j];
}
cin >> n;
int num;
while(n--){
  cin >> num;
  rep(j,3)
    rep(k,3) if(a[j][k]==num) a[j][k]=0;
}
bool ans=false;
rep(i,3){
  int sum=0;
  rep(j,3) sum+=a[i][j];
  if(sum==0)ans=true;
  sum=0;
  rep(j,3) sum+=a[j][i];
  if(sum==0) ans=true;
}
if(a[0][0]+a[1][1]+a[2][2]==0 || a[0][2]+a[1][1]+a[2][0]==0) ans=true;
cout << (ans?"Yes":"No") << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>	// 配列	
#include <algorithm> // sort
#include <cstdlib>  // abs() for integer


using namespace std;

int main() {
	int N;

	cin >> N;

	std::vector<long long> card;

	long long inp = 0; // 入力値
	long long tot = 0; // 入力値の合計
	for (int i = 0; i < N; i++) {
		cin >> inp;

		// 配列に要素を追加
		card.push_back(inp);

		tot += inp; // 入力値を集計

		//// debug 002
		//cout << "inp:" << inp << endl;
		//cout << "card[i]:" << card[i] << endl;

	}

	
	long long snu = 0; // すぬけ
	long long ara = 0; // アライグマ
	std::vector<long> absary; // 絶対値の配列

	for (int j = 0; j < N - 1; j++) {
		
		// すぬけの集計
		snu += card[j];

		ara = tot - snu;
		//for (int k = j + 1; k < N; k++) {
		//	// アライグマの集計
		//	ara += card[k];
		//}
		
		//// debug 002
		//cout << "snu:" << snu << endl;
		//cout << "ara:" << ara << endl;

		long buf = abs(snu - ara);
		absary.push_back(buf);

	}



	// 配列のソート
	std::sort(absary.begin(), absary.end());

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

Measured memory_bytes: 4848
import java.lang.*;
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if(a >= b) System.out.println("10");
    else System.out.println("0");
  }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define MAX 10
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Og")
#pragma GCC push_options
#pragma GCC pop_options

int n;
int Bool[MAX] = {0}; //Đánh dấu chưa có phần tử nào sử dụng hết
int A[MAX];          //Lưu hoán vị vào mảng A
int p[MAX], q[MAX];
int vt1, vt2;
int dem = 0;
void xuatvt2()
{
    int b = 0;
    for (int i = 1; i <= n; i++)
    {
        if (A[i] == q[i])
        {
            b++;
        }
        else
            return;
    }
    if (b == n)
    {
        vt2 = dem;
    }
    else
        return;
}

void xuatvt1()
{
    int a = 0;
    for (int i = 1; i <= n; i++)
    {
        if (A[i] == p[i])
        {
            a++;
        }
        else
            return;
    }
    if (a == n)
    {
        vt1 = dem;
    }
    else
        return;
}

void thu(int k)
{
    for (int i = 1; i <= n; i++)
    {
        //Kiểm tra nếu phần tử chưa được chọn thì sẽ đánh dấu
        if (!Bool[i])
        {
            A[k] = i;    // Lưu một phần tử vào hoán vị
            Bool[i] = 1; //Đánh dấu đã dùng
            if (k == n)  //Kiểm tra nếu đã chứa một hoán vị thì xuất
            {
                dem++;
                xuatvt1();
                xuatvt2();
            }
            else
                thu(k + 1);
            Bool[i] = 0;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> p[i];
    }
    for (int i = 1; i <= n; i++)
    {
        cin >> q[i];
    }
    thu(1);
    cout << abs(vt1 - vt2);
}

Measured memory_bytes: 256
integer N,K
integer(16) nK,nK2
integer(16) ans
read*,N,K
select case(mod(K,2))
  case(0)
    nK=N/K
    nK2=(N+K/2)/K
    ans=nK**3+nk2**3
  case(1)
    nK=N/K
    ans=nk**3
end select
print"(i0)",ans
end

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

int main() {
  long N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  long min_ = min(A, min(B, min(C, min(D, E))));
  long ans;
  if (min_ > N) ans = 5;
  else {
    double tmp = ((double)N/min_)+0.9;
    ans = (long)(tmp) - 1 + 5;
  }
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<bool> chk(10, true);
  for(int i = 0; i < k; i++){
    int d;
    cin >> d;
    chk[d] = false;
  }
  string m = to_string(n);
  while(1){
    bool flag = true;
    for(int i = 0; i < m.length(); i++){
      if(!chk[m[i]-'0']) flag = false;
    }
    if(flag) break;
    n++;
    m = to_string(n);
  }
  cout << n << endl;
}

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

int main(){
    long long n,m;
    cin >> n >> m;
    if(n==1 && m==1) {cout << 1; return 0;}
    if(n==1) {cout << m-2; return 0;}
    if(m==1) {cout << n-2; return 0;}
    if(m == 2 || n == 2) {cout << 0; return 0;}
    long long result = (m*n - 2*m - 2*n + 4);
    cout << result;
		
}


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

int main(){
  int N, X;
  cin >> N >> X;
  int x = 0, r = 1;
  REP(i, N) {
    int L;
    cin >> L;
    x += L;
    if(x <= X) r++;
  }
  cout << r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    ll n , k;
    cin >> n >> k;

    ll a[n+1] , pref[n];
    pref[0] = 0;
    for(int i = 1 ; i <= n ; i++)
    {
        cin >> a[i];
        pref[i] = pref[i-1] + a[i];
    }
    map<ll,ll> m;
    
    for(int i = 1 ; i <= n ; i++){
        pref[i] = (pref[i] - i + k)%k;
    }
    ll ans = 0;
    m[0]++;
    for(int i = 1 ; i <= n ; i++){
        if(i - k >= 0)m[pref[i-k]]--;
        ans += m[pref[i]];
        m[pref[i]]++;
    }

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

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int AB = abs(a - b);
  int BC = abs(b - c);
  int AC = abs(a - c);
  if(AC <= d || (AB <= d && BC <= d)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

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

    vector<int> cnt(n, 0);
    for(int i=2; i<=n; i++){
        int a;
        cin>> a;
        a--;
        cnt[a]++;
    }
    for(int i=0; i<n; i++){
        cout<<cnt[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4068
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ps push
#define pf push_front
#define mp make_pair
#define And &&
#define Or ||
#define ppb pop_back
#define ppf pop_front
#define inf INT_MAX
#define sz(name) name.size()
#define len(name) name.length()
#define ig cin.ignore()
#define Sort(name) sort(name.begin(),name.end())
#define For(name,start,finish) for(int name=start;name<finish;name++)
#define fast_in_out ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
//int row[]={-1,0,1,0};
//int col[]={0,1,0,-1};
 
const ll N=1e4+10;
const ll M=1e9+7;
 
ll Max(ll a,ll b){if(a>b)return a;return b;}
ll Min(ll a,ll b){if(a>b)return b;return a;}
ll big_mul(ll a,ll b,ll m){ll x=0,y=a%m;while(b>0){if(b&1)x=(x+y)%m;y=(2*y)%m;b>>=1;}return x%m;}
ll big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=(x*y)%m;y=(y*y)%m;b>>=1;}return x%m;}
ll Big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=big_mul(x,y,m);y=big_mul(y,y,m);b>>=1;}return x%m;}
ll mod_inverse(ll a,ll m){return big_mod(a,m-2,m);}  //a^-1 mod m = a^(m-2) mod m

int fnct(int pos1,int pos2,string s1,string s2,int k)
{
    
    for(int i=pos1;i<=pos2;i++,k++)
    {
        if(s1[i]!=s2[k])
        return false;
    }
    
    return true;
}
 
int main()
{
    fast_in_out;
    
    int a,b,c;
    cin>>a>>b>>c;
    
    int p=Min(abs(a-b)+abs(b-c),abs(a-c)+abs(b-c));
    int q=Min(abs(a-b)+abs(a-c),abs(b-c)+abs(a-c));
    int r=Min(abs(c-a)+abs(a-b),abs(c-b)+abs(a-b));
    
    cout<<Min(p,Min(q,r))<<endl;
    
    return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long int n,m; cin>>n>>m;
    if(n==1&&m==1)
    {
        cout<<1;
        return 0;
    }
    if(n==2&&m==1)
    {
        cout<<0;
        return 0;
    }
    if(n==1&&m==2)
    {
        cout<<0;
        return 0;
    }
    
    if(n==1)
    {
        cout<<m-2;
        return 0;
    }
    if(m==1)
    {
        cout<<n-2;
        return 0;
    }
    
    if(m>=2&&n>=2)
    {
        cout<<(m-2)*(n-2);
        return 0;
    }
    
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = sc.nextInt();
        int max = min;
        for(int i = 0 ; i < n-1 ; i++){
            int x = sc.nextInt();
            if(x < min)
                min = x;
            else if(x > max)
                max = x;
        }
        int ans = max - min;
        if(ans % 2 == 0)
            System.out.println(ans/ 2);
        else
            System.out.println(ans / 2 + 1);
    }
}


Measured memory_bytes: 29976
#include <bits/stdc++.h>
    #define ll long long
    #define rep(X,N) for(int X = 0; X < N; X++)

    using namespace std;

    int main(){

        int n;
        cin >> n;

        bool ans = true;

        if(n % 3 == 0){

            vector<int> v;
            map<int,int> m;

            rep(i,n){
                int tmp;
                cin >> tmp;

                if(m[tmp] == 0){
                    v.push_back(tmp);
                }
                m[tmp]++;
            }

            sort(v.begin(),v.end());

            if(v[0] == 0){
                ans = (m[0] == n / 3 && m[v[1]] == n * 2 / 3) || m[0] == n;
            }else{
                ans = m[v[0]] == n / 3 && m[v[1]] == n / 3 && m[v[0] xor v[1]] == n / 3;
            }

        }else{
            rep(i,n){
                int tmp;
                cin >> tmp;

                if(tmp != 0){
                    ans = false;
                    break;
                }
            }
        }

        

        if(ans){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }

    }

Measured memory_bytes: 4216
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        management solver = new management();
        solver.solve(1, in, out);
        out.close();
    }

    static class management {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] nums = new int[n + 1];
            for (int i = 2; i <= n; i++) {
                int boss = in.nextInt();
                nums[boss]++;
            }

            for (int i = 1; i <= n; i++) {
                out.println(nums[i]);
            }
        }

    }
}



Measured memory_bytes: 60416
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<62;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	ll X,K;cin>>X>>K;
	vector<ll> r(K+1),sum(K+1);
	for(int i=1;i<=K;i++)cin>>r[i];
	for(int i=1;i<=K;i++){
		if(i%2==0){
			sum[i]=sum[i-1]+r[i]-r[i-1];
		}else{
			sum[i]=sum[i-1]-r[i]+r[i-1];
		}
	}
	int a=0;
	vector<ll> v1(K+1),v2(K+1);
	for(int i=1;i<=K;i++){
		if(i%2){
			v1[i]=max(0LL,v1[i-1]-(r[i]-r[i-1]));
		}else{
			v1[i]=min(X,v1[i-1]+r[i]-r[i-1]);
		}
	}
	v2[0]=X;
	for(int i=1;i<=K;i++){
		if(i%2){
			v2[i]=max(0LL,v2[i-1]-(r[i]-r[i-1]));
		}else{
			v2[i]=min(X,v2[i-1]+r[i]-r[i-1]);
		}
	}
	int q;cin>>q;
	vector<pair<P,int>> qs(q);
	for(int i=0;i<q;i++){
		cin>>qs[i].first.second>>qs[i].first.first;
		qs[i].second=i;
	}
	sort(all(qs));
	int i1=0,i2=0;
	vector<int> id1(q),id2(q);
	for(int i=0;i<q;i++){
		a=qs[i].first.first;
		while(i1<=K&&sum[i1]+a>0)i1++;
		id1[i]=i1;
	}
	for(int i=q-1;i>=0;i--){
		a=qs[i].first.first;
		while(i2<=K&&sum[i2]+a<X)i2++;
		id2[i]=i2;
	}
	vector<ll> ans(q);
	for(int i=0;i<q;i++){
		a=qs[i].first.first;ll t=qs[i].first.second,id=qs[i].second;
		int nt=upper_bound(all(r),t)-r.begin();--nt;
		if(id1[i]<id2[i]){
			if(nt>=id1[i]){
				ans[id]=v1[nt];
			}else{
				ans[id]=sum[nt]+a;
			}
		}else{
			if(nt>=id2[i]){
				ans[id]=v2[nt];
			}else{
				ans[id]=sum[nt]+a;
			}
		}
		if(nt%2){
			ans[id]+=t-r[nt];
		}else{
			ans[id]-=t-r[nt];
		}
		chmin(ans[id],X);
		chmax(ans[id],0LL);
	}
	for(int i=0;i<q;i++){
		cout<<ans[i]<<endl;
	}
}

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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
//#define int long long
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define all(x) x.begin(), x.end()
using pii = pair<int, int>;
using ll = long long;

bool candiv[202][202];
string ss[202];
int M, N;
int dat[150];
int dp[1 << 11][1 << 11];
int rec(int used, int yn) {
    if (dp[used][yn] >= 0) return dp[used][yn];
    int cnt = 0;
    REP(i, N) {
        if ((used & dat[i]) == yn) cnt++;
    }
    if (cnt <= 1) return dp[used][yn] = 0;
    int ret = 1e9;
    REP(j, M) {
        if (used & (1 << j)) continue;
        int nu = used | (1 << j);
        int nyn1 = yn | (1 << j), nyn2 = yn;
        int res = max(rec(nu, nyn1), rec(nu, nyn2)) + 1;
        ret = min(ret, res);
    }
    return dp[used][yn] = ret;
}
bool solve() {
    cin >> M >> N;
    if (M == 0) return false;
    REP(i, 1 << M) REP(j, 1 << M) dp[i][j] = -1;
    REP(i, N) dat[i] = 0;
    REP(i, N) {
        string s;
        cin >> s;
        REP(j, M) {
            if (s[j] == '1') dat[i] |= (1 << j);
        }
    }
    int ans = rec(0, 0);
    cout << ans << endl;
    return true;
}

signed main() {
    while (solve())
        ;
}


Measured memory_bytes: 19500
#include<stdio.h>

int main(){
int H,W,i,j;

while(1){
  scanf("%d %d",&H,&W);
if(H==0 && W == 0) break;

for(i = 0;i<W;i++) printf("#");
printf("\n");
for(j = 2;j < H;j++){
printf("#");
for(i = 2;i<W;i++) printf(".");
printf("#\n");
}
for(i = 0;i<W;i++) printf("#");

printf("\n");
 printf("\n");
 }

return 0;
}



Measured memory_bytes: 2112
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b; int k;
  cin >> a >> b >> k;
  REP(kk,k){
    if(kk%2==0){
      if(a%2==1) a--;
      b += a/2;
      a /= 2;
    }else{
      if(b%2==1) b--;
      a += b/2;
      b /=2;
    }
  }
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 3544
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

bool ok(string s) {
  for (int i = 1; i < s.size(); i++)
    if (s[0] != s[i]) return false;
  return true;
}

void solve() {
  string s; cin >> s;
  int ans = __INT_MAX__;

  for (char c = 'a'; c <= 'z'; c++) {
    string t = s;
    while (!ok(t)) {
      string u = "";
      for (int i = 0; i < t.size() - 1; i++) {
        if (t[i] == c || t[i + 1] == c) u += c;
        else u += t[i];
      }
      t = u;
    }
    ans = min(ans, int(s.size() - t.size()));
  }

  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int K, S;

signed main(void) {
    cin>>K>>S;
    int cnt=0;
    REP(x, 0, K) {
        REP(y, 0, K) {
            int z=S-(x+y);
            if (0<=z&&z<=K) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline()[:-1]

n, m = map(int, input().split())
adj = [[i] for i in range(n)]
for _ in range(m):
	a, b = map(int, input().split())
	adj[a-1].append(b-1)
	adj[b-1].append(a-1)

dp = [[0 for _ in range(11)] for _ in range(n)]
qs = [0]

q = int(input())
for i in range(q):
	v, d, c = map(int, input().split())
	qs.append(c)
	dp[v-1][d] = i+1

for j in range(10, 0, -1):
	for i in range(n):
		for v in adj[i]:
			dp[v][j-1] = max(dp[v][j-1], dp[i][j])

for i in range(n):
	print(qs[dp[i][0]])

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

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------
ll dp[100001][13]={};

int main(void) {
  string s;
  cin >> s;
  int n=s.size();

  dp[0][0]=1;

  ll mul=1;
  rep(i,n){
    if(s[n-i-1]=='?')
    {
      rep(k,10)
      {
        rep(j,13)
        {
          ll num=(k*mul+j)%13;
          dp[i+1][num]+=dp[i][j];
          dp[i+1][num]%=MOD;
        }
      }
    } else {
      int k=(ll)(s[n-i-1]-'0');
      rep(j,13)
      {
        ll num=(k*mul+j)%13;
        dp[i+1][num]+=dp[i][j];
        dp[i+1][num]%=MOD;
      }
    }
    mul*=10;
    mul%=13;
    //prt2("multiplier : ", mul);
  }

  prt(dp[n][5]);
}


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

int main()
{
    int N;
    int b[200001] = {0};
    int a[200001] = {0};
    bool hasAns = true;

    std::cin >> N;

    for(int i=1; i<=N; i++){
        std::cin >> a[i];
    }

    for(int i=N; i>=1; i--){

        int j=i+i;
        int sum=0;
        while(j<=N){
            sum+=b[j];
            j+=i;
        }
        // if(sum%2 != a[i]){
        //     hasAns = false;
        //     break;
        // }
        b[i] = (sum%2 + a[i])%2;
    }

    //  for(auto e:b)std::cout << e;

    if(hasAns==false){ 
        std::cout << -1 << std::endl;
        return 0;
    }

    std::string ans = "0";
    int count = 0;
    for(int i=1; i<=N; i++){
        if(b[i]==1){
            count++;
            if(ans=="0"){
                ans=std::to_string(i);
            }else{
                ans+=" " + std::to_string(i);
            }
        }
    }

    if(count == 0){
        std::cout << count << std::endl;
    }else {
        std::cout << count << std::endl;
        std::cout << ans << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3584
h, w = map(int, input().split())

ans_wsplit = [max(abs((i * w) - (((h - i) + 1) // 2) * w), abs((i * w) - ((h - i) // 2) * w)) for i in range(1, h)]
ans_hsplit = [max(abs((i * h) - (((w - i) + 1) // 2) * h), abs((i * h) - ((w - i) // 2) * h)) for i in range(1, w)]

ans_wline = [max(abs((i * w) - ((w + 1) // 2) * (h - i)), abs((i * w) - (w // 2) * (h - i))) for i in range(1, h)]
ans_hline = [max(abs((i * h) - ((h + 1) // 2) * (w - i)), abs((i * h) - (h // 2) * (w - i))) for i in range(1, w)]

print(min(ans_wsplit + ans_hsplit + ans_wline + ans_hline))


Measured memory_bytes: 64108
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let mut m1 = 0;
    let mut m2 = 0;
    for &x in &v {
        if x > m1 {
            m2 = m1;
            m1 = x;
        } else if x > m2 {
            m2 = x;
        }
    }
    for &x in &v {
        println!("{}", if x == m1 { m2 } else { m1 });
    }
}


Measured memory_bytes: 7676
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
 
class Program{
    static void Main(){
        int[] inputs = Console.ReadLine().Split(' ')
                                         .Select(val => int.Parse(val))
                                         .ToArray();
        Dice dc = new Dice(inputs);
        string order = Console.ReadLine();
        foreach (char ch in order)
        {
            dc.Move(ch);
        }
        Console.WriteLine(dc.rables[0]);
    }

    class Dice
    {
        public int[] rables {get; set;}
        public Dice(int[] iarr){
            rables = new int[6];
            Array.Copy(iarr, 0, this.rables, 0, iarr.Length);
        }
        public void Move(char direction){
            int tmp;
            switch (direction)
            {
                case 'N':
                    tmp = rables[0];
                    rables[0] = rables[1];
                    rables[1] = rables[5];
                    rables[5] = rables[4];
                    rables[4] = tmp;
                    break;
                case 'W':
                    tmp = rables[0];
                    rables[0] = rables[2];
                    rables[2] = rables[5];
                    rables[5] = rables[3];
                    rables[3] = tmp;
                    break;
                case 'S':
                    tmp = rables[0];
                    rables[0] = rables[4];
                    rables[4] = rables[5];
                    rables[5] = rables[1];
                    rables[1] = tmp;
                    break;
                case 'E':
                    tmp = rables[0];
                    rables[0] = rables[3];
                    rables[3] = rables[5];
                    rables[5] = rables[2];
                    rables[2] = tmp;
                    break;
            }
        }
    }
}

Measured memory_bytes: 9612
from collections import Counter

N = int(input())
a = list(input().split())
A = [int(a[i]) for i in range(N)]
Q = int(input())
Query = [input().split() for i in range(Q)]
SUM = sum(A)
A_count = Counter(A)
num = [A_count[i+1] for i in range(100000)]

for i in range(Q):
    B = int(Query[i][0])
    C = int(Query[i][1])
    SUM += (C-B) * num[B-1]
    print(SUM)
    num[C-1] += num[B-1]
    num[B-1] = 0 

Measured memory_bytes: 54588
#include <bits/stdc++.h>
#define ri register int
#define il inline
#define ll long long
using namespace std;

const int N = 1e6 + 110;
const int MAXN = 110;
const int inf = 0x7fffffff;
const double eps = 1e-8;

il int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (isdigit(ch))
	{
		x = (x << 3) + (x << 1) + ch - '0';
		ch = getchar();
	}
	return x * f;
}

int a, b;

int main()
{
	a = read(), b = read();
	if ((a % 2) && (b % 2))
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 256
n=int(input())
c=0
m=0
for i in range(n):
  a,b=map(int,input().split())
  if a==b:
    c+=1
  else:
    c=0
  m=max(c,m)
if m>=3:
  print("Yes")
else:
  print("No")
#print(c)

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

int main(){
    string s;
    cin >> s;
    if(s=="abc" || s=="acb" || s=="bac" || s=="bca" || s=="cab" || s=="cba"){
        cout <<"Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

ll count_divs[10000000] = {0};
void solve(int n)
{
	//fill(count_divs + 1, count_divs+n+1, 0);
	rep(i, 1, n)
		for(ll j = i ; j <= n; j+=i)
			count_divs[j] += 1;
}



int main()
{
	//ifstream cin("input.txt");
	int n;
	cin>>n;
	ll sum = 0;
	solve(n);
	rep(i, 1, n)
	{
		sum += i * count_divs[i];
	}
	cout<<sum;
}

Measured memory_bytes: 81732
A, B, C, K = input().split()
A, B, C, K = int(A), int(B), int(C), int(K)

if K >= A:
    Anum = A
    N = K - A
else:
    Anum = K
    N = 0

if N >= B:
    Bnum = B
    N = N - B
else:
    Bnum = N
    N = 0

Cnum = N

Total = Anum * 1 + Bnum * 0 + Cnum * (-1)

print(Total)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N,M;
    cin >>N>>M;
    vector<int> frag(M);
   for(int i = 0;i < N;i++){
       int K = 0;
       cin >> K;
       for(int j = 0;j < K;j++){
           int A;
           cin>>A;
           A--;
           frag[A]++;
       }
   }
   int ans = 0;
   for(int i = 0;i < M;i++){
       if(frag[i] == N)ans++;
   }
   cout << ans << endl;
}

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

using namespace std;
using ll = long long;

class range {private: struct I{ll x;ll operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(ll n):i({0}),n({n}){}range(ll i,ll n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

#define all(x) (x).begin(),(x).end()

int main() {
    int N, tmp;
    vector<int> v,a,b;
    cin >> N;
    for (int i : range(N)) {
        cin >> tmp;
        v.push_back(tmp);
    }
    sort(all(v));
    reverse(all(v));

    int j = 0;
    for (int i : v) {
        if (j++ % 2 == 0) {
            a.push_back(i);
        }
        else
        {
            b.push_back(i);

        }
    }

    cout << accumulate(all(a), 0) - accumulate(all(b), 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;

const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 2e9
#define ALL(v) v.begin(), v.end()
int n,m;
int k[10];
int s[10][10];
int p[10];
ll dfs(ll count,ll g,int jj){
    if(jj==n){
        ll ss[n];
        ll te=10;
        ll temp1=g;
        for(int i=0;i<n;i++){
            ss[i]=temp1%10;
            temp1=temp1/10;
        }
        for(int i=0;i<m;i++){
            ll a=0;
            for(int j=0;j<k[i];j++){
                if(ss[s[i][j]-1]==1){
                    a++;
                }
            }
            if(a%2!=p[i]) return 0;
        }
        return 1;
    }
    ll temp=count+g;
    ll f=dfs(count*10,temp,jj+1);
    ll b=dfs(count*10,g,jj+1);
    return (f+b);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m;
    for(int i=0;i<n;i++) {
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            cin>>s[i][j];
        }
    }
    for(int i=0;i<m;i++){
        cin>>p[i];
    }
    cout << dfs(1,0,0)<< "\n";
}

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

using namespace std;

void dfs(int v, vector<vector<int>> & g, 
		 vector<bool> & visited, vector<int> & dp){
	visited[v] = true;
	for(int to : g[v]){
		if(!visited[to]){
			dfs(to, g, visited, dp);
		}
		dp[v] = max(dp[v], dp[to] + 1);
	}
}

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n + 1, vector<int>());
	for(int i = 0; i < m; ++i){
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
	}

	vector<bool> visited(n + 1, false);
	vector<int> dp(n + 1, 0);

	for(int v = 1; v <= n; ++v){
		if(!visited[v]){
			dfs(v, g, visited, dp);
		}
	}
	
	cout << *max_element(dp.begin(), dp.end());
    return 0;
}


Measured memory_bytes: 9600
#include<iostream>
#include<set>
#include <stdlib.h>
using namespace std;

int main(){
  int N, Y;
  cin >> N >> Y;
  for (int i=0; i <=N ; i++){
    for (int j=0; j<= N-i; j++){
      if (10000*i+5000*j==Y-(N-i-j)*1000){
        cout<< i <<' '<< j <<' ' << N-i-j << "\n";
        return 0;
      }
    }
  }
  cout<< "-1 -1 -1" << "\n";
  return 0;
}

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

int main() {
  // 命令の行数を取得
  int N;
  cin >> N;
  int max = 0;
  int min = 0;
  
  vector<int> a[100];
  for(int i = 0; i < N; i++){
    int num;
    cin >> num;
    if(i ==0){
      max = num;
      min = num;
    }
    if((i != 0) & (num > max)){
      max = num;
    }
    if((i != 0) & (num < min)){
      min = num;
    }
  }
  cout << max-min << endl;
  
}

Measured memory_bytes: 256
#Hopscotch Addict

N,M=map(int,input().split())
graph={(i,j):[] for i in range(1,N+1) for j in range(1,4)}
for _ in range(M):
    u,v=map(int,input().split())
    graph[(u,1)].append((v,2))
    graph[(u,2)].append((v,3))
    graph[(u,3)].append((v,1))
S,T=map(int,input().split())

import heapq
def dijkstra(s,graph):
    dist={(i,j):float("inf") for i in range(1,N+1) for j in range(1,4)}
    dist[(s,3)]=0
    pq=[]
    heapq.heapify(pq)
    heapq.heappush(pq,(0,(s,3)))
    while pq:
        x=heapq.heappop(pq)
        node,mini_dis=x[1],x[0]
        for next_node in graph[node]:
            newlen=dist[node]+1
            if newlen<dist[next_node]:
                heapq.heappush(pq,(newlen,next_node))
                dist[next_node]=newlen
    return dist
K=dijkstra(S,graph)[(T,3)]
if K==float("inf"):
    print(-1)
else:
    print(K//3)



Measured memory_bytes: 141052
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}

int n;
int ans =1;

int main(){
  scanf("%d",&n);
  while(true){
    if(pow(ans,2) > n){
      ans--;
      break;
    }
    ans++;
  }
  printf("%d\n",ans*ans);
}


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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int ans, b;
    cin >> ans;
    for(int i = 1; i < n; ++i){
        cin >> b;
        ans = __gcd(ans,b);
    }
    cout << ans << endl;
}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int main() {

    int N; cin >> N;
    string st; cin >> st;

    vector<int> s(N);
    if (st[0] == 'W') s[0] = 1;
    else s[0] = 0;
    for (int i = 1; i < N; i++) {
        s[i] = s[i-1];
        if (st[i] == 'W') s[i]++;

    }

    int ans = (1<<21);
    for (int i = 0; i < N; i++) {

        if (i == 0) {
            ans = min(ans, (N-1-s[N-1]+s[0]) );

        } else if ( i == N-1 ) {

            ans = min(ans, s[N-2]);
        } else {
            ans = min(ans, s[i-1] + (N-i-1 - s[N-1] + s[i]));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1796
class ipy:
    def __init__(self, i, p, y):
        self.i = i
        self.p = p
        self.y = y


N, M = map(int, input().split())
list_ipy = []
for i in range(M):
    p, y = map(int, input().split())
    list_ipy.append(ipy(i, p, y))
list_ipy.sort(key=lambda x: x.y)
p_ord = {}
out = {}
for x in list_ipy:
    if x.p in p_ord:
        p_ord[x.p] += 1
    else:
        p_ord[x.p] = 1
    out[x.i] = [x.p, p_ord[x.p]]
for k in out:
    print('{0:06d}{1:06d}'.format(out[k][0], out[k][1]))


Measured memory_bytes: 53412
while True:
    rx = 10
    ry = 10
    n = int(input())
    if n == 0:
        exit()
    gems = [[0 for j in range(21)] for i in range(21)]
    for _ in range(n):
        (x, y) = [int(x) for x in input().split()]
        gems[x][y] = 1
    m = int(input())
    for _ in range(m):
        (d, l) = input().split()
        if d=='N':
            for i in range(1, int(l)+1):
                gems[rx][ry+i] = 0
            ry = ry+int(l)
        elif d=='W':
            for i in range(1, int(l)+1):
                gems[rx-i][ry] = 0
            rx = rx-int(l)
        elif d=='E':
            for i in range(1, int(l)+1):
                gems[rx+i][ry] = 0
            rx = rx+int(l)
        elif d=='S':
            for i in range(1, int(l)+1):
                gems[rx][ry-i] = 0
            ry = ry-int(l)
    if sum([sum(gems[i]) for i in range(21)])==0:
        print('Yes')
    else:
        print('No')

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	ll K, ans = INF;

	cin >> K;

	vector<pii> edge[100005];
	rep(i,K){
		if( i%10 < 9 ) edge[i].emplace_back( (i+1 )%K, 1);
		if( i    > 0 ) edge[i].emplace_back( (i*10)%K, 0);
	}

	deque<int> que;
	que.push_back(1);
	ll d[100005];
	Fill(d, INF);
	d[1] = 1;
	bool used[100005] = {};
	while( que.size() ){
		int n = que.front();
		que.pop_front();
		if( used[n] ) continue;
		used[n] = true;
		for(auto t: edge[n]) if(d[t.X] > d[n] + t.Y){
			d[t.X] = d[n] + t.Y;
			if( t.Y == 1 ) que.push_back(t.X);
			if( t.Y == 0 ) que.push_front(t.X);
		}
	}

	ans = d[0];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8064
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			String s = stdIn.nextLine();
			char[] a = s.toCharArray();
			for(int i = 0; i < 26; ++i)
			{
				for(int j = 0; j < a.length; ++j)
				{
					if('a' <= a[j] && a[j] <= 'z')
					{
						if(a[j] == 'z')
						{
							a[j] = 'a';
						}
						else
						{
							++a[j];
						}
					}
				}
				String ans = String.valueOf(a);
				if(ans.contains("this") || ans.contains("that") || ans.contains("the") )
				{
					System.out.println(ans);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 12000
a, b, c = input().split()
# a = int(num[0])
# b = int(num[1])
# c = int(num[2])

if a > c:
    a, c = c, a
if a > b:
    a, b = b, a
if b > c:
    b, c = c, b

print(str(a) + " " + str(b) + " " + str(c))


Measured memory_bytes: 5560
#include <stdio.h>

int main() {
    double a, b, c, d, e, f;
    double x=0, y=0;

    while(scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f) != EOF) {
        x = (c*e-b*f)/(a*e-b*d);
        y = (a*f-c*d)/(a*e-b*d);
        if(x == -0.0) x=0.0;
        if(y == -0.0) y=0.0;
        printf("%.3lf %.3lf\n", x, y);
    }

    return 0;
}

Measured memory_bytes: 652
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int A = sc.nextInt();
        int V = sc.nextInt();
        int B = sc.nextInt();
        int W = sc.nextInt();
        int T = sc.nextInt();

        System.out.println(solve(A, V, B, W, T) ? "YES" : "NO");
    }

    private static boolean solve(int A, int V, int B, int W, int T) {
        if (V <= W) return false;

        long dist = Math.abs(A - B);
        long velocity = V - W;

        if (dist <= (long)T * velocity) return true;


        return false;
    }
}

Measured memory_bytes: 35792