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

using namespace std;

#define P(s) cout << s << endl;
#define DEBUG(x) cout << #x << ": " << x << endl;
#define INF 1001001001

vector<int> rs; // 巡回必要なもの全てRs
int Cs[201][201] = {0}; // 全パスの距離

int main() {

  int N, M, R;
  cin >> N >> M >> R;
  
  for (int i = 0; i < R; i++) {
    int r;
    cin >> r;
    rs.push_back(r);
  }

  for (int i = 1; i <= N; i++) { 
    for (int j = 1; j <= N; j++) { 
      if (i != j) {
        Cs[i][j] = INF;
      }
    }
  } // fill

  for (int i = 0; i < M; i++) {
    int A, B, C;
    cin >> A >> B >> C;
    Cs[A][B] = C;
    Cs[B][A] = C;
  }

  // cout << "---------" << endl;
  // for (int i = 1; i <= N; i++) { 
  //   for (int j = 1; j <= N; j++) { 
  //     DEBUG(i);
  //     DEBUG(j);
  //     DEBUG(Cs[i][j]);
  //   }
  // }
  // cout << "---------" << endl;

  // 1. ワーシャルフロイドですべての頂点の対の最小距離を求める
  for (int k = 1; k <= N; k++) {
    for (int i = 1; i <= N; i++) { 
      for (int j = 1; j <= N; j++) { 
        if(Cs[i][k] != INF && Cs[k][j] != INF) { // オーバーフロー対策
          Cs[i][j] = min(Cs[i][j], Cs[i][k] + Cs[k][j]);
        }
      }
    }
  }

  // for (int i = 1; i <= N; i++) { 
  //   for (int j = 1; j <= N; j++) { 
  //     DEBUG(i);
  //     DEBUG(j);
  //     DEBUG(Cs[i][j]);
  //   }
  // }

  // 2. rsのすべての順列組み合わせを作り、最短距離を使ってそれぞれの全コストを求め、最短を出力
  vector<int> paths = rs;
  int min = INF;
  sort(paths.begin(), paths.end());
  do {
    int sum = 0;
    for (int i = 0; i < R - 1; i++) {
      int start = paths[i];
      int end = paths[i + 1];
      sum = sum + Cs[start][end];
      // cout << start << "->" << end << " ";
    }
    // cout << " : " << sum << endl;
    if (sum <= min) min = sum;
  } while (next_permutation(paths.begin(), paths.end()));

  cout << min << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int[] sides = new int[4];
		for(int i = 0; i < 4; i++) {
			sides[i] = stdin.nextInt();
		}

		if(sides[0] == sides[1] && sides[2] == sides[3]) {
			System.out.println("yes");
		} else if(sides[0] == sides[2] && sides[1] == sides[3]) {
			System.out.println("yes");
		} else if(sides[0] == sides[3] && sides[2] == sides[1]) {
			System.out.println("yes");
		} else {
			System.out.println("no");
		}
	}

}

Measured memory_bytes: 26288
import sys

class Dice:
    def __init__(self,d1,d2,d3,d4,d5,d6):
        self.dice = [d1,d2,d3,d4,d5,d6]
    def turn(self,dir):
        if dir == 'S':
            self.dice = [self.dice[4],self.dice[0],self.dice[2],self.dice[3],self.dice[5],self.dice[1]]
        if dir == 'N':
            self.dice = [self.dice[1],self.dice[5],self.dice[2],self.dice[3],self.dice[0],self.dice[4]]
        if dir == 'W':
            self.dice = [self.dice[2],self.dice[1],self.dice[5],self.dice[0],self.dice[4],self.dice[3]]
        if dir == 'E':
            self.dice = [self.dice[3],self.dice[1],self.dice[0],self.dice[5],self.dice[4],self.dice[2]]


def check(dice1,dice2):
    for b in range(4):
        dice1.turn('N')
        if dice1.dice[0] == dice2.dice[0] and dice1.dice[1] == dice2.dice[1] and dice1.dice[2] == dice2.dice[2] and dice1.dice[3] == dice2.dice[3] and dice1.dice[4] == dice2.dice[4] and dice1.dice[5] == dice2.dice[5]:
            print('Yes')
            sys.exit()

dice1_num = list(map(int,input().split()))
dice2_num = list(map(int,input().split()))
init_Dice1 = Dice(dice1_num[0],dice1_num[1],dice1_num[2],dice1_num[3],dice1_num[4],dice1_num[5])
init_Dice2 = Dice(dice2_num[0],dice2_num[1],dice2_num[2],dice2_num[3],dice2_num[4],dice2_num[5])


check(init_Dice1,init_Dice2)
init_Dice2.turn('E')
check(init_Dice1,init_Dice2)
init_Dice2.turn('E')
check(init_Dice1,init_Dice2)
init_Dice2.turn('E')
check(init_Dice1,init_Dice2)
init_Dice2.turn('N')
init_Dice2.turn('E')
check(init_Dice1,init_Dice2)
init_Dice2.turn('E')
check(init_Dice1,init_Dice2)
init_Dice2.turn('E')
check(init_Dice1,init_Dice2)
init_Dice2.turn('E')
check(init_Dice1,init_Dice2)
print('No')



Measured memory_bytes: 5624
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{


long long x;
cin>>x;
std::vector<int> v(x);
int totalmin=INT_MAX;
for (int i = 0; i < x; ++i)
{
	/* code */
	cin>>v[i];
	int  d=0;
	while(v[i]%2==0){
		++d;
		v[i]/=2;
	}
	totalmin=min(totalmin,d);
}

cout<<totalmin<<endl;
return 0;
}



Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
  cin >> N;
 
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if(S == "Y"){
    cout << "Four" << endl;
      return 0;
    }
  }
 
  cout << "Three" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int a, b, h;
    cin >> a >> b >> h;
    cout << ( a + b ) * h / 2 << endl;;
    return 0;
}


Measured memory_bytes: 3628
///Bismillahir Rahmanir Rahim
///Hello_World_Its_Rakib_Alam_Bappi
#include<bits/stdc++.h>
using namespace std;
///ascii for  A=65   and   a=97
#define		int 	long long
#define 		pb 	push_back
#define 		mp 	make_pair
#define 		pi 	2*acos(0.0)
#define 		loopi 	for(int i = 0 ; i <t ; i++)
#define 		loopj 	for(int j = 0 ; j < n-1 ; j++)
#define 		backj 	for(int j = n-1 ; j >=0 ; j--)
#define 		vect 	vector<int>
#define 		vec_it 	vector<int>::iterator vi
#define 		mapp 	map<int,int>m
#define 		pairr 	pair<int,int>p
#define 		sett	set<int>s
#define 		set_it 	set<int>::iterator si
#define 		yes 	cout<<"YES"<<endl
#define 		no 	cout<<"NO"<<endl
#define 		xx 	first
#define 		xy 	second
main()
{
    /// freopen ("in.txt" , "r",  stdin) ;
    string st;
    int n,k,t,temp=0,cnt=0,x,y=0,sum=0;
    cin>>n;
    int a[n-1];
    loopj cin>>a[j];
    sort(a,a+n-1);
    for(int i=1;i<=n;i++)
    {
        for(int j=temp;j<n-1;j++)
        {
            if(i==a[j])
                    cnt++;
                    else
                        break;
            temp++;
        }
        cout<<cnt<<endl;
        cnt=0;
            
    }
}

Measured memory_bytes: 5188
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main()
{
    int a, b;
    cin >> a >> b;
    if(a != 0)
        a = (a * (a - 1)) / 2;
    if(b != 0)
        b = (b * (b-1)) / 2;
    cout << (a + b) << endl;
    return 0;
}


Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define        u64             uint64_t
#define        ll              long long
#define        endl            "\n"
#define        PI              acos(-1)
#define        fi              first
#define        si              second
#define        mkp             make_pair
#define        pb              push_back
#define        set0(arr)       memset(arr, 0, sizeof(arr))
#define        setinf(arr)     memset(arr, 126, sizeof(arr))
#define        all(x)          (x).begin(),(x).end()
#define        sz(v)           ((int)(v).size())
#define        IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
using          pll        =      pair<ll, ll> ;
using          vl         =      vector<ll> ;
using          vpll       =      vector<pll> ;
using          mll        =      map<ll, ll> ;
using          mcl        =      map<char, ll> ;
using          msl        =      map<string,ll> ;
using          sl         =      set<ll> ;
using          sc         =      set<char> ;
using          dl         =      deque<ll> ;
const int N = 1e6+5 ;

ll      mod = 1e9+7 ;
vl      adj[N] ;
vpll    adjc[N] ;
ll      vis[N] ;
ll      arr[N],g ;

void dfs(ll x)
{
       g++;
       vis[x]=1;
       for(ll i=0;i<sz(adj[x]);i++)
       {
              ll p=adj[x][i];
              if(!vis[p])
              {
                     dfs(p);
              }
       }
}
int main()
{
    IOS;
    ll a, b, c, d, n, m, p, x, y, z, i, j, k, f = 0, tc, cnt = 0, sum = 0, mul = 1, mi = 1e18, ma = -1e18;
    string   str ;
    char     ch ;
    double   db ;
    ll       l, r ;
    //code

    cin>>n>>m;
    map<pair<ll,ll>,ll>mp;
    for(i=0;i<m;i++)
    {
           cin>>a>>b;
           adj[a].pb(b);
           adj[b].pb(a);
    }
    set0(vis);
    for(i=1;i<=n;i++)
    {
           g=0;
           if(!vis[i])
           {
                dfs(i);
           }
           ma=max(ma,g);
    }
    cout<<ma<<endl;


    //code
    return 0;
}



Measured memory_bytes: 70780
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define log(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n,m;cin>>n>>m;
  vector<int> h(n);rep(i,n)cin>>h[i];
  vector<int> hm(n,0);
  
  rep(i,m){
    int a,b;cin>>a>>b;
    a--;b--;
    chmax(hm[a],h[b]);
    chmax(hm[b],h[a]);
  }
  int ans = 0;
  rep(i,n)ans += h[i] > hm[i];
  print(ans);
  return 0; 
}


Measured memory_bytes: 4032
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        double a;
        cin >> a;
        if(a < 0.0)
            return 0;

        string s;
        double b = (1<<7);
        for(int i=0; i<12; ++i){
            if(i == 8)
                s += '.';
            if(a >= b){
                s += '1';
                a -= b;
            }else{
                s += '0';
            }
            b /= 2.0;
        }

        if(a == 0.0)
            cout << s << endl;
        else
            cout << "NA" << endl;
    }
}

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

using namespace std;

int main() {
  int N; cin >> N;
  long a = 1000000007;
  long ans = 1;

  for (int i = 0; i < N; i++) {
    ans *= i+1;
    ans %= a;
  }
  
  cout << ans << endl;
}


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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

signed main(){
    IOS;
    LCIN(A,B,C,D);
    A--;
    ll cur=GCD(C,D);
    ll a=A-(A/C+A/D-A/(C*D/cur));
    ll b=B-(B/C+B/D-B/(C*D/cur));
    ll ans=b-a;
    COUT(ans);

    return 0;
}


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

struct Graph(T)
{
    T L, R;
    T[][] adj;

    this(T L, T R)
    {
        this.L = L;
        this.R = R;
        adj.length = L + R;
    }

    void add_edge(T u, T v)
    {
        adj[u] ~= v+L;
        adj[v+L] ~= u;
    }

    T maximum_matching()
    {
        bool[] visited;
        T[] meta;
        visited.length = L;
        meta.length = L + R;
        meta[] = -1;

        bool augment(T u) {
            if (visited[u]) return false;
            visited[u] = true;
            foreach (w; adj[u]) {
                auto v = meta[w];
                if (v < 0 || augment(v)) {
                    meta[u] = w;
                    meta[w] = u;
                    return true;
                }
            }
            return false;
        }

        auto match = 0;
        foreach (u; 0..L) {
            visited[] = false;
            if (augment(u)) ++match;
        }
        return match;
    }
}

alias P = Tuple!(int, "x", int, "y");

void main()
{
    auto N = readln.chomp.to!int;
    P[] RS, BS;
    foreach (_; 0..N) {
        auto ab = readln.split.to!(int[]);
        RS ~= P(ab[0], ab[1]);
    }
    foreach (_; 0..N) {
        auto cd = readln.split.to!(int[]);
        BS ~= P(cd[0], cd[1]);
    }

    auto G = Graph!int(N, N);

    foreach (i, b; BS) {
        foreach (j, r; RS) {
            if (r.x < b.x && r.y < b.y) {
                G.add_edge(i.to!int, j.to!int);
            }
        }
    }

    writeln(G.maximum_matching());
}

Measured memory_bytes: 380
H, W, A, B = map(int, input().split())
L = [[0 for __ in range(W)] for _ in range(H)]
for i in range(B):
  for j in range(A):
    L[i][j] = 1
for i in range(B, H):
  for j in range(A, W):
    L[i][j] = 1
for i in range(H):
  for j in range(W):
    print(L[i][j], end = '')
  print()

Measured memory_bytes: 18588
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t=1;
	while(t--){
		int n,k;
		cin>>n>>k;
		int a[n];
		int dp[n];
		for(int i=0;i<n;i++){
			cin>>a[i];
			dp[i]=INT_MAX;
		}
		dp[0]=0;
		if(n>1)
			dp[1]=abs(a[0]-a[1]);
		for(int i=2;i<n;i++){
			for(int j=1;j<=k;j++)
				if(i-j>=0)
					dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
		}
		cout<< dp[n-1]<<endl;
		

	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ps push
#define pf push_front
#define mp make_pair
#define And &&
#define Or ||
#define inf INT_MAX
#define sz(name) name.size()
#define len(name) name.length()
#define ig cin.ignore()
#define sc(name) scanf("%d",&name)
#define ssc(name1,name2) scanf("%d%d",&name1,&name2)
#define sssc(name1,name2,name3) scanf("%d%d%d",&name1,&name2,&name3)
#define scl(name) scanf("%lld",&name)
#define sscl(name1,name2) scanf("%lld%lld",&name1,&name2)
#define ssscl(name1,name2,name3) scanf("%lld%lld%lld",&name1,&name2,&name3)
#define Sort(name) sort(name.begin(),name.end())
#define For(name,start,finish) for(int name=start;name<finish;name++)
#define Forr(name,start,finish) for(int name=start;name>=finish;name--)
#define fast_in_out ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


//int row[]={-1,0,1,0};
//int col[]={0,1,0,-1};

const ll N=2e5+10;
const ll M=1e9+7;

ll logx(ll a,ll b){return log(a)/log(b);}
ll Max(ll a,ll b){if(a>b)return a;return b;}
ll Min(ll a,ll b){if(a>b)return b;return a;}
ll big_mul(ll a,ll b,ll m){ll x=0,y=a%m;while(b>0){if(b&1)x=(x+y)%m;y=(2*y)%m;b>>=1;}return x%m;}
ll big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=(x*y)%m;y=(y*y)%m;b>>=1;}return x%m;}
ll Big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=big_mul(x,y,m);y=big_mul(y,y,m);b>>=1;}return x%m;}
ll mod_inverse(ll a,ll m){return big_mod(a,m-2,m);}  //a^-1 mod m = a^(m-2) mod m



int main()
{
    fast_in_out;


    ll n;
    cin>>n;

    cout<<(n*(n-1))/2<<endl;


    return 0;

}


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

from typing import List


def main():
    args = input().split()
    H = int(args[0])
    W = int(args[1])

    result: List[str] = []
    for row in range(H):
        rowStr = input()
        result.append(rowStr)
        result.append(rowStr)

    for item in result:
        print(item)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long X,K,D;cin>>X>>K>>D;
  long long H=(abs(X)/D)%2;
  if(abs(X)*1.0/K>D){
    cout<<abs(X)-K*D<<endl;
    return 0;
  }
  else{
    if(K%2==0){
      if(H==0){
        cout<<abs(X)%D<<endl;
      }
      else{
        cout<<D-abs(X)%D<<endl;
      }
    }
    else{
      if(H==0){
        cout<<D-abs(X)%D<<endl;
      }
      else{
        cout<<abs(X)%D<<endl;
      }
    }
  }
}


Measured memory_bytes: 3640
#include <stdio.h>
int main()
{
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);
    a = x - a;
    b = x - b;
    a = a*a;
    b = b*b;

    if(a<b)
    {
        printf("A");
    }
    else
    {
        printf("B");
    }
    return 0;
}

Measured memory_bytes: 2044
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[] input = new int[2];
		for(int i = 0;  i < N; i++){
			int A = stdIn.nextInt();
			int B = stdIn.nextInt();
			if(input[0] < A){
				input[0] = A;
				input[1] = B;
			}
		}
		System.out.println(input[0]+input[1]);
	}
}

Measured memory_bytes: 62716
#include<iostream>
#include<iomanip>
#include<cmath>

int main(){

    double r;
    std::cin >> r;
    
    std::cout << std::fixed << std::setprecision(7) 
        << r * r * M_PI << " " << 2 * r * M_PI << std::endl;

    return 0;
}


Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul  unsigned long long int
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod
//ll divide(ll a, ll b)  //euler's theorem(a/b)%mod
//{
//   return a*power(b,mod-2)%mod;  //only when mod is prime
//}

ll power(ll x, ll y)
{
    ll res = 1;
   while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
int main()
{
    speed;
    int n;
    cin>>n;
    vector<int> height(n+1);
    for(int i=1;i<=n;i++) cin>>height[i];
    
    int dp[100007];
    dp[1]=0;
    dp[2]=abs(height[2]-height[1]);
    for(int i=3;i<=n;i++)
    dp[i]=min(dp[i-1]+abs(height[i]-height[i-1]),dp[i-2]+abs(height[i]-height[i-2]));
    cout<<dp[n]<<'\n';
    return 0;
}


Measured memory_bytes: 3980
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  ll n,a,b,c,d,e; cin>>n>>a>>b>>c>>d>>e;
  ll mm=min({a,b,c,d,e});
  if(n%mm==0)
  cout<<n/mm+4<<endl;
  else
  cout<<n/mm+5<<endl;

  return 0;
}


Measured memory_bytes: 256
/*
for ZyFei
构造题
%2L不影响答案
绕两下不影响答案 
	贪心绕，先把两边都可以绕的分配给只能绕前面的，如果碰到个只能绕后面的就改成和绕后面的配
特判是否需要额外一轮来保证每个点都被经过
2018.4.11 
*/
#include <bits/stdc++.h>
#define rep(i, s, t) for(int i = s; i <= t; ++i)

using namespace std;
 
const int M = 3e5 + 10;
 
typedef long long LL;
int n, both, res; LL ans;
LL L, x[M], t;
bool oL[M], oR[M];
 
int main() {
	scanf("%d%lld", &n, &L); L <<= 1;
	ans = L;
	rep(i, 1, n) scanf("%lld", &x[i]);
	
	rep(i, 1, n) {
		scanf("%lld", &t);
		ans += (t + L - 1) / L * L;
		t %= L;
		if(t > 0 && t <= 2 * x[i]) oL[i] = 1;
		if(t > 0 && t <= L - 2 * x[i]) oR[i] = 1;
	}
	
	rep(i, 1, n-1) {
		if(res && oR[i]) {
    		if(oL[i]) ++both;
			--res; ans -= L;
		} else
		if(!oL[i] && oR[i]) {
			if(both) --both, ++res;
		} else
		if(oL[i]) ++res;
	}
	if(oR[n]) ans -= L;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = Integer.parseInt(s.next());
        int b = Integer.parseInt(s.next());
        int c = Integer.parseInt(s.next());
        if (a == b) {
            if (b == c) {
                // No
                System.out.println("No");
            } else {
                // Yes
                System.out.println("Yes");
            }
        } else {
            if (a == c || b == c) {
                // Yes
                System.out.println("Yes");
            } else {
                System.out.println("No");
                // No
            }
        }
    }
}

Measured memory_bytes: 23764
import math

a, b, h, m = list(map(int, input().split()))
deg_a = (60 * h + m) * 0.5
deg_b = 6 * m
deg = abs(deg_a - deg_b)
rad = math.radians(deg)

c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)
print(c2 ** 0.5)


Measured memory_bytes: 9564
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

  string S, T;
  cin >> S >> T;
  bool can = true;

  map<char, char> s_map;
  map<char, char> t_map;

  for (int i = 0; i < S.size(); i++) {
    char si = S[i];
    char ti = T[i];

    if (s_map[si] != 0 && s_map[si] != ti) {
      can = false;
      break;
    }
    if (t_map[ti] != 0 && t_map[ti] != si) {
      can = false;
      break;
    }

    s_map[si] = ti;
    t_map[ti] = si;
  }

  if (can) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 916
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
 
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int a,b;
    cin>>a>>b;
    int n=1,p=0;
    while(1){
        if(n>=b){
            cout<<p<<endl;
            return 0;
        }
        n=n-1+a;
        p++;
    }
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

ll modpow(ll a, ll b)
{
    if (b == 0)
    {
        return 1;
    }

    if (b % 2 == 0)
    {
        return (modpow(a, b / 2) * modpow(a, b / 2)) % MOD;
    }
    else
    {
        return (a * modpow(a, b - 1)) % MOD;
    }
}

int main()
{
    ll N;
    cin >> N;
    ll ans = modpow(10, N) - (2 * modpow(9, N) - modpow(8, N));
    while (ans < 0)
    {
        ans += MOD;
    }
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 3608
def mergesort(A, left, right):
 
    if left + 1 < right:
        mid = (left + right)/2
         
        mergesort(A, left, mid)
        mergesort(A, mid, right)
        merge(A, left, mid, right)
 
 
def merge(A, left, mid, right):

    n1 = mid -left
    n2 = right - mid
    L = []
    R = []
    x = "  10000000000"
    for i in range(0, n1):
        L.append(A[left + i])
    for i in range(0, n2):
        R.append(A[mid + i])
    L.append(x)
    R.append(x)
    i = 0
    j = 0
    for k in range(left, right):
        if int(L[i][2:]) <= int(R[j][2:]):
            A[k] = L[i]
            i = i + 1
        else:
            A[k] = R[j]
            j = j + 1
            
            
def partition(A, p, r):
    x = int(A[r-1][2:])
    i = p - 1
    for j in range(p, r-1):
        if int(A[j][2:]) <= x:
            i = i + 1
            A[i],A[j]=A[j], A[i]
             
    A[i+1], A[r-1]=A[r-1], A[i+1]
    return i+1
 
def quicksort(A, p, r):
    if p < r-1:
        q = partition(A, p, r)
         
        quicksort(A, p, q)
        quicksort(A, q+1, r)
 
 
 
 
if __name__ == "__main__":
    num = int(raw_input())
    num_list = []
    num_list1 = []
    for i in range(num):
        num_list.append(raw_input())
    num_list1 = list(num_list)
    quicksort(num_list, 0, len(num_list))
  
    mergesort(num_list1, 0, len(num_list1))
     
    if num_list == num_list1:
        print ("Stable")
    else:
        print ("Not stable")
    print "\n".join(num_list)
    

Measured memory_bytes: 16940
package main

import "fmt"

func main() {
	var N, M, X, Y int
	fmt.Scan(&N, &M, &X, &Y)
	var (
		l = X
		t int
	)
	for i := 0; i < N; i++ {
		fmt.Scan(&t)
		if t > l {
			l = t
		}
	}
	r := Y
	for i := 0; i < M; i++ {
		fmt.Scan(&t)
		if t < r {
			r = t
		}
	}
	if r-l >= 1 {
		fmt.Println("No War")
	} else {
		fmt.Println("War")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,t;
    cin >> n >> t;

    vector<int> ti(n);
    for (int i = 0; i < n; i++)
    {
        cin >> ti[i];
    }
    
    int ans = t;
    for (int i = 0; i < n - 1; i++)
    {
        if(ti[i + 1] - ti[i] <= t)
        {
            ans += ti[i + 1] - ti[i];
        }
        else
        {
            ans += t;
        }
        
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
int mod = 1000000007;
int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
template<class... T> int add(int x, T... y) { return add(x, add(y...)); }
int mul(int x, int y) { return 1LL * x * y % mod; }
template<class... T> int mul(int x, T... y) { return mul(x, mul(y...)); }
int sub(int x, int y) { return add(x, mod - y); }
int modpow(int a, long long b) { int ret = 1; while (b > 0) { if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod; b >>= 1; } return ret; }
int modinv(int a) { return modpow(a, mod - 2); }
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int N, M;
vector<pair<int, int>> rule[303];
int dp[303][303][303];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, M) {
        int L, R, X; cin >> L >> R >> X;
        rule[R].push_back({ L, X });
    }

    int ans = 0;
    dp[0][0][0] = 1;
    rep(r, 0, N + 1) rep(g, 0, N + 1) rep(b, 0, N + 1) {
        int ma = max(r, max(g, b));
        int mi = min(r, min(g, b));
        int md = r + g + b - ma - mi;

        for (auto p : rule[ma]) {
            int L = p.first, X = p.second;

            if (X == 1) {
                if (L <= md) dp[r][g][b] = 0;
            } else if (X == 2) {
                if (md < L) dp[r][g][b] = 0;
                else if (L <= mi) dp[r][g][b] = 0;
            } else if (X == 3) {
                if (mi < L) dp[r][g][b] = 0;
            }
        }

        if (ma == N) ans = add(ans, dp[r][g][b]);

        dp[ma + 1][g][b] = add(dp[ma + 1][g][b], dp[r][g][b]);
        dp[r][ma + 1][b] = add(dp[r][ma + 1][b], dp[r][g][b]);
        dp[r][g][ma + 1] = add(dp[r][g][ma + 1], dp[r][g][b]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 108800
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e6+7;
const int INF = 2e9+7;
char s[10];

struct cmp {
    bool operator()(int a, int b) {
        return a<b;
    }
};

priority_queue<int, vector<int>, cmp> a;
int h;

void insert_num(int num) {
    a.push(num);
}

int extract() {
    int k = a.top();
    a.pop();
    return k;
}
int main() {
//    freopen("../in.txt", "r", stdin);
    h = 0;
    while(true) {
        scanf("%s", s);
        if(s[2]=='s') {
            int num;
            scanf("%d", &num);
            insert_num(num);
        } else if(s[2] == 't') {
            int k = extract();
            printf("%d\n", k);
        } else {
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 7044
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define what_is(x) cerr << #x << " is " << x << endl;
#define pii pair < int , int >
#define fi first
#define se second
using namespace std;
typedef long long ll;

int main()
{
    optimiza_io
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    if( s[0] == '3' )
        cout << "bon\n";
    else if( s[0] == '0' or s[0] == '1' or s[0] == '6' or s[0] == '8' )
        cout << "pon\n";
    else
        cout << "hon\n";
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
main()
{
	//freopen("input.txt","rt",stdin);
	int a,b;
	cin>>a>>b;
	int c = a- 2*b;
	if(c >0)
	{
		cout<<c<<endl;
	}
	else
	{
		cout<<"0"<<endl;
	}
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) { // scc puzzle
		Scanner sc = new Scanner(System.in);
		String a = sc.nextLine();
		String[] b = a.split(" ");
		BigInteger n = new BigInteger(b[0]);
		BigInteger m = new BigInteger(b[1]);
		BigInteger leftOverM = BigInteger.valueOf(0);
		if (n.multiply(BigInteger.valueOf(2)).compareTo(m) == -1) {
			leftOverM = m.subtract(n.multiply(BigInteger.valueOf(2)));
			n = n.add(leftOverM.divide(BigInteger.valueOf(4)));
			m = m.subtract(leftOverM.divide(BigInteger.valueOf(2)));
			System.out.println(n);
		} else {
			System.out.println(m.divide(BigInteger.valueOf(2)));
		}
	}

}

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

typedef long long int ll;
const int N_MAX = 100005;
const ll ANS_MAX = 1E+18;
ll A[N_MAX];

int main(){
    int n;
    bool zero = false;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        if (A[i] == 0) zero = true;
    }
    ll ans = 1;
    if (zero) ans = 0;
    else{
        ll big = ANS_MAX;
        for(int i = 0; i < n; i++){
            if (big < A[i]){
                ans = -1;
                break;
            }
            else{
                ans *= A[i];
                big = ANS_MAX / ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4416
n=int(input())
c=0
l=n
while l>0:
    l=l//10
    c+=1

def f(p):
    return 10**(p-1)*9

ans=0
if c==1:
    print(n)
elif c%2==0:
    for i in range(1,c,2):
        ans+=f(i)
    print(ans)
else:
    ans+=n
    for i in range(2,c,2):
        ans-=f(i)
    print(ans) 

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
  int a[3],i,j,b;
  for (i=0;i<3;i++) cin >> a[i];
  for (i=0;i<3;i++){
    for (j=i+1;j<3;j++){
      if (a[i]>a[j]){
        b=a[i];
        a[i]=a[j];
        a[j]=b;
      }
    }
  }
  cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
  return 0;
}


Measured memory_bytes: 3088
//Daniel Grzegorzewski
#include <bits/stdc++.h>

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (int)1e5 + 10;

int n, k, res = 1e18, x[N];

signed main() {
  init_ios();
  cin >> n >> k;
  for (int i = 1; i <= n; ++i)
    cin >> x[i];
  for (int i = 1; i+k-1 <= n; ++i) {
    int lst = i+k-1;
    if (x[lst] < 0)
      res = min(res, abs(x[i]));
    else if (x[i] > 0)
      res = min(res, x[lst]);
    else
      res = min(res, min(2*abs(x[i])+x[lst], abs(x[i])+2*x[lst]));
  }
  cout<<res<<"\n";
}

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

typedef long long ll;

// n * (n + 1) / 2;

ll sum(ll n);
ll bsearch(ll n);

ll array[10000005];

int main()
{
    ll n;

    cin >> n;

    for (ll i = 0; i < 10000005; i++) {
        array[i] = sum(i);
    }

    
    ll p = (ll)(lower_bound(begin(array), end(array), n) - array);

    for (ll i = 1; i <= p; i++) {
        if (i != (sum(p) - n)) {
            cout << i << endl;
        }
    }

    return 0;
}

ll sum(ll n) {
    return n * (n + 1) / 2;
}

ll bsearch(ll n)
{
    ll l, r, mid;

    l = 1;
    r = n + 1;

    while (r - l > 1) {
        mid = (r + l) / 2;
        ll tmp = sum(mid);

        if (tmp == n) {
            r = l = mid;
        } else if (tmp > n) {
            r = mid + 1;
        } else {
            l = mid + 1;
        }
    }

    return l;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;
   
typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
const int N = 2e6 + 233;
int n, m, a[N], v[N], s, x, p;

int main(void) {
    read(n);
    rep (i, n - 1) {
	read(a[i]);
	if (i <= 2) continue;
	for (int j = 1; j <= a[i]; j++) {
	    if (j >= s) v[s + j] = j - s;
	    else v[s + j] = v[s - j];
	}
	s += a[i];
    }
    read(m);
    rep (i, m) {
	read(x); p = x - s;
	cout << (p >= 0 ? p : v[-p]) + a[1] - a[2] << "\n";
    }    
}


Measured memory_bytes: 10368
// Problem : C - Skill Up
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;



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

    long n, m, x;
    cin >> n >> m >> x;
    vector<long> c(n);
    vector<vector<long>> a(n, vector<long>(m, 0));
    for (long i = 0; i < n; i++) {
        cin >> c[i];
        for (long j = 0; j < m; j++) cin >> a[i][j];
    }
    long bestCost = LONG_MAX;
    vector<long> bin(n, 0);
    for (long i = 0; i < pow(2, n); i++) {
        vector<long> knowledge(m, 0);
        long cost = 0;
        for (long j = 0; j < n; j++) {
            if (bin[j] == 1) {
                cost += c[j];
                for (long h = 0; h < m; h++) {
                    knowledge[h] += a[j][h];
                }
            }
        }
        bool ok = true;
        for (long j = 0; j < m; j++) {
            if (knowledge[j] < x) ok = false; 
        }
        if (ok) bestCost = min(bestCost, cost);
        bin[0]++;
        long j = 0;
        while (j < bin.size()) {
            if (bin[j] == 2) {
                if (j+1 <  bin.size()) bin[j+1]++;   
                bin[j] = 0;
            }
            j++;
        }
    }
    if (bestCost == LONG_MAX) cout << -1 << "\n";
    else cout << bestCost << "\n";
    
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
  bitDP
  dp[i][S] 男性i人目までの女性の集合Sの時の場合の数
*/

int a[21][21], dp[22][(1<<21)];

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

  rep(i, n) rep(j, n){
    cin >> a[i][j];
  }

  dp[0][0] = 1;
  rep(mask, 1<<n){
    int i = __builtin_popcount(mask);
    rep(j, n){
      if(a[i-1][j] and mask & 1<<j){
        dp[i][mask] += dp[i-1][mask & ~(1<<j)];
        dp[i][mask] %= mod;
      }
    }
  }

  cout << dp[n][(1<<n)-1] << endl;

  return 0;
}


Measured memory_bytes: 162048
N = int(input())
Point = [tuple(map(int,input().split(" "))) for _ in range(N)]
# スタート地点(t,x,y)
Now = (0,0,0)
flag = 0
for Next in Point:
    # 次の点へのマンハッタン距離    
    dist = abs((Next[1]+Next[2]) - (Now[1]+Now[2]))
    # 移動に使える時間
    T = Next[0]-Now[0]
    if T<dist:
        flag=1
        break
    else:
        if T%2!=dist%2:
            flag=1
            break
if flag==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 17320
#include <bits/stdc++.h>
#define rep(i, n, s) for (int i = s; i < n; i++)
#define graph map<int, vector<int>>
#define field vector<vector<int>>
using namespace std;
int main(){
    int l,r,d,ans;
    cin >> l >> r >> d;
    ans = 0;
    rep(i,r+1,l){
        if (i%d == 0){
            ans ++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define endl "\n"
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi first
#define se second
typedef long long int ll;
const int INF = 1e9;
 
using namespace std;
 
void solve()
{
  ll i, j, n, k, a, b, c, d, x, y;
  cin>>a>>b>>c>>k;
  if(k<=a) cout<<k<<endl;
  else if(k<=(a+b)) cout<<a<<endl;
  else cout<<a+((k-(a+b))*-1)<<endl;
}
 
int main()
{
    FASTIO
    solve();
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void)
{
   int N, i, j, minj, tmp;
   int wa = 0;
   int A[100];

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

   for ( i = 0; i < N - 1; i++ ) {
      minj = i;
      for ( j = i; j < N; j++ ) {
         if ( A[ minj ] > A [ j ] ) {
            minj = j;
         }
      }
      if ( i != minj ) {
         tmp = A[ i ];
         A[ i ] = A[ minj ];
         A[ minj ] = tmp;
         wa = wa + 1;
      }
   }

   for ( i = 0; i < N; i++ ) {
      if ( i > 0 ) {
         printf(" ");
      }
      printf("%d", A[ i ]);
   }
   printf("\n");
   printf("%d\n", wa);

   return 0;
}

Measured memory_bytes: 1848
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int a,b;
	cin >> a >> b;
	cout << ((a<10&&b<10)?a*b:(-1)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  int a,b;
  cin>>a>>b;
  int sum=a+b;
  if(sum%2==0)cout<<sum/2<<endl;
  else cout<<sum/2+1<<endl;
  
  return 0;
}


Measured memory_bytes: 256
from collections import deque
N = int(input())

def split_by_zero(l):
    if 0 not in l:
        return [l]
    ret_l = []
    while 0 in l:
        idx = l.index(0)
        if l[:idx]:
            ret_l.append(l[:idx])
        l = l[idx+1:]
    if l:
        ret_l.append(l)
    return ret_l

def main():
    
    H = list(map(int, input().split()))
    H = split_by_zero(H)
    que = deque(H)

    cnt = 0
    while que:
        q = que.popleft()
        q = [i-1 for i in q]
        cnt += 1
        q = split_by_zero(q)
        if q:
            for qq in q:
                que.append(qq)
    
    print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <stdio.h>
int main(){
	int x,y,z;
	int temp;
	scanf("%d %d %d",&x,&y,&z);
	if(x<=y){
		;
	}else{
		temp=y;
		y=x;
		x=temp;
	}
	
	if(y<=z){
		;
	}else{
		temp=z;
		z=y;
		y=temp;
	}
	
	if(x<=y){
		;
	}else{
		temp=y;
		y=x;
		x=temp;
	}
	
	printf("%d %d %d\n",x,y,z);
	
	return 0;
} 


Measured memory_bytes: 2112
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0]*n

t = list(map(int, input().split()))
for i in range(n-1):
  c[i] = t[i]
  

x = 0
y = 0
z = 0
for i in range(n):
  if a[i] == x+1:
    z += y
  z += b[a[i] - 1] 
  x = a[i]
  y = c[a[i] -1]
print(z)

Measured memory_bytes: 3064
import sys
H, W = map(int, input().split())

if H == 1 or W == 1:
    print(1)
    sys.exit()
if H % 2 == 0:
    print(H*W//2)
else:
    if W % 2 == 0:
        print(H*W//2)
    else:
        print((H-1)*(W-1)//2 + (H-1)//2 + (W-1)//2 + 1)


Measured memory_bytes: 38288
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int N = s.size();
  string a;
  
  for (int i = 0; i < N; i++) if (i % 2 == 0) a += s.at(i);
  
  cout << a << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <algorithm>
#include<string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string A, B, C;
    cin >> A >> B >> C;
    if ((A[A.size() - 1] == B[0]) && B[B.size() - 1] == C[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        _: usize,
        s: Chars,
    };
    let mut count = 0;
    for i in 0..=999 {
        let d = format!("{:03}", i).chars().collect::<Vec<char>>();
        let mut j = 0;
        for &s_i in s.iter() {
            if j == 3 {
                break;
            }
            if d[j] == s_i {
                j += 1;
            }
        }
        if j == 3 {
            count += 1;
        }
    }
    let ans = count;
    println!("{}", ans);
}


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

ostream& operator<<(ostream &out, string str) {
	for(char c : str) cout << c;
	return out;
}

template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}

template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}

void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}

#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif

#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second

template<class T> int size(T && a) {
	return a.size();
}

using LL = long long;
using PII = pair<int, int>;

vector<vector<int>> adj;
LL ans = 1;
int k, mod = 1e9 + 7;
int mul(int a, int b) {
	return (LL) a * b % mod;
}
void dfs(int v, int p) {
	if(p == -1) ans = k;	
	int cnt = (p != -1);
	for(int u : adj[v]) if(u != p) {
		cnt++;
		ans = mul(ans, k - cnt);
		dfs(u, v);
	}
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n >> k;
	adj.resize(n);
	REP(i, n - 1) {
		int u, v;
		cin >> u >> v;
		adj[u - 1].emplace_back(v - 1);
		adj[v - 1].emplace_back(u - 1);
	}

	dfs(0, -1);
	cout << ans << "\n";
}


Measured memory_bytes: 9216
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stack>
#include<vector>
#include<cmath>
#include<string>
#include<queue>
#include<map>
#include<cstring>
#include<sstream>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<time.h>
typedef long long ll;
using namespace std;

int main() {
	//freopen("run.in", "r", stdin);
	//freopen("run.out", "w", stdout);

	int n;
	int a[100];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int cnt = 0;
	for (int i = 0; i <= n - 2; i++) {
		int min, idx;

		min = i;
		for (int j = i + 1; j < n; j++) {
			if (a[j] < a[min]) {
				min = j;
			}
		}
		if (i != min) {
			swap(a[i], a[min]);
			cnt++;
		}
	}
	cout << a[0];
	for (int i = 1; i < n; i++) {
		cout << ' ' << a[i];
	}
	cout << endl << cnt << endl;
}

Measured memory_bytes: 3116
import collections

def test():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = collections.Counter(a)
    ans = 0
    for x in range(max(a)+1):
        ex = b[x]
        if x - 1 in b:
            ex += b[x-1]
        if x + 1 in b:
            ex += b[x+1]
        ans = max(ans,ex)

    print(ans)


if __name__ == "__main__":
    test()


Measured memory_bytes: 14564