akhauriyash/Code-Regression huggingface dataset:
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(13)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int A, B, C, D; cin >> A >> B >> C >> D; A--;
  int L = LCM(C, D);
  int num = L - L/C - L/D + 1;
  int a = num*(A/L) + A%L - (A%L)/C - (A%L)/D;
  int b = num*(B/L) + B%L - (B%L)/C - (B%L)/D;
  cout << b - a << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let a: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let acc = a.iter().scan(0, |s, &x| {
        *s += x;
        Some(*s)
    }).collect::<Vec<_>>();
    let ans = (0..(N - 1)).map(|i| (acc[N - 1] - 2 * acc[i]).abs()).min().unwrap();

    println!("{}", ans);
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl
#define COUT(x) cerr<<#x<<" = "; cout<<(x)<<endl

struct edge { int to, cost; };

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

signed main()
{
   int a, b, c; cin >> a >> b >> c;

   int ans = INF;
   chmin(ans, (a % 2) * (b * c));
   chmin(ans, (b % 2) * (c * a));
   chmin(ans, (c % 2) * (a * b));
   COUT(ans);

   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner input  = new Scanner(System.in);
		String S = input.nextLine();
		input.close();
		String correct = "CODEFESTIVAL2016";
		int num = 0;
		for(int i = 0; i < 16;i++){
			if(S.charAt(i) != correct.charAt(i)) num++;
		}
		System.out.println(num);
	}

}


Measured memory_bytes: 9680
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]

target_len = int(fetch_one_line())
target_str = fetch_one_line()

echo_result = ["Yes", "No"]
IS_REPEAT = 0
ISNT_REPEAT = 1
if target_len % 2 == 1:
    print(echo_result[ISNT_REPEAT])
else:
    half_len = int(target_len / 2)
    if target_str[:half_len] == target_str[half_len:]:
        print(echo_result[IS_REPEAT])
    else:
        print(echo_result[ISNT_REPEAT])





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

using namespace std;

int dx[] = {0, 0, 1, -1, 1,-1,1,-1};
int dy[] = {1, -1, 0, 0, 1,-1,-1,1};
int m,n;
bool isSafe(int x, int y){
    if(x<0||y<0||x>=n||y>=m)return false;
    return true;
}

int main()
{

    char a,b;
    scanf("%c %c",&a,&b);
    if(a<b)
        printf("<");
    else if(a>b)
        printf(">");
    else
        printf("=");
    /*
 scanf("%d %d",&n,&m);
 char c[n][m];
 int x[n][m];
 for(int i=0;i<n;i++)
    fill(x[i],x[i]+m,0);

 for(int i=0;i<n;i++)
    scanf("%s",&c[i]);

 for(int i=0;i<n;i++)
 {
     for(int j=0;j<m;j++)
     {
         if(c[i][j]=='.')
         {
             //cout<<" i = "<<i<<" // "<<" j = "<<j<<endl;
             for(int k=0;k<8;k++)
             {
                 if(isSafe(i+dx[k],j+dy[k])&&c[i+dx[k]][j+dy[k]]=='#')
                 {
                     x[i][j]++;
                     //cout<<"x = "<<x[i][j]<<" i = "<<i+dx[k]<<" j ="<<j+dy[k]<<endl;
                 }
             }
         }
     }
 }
for(int i=0;i<n;i++)
{
    for(int j=0;j<m;j++)
    {
        if(c[i][j]=='.')
            printf("%d",x[i][j]);
        else
            printf("%c",c[i][j]);
    }
    printf("\n");
}
*/
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
sift = [list(map(int, input().split())) for _ in range(M)]
ball = [0] * N
ball[0] = 1
num_ball = [1] * N
for i in range(M):
    #print(ball)
    a, b = sift[i]
    a -= 1
    b -= 1
    if ball[a] == 1:
        if num_ball[a] > 1:
            ball[b] = 1
            num_ball[a] -= 1
            num_ball[b] += 1
        else:
            ball[b] = 1
            ball[a] = 0
            num_ball[b] += 1
            num_ball[a] -= 1
    else:
        num_ball[a] -= 1
        num_ball[b] += 1
print(sum(ball))

Measured memory_bytes: 28964
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string.h>
#include<string>
using namespace std;
typedef long long int llint;
int main() {
	int k, s;
	cin >> k >> s;
	int ans = 0;
	for (int i = 0;i <= k;i++) {
		for (int j = 0;j <= k;j++) {
			if (i + j <= s&&i + j + k >= s) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	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 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  string w;
  cin >> w;

  int flag = 0;
  FOR(i,'a','z'){
    int cnt = 0;
    REP(j,w.size()){
      if(w.at(j) == i){
        cnt++;
      }
    }
    if(cnt%2 == 1){
      flag = 1;
    }
  }

  if(flag == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e11;

int N, K;
vector<int> D;

bool check(int m) {
  string s = to_string(m);
  for (int s_num = 0; s_num < s.size(); s_num++) {
    for (int d_num = 0; d_num < D.size(); d_num++) {
      if (s[s_num] - '0' == D[d_num]) {
        return false;
      }
    }
  }
  return true;
}

void abc042c() {
  for (int i = N; i <= 999999; i++) {
    if (check(i)) {
      cout << i << "\n";
      return;
    }
  }
}

int main() {
  cin >> N >> K;
  D.resize(K);
  for (int i = 0; i < K; i++) {
    cin >> D[i];
  }
  abc042c();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int height[10];
	int i;
	for(i=0;i<10;i++)
		cin>>height[i];
	int j;
	int temp;
	for(i=9;i>0;i--)
		for(j=0;j<i;j++)
		{
			if(height[j]<height[j+1])
			{
				temp=height[j];
				height[j]=height[j+1];
				height[j+1]=temp;
			}

		}
		for(i=0;i<3;i++)
			cout<<height[i]<<endl;
		return 0;
}

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

using namespace std;

int main()
{
	string c;
	cin >> c ;
	if (c == "a" || c == "i" || c == "u" || c == "e" || c == "o") cout << "vowel" << endl;
	else cout << "consonant" << endl;

    return 0;
}

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

int main()
{
	int n, k,ans=0;
	cin >> n >> k;

	vector<int> l(n);

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

	sort(l.begin(), l.end(), greater<int>());
	
	for (int i = 0; i < k; i++)
	{
		ans += l[i];
	}

	cout << ans << endl;
}

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

int N;
char c;
int main(){
    scanf("%d", &N);//cin >> N;でもいいけど，scanf()の方が速いらしい
    bool flag = false;
    for(int i=0; i<N; i++){
        scanf("%c", &c);
        if(c=='Y'){flag=true;}
    }
    if(flag)cout << "Four" << endl;
    else cout << "Three" << endl;
}

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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 100100;
int grundy[N];
vi a[N];
int n;

void calc(int v, int pr) {
	grundy[v] = 0;
	forn(i, sz(a[v])) {
		int to = a[v][i];
		if (to == pr)
			continue;
		calc(to, v);
		grundy[v] ^= grundy[to];
	}
	if (v) {
		grundy[v]++;
	}
}

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	cin >> n;
	forn(i, n - 1) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		a[u].pb(v);
		a[v].pb(u);
	}	
	calc(0, -1);
	if (grundy[0]) {
		puts("Alice");
	} else {
		puts("Bob");
	}
	return 0;
}



Measured memory_bytes: 13952
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d,ty,by;
    cin>>a>>b>>c>>d;
    if(a<=b)
    {
        ty=a;
    }
    else
    {
        ty=b;
    }
    if(c<=d)
    {
        by=c;
    }
    else
    {
        by=d;
    }
    cout<<by+ty<<endl;
}


Measured memory_bytes: 256
/*
    ThunderClap and Flash
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod) + (b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod) * (b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod) - (b%mod) + mod)%mod;}
ll dp[2001][2001];
void Flash(){
    ll sum;
    cin>>sum;
    ll n = (sum / 3);
    memset(dp, 0, sizeof(dp));
    for (ll i = 0; i <= n; i++) {
        dp[i][0] = 1;
    }
    for (ll j = 1; j <= sum; j++) {
        dp[0][j] = 1;
    }
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= sum; j++) {
            if ((j - 3) >= 0) {
                dp[i][j] = add(dp[i][j], dp[i - 1][j - 3]);
            }
            dp[i][j] = add(dp[i][j], dp[i][j - 1]);
        }
    }
    ll ans = sub(dp[n][sum], dp[n][sum - 1]);
    cout<<ans<<"\n";
}

int main(int argc, char const *argv[]){ 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    ThunderClap;
    ll t = 1;
    for(ll i = 1; i <= t; i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


Measured memory_bytes: 34888
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  double n;
  cin>>n;
  int r=n;
  double ans=0.5;
  if(r%2==1) ans=(n+1)/2/n;
  cout<<ans<<endl;
}


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

int main(){
  int a,b;
  cin >> a >>b;
  if((a==1&&b==2)||(a==2&&b==1)) cout << 3 << endl;
  else if((a==2&&b==3)||(a==3&&b==2)) cout << 1 << endl;
  else cout << 2 <<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 5e2 + 5;

struct Node
{
	int x,y;
};

int s[MAXN],t[MAXN];
ull u[MAXN],v[MAXN];

ull ans[MAXN][MAXN];

int main(void)
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; ++i) scanf("%d",&s[i]);
	for(int i=1; i<=n; ++i) scanf("%d",&t[i]);
	for(int i=1; i<=n; ++i) scanf("%llu",&u[i]);
	for(int i=1; i<=n; ++i) scanf("%llu",&v[i]);
	
	try
	{
		for(int k=0; k<64; ++k)
		{
			static int p[MAXN],q[MAXN];
			for(int i=1; i<=n; ++i)
				p[i] = (u[i]>>k)&1,
				q[i] = (v[i]>>k)&1;
			
			static int a[MAXN][MAXN];
			static bool must[MAXN][MAXN];
			static bool delr[MAXN], delc[MAXN];
			static queue<Node> que;
			
			memset(must,0,sizeof(must));
			memset(delr,0,sizeof(delr));
			memset(delc,0,sizeof(delc));
			
			for(int i=1; i<=n; ++i)
			{
				if(s[i] == p[i]) continue;
				for(int j=1; j<=n; ++j)
				{
					if(must[i][j] && a[i][j]!=p[i]) throw 114514;
					a[i][j]=p[i]; must[i][j]=1;
					que.push((Node){i,j});
				}
				delr[i]=1;
			}
			for(int j=1; j<=n; ++j)
			{
				if(t[j] == q[j]) continue;
				for(int i=1; i<=n; ++i)
				{
					if(must[i][j] && a[i][j]!=q[j]) throw 114514;
					a[i][j]=q[j]; must[i][j]=1;
					que.push((Node){i,j});
				}
				delc[j]=1;
			}
			
			while(!que.empty())
			{
				int x=que.front().x, y=que.front().y;
				que.pop();
				
				if(!delr[x])
				{	
					if(!must[x][y])
					{
						a[x][y] = p[x];
						must[x][y]=1;
					}
					if(p[x] == a[x][y])
					{
						for(int j=1; j<=n; ++j)
							que.push((Node){x,j});
						delr[x]=1;
					}
				}
				if(!delc[y])
				{
					if(!must[x][y])
					{
						a[x][y] = q[y];
						must[x][y]=1;
					}
					if(q[y] == a[x][y])
					{
						for(int i=1; i<=n; ++i)
							que.push((Node){i,y});
						delc[y]=1;
					}
				}
			}
			
			int r=0,c=0;
			for(int i=1; i<=n; ++i)
				if(!delr[i]) ++r;
			for(int i=1; i<=n; ++i)
				if(!delc[i]) ++c;
			
			if(((bool)r) ^ ((bool)c)) throw 114514;
			if(r==1)
			{
				for(int i=1; i<=n; ++i)
					for(int j=1; j<=n; ++j)
					{
						if(!must[i][j])
							a[i][j] = q[j];
					}
			}
			if(c==1)
			{
				for(int i=1; i<=n; ++i)
					for(int j=1; j<=n; ++j)
					{
						if(!must[i][j])
							a[i][j] = p[i];
					}
			}
			if(r>1 && c>1)
			{
				for(int i=1,tmp=0; i<=n; ++i) if(!delr[i])
				{
					for(int j=1,now=tmp; j<=n; ++j) if(!delc[j])
					{
						a[i][j] = now;
						now^=1;
					}
					tmp^=1;
				}
			}
			
			for(int i=1; i<=n; ++i)
				for(int j=1; j<=n; ++j)
					ans[i][j] |= ((ull)a[i][j]<<k);
		}
	}
	catch(...)
	{
		printf("-1");
		return 0;
	}
	
	for(int i=1; i<=n; ++i,putchar('\n'))
		for(int j=1; j<=n; ++j) printf("%llu ",ans[i][j]);
	return 0;
}

Measured memory_bytes: 12540
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    long A,B; cin>>A>>B;
    if(A+B>=10) pr("error");
    else pr(A+B);

    
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,K=map(int,input().split())
    if N%K==0:
        print(0)
    else:
        print(1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
input1 = input()
input2 = input()

input1_splited = input1.split(" ")
n = input1_splited[0]
k = input1_splited[1]
s = input2
k = int(k) - 1
list = list(input2)
tochange = list[int(k)]
changed = tochange.lower()
list[k] = changed
result_str = "".join(list)
print(result_str)

Measured memory_bytes: 3064
#include <algorithm>
#include <atcoder/all>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

using mint = atcoder::modint998244353;

int cnt[110000];
mint factorial[220000];
mint inv_factorial[220000];
mint perfect[220000];
queue<vector<mint>> polynomials;

mint nCk(int n, int k)
{
    if (k < 0 || n < k)
        return 0;
    return factorial[n] * inv_factorial[k] * inv_factorial[n - k];
}

int main()
{
    factorial[0] = 1;
    perfect[0] = 1;
    for (int i = 1; i < 220000; i++) {
        factorial[i] = factorial[i - 1] * i;
        perfect[i] = perfect[i - 1] * (2 * i - 1);
    }
    inv_factorial[220000 - 1] = factorial[220000 - 1].inv();
    for (int i = 220000 - 1; i > 0; i--) {
        inv_factorial[i - 1] = inv_factorial[i] * i;
    }

    int n;
    cin >> n;
    for (int i = 0; i < n * 2; i++) {
        int h;
        cin >> h;
        cnt[h]++;
    }
    mint odd = 0, even = 1;

    for (int h = 0; h < 110000; h++) {
        int c = cnt[h];
        if (c == 0)
            continue;
        vector<mint> polynomial;
        for (int k = 0; k * 2 <= c; k++) {
            polynomial.push_back(nCk(c, 2 * k) * perfect[k]);
        }
        polynomials.push(polynomial);
    }
    polynomials.push({1});
    while (polynomials.size() > 1) {
        auto x = polynomials.front();
        polynomials.pop();
        auto y = polynomials.front();
        polynomials.pop();
        polynomials.push(atcoder::convolution(x, y));
    }
    mint ans = 0;
    auto poly = polynomials.front();
    for (int i = 0; i < poly.size(); i++) {
        mint cnt = poly[i] * perfect[n - i];
        if (i % 2 == 0)
            ans += cnt;
        else
            ans -= cnt;
    }
    cout << ans.val() << endl;
}

Measured memory_bytes: 11512
#include<iostream>
using namespace std;
long NMAX= (long) 1e5;

int main(){
    long N;
    long K;
    cin >> N >> K;
    long a[NMAX+1]={};
    long atmp, btmp;

    for(long i=0; i<N; i++){
        cin >> atmp >> btmp;
        a[atmp] += btmp;
    }

    long Kleft;
    Kleft=K;
    for(long i=1; i<NMAX+1; i++){
        Kleft= Kleft - a[i];
        if(Kleft<=0){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int S1 = a * b;
  int S2 = c * d;

  cout << (S1 > S2 ? S1 : S2) << "\n";

  return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
import numpy as np
a = np.arange(1, n+1)
c = 0
for i in range(n):
  if p[i] != a[i]:
    c += 1
if c == 2 or c == 0:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 12504
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		// 文字列の入力
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
        int x = int.Parse(input[2]);
        
        int[] c = new int[n];
        int[][] a = new int[n][];
        for(int i=0; i<n; i++)
        {
          a[i] = new int[m];
          input = Console.ReadLine().Split(' ');
          c[i] = int.Parse(input[0]);
          for(int j=0; j<m; j++) a[i][j] = int.Parse(input[j+1]);
        }
      
        int cmin = -1;
        bool[] index = new bool[n];
        for(int i = 0; i < n; i++) index[i] = false;
        bool flgall = false;
        bool first = true;
        while(!flgall)
        {
          if(first)
          {
            first = false;
          }
          else
          {            
            for(int i = 0; i<n; i++)
            {
              index[i] = index[i] ^ true;
              if(index[i]) break;
            }
            flgall = true;
            for(int i = 0; i<n; i++) flgall = flgall && index[i];
          }
          
          //Console.WriteLine(index[0]);
          int[] aTmp = new int[m];
          int cTmp = 0;
          for(int i = 0; i<n; i++)
          {
            if(index[i])
            {
              cTmp += c[i];
              for(int j = 0; j<m; j++) aTmp[j] += a[i][j];                
            }
          }
          bool success = true;
          for(int j = 0; j<m; j++) success = success && aTmp[j] >= x;
          if(success && (cmin > cTmp || cmin == -1)) cmin = cTmp;
        }
      
        Console.WriteLine(cmin);
	}
}

Measured memory_bytes: 27832
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }
 
    // 素数である
    return 1;
}
 
int main(){
    lint N;
  
    cin>>N;   long long int T[N];
     rep(i,N){
         cin>>T[i];
     }
     if(N==1){
         cout<<T[0];
         return 0;
     }
    long long int x;
     rep(i,N-1){
         
         if(i==0) x= T[i] /__gcd(T[i],T[i+1])*T[i+1];
         else x=x/__gcd(x,T[i+1])*T[i+1];
         
     }
     cout<<x<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int W, a, b;
    cin >> W >> a >> b;

    if(a+W<b || b+W<a) {
        cout << min(abs(a+W-b), abs(b+W-a));
    } else {
        cout << 0 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
N, X, M = map(int, input().split())
 
def next_f(a):
    return a * a % M
 
visited = [None] * M
sum_at_visit = [None] * M
loop_done = False
 
time = 1
ans = 0
x = X
while time <= N:
    if not loop_done and visited[x] is not None:
        # found cycle                                                                                                                                         
        loop_len = time - visited[x]
        loop_sum = ans + x - sum_at_visit[x]
        loops = (N-loop_len-time) // loop_len
        time += loop_len * loops
        ans += loop_sum * loops
        loop_done = True
    ans += x
    visited[x] = time
    sum_at_visit[x] = ans
    time += 1
    x = next_f(x)
print(ans)

Measured memory_bytes: 15052
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
void solve(){
	ll h1, m1, h2, m2, k;
	cin>>h1>>m1>>h2>>m2>>k;
	ll t1=h1*60+m1, t2=h2*60+m2;
	cout<<t2-k-t1;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;

long long MOD = 1000000007;
long long dp[100005][4];

int A[1000][999];
bool todayState[1000][1000*999/2];
queue<int>que;
vector<int>shintyoku(1000, 0);
int endCount = 0;
int N;

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

bool IsSuccess(int day, int currentP) {
	bool isSuccess = false;
	if (todayState[currentP][day])return isSuccess;
	int aite = A[currentP][shintyoku[currentP]] - 1;
	if (A[aite][shintyoku[aite]] - 1 == currentP && !todayState[aite][day]) {
		todayState[currentP][day] = true;
		todayState[aite][day] = true;
		que.push(currentP);
		que.push(aite);
		shintyoku[currentP]++;
		shintyoku[aite]++;
		isSuccess = true;
		if (shintyoku[currentP] == N - 1)endCount++;
		if (shintyoku[aite] == N - 1)endCount++;
	}
	return isSuccess;
}

int Get(int a,int b) {
	if (a<b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main() {

	int N;
	cin >> N;

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

	int current = A[0];
	for (int i = 1; i < N;++i) {
		current = (current*A[i])/Get(current,A[i]);
	}

	int ue = 0;
	for (int i = 0; i < N; ++i)ue += current / A[i];

	double ans = (double)current / (double)ue;
	printf("%.7f\n",ans);
}


Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

bool END = false;
int ENDcount = 0;
vector< vector< vector<int> > > word(7);

bool check(deque<int> v){
	++ENDcount;
	if( ENDcount > 420 ){
		END = true;
		return true;
	}
	int size = v.size();
	string A,B;
	for(int i=0;i<size;++i){
		if( v[i]&1 ){
			A += '#';
		}else{
			A += '.';
		}
		if( v[i]&2 ){
			B += '#';
		}else{
			B += '.';
		}
	}
	cout << A << '\n' << B << endl;
	string res;
	cin >> res;
	if( res[0] == 'T' ){
		return true;
	}else if( res[0] == 'F' ){
		return false;
	}
	END = true;
	return true;
}

void solve(){
	int N;
	cin >> N;
	
	deque<int> ans;
	int pos = -1;
	while(1){//右に伸ばす
		ans.push_back(0);
		++pos;
		bool flag = false;
		for(int i=0;i<4;++i){
			ans[pos] = i;
			if( check( ans ) ){
				flag = true;
				if( END ){
					return;
				}
				break;
			}
		}
		if( flag == false ){//右に伸ばす4通りがダメだった
			ans.pop_back();//右の伸ばしたものを消す。
			break;
		}
	}

	while(1){//左に伸ばす
		ans.push_front(0);
		for(int i=0;i<4;++i){
			ans[0] = i;
			if( check( ans ) ){
				if( END ){
					return;
				}
				break;
			}
		}
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

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

vector<ll> sum;
ll i;
void pre_process(vector<ll> &a,vector<ll> &s){//累積和のvector
    ll n=(ll)a.size();
    s.assign(n+1,0);
    for(i=0;i<n;i++){
        s[i+1]=s[i]+a[i];
    }
}
ll query(ll i,ll j,vector<ll> &s){//区間[i,j]の和
    return s[j]-s[i];
}


int main(){
    ll n,k;cin>>n>>k;
    string s;cin>>s;
    vector<ll> a;

    if(n==1){cout<<"1"<<endl;return 0;}//例外処理

    vector<ll> Nums;//1 0の塊の大きさを記録する配列
    int now=1;//今見ている数
    int cnt=0;//nowがいくつ並んでいるか
    for(i=0;i<n;i++){
        if(s[i]==(char)('0'+now)){cnt++;}
        else{
            Nums.push_back(cnt);//最初に1がなければ0が追加される
            now=1-now;//0 1の交換
            cnt=1;//新しいのをカウント
        }
    }
    if(cnt!=0){Nums.push_back(cnt);}

    //0で終わっていたらたす
    if(Nums.size()%2==0){Nums.push_back(0);}
    //1で始まり1で終わる

    pre_process(Nums,sum);//累積和の作成

    ll add=2*k+1;
    ll ans=-1;
    for(i=1;i<=sum.size()-add;i+=2){
        if(i+add-1>sum.size()){cout<<n<<endl;return 0;}//例外処理
        ans=max(ans,query(i-1,i+add-1,sum));//できる限り多くひっくり返したときの最大人数
    }

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

Measured memory_bytes: 2164
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
#include<regex>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

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

	vector<int> blackboard_num = { A,B,C };
	sort(RALL(blackboard_num));

	for (int i = 0; i < K; i++) {
		blackboard_num[0] *= 2;
	}

	cout << accumulate(ALL(blackboard_num), 0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    int n, m;
    std::cin >> n >> m;

    std::vector<int> a(m);
    for (int i = 0; i < m; i++) {
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end(), std::greater<int>());

    std::vector<int> num_match = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

    std::vector<int> dp(n + 1, 0);
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j < m; j++) {
            if (i - num_match[a[j]] >= 0) {
                dp[i] = std::max(dp[i], dp[i - num_match[a[j]]] + 1);
            }
        }
    }

    std::vector<std::string> ans(n + 1, "");
    for (auto num : a) {
        if (n >= num_match[num]) {
            ans[n - num_match[num]] = std::max(ans[n - num_match[num]], std::to_string(num));
        }
    }
    for (int i = n - 1; i >= 0; i--) {
        if (ans[i] == "") {
            continue;
        }
        for (auto num : a) {
            if (i - num_match[num] >= 0) {
                if (ans[i - num_match[num]].size() <= ans[i].size()) {
                    ans[i - num_match[num]] = ans[i] + std::to_string(num);
                } else if (ans[i - num_match[num]].size() - 1 == ans[i].size()) {
                    ans[i - num_match[num]] = std::max(ans[i - num_match[num]], ans[i] + std::to_string(num));
                }
            }
        }
    }
    std::cout << ans[0] << std::endl;
}


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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

#include <queue>
#define INF LONG_MAX
typedef long long ll;
struct edge {
  ll to, cost;
};
typedef pair<ll, ll> P;

struct graph {
  ll V;
  vector<vector<edge>> G;
  vector<ll> d;

  graph(ll n) { init(n); }

  void init(ll n) {
    V = n;
    G.resize(V);
    d.resize(V);
    for(int i = 0; i < V; i++) {
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost) {
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s) {
    for(int i = 0; i < V; i++) {
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));
    while(!que.empty()) {
      P p = que.top();
      que.pop();
      ll v = p.second;
      if(d[v] < p.first)
        continue;
      for(auto e : G[v]) {
        if(d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          que.push(P(d[e.to], e.to));
        }
      }
    }
  }
};

/*
graph g(n);

と書けばn頂点のグラフが作成され、

  g.add_edge(a,b,cost);

とすれば頂点aから頂点bへのコストcostの辺が張られます。そして

  g.dijkstra(s);

とすれば頂点sから各頂点への最短経路をダイクストラ法で探索できます。探索結果は

  int dist = g.d[i]:

と呼び出して使うことができます。
*/

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, x, y;
  cin >> n >> x >> y;
  x--, y--;
  graph g(n);
  rep(i, n - 1) {
    g.add_edge(i, i + 1, 1);
    g.add_edge(i + 1, i, 1);
  }
  g.add_edge(x, y, 1);
  g.add_edge(y, x, 1);
  VI ans(n + 1, 0);
  rep(i, n) {
    g.dijkstra(i);
    rep(j, n) { ans[g.d[j]]++; }
  }
  FOR(i, 1, n) { cout << ans[i] / 2 << endl; }
  return 0;
}


Measured memory_bytes: 384
from sys import stdin

n = int(stdin.readline().strip())
k = int(stdin.readline().strip())
x_lst = [int(x) for x in stdin.readline().strip().split()]
sum_move = 0

# 絶対値の小さい方で和を取ればいいだけ
for x in x_lst:
  sum_move += min(abs(k-x), abs(x)) * 2
  
print(sum_move)

Measured memory_bytes: 9148
#include<stdio.h>

int main (void) {
  int x, y, a, b, temp;
  scanf("%d %d", &x, &y);

  if (x > y) {
    a = x;
    b = y;
  } else {
    a = y;
    b = x;
  }

  while (b != 0) {
    temp = b;
    b = a % b;
    a = temp;
  }

  printf("%d\n", a);

  return 0;
}

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

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

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

int main() {
    long long A,B;cin >> A >> B;
    cout << lcm(A,B) << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        int cnt1 = 0;
        int bi = 0;
        int ei = 1;
        int add = 1;
        int odd = 1;
        while (true) {
            if (ei>=S.length()) {
                if (ei==S.length()) {
                    if (S.length()==1) {
                        cnt1++;
                    } else if (add==1 && odd==1 && S.substring(S.length()-1, S.length()).equals(S.substring(S.length()-2,S.length()-1))) {
                        cnt1 = 0;
                    } else {
                        cnt1++;
                    }
                } else {}
                break;
            }
            String d = S.substring(bi, ei);
            odd = add;
            if (d.length()==1 && d.equals(S.substring(ei,ei+1))) {
                add = 2;
            } else {
                add = 1;
            }
            bi = ei;
            ei += add;
            cnt1++;
        }

        int cnt2 = cnt1;
        cnt1 = 0;
        bi = 0;
        ei = 2;
        add = 1;
        odd = 1;
        while (true) {
            if (ei>=S.length()) {
                if (ei==S.length()) {
                    if (S.length()==1) {
                        cnt1++;
                    } else if (add==1 && odd==1 && S.substring(S.length()-1, S.length()).equals(S.substring(S.length()-2,S.length()-1))) {
                        cnt1 = 0;
                    } else {
                        cnt1++;
                    }
                } else {}
                break;
            }
            String d = S.substring(bi, ei);
            odd = add;
            if (d.length()==1 && d.equals(S.substring(ei,ei+1))) {
                add = 2;
            } else {
                add = 1;
            }
            bi = ei;
            ei += add;
            cnt1++;
        }

        System.out.println(Math.max(cnt1,cnt2));
    }
}

Measured memory_bytes: 46188
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  string s;
  cin >> s;
  puts(s.find("YAKI") == 0 ? "Yes" : "No");

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;

///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int N, Q;
    cin >> N >> Q;
    dsu d(N);

    REP(i,Q){
        int t,u,v;
        cin >> t >> u >> v;
        if (t == 0){
            d.merge(u,v);
        }else{
            cout << d.same(u,v) << "\n";
        }
    }
}

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

int main(){
     string s;
     map<string,int>m;
     int n;
     cin>>n;
     while(n--){
     	cin>>s;
     	m[s]++;
     }
     cout<<m.size()<<endl;


      
      //cout<<mp.size()<<endl
     

}

Measured memory_bytes: 19228
import java.util.*;
 public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);

      int N = sc.nextInt();
      int M = sc.nextInt();
      int[] a = new int[M];
      

      for(int i = 0;i < M;i++){
        a[i] = sc.nextInt();
      }

      for(int i = 0;i < a.length;i++){
         N -= a[i];
      }
         if(N >= 0){
            System.out.println(N);
         }else{
            System.out.println(-1);
         }
      
         
   }
 }


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

int main()
{
	int n;
	while(cin >> n, n)
	{
		int ans=0;
		for(int i=1; i<=1000; i++)
		{
			int a=i;
			for(int j=i+1; j<=1000; j++)
			{
				a+=j;
				if(a==n)
				{
					ans++;
				}
			}
		}
		
		cout << ans << endl;
	}

}

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

ll dfs(vector<vector<ll>>& graph, ll index, vector<ll>& visited){
	if(visited[index]!=-1)
		return visited[index];

	ll ma = -1;
	for(ll i=0; i<graph[index].size(); i++){
		ma = max(ma, dfs(graph, graph[index][i], visited));
	}

	visited[index]=ma+1;
	return ma+1;
}


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

    ll v, e;
    cin>>v>>e;

    vector<vector<ll>> graph(v);
    for(ll i=0, u, v; i<e; i++){
    	cin>>u>>v;
    	graph[--u].push_back(--v);
    }

    vector<ll> visited(v, -1); 
    for(ll i=0; i<v; i++){
    	if(visited[i]==-1){
    		dfs(graph, i, visited);
    	}
    }

    ll ans =0;
    for(ll i=0; i<v; i++){
    	// cout<<visited[i]<<" ";
    	ans = max(ans, visited[i]);
    }
    // cout<<endl;
    cout<<ans;

	return 0;
}		


Measured memory_bytes: 9216
#include<iostream>
using namespace std;
int main(){
  int x=0,y,s,ts=0;
  for(int i=0;i<4;i++){
    cin >> s;
    ts+=s;
  }
  while(1){
    if(ts<60)break;
    ts-=60;
    x++;
  }
  y=ts;
  cout << x << endl;
  cout << y << endl;
  return 0;
}

Measured memory_bytes: 1160
main :: IO ()
main = do
    [a, b, c, x, y] <- map read . words <$> getLine :: IO [Int]
    let cv  = (max x y) * 2 * c -- C only
    let abv = x*a + y*b -- A, B only

    let cxv = x*2*c + (if y-x >= 0 then (y-x)*b else 0)
    let cyv = y*2*c + (if x-y >= 0 then (x-y)*a else 0)

    print $ minimum [cv, abv, cxv, cyv]

Measured memory_bytes: 508