akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(){
  int i,n,a[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  printf("%d",a[n-1]);
  for(i=n-2;i>=0;i--){
    printf(" %d",a[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = "";
            var array = new int[3];
            var count = 0;
            while (!string.IsNullOrEmpty(read = Console.ReadLine()))
            {
                array = read.Split().Select(s => int.Parse(s)).ToArray();
                foreach (var val in Enumerable.Range(array[0], array[1]-array[0]+1))
                {
                    if (array[2] % val == 0) count++;
                }

            }

            Console.WriteLine(count);
        }
    }
}



Measured memory_bytes: 18464
#include <bits/stdc++.h>
 
int main()
{
    int tr[10], v1, v2;
   
    while (~scanf("%d", &tr[0])) {
        int sum = tr[0];
        for (int i = 1; i < 10; i++) {
            scanf(",%d", &tr[i]);
            sum += tr[i];
        }
        scanf(",%d,%d", &v1, &v2);
         
        double a = v1 * ((double)sum/(v1+v2));
         
        sum = 0;
        for (int i = 0; i < 10; i++) {
            sum += tr[i];
            if (a <= sum) {
                printf("%d\n" ,i+1);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int a;
  cin >> a;
  vector<int> nums(a);
  vector<int> numt(a);
  rep(i, a){
    cin >> nums.at(i);
    numt.at(i) = nums.at(i);
  }
  sort(all(numt));
  int count = 0;
  rep(i, a){
    if (nums.at(i) != numt.at(i)) count++;
  }
  if (count <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		String x = sc.next();
		
		// 計算
		//int result = 0;
		int cnt = 0;
		for(int i = 0; i < n; i++){
		    if(x.charAt(i) == '1') cnt++;
		}
		int mplus = 0;
		int tmp = 1;
		for(int i = 0; i < n; i++){
		    if(x.charAt(n-i-1) == '1'){
		        mplus += tmp%(cnt+1);
		        mplus %= cnt+1;
		    }
		    tmp *= 2;
		    tmp %= (cnt+1);
		}
		int mminus = 0;
		tmp = 1;
		for(int i = 0; i < n; i++){
		    if(cnt == 1) break;
		    if(x.charAt(n-i-1) == '1'){
		        mminus += tmp%(cnt-1);
		        mminus %= cnt-1;
		    }
		    tmp *= 2;
		    tmp %= (cnt-1);
		}
		int[] plus = new int[n+1];
		int[] minus = new int[n+1];
		tmp = 1;
		for(int i = 0; i < n; i++){
		    plus[n-i-1] = tmp%(cnt+1);
		    tmp *= 2;
		    tmp %= (cnt+1);
		}
		tmp = 1;
		for(int i = 0; i < n; i++){
		    if(cnt == 1) break;
		    minus[n-i-1] = tmp%(cnt-1);
		    tmp *= 2;
		    tmp %= (cnt-1);
		}
		
		for(int i = 0; i < n; i++){
		    int result = 0;
		    boolean flg = false;
		    if(x.charAt(i) == '1') flg = true;
		    
		    if(flg){
		        if(cnt != 1) result = f((mminus-minus[i]+(cnt-1))%(cnt-1)) + 1;
		    }else{
		        result = f((mplus+plus[i])%(cnt+1)) + 1;
		    }
		    System.out.println(result);
		}
		

		// 出力
		//System.out.println(result);
	}
	
	public static int f(int n) {
	    if(n == 0) return 0;
	    int m = Integer.bitCount(n);
	    return f(n%m)+1;
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
	
}



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

int main(void)
{
	int N, M;
	cin >> N >> M;
	
	vector<int> A(N);

	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}

	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += A.at(i);
	}

	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (A.at(i) >= (float)sum / (4 * M)) cnt++;
	}

	if (cnt >= M) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());

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

  
  int a = 0, b = 0;

  a = (C + B - 1) / B;
  b = (A + D - 1) / D;

  if (a <= b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int h, w, d, i, j, k;
	cin >> h >> w >> d;
	vector< vector<char> > color(h, vector<char>(w));
	vector< vector<char> > cl = { {'R','Y'},{'B','G'} };
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			int y = i + j;
			int x = h - i + j;
			int i2 = (y / d) % 2, j2 = (x / d) % 2;
			if (i2 < 0) {
				i2 += 2;
			}
			if (j2 < 0) {
				j2 += 2;
			}
			color[i][j] = cl[i2][j2];
		}
	}
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			cout << color[i][j];
		}
		cout << endl;
	}


}

Measured memory_bytes: 768
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	double n;
	double sum;
	double ave;
	double hyojun;
	double s[1000];
	double a[1000];
	int count = 0;

	while (1)
	{
		sum = 0;
		hyojun = 0;

		cin >> n;
		
		if (n==0)
		{
			break;
		}

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

		ave = sum / n;

		for (int i = 0; i < n; i++)
		{
			hyojun = hyojun + (s[i] - ave)*(s[i] - ave);
		}

		a[count] = sqrt(hyojun / n);
		count++;

	}

	for (int i = 0; i < count; i++)
	{
		cout << a[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3240
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

	int H, W;
	std::vector<std::string> S;

void count_area(long* n, int x, int y, char ch)
{
	S[y][x] = ' ';
	++n[(x+y)%2];
	if (x > 0 && S[y][x-1] == ch) {
		count_area(n, x-1, y, ch);
	}
	if (x < W-1 && S[y][x+1] == ch) {
		count_area(n, x+1, y, ch);
	}
	if (y > 0 && S[y-1][x] == ch) {
		count_area(n, x, y-1, ch);
	}
	if (y < H-1 && S[y+1][x] == ch) {
		count_area(n, x, y+1, ch);
	}
}

int main()
{

	std::cin >> H >> W;
	S.reserve(H);
	for (int i = 0; i < H; ++i) {
		std::string s;
		std::cin >> s;
		S.push_back(s);
	}

	for (int i = 0; i < H; ++i) {
		auto& s = S[i];
		for (int j = i%2; j < s.size(); j += 2) {
			if (s[j] == '.')
				s[j] = '#';
			else
				s[j] = '.';
		}
	}

	long total = 0;
	for (int y = 0; y < H; ++y) {
		for (int x = 0; x < W; ++x) {
			if (S[y][x] != ' ') {
				long n[2] = {0,0};
				count_area(n, x, y, S[y][x]);
				total += n[0] * n[1];
			}
		}
	}
	std::cout << total << "\n";
}


Measured memory_bytes: 15488
N,M = gets.chomp.split(" ").map(&:to_i);

K = Array.new(M,0)
H = Array.new(N,0)
count = 0

N.times do |i|
    H[i] = gets.chomp.split(" ").map(&:to_i);
    H[i][0].times do |j|
        K[H[i][j+1]-1] += 1
        if K[H[i][j+1]-1] == N then
            count += 1
        end
    end
end

print "#{count}\n"


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

long unsigned int bit[100000];
int n;

long unsigned int s(int i){
	long unsigned int S=0;
	while(i>0){
		S+=bit[i];
		i-=(i&-i);
	}
	return S;
}

void add(int i,int x){
	while(i<n){
		bit[i]+=x;
		i+=(i&-i);
	}
}

int main(){
	int m,p[100001],a[100000],b[100000],c[100000];
	cin>>n>>m;
	for(int j=1;j<=m;++j){
		cin>>p[j];
	}
	for(int i=1;i<n;++i){
		cin>>a[i]>>b[i]>>c[i];
		bit[i]=0;
	}
	for(int j=2;j<=m;++j){
		add(min(p[j-1],p[j]),1);
		add(max(p[j-1],p[j]),-1);
	}
	long unsigned int x=0;
	for(int i=1;i<n;++i){
		if(a[i]*s(i)<=b[i]*s(i)+c[i]){
			x+=a[i]*s(i);
		}else{
			x+=b[i]*s(i)+c[i];
		}
	}
	cout<<x<<endl;
}

Measured memory_bytes: 3496
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define all(v) (v).begin(),(v).end()
#define vl vector<lli>
#define pll pair<lli,lli>
#define vpll vector<pll >
const lli MAX=100005;

int main(){
	lli n;
	cin>>n;
	lli a[n],b[n];
	loop(i,0,n) cin>>a[i];
	if(n==1){
		cout<<"0";
		return 0;
	}
	if(n==2){
		lli t=abs(a[0]-a[1]);
		cout<<t;
		return 0;
	}
	b[0]=0;
	b[1]=abs(a[0]-a[1]);
	loop(i,2,n){
		b[i]=min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<b[n-1];
}

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

lli n;

int main(void){
	cin >> n;
	unordered_map<string, lli> mp;
	rep(i, n){
		string a;
		cin >> a;
		mp[a]++;
	}
	lli ans = 0;
	for(auto i : mp){
		if(i.second%2==1) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10276
#include <iostream>
#include<algorithm>
#include<vector>
#include <unordered_map>
#include <cstdint>
#include <cstring>

using namespace std;
int main(){
    
    int N,a;
    int X[200000],X_dash[200000];
    unordered_map<int, int> mp;
    cin>>N;
//    for(int i=0;i<N;i++)cin>>X[i];
    for(int i=0;i<N;i++){
        cin>>X[i];
    }

    memcpy(X_dash, X, sizeof(int) * 200000);
    sort(X_dash,X_dash+N);
    for(int i=0;i<N;i++){
        mp[X_dash[i]]=i;
//        X_vector.push_back(X_dash[i]);
    }

    for(int i=0;i<N;i++){
        if(mp[X[i]]<N/2){
//            if(mp[X[i]]==N/2-1) cout<<X_dash[N/2]<<endl;
//            else cout<<X_dash[N/2-1]<<endl;
            cout<<X_dash[N/2]<<endl;
        }
        else {
//            if(mp[X[i]]==N/2) cout<<X_dash[N/2-1]<<endl;
//            else cout<<X_dash[N/2]<<endl;
            cout<<X_dash[N/2-1]<<endl;
        }

    }
    return 0;

}

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

#define int ll

typedef pair<int, int> ii;

const int N = 1e5+100;

vector<int> g[N];

ii mul[N];
int par_u[N], par_m[N], sz;

int root(int v, int *par){
	if(par[v] == v)
		return v;
	return par[v] = root(par[v], par);
}

void merge(int v, int u, int *par){
	v = root(v, par);
	u = root(u, par);
	par[v] = u;
}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, m, q;cin >> n >> m >> q;
	
	for(int i=0 ; i<n ; i++)
		par_u[i] = par_m[i] = i;

	while(q --){
		int v, u, c;cin >> v >> u >> c;
		if(c)
			mul[sz ++] = ii(v, u);
		else
			merge(v, u, par_u);
	}
	for(int i=0 ; i<sz ; i++){
		int v = mul[i].first, u = mul[i].second;
		v = root(v, par_u);
		u = root(u, par_u);
		if(v == u){
			cout << "No\n";
			return 0;
		}
		merge(v, u, par_m);
	}
	map<int, int> mp;
	for(int i=0 ; i<n ; i++)
		mp[root(i, par_u)] ++;
	int l=0, r=0, all=0;
	for(auto P : mp){
		l += P.second-1;
		r += P.second-1;
	}
	mp.clear();
	for(int i=0 ; i<n ; i++){
		int v = root(i, par_u);
		if(i != v)
			continue;
		all ++;
		mp[root(v, par_m)] ++;
	}
	int fr=0;
	for(auto P : mp)
		if(P.second == 1)
			fr ++;
	for(auto P : mp){
		int cnt = P.second;
		if(cnt == 2){
			if(!fr){
				cout << "No\n";
				return 0;
			}else{
				fr --;
				l += 3;
			}
		}
		if(cnt > 2)
			l += cnt;
	}
	r += all*(all-1)/2;
	if(m >= l && m <= r)
		cout << "Yes\n";
	else
		cout << "No\n";
 	return 0;
}
















Measured memory_bytes: 12032
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define SORT(x) sort((x).begin(),(x).end())
int main(void){
    
    int a, b, c, d;
    cin >>a >>b >>c >>d;
    
    if((abs(a-c)<=d)||((abs(a-b)<=d)&&(abs(b-c)<=d))){
        cout <<"Yes";
    }else{
        cout <<"No";
    }
    
    cout <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define EPS (1e-12)

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct unionset {
    int ud[50000];
    void init() { memset(ud, -1, sizeof(ud)); }
    int root(int x) { return ud[x]<0 ? x : ud[x]=root(ud[x]); }
    int size(int x) { return -ud[root(x)]; }
    bool same(int x, int y) { return root(x)==root(y); }
    bool set(int x, int y) {
        x=root(x); y=root(y);
        if(x!=y) {
            if(ud[y]<ud[x]) std::swap(x, y);
            ud[x]+=ud[y]; ud[y]=x;
        }
    return x!=y;
    }
} us;

int W, H, Fx, Fy, F, P[16][16];
int L, T[16], X[16], Y[16], ans[16];
int e[16*16];
double v[16][16], f[16][16], s[16*16];

void fix_flow() {
    bool any = true;
    while(any) {
        rep(i, 16*16) s[i] = 0;
        rep(i, H) rep(j, W) s[us.root(i*W+j)] += f[i][j];
        rep(i, H) rep(j, W) f[i][j] = s[us.root(i*W+j)]/us.size(i*W+j);
        any = false;
        rep(i, H) rep(j, W) if(f[i][j] && v[i][j]==30*30*30) {
            rep(d, 4) {
                const int x = i+dx[d], y = j+dy[d];
                if(x<0 || x>=H || y<0 || y>=W || P[i][j]<=P[x][y]) continue;
                f[x][y] += f[i][j]*us.size(i*W+j)/e[us.root(i*W+j)];
            }
            any = true;
            f[i][j] = 0;
        }
    }
}

void simulate() {
    us.init();
    rep(i, H) rep(j, W) rep(d, 4) {
        const int x = i+dx[d], y = j+dy[d];
        if(x<0 || x>=H || y<0 || y>=W) continue;
        if(P[i][j]==P[x][y]) us.set(i*W+j, x*W+y);
    }
    rep(i, 16*16) e[i] = 0;
    rep(i, H) rep(j, W) rep(d, 4) {
        const int x = i+dx[d], y = j+dy[d];
        if(x>=0 && x<H && y>=0 && y<W && P[i][j]<=P[x][y]) continue;
        e[us.root(i*W+j)]++;
    }
    int mt = 1;
    rep(i, L) mt = max(mt, T[i]+1);
    rep(i, H) rep(j, W) v[i][j] = 0;
    rep(i, H) rep(j, W) f[i][j] = 0;
    f[Fy][Fx] = F;
    double ct = 0;
    while(ct<mt) {
        fix_flow();
        double dt = 10000;
        rep(i, H) rep(j, W) if(f[i][j] && v[i][j]<30*30*30) {
            dt = min(dt, (30*30*30-v[i][j])/f[i][j]);
        }
        rep(i, L) if(ct-EPS<T[i] && T[i]<ct+dt+EPS) {
            const int x = Y[i], y = X[i];
            ans[i] = (v[x][y]+f[x][y]*(T[i]-ct))/(30*30);
        }
        rep(i, H) rep(j, W) {
            v[i][j] += dt*f[i][j];
            if(v[i][j]>30*30*30-EPS) v[i][j] = 30*30*30;
        }
        ct += dt;
    }
}

int main() {
    for(;;) {
        scanf("%d%d", &W, &H);
        if(W==0 && H==0) return 0;
        scanf("%d%d%d", &Fx, &Fy, &F);
        rep(i, H) rep(j, W) scanf("%d", P[i]+j);
        scanf("%d", &L);
        rep(i, L) scanf("%d%d%d", T+i, X+i, Y+i);
        simulate();
        rep(i, L) printf("%d\n", ans[i]);
    }
}

Measured memory_bytes: 0
#include"bits/stdc++.h"
using namespace std;

int main() {
	vector<int> N(4);
	cin >> N[0] >> N[1] >> N[2] >> N[3];
	sort(N.begin(), N.end());
	cout << (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9 ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let mut ans = 0;
    for ch in read::<String>().chars() {
        if ch == '1' {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> vec;
  for(int i =0; i<2*M;i++){
    int A;
    cin>>A;
    vec.push_back(A);
  }
  for(int i=1; i<N+1;i++){
    int j=0;
    for (int k=0; k<2*M; k++){
      if (i==vec.at(k))
        j++;
    }
    cout<<j<<endl;
  }
}

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

int main(void){
  int mod = 1000000007;
  int N;
  cin >> N;
  int x[101][4][4][4];
  for(int i=0; i <= 100; i++) for(int a=0; a<4; a++) for(int b=0; b<4; b++) for(int c=0; c<4; c++) x[i][a][b][c] = 0;
  // x[i][a][b][c]: 文字列長がiで、末尾がabcとなる場合の数
  x[0][3][3][3] = 1;
  for(int i=0; i < N; i++){
    // 末尾から3桁目
    for(int a=0; a<4; a++){
      // 末尾から2桁目
      for(int b=0; b<4; b++){
        // 末尾
        for(int c=0; c<4; c++){
          // 条件にあてはまるものがない場合飛ばす
          if(x[i][a][b][c] == 0) continue;
          // 追加する数
          for(int d=0; d<4; d++){
            if(b == 0 && c == 1 && d == 2) continue;
            if(b == 0 && c == 2 && d == 1) continue;
            if(b == 1 && c == 0 && d == 2) continue;
            if(a == 0 && c == 1 && d == 2) continue;
            if(a == 0 && b == 1 && d == 2) continue;
            x[i+1][b][c][d] += x[i][a][b][c];
            x[i+1][b][c][d] %= mod;
          }
        }
      }
    }
  }
    
  int ans = 0;
  for(int a=0; a<4; a++){
    for(int b=0; b<4; b++){
      for(int c=0; c<4; c++){
        ans += x[N][a][b][c];
        ans %= mod;
//        cout << "(" << a << ", " << b << ", " << c << "): " << x[N][a][b][c] << endl;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

A = [0] + A


from collections import deque

i = 1
for h in range(H):
    C = deque([])
    for w in range(W):
        if h%2 == 0:
            C.append(str(i))
        else:
            C.appendleft(str(i))
        A[i] -= 1
        if A[i] == 0:
            i += 1
            
    print(' '.join(C))

Measured memory_bytes: 73904
#include<stdio.h>
int main(){
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if(a < b && b < c)printf("%d %d %d\n", a, b, c);
else if(c <= b && b <= a)printf("%d %d %d\n", c, b, a);
else if(b <= a && a <= c)printf("%d %d %d\n", b, a, c);
else if(c <= a && a <= b)printf("%d %d %d\n", c, a, b);
else if(a <= c && c <= b)printf("%d %d %d\n", a, c, b);
else if(b <= c && c <= a)printf("%d %d %d\n", b, c, a);
return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, k; cin >> n >> k;
  set<ll> nny = {0};
  vll ny = {0};
  ll i=1;
  while (i*i<=n) {
    if (nny.find(i) == nny.end()) {
      nny.insert(i);
      ny.push_back(i);
    }
    if (nny.find(n/i) == nny.end()) {
      nny.insert(n/i);
      ny.push_back(n/i);
    }
    i++;
  }
  sort(ny.begin(), ny.end());
  map<ll, ll> idx;
  REP(i, ny.size()) idx[ny[i]] = i;
  vvll dp(ny.size(), vll(k, 0));
  rep(i, 1, ny.size()) dp[i][1] = (((ny[i]-ny[i-1]) * (n/ny[i])) % MOD + dp[i-1][1]) % MOD;
  rep(i, 2, k) {
    rep(j, 1, ny.size()) {
      dp[j][i] = (((ny[j]-ny[j-1])*dp[idx[n/ny[j]]][i-1]) % MOD + dp[j-1][i]) % MOD;
    }
  }
  cout << dp[ny.size()-1][k-1] << endl;
  return 0;
}


Measured memory_bytes: 59512
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    string s; cin >> s;
    string sr = s;
    reverse(sr.begin(), sr.end());
    if(s == sr){
        cout << 0 << endl;
        return 0;
    }

    string swox, swoxr;
    rep(i, s.length()){
        if(s[i] != 'x') swox += s[i];
        if(sr[i] != 'x') swoxr += sr[i];
    }
    if(swox != swoxr){
        cout << -1 << endl;
        return 0;
    }
    ll cnt = 0;
    rep(i,s.length()){
        if(s[i] == 'x' && sr[i] != 'x'){
            s.insert(s.end()-i, 'x');
            sr.insert(sr.begin()+i, 'x');
            cnt ++;
        }else if(sr[i] == 'x' && s[i] != 'x'){
            s.insert(s.begin()+i, 'x');
            sr.insert(sr.end()-i, 'x');
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4008
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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

#define REP(i, n) for(ll i = 0; i < n; i++)











map<ll, ll> memo;

ll f(ll h){
    if(h <= 1) return 1;
    if(memo[h]) return memo[h];
    return memo[h] = f(h / 2) + f(h / 2) + 1;
}



int main(){
    ll h;
    cin >> h;
    cout << f(h) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	cout << min(a, k) - max(k - a - b, 0LL) << endl;

}

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

using namespace std;

const int LOOP = 1000; //??????????????°
const double EPS = 1e-6; //??????????????¨(?°??????????????????????)
int L;
int N; //???????????±???????????°

//???????????±????????????????????????????????¨?????¨???????¨????????¨??????????
double Evaluate(int r[12]) {
	double val = r[0] + r[N-1];
	for (int i = 0; i < N - 1; i++)
	{
		int a = abs(r[i] - r[i+1]), c = r[i] + r[i+1];
		val += sqrt(c*c - a*a);
	}
	return val;
}

//?????¨?????????????????°???????????¨??????????????????????§???????????±???????
//(????§?????????????true)
bool Changes(int cnt) {
	return cnt < rand()%LOOP;
}

//?????????????????????????????¢??°
//?????????????°??????????????¨?????????????
//int r[12] : ???????????±?????????0??????N-1???????????????????????????????????????????????????????´???????
double Solve(int r[12]) {
	double score = Evaluate(r); //?????¨?????¶???r[]????¨???????????´????????????°
	double mi = score; //???????????§?????¶???????¨???????????°???????????´????????????°
	for (int cnt = 0; cnt < LOOP; cnt++)
	{
		int a = rand() % N, b = rand() % N;
		swap(r[a], r[b]);
		double tmpev;
		if ((tmpev = Evaluate(r)) < mi) {
			mi = tmpev;
			continue;
		} else if (mi == tmpev) continue;
		if (Changes(cnt)) {
			mi = min(mi, tmpev);
			continue;
		}
		swap(r[a], r[b]);
	}
	return mi; //????°?????????????
}

//??\?????¢????????????????????¢????????£????????§???????????????
int main() {
	srand(time(NULL));
	while (cin >> L)
	{
		N = 0;
		int r[12];
		string S;
		getline(cin, S);
		stringstream SS(S);
		while (!SS.eof()) SS >> r[N++];

		double ans;
		if (N == 1) ans = r[0]*2;
		else ans = Solve(r);

		if (L - ans + EPS > 0) puts("OK");
		else puts("NA");
	}
	return 0;
}

Measured memory_bytes: 1212
//13-3 ??????
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main(){
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for(int i=0; i<N; i++){
        bool flg = false;
        string tmp;
        cin >> tmp;
        for(int j=0; j<tmp.length()-S.length()+1; j++){
            if(tmp[j] == S[0]){
                for(int k=j+1; j+(k-j)*(S.length()-1)<tmp.length(); k++){
                    if(tmp[k] == S[1]){
                        int c = 0;
                        for(int l=2; l<S.length(); l++){
                            if(tmp[j+(k-j)*l] == S[l]) c++;
                        }
                        if(c+2 == S.length()) flg = true;
                    }
                }
            }
        }
        if(flg) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

string s;

int have(char c) {
	return s.find(c) < s.size();
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	cout << ((have('N') ^ have('S')) | (have('E') ^ have('W'))? "No": "Yes");
}


Measured memory_bytes: 256
S = gets.chomp.split("").map(&:to_i)

first = S[0]
count = 0
S.each_with_index do |num,i|
    if (i != 0)&&(i%2 == 0)
        if num != first
            count += 1
        end
    elsif (i !=0 )&&(i%2 == 1)
        if num == first
            count += 1
        end
    end
end
puts count


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

using namespace std;
#define INF 1000000001


int solve(const int &i,const vector<int> &costs,vector<int> &dp){
    if(i==0) dp[i] = 0;
    else if(i==1) dp[i] = abs(costs[i] - costs[i-1]);
    else{
        if(dp[i-1] == INF) dp[i-1] = solve(i-1,costs,dp);
        if(dp[i-2] == INF) dp[i-2] = solve(i-2,costs,dp);
        dp[i] = min(abs(costs[i]-costs[i-1]) + dp[i-1],abs(costs[i]-costs[i-2]) + dp[i-2]);
    }
    return dp[i];
}

int main()
{
    int N;
    cin >> N;
    vector<int> costs(N,0);
    vector<int> dp(N,INF);
    for(int i = 0 ;i < N;i++){
        cin >> costs[i];
    }

    int ans = solve(N-1,costs,dp);
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 7296
#include<stdio.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
int main(){
	ll n,k,ans=1;
	scanf("%lld %lld",&n,&k);
	FOR(i,0,n) ans *= k-1;
	printf("%lld",ans*k/(k-1));
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split("");
			char a = (chr[0].charAt(0));
			char b = (chr[1].charAt(0));
			char c = (chr[2].charAt(0));
			char d = (chr[3].charAt(0));
			System.out.println((a==b&&b==c)||(b==c&&c==d)?"Yes"
							   :"No");

		}
	}
}

Measured memory_bytes: 25500
import java.util.Scanner;

public class Main {
  static String s;

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

    s = sc.next();

    int n = s.length();
    char[] buf = new char[n];
    int sp = 0;
    for(int i = 0; i < n; i++){
      char ch = s.charAt(i);
      if(ch == '0'){
        buf[sp++] = '0';
      }
      else if(ch == '1'){
        buf[sp++] = '1';
      }
      else{
        if(sp - 1 >= 0){
          sp--;
        }
      }
    }

    System.out.println((new String(buf, 0, sp)));
  }
}

Measured memory_bytes: 9812
def factorize_dict(n):
    i=2
    result={}
    while True:
        if i**2>n:
            break
        count=0
        while n%i==0:
            n//=i
            count+= 1
        if count!=0:
            result[i]=count
        i+=1
    if n>1:
        result[n]=1
    return result

def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    return divisors

def judge(n,k):
    while n%k==0:
        n//=k
    return n%k

def main():
    n=int(input())
    ans=0
    f_d=factorize_dict(n-1)
    tmp=1
    for v in f_d.values():
        tmp*=(v+1)
    tmp-=1
    ans+=tmp
    D=make_divisors(n)
    for d in D:
        if d==1:
            continue
        if judge(n,d)==1:
            ans+=1
    print(ans)
    
if __name__=='__main__':
    main()

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

int main()
{ 	
//freopen ("test.txt","r",stdin);

	string arr1,arr2;
	cin>>arr1>>arr2;
int n =arr1.size();
int m =arr2.size();
	
	int L[n+1][m+1];
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if(i==0 || j==0) { L[i][j]=0;}

			else if(arr1[i-1]==arr2[j-1]){ L[i][j]=L[i-1][j-1]+1;}

			else 
				{ L[i][j]=max(L[i-1][j],L[i][j-1]); }
		}
	}

string l="";

int i=n;int j=m;
while(i>0 && j>0)
{
	if(arr1[i-1]==arr2[j-1]){ i--; j--; l.push_back(arr1[i]); }
else if (L[i-1][j]>L[i][j-1]){ i--;}
else {j--;}	
}
for(int i=l.size()-1;i>=0;i--)
{
	cout<<l[i];
}

return 0;

}

Measured memory_bytes: 35456
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int[] a = new int[N];
		int[] b = new int[N];
		int count = 0;
		int sum = 0;
		
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			int x = a[i];
			count = 0;
			for(int j = 0; j < x; j++) {
				if(a[i] % 2 == 0) {
					count++;
					a[i] /= 2;
				} else {
					b[i] = count;
					break;
				}
			}
			sum += count;
		}
		System.out.println(sum);	
	}
}


Measured memory_bytes: 34896
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();

        int N = sc.nextInt();
        int d[] = sc.nextIntArray(N);

        Arrays.sort(d);
        int min = d[N/2-1] + 1;
        int max = d[N/2];

        int ans = Math.max(0, max - min + 1);

        out.println(ans);
        out.flush();
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }

        int[] nextIntArray(int N) {
            int a[] = new int[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextInt();
            }

            return a;
        }

        long[] nextLongArray(int N) {
            long a[] = new long[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextLong();
            }

            return a;
        }

        double[] nextDoubleArray(int N) {
            double a[] = new double[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextDouble();
            }

            return a;
        }

        String[] nextTokenArray(int N) {
            String a[] = new String[N];
            for (int i=0;i<N;i++) {
                a[i] = this.nextToken();
            }

            return a;
        }
    }
}

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

using namespace std;

const int N = 5000 + 5;
const long long INF = 1e9 + 5;
const int MAXN = 1e6;
const int base = 317;

typedef long long ll;

const ll bs = 1e5 + 1;
const ll mod = 1e9 + 7;

int n, k, ct, dd[N];
vector <int> g[N];

void dfs(int v, int x, int p = 0, int d = 0) {
    if (d > x / 2) {
        ct++;
    }
    if (d == x / 2 + 1)
        dd[v]++;
    for (int to : g[v]) {
        if (to != p) {
            dfs(to, x, v, d + 1);
            dd[v] += dd[to];
        }
    }
}

int check(int x) {
    int ans = INF;
    for (int i = 1; i <= n; i++) {
        ct = 0;
        memset(dd, 0, sizeof(dd));
        dfs(i, x);
        if (x % 2) {
            int mx = 0;
            for (int to : g[i]) {
                mx = max(mx, dd[to]);
            }
            ct -= mx;
        }
        ans = min(ans, ct);
//        if (ct <= k)
//            return 1;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    cout << check(k);
//    int l = -1, r = n;
//    while (r - l > 1) {
//        int md = (l + r) >> 1;
//        if (check(md)) {
//            r = md;
//        } else {
//            l = md;
//        }
//    }
//    cout << r;
    return 0;
}
/**

*/



Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int H;
        int W;
        while ((H = scanner.nextInt()) != 0 && (W = scanner.nextInt()) != 0) {
            for (int h = 0; h < H; h++) {
                for (int w = 0; w < W; w++) {
                    System.out.print('#');
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}


Measured memory_bytes: 36208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  string s, t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();

  vector<vi> dp(n+1, vi(m+1));

  rep(i, n) {
    rep(j, m) {
      if (s[i] == t[j]) {
        dp[i+1][j+1] = dp[i][j]+1;
      } else {
        dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
      }
    }
  }

  string ans = "";

  int i = n, j = m;
  while (i > 0 && j > 0) {
    if (s[i-1] == t[j-1]) {
      ans += s[i-1];
      i--;
      j--;
    } else if (dp[i][j-1] > dp[i-1][j]) {
      j--;
    } else {
      i--;
    }
  }

  reverse(all(ans));
  cout << ans << endl;
}


Measured memory_bytes: 35584
#include<stdio.h>
#include<bitset>
#include<string.h>
#define For(i,a,b) for(register int i=a;i<=b;i++)
using namespace std;
const int maxn=1e5+1000;
int n,m,pos[maxn],x[maxn],cf[maxn],a,s[maxn];
long long ans[maxn],k;
bitset <maxn> vis;
inline void swap(int &a,int &b){int c=a;a=b;b=c;}
inline int rd(){
		int ans=0,f=1;char c=getchar();
		while(!isdigit(c)){ f^=(c=='-'); c=getchar(); }
		for(;isdigit(c);c=getchar()) ans=(ans<<1)+(ans<<3)+(c^48); return f?ans:-ans;
}
inline void pr(long long x){
    if(x<0){putchar('-');x=~(x-1);}
    int s[30],top=0;
    while(x){s[++top]=x%10;x/=10;}
    if(!top)s[++top]=0;
    while(top)putchar(s[top--]+'0');
}
signed main(){
	//scanf("%d",&n);
	n=rd();
	For(i,1,n){
		x[i]=rd();
		//scanf("%d",&x[i]);
		pos[i]=i;
		cf[i]=x[i]-x[i-1];
	}
	m=rd();scanf("%lld",&k);
	//scanf("%d%lld",&m,&k);
	For(i,1,m){
		//scanf("%d",&a);
		a=rd();
		swap(pos[a],pos[a+1]);
	}
	For(i,1,n){
		if(vis[i]){
			continue ;
		}
		int cnt=0;
		for(int j=i;!vis[j];j=pos[j]) {
			s[++cnt]=j;
			vis[j]=1;
		}
		For(j,1,cnt) {
			ans[s[j]]=1ll*cf[s[(k+j-1)%cnt+1]];
		}
	}
	For(i,1,n){
		ans[i]+=ans[i-1];
		//printf("%lld.0\n",ans[i]);
		pr(ans[i]);
		putchar('.');
		putchar('0');
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 3712
import sys

input = sys.stdin.readline

N = int(input())

count = 0
for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
    else:
        count = 0
    if count == 3:
        print("Yes")
        exit(0)
print("No")

Measured memory_bytes: 9176
using System;
using System.Linq;
using System.Collections.Generic;
class ProgramD
{
    static void Main(string[] args)
    {
        //入力
        long n = int.Parse(Console.ReadLine());
        long[] a = new long[n];
        long sum = 0;
        string[] input = Console.ReadLine().Split(' ');
        long mod = 1000000000 + 7;

        //代入する
        for(long i = 0; i < n;i++)
            a[i] = long.Parse(input[i]);

        //条件入力
        for(long k = 0; k < 60;k++)
        {
            long zero = 0;
            long one = 0;
            for(long i = 0; i < n;i++)
            {
                if(bitter(a[i],(int)k) == 1)
                    one++;
                else
                    zero++;

            }
            //i桁目の和を出す
            sum += (one * zero) % mod * modpow(2,k,mod) % mod;
            sum %= mod;
        }

        //答え出力
        Console.WriteLine(sum);
    }

    //xのk番目のビットを出す
    static long bitter(long x, int k)
    {
        if(((x >> k) & 1) == 0)
            return 0;
        return 1;
    }

    //繰り返し二乗法
    static long modpow(long a, long n,long mod)
    {
        if(n == 0)
            return 1;
        
        if(n % 2 == 0)
        {
            long temp = modpow(a,n/2,mod);
            return temp*temp % mod;
        }

        return a * modpow(a,n-1,mod) % mod;
    }
}

Measured memory_bytes: 52552
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int main()
{
	int n, a[1005];
	while (1)
	{
		cin >> n; if (n == 0)return 0;
		REP(i, n)cin >> a[i];
		int cnt = 0;
		REP(i, n-1)REP(j, n-1)
		{
			if (a[j] > a[j + 1])
			{
				swap(a[j], a[j + 1]);
				cnt++;
			}
		}
		cout << cnt << endl;

	}
	return 0;

}

Measured memory_bytes: 1160
def occur_change(s,t):
    cnt = 0
    if s == t:
        return cnt
    for i in range(len(s)):
        if s[i]!=t[i]:
            cnt+=1
    return cnt

def main():
    s = str(input())
    t = str(input())
    print(occur_change(s,t))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9460
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    if (n % k == 0) {
        cout << 0 << endl;
    }
    else cout << 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    cout << ((a <= 8 && b <= 8) ? "Yay!" : ":(") << endl;

    return 0;
}

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

int main()
{
  long N, K;
  std::cin >> N >> K;

  unsigned S = 0;
  for (long  n = 0; n < N; ++n) {
    long x;
    std::cin >> x;
    S += 2 * std::min(x, std::abs(K - x));
  }
  std::cout << S << std::endl;
  return 0;
}

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


def solve(N: int, A: "List[int]"):
    d = [int()]*N

    for x in A:
        d[x-1]+=1
    [print(d_) for d_ in d]

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N - 2 + 1)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 99212
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  string s,t;
  cin>>s>>t;
  int n=s.size();
  string r=s;
  for(int i=0;i<n;i++){
    r=r.back()+r.substr(0,n-1);//cout<<r<<endl;
    if(r==t){cout<<"Yes"<<endl;return 0;}
  }
  cout<<"No"<<endl;
  return 0;
}

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

int main(){
  int h,w;
  cin >> h >> w;
  while(h*w){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cout << "#";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  
  return 0;

}

Measured memory_bytes: 3096
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  1000005

ll int fac[N];

int expo(int base,int exponent,int mod){
    int ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}

ll int ncr(ll int n,ll int r)
{
	ll int ret=fac[n];
	ret=(ret*expo(fac[r],hell-2,hell))%hell;
	ret=(ret*expo(fac[n-r],hell-2,hell))%hell;
	return ret;
}

void init()
{
	fac[0]=1;
	for(ll int i=1;i<N;i++) fac[i]=(fac[i-1]*i)%hell;
}

ll int dp[N];

int main()
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(0);
	// cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	init();
	while(TESTS--)
	{
		ll int h,w,n;
		cin>>h>>w>>n;
		n+=2;
		vector<pii> v(n);
		v[0]={1,1};
		v[n-1]={h,w};
		for(ll int i=1;i<n-1;i++) cin>>v[i].F>>v[i].S;
		sort(all(v));
		// cout<<endl;
		// for(auto i:v) cout<<i.F<<" "<<i.S<<endl;
		// cout<<endl;
		dp[0]=1;
		for(ll int i=1;i<n;i++)
		{
			dp[i]=ncr(v[i].F+v[i].S-2,v[i].F-1);
			for(ll int j=1;j<i;j++)
			{
				if(v[j].S>v[i].S) continue;
				ll int tmp=(dp[j]*ncr(v[i].F-v[j].F+v[i].S-v[j].S,v[i].F-v[j].F))%hell;
				dp[i]=(hell+dp[i]-tmp)%hell;
			}
		}
		cout<<dp[n-1]%hell;
	}
	return 0;
}

Measured memory_bytes: 9856
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

let count = 0;
var numberOfStudents = 0;
var totalStudents = 0;

while(count < lines.length) {
	

	if(count%2 == 0) {
		numberOfStudents = +lines[count];
		if (numberOfStudents==0) {
			break;
		} else if(numberOfStudents>1000) {
			console.log('Number of students must not be greater than 1,000.');
			break;
		} else if(numberOfStudents<2) {
			console.log('Number of students must not be less than 2.');
			break;
		} else {
			totalStudents += numberOfStudents;
			if(totalStudents>50000) {
				break;
			}
		}
	} else {
		let scoresString = lines[count].split(' ');
		
		if(scoresString.length != numberOfStudents) {
			console.log(`Number of students is not equal to number of scores at line ${count+1}`);
			break;
		} else {
		let scores = scoresString.map(score => +score);
			var leastDiff = null;
			var currentDiff;
			for (let i = scores.length - 1; i >= 0; i--) {
				if(isNotGreaterThanMillion(scores[i])) {
					break;
				} else {
					for(j=i; j>=0; j--) {
					if(i) {
						if (leastDiff != null) {
							currentDiff = Math.abs(scores[i] - scores[j-1]);
						if (currentDiff < leastDiff) {
							leastDiff = currentDiff;
						}
					} else {
						leastDiff = Math.abs(scores[i] - scores[j-1]);
					}

				}		
					}
				}



			}
			console.log(leastDiff);
		}
	}

count++;

}

function isNotGreaterThanMillion(number) {
	if (number>1000000) {
		return true;
	}
}


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

const int INF = 1000000000;

int main(){
	static int n,m;
	static int a[200],b[200],c[200];
	scanf("%d%d",&n,&m);
	for(int i = 0 ; i < m ; i ++){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		a[i] --;
		b[i] --;
	}
	
	static int d[1<<15];
	for(int s = 0 ; s < (1<<n) ; s ++){
		d[s] = 0;
		for(int i = 0 ; i < m ; i ++){
			if((s>>a[i])&1)if((s>>b[i])&1)d[s] += c[i];
		}
	}
	
	int w[17][17];
	for(int i = 0 ; i < 15 ; i ++){
		for(int j = 0 ; j < 15 ; j ++){
			w[i][j] = -INF;
		}
	}
	for(int i = 0 ; i < m ; i ++){
		w[a[i]][b[i]] = c[i];
		w[b[i]][a[i]] = c[i];
	}
	
	static int dp[1<<15][15] = {};
	for(int i = 0 ; i < (1<<15) ; i ++){
		for(int j = 0 ; j < 15 ; j ++){
			dp[i][j] = -INF;
		}
	}
	for(int s = 0 ; s < (1<<n) ; s ++){
		if(s&1){
			dp[s][0] = d[s];
		}
		int ss = (1<<n)-1-s;
		for(int t = ss ; t > 0 ; t --, t &= ss){
			for(int i = 0 ; i < n ; i ++){
				if(dp[s][i] < 0)continue;
				//if(((s>>i)&1) == 0)continue;
				for(int j = 0 ; j < n ; j ++){
					if(((t>>j)&1) == 0)continue;
					dp[s+t][j] = max( dp[s+t][j] , dp[s][i]+d[t]+w[i][j] );
					/*if(dp[s][i]+d[t]+w[i][j] == d[(1<<n)-1]-91274){
						cerr << s << " " << t << " " << i << " " << j << endl;
					}*/
				}
			}
		}
	}
	cout << d[(1<<n)-1]-dp[(1<<n)-1][n-1] << endl;
}

Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
 
using namespace std;
int main()
{
	string a;
	cin >> a;
 
	
	if (a[0] == a[2])
		cout << "Yes" << endl;
 
	else
		cout << "No" << endl;
 
 
	return 0;
}

Measured memory_bytes: 256