akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1187&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


class Team(object):
    def __init__(self, id):
        self.id = id
        self.correct = 0        #  ??£?§£??°
        self.time = 0           #  ????????????
        self.penalty = 0        #  ??????????????£
        self.status = {}        #  ?????£?§£?????¶??? key: ????????????, value: ????????£????????°

    def judge(self, m, p, j):
        if j == 0:
            self.correct += 1
            self.time += m
            if p in self.status:
                self.penalty += 20 * self.status[p]
                del self.status[p]
        else:
            if p in self.status:
                self.status[p] += 1
            else:
                self.status[p] = 1


def calc_result(scores):
    # ???????????????????????¢????????§?????????????????£?§£??°?????????????????????????????????????????§???????????????????????????l
    result = []                 #  ??????????????¨??????[??£?§£??°*(-1), ????????????, ???????????????*(-1)] ??????????????§?¨??????????
    for i, s in enumerate(scores[1:], start=1):
        if s is not None:
            result.append([-s.correct, s.time+s.penalty, s.id*-1]) #  sort()??????????????????????????£????????????????????????????????£?§£??°??¨??????????????????-1???????????????
        else:
            result.append([0, 0, -i])
    result.sort()
    return result


def main(args):
    # M, T, P, R = 300, 10, 8, 5,
    # data = [[50, 5, 2, 1,], [70, 5, 2, 0], [75, 1, 1, 0], [100, 3, 1, 0], [150, 3, 2, 0]]

    while True:
        M, T, P, R = map(int, input().split())
        if M == 0 and T == 0 and P == 0 and R == 0:
            break
        data = [[int(i) for i in input().split()]  for x in range(R)]

        scores = [None] * (T+1)
        for d in data:
            m, t, p, j = d
            if scores[t] == None:
                team = Team(t)
                scores[t] = team
            scores[t].judge(m, p, j)

        # ???????????????
        result = calc_result(scores)

        # ?????????????????????????????????
        prev_corrent = result[0][0]
        prev_time = result[0][1]
        final_output = str(result[0][2]*-1)
        for r in result[1:]:
            if r[0] == prev_corrent and r[1] == prev_time:
                final_output += '='
                final_output += str(r[2]*-1)
            else:
                final_output += ','
                final_output += str(r[2]*-1)
                prev_corrent = r[0]
                prev_time = r[1]
        print(final_output)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7968
#include<cstdio>
#include<algorithm>
using namespace std;
long long a,b;
long long gcd(long long x,long long y)
{
	if(!y) return x;
	return gcd(y,x%y);
}
int main()
{
	scanf("%lld%lld",&a,&b);
	long long d=gcd(a,b);
	if(d==b)
	{
		printf("-1");
		return 0;
	}
	printf("%lld",a);
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;


int main() {

	int x, y, z;
	cin >> x >> y >> z;
	int k;
	cin >> k;
	vector<long long int>a(x), b(y), c(z);
	for (int i = 0; i < x; i++)cin >> a[i];
	for (int i = 0; i < y; i++)cin >> b[i];
	for (int i = 0; i < z; i++)cin >> c[i];
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	sort(c.rbegin(), c.rend());
	priority_queue<long long int>t;

	for(int i=0;i<x;i++)
		for(int j=0;j<y;j++)
			for (int kk = 0; kk < z; kk++) {
				if (i*j*kk > min(k,x*y*z))break;
				t.push(a[i] + b[j] + c[kk]);
			}
	//sort(t.rbegin(), t.rend());

	for (int i = 0; i < k; i++) {
		cout << t.top() << endl;
		t.pop();
	}

	return 0;


}

Measured memory_bytes: 35176
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define ld long double
typedef pair<ll,ll> pll;
typedef pair<pll,pll> ppll;
typedef vector <pll> vi;
#define out(x) return cout<<x,0;
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define lc(n) 2*n+1
#define rc(n) 2*n+2
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

ll slove ( ll n ){
	if ( n == 0 ) return 0;
	return 1 + 2*slove(n/2);
}

int main() {
    FAST;
    ll n, i, m, k, x = 0, y = 0, t, z = 0, ans = 0, j, c = 0;
    cin >> n;
    cout << slove(n);
}

Measured memory_bytes: 256
'use strict'

function Main(input) {
  input = input.trim().split(' ').map(s => parseInt(s))

  const N = input[0]
  const R = input[1]

  if (N < 10) {
    console.log(R + 100 * (10 - N))
  } else {
    console.log(R)
  }
  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
N = int(input())
cards = list(map(int, input().split()))
cards = sorted(cards)

Alice = 0
Bob = 0
while len(cards) >= 2:
    Alice += cards[-1]
    cards = cards[:-1]
    Bob += cards[-1]
    cards = cards[:-1]
if len(cards) == 1:
    Alice += cards[-1]
print(Alice - Bob)


Measured memory_bytes: 61456
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  long long n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<string> in(n);
  for (int i = 0; i < n; i++) {
    cin >> in[i];
  }
  if (a + b + c == 0) {
    cout << "No\n";
    return 0;
  }
  vector<char> ans;
  for (int i = 0; i < n; i++) {
    string ss = in[i];
    if (ss == "AB") {
      if (a == 0 && b == 0) {
        cout << "No\n";
        return 0;
      }
      if (a != b || a + b + c > 2 || i == n - 1) {
        if (a >= b) {
          a--;
          b++;
          ans.push_back('B');
        } else {
          a++;
          b--;
          ans.push_back('A');
        }
      } else {
        string sss = in[i + 1];
        if (sss == "AB") {
          a--;
          b++;
          ans.push_back('B');
        }
        if (sss == "AC") {
          a++;
          b--;
          ans.push_back('A');
        }
        if (sss == "BC") {
          a--;
          b++;
          ans.push_back('B');
        }
      }
    } 
    if (ss == "AC") {
      if (a == 0 && c == 0) {
        cout << "No\n";
        return 0;
      }
      if (a != c || a + b + c > 2 || i == n - 1) {
        if (a >= c) {
          a--;
          c++;
          ans.push_back('C');
        } else {
          a++;
          c--;
          ans.push_back('A');
        }
      } else {
        string sss = in[i + 1];
        if (sss == "AB") {
          a++;
          c--;
          ans.push_back('A');
        }
        if (sss == "AC") {
          a++;
          c--;
          ans.push_back('A');
        }
        if (sss == "BC") {
          a--;
          c++;
          ans.push_back('C');
        }
      }
    }
    if (ss == "BC") {
      if (b == 0 && c == 0) {
        cout << "No\n";
        return 0;
      }
      if (b != c || a + b + c > 2 || i == n - 1) {
        if (b >= c) {
          b--;
          c++;
          ans.push_back('C');
        } else {
          b++;
          c--;
          ans.push_back('B');
        }
      } else {
        string sss = in[i + 1];
        if (sss == "AB") {
          c--;
          b++;
          ans.push_back('B');
        }
        if (sss == "AC") {
          b--;
          c++;
          ans.push_back('C');
        }
        if (sss == "BC") {
          b--;
          c++;
          ans.push_back('C');
        }
      }
    }
  }
  cout << "Yes\n";
  for (auto& c : ans) {
    cout << c << '\n';
  }
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

// dp[i][j]  TOPがiでBOTがｊになる数字の個数
int dp[10][10];

signed main() {
  int N;
  cin >> N;
  int Nbuf = N;
  int length = 1, bot = N % 10, top = Nbuf;
  rep(i, 6) {
    Nbuf = Nbuf / 10;
    if (Nbuf == 0) {
      break;
    }
    length++;
    top = Nbuf;
  }

  //cout << length << " " << top << " " << bot << endl;


  rep(i, N+1) {
    int f,s;
    f = i;
    while(f/10 != 0){
      f /= 10;
    }
    s = i % 10;

    dp[f][s] ++;
  }

  int ans = 0;

  rep(i, 9) {
    rep(j, 9) {
      ans += dp[i+1][j+1] * dp[j+1][i+1];
    }
  }

  cout << ans << endl;


}

Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
int main(){
    string W;
    string T;
    int counter = 0;
    cin >> W;
    for (int i = 0;i < W.size(); i++) {
        W[i] = tolower(W[i]);
    }
   
    while(cin >> T) {
        if(T == "END_OF_TEXT") break;
        for (int i = 0;i < T.size(); i++) {
            T[i] = tolower(T[i]);
        }   
        
        if(W == T) counter+=1;
    }
    cout << counter << endl;
    
    return 0;
}

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

void fnInput(string& rsNumStr)
{
  cin >> rsNumStr;
}

int fnMinDiffChk(string sNumStr)
{
  const int cnnNum = 753;
  int nMinDiff = INT_MAX;

  for (int i = 0; i < sNumStr.size() - 2; i++)
  {
    int nNum = (sNumStr[i]     - '0') * 100 +
               (sNumStr[i + 1] - '0') * 10  + (sNumStr[i + 2] - '0');
    if (abs(nNum - cnnNum) < nMinDiff)
      nMinDiff = abs(nNum - cnnNum);
  }
  return nMinDiff;
}

int main()
{
  string sNumStr;

  fnInput(sNumStr);
  cout << fnMinDiffChk(sNumStr) << endl;

  return 0;
}

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


int main()
{
    int n,m;cin>>n>>m;
    vector<int> a(n), b(n), c(m), d(m);
    for(int i = 0; i<n;i++)cin>>a[i]>>b[i];
    for(int i = 0; i<m;i++)cin>>c[i]>>d[i];
    for(int i = 0; i<n;i++){
        int rec;
        int mi = 1000000000;
        for(int j = 0; j<m;j++){
            if(mi > abs(c[j] - a[i]) + abs(d[j] - b[i])){
                mi = abs(c[j] - a[i]) + abs(d[j] - b[i]);
                rec = j;
            }
        }
        cout << rec + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    REP(i,3){
        string s;
        cin >> s;
        cout << s[i];
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		long[] d = new long[N];
		long sum = 0;
		long d_sum = 0;
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			sum += A[i];
			if (i > 0) {
				d[i] = A[i] - A[i - 1];
				d_sum += d[i];
			}
		}
		d[0] = A[0] - A[N - 1];
		d_sum += d[0];
		sc.close();

		long m = ((long) N) * ((long) (N + 1)) / 2L;
		String ans = "YES";
		long div = 0;
		long[] a = new long[N];
		long chk = 0;
		if ((sum % m) != 0 || d_sum != 0L) {
			ans = "NO";
		} else {
			long cnt = sum / m;
			for (int i = 0; i < N; i++) {
				d[i] -= cnt;
				if (((-d[i]) % N) != 0 || d[i] > 0) {
					ans = "NO";
					break;
				} else {
					a[i] = (-d[i]) / N;
					div += a[i];
					int mul = (N - i + 1) % N;
					mul = mul == 0 ? N : mul;
					chk += a[i] * mul;
				}
			}
			if (div != cnt) {
				ans = "NO";
			}
			for (int i = 0; i < N; i++) {
				if (chk != A[i]) {
					ans = "NO";
				}
				chk += (div - N * a[(i + 1) % N]);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 48836
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define poly vector<ll>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
inline ll read(){
	ll x=0;char ch=getchar();bool d=1;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') d=0;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return d?x:-x;
}
inline void write(ll x){
	if(x<0) x=-x,putchar('-');
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=2005,mo=1e9+7;
int f[N][N],g[N][N];
void upd(int &x,int y){
	x+=y;if(x>=mo) x-=mo;
}
int main(){
	int n=read(),m=read();
	For(i,2,n) f[1][i]=1;
	For(i,1,m-1){
		int sum=f[i][n-i+1];
		Rep(j,n-i,2){
			upd(sum,f[i][j]);
			upd(f[i+1][j],sum);
		}
	}
	int ans=0;
	For(i,2,n-m+2) upd(ans,f[m-1][i]);
	if(m==1) ans=1;
	int tot=1;
	For(i,1,n-m-1) tot=(ll)2*tot%mo;
	cout<<(ll)ans*tot%mo;
}

Measured memory_bytes: 17188
#include<iostream>
#include<string>
#include<map>
using namespace std;

string S, T;
map<char, int> mpa, mpb;

int main(){
	cin >> S >> T;;
	int cnt = 0;
	for(int i = 0; i < S.length(); i++){
		if(mpa[S[i]] == 0){
			cnt++;
			mpa[S[i]] = cnt;
		}
	}
	for(int i = 0; i < S.length(); i++){
		S[i] = (char)(mpa[S[i]] + 'a' - 1);
	}
	cnt = 0;
	for(int i = 0; i < T.length(); i++){
		if(mpb[T[i]] == 0){
			cnt++;
			mpb[T[i]] = cnt;
		}
	}
	for(int i = 0; i < T.length(); i++){
		T[i] = (char)(mpb[T[i]] + 'a' - 1);
	}
	if(S == T) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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 pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int n;
	cin >> n;
	cout << 180 * (n - 2) << endl;
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<utility>
using namespace std ;
const int inf = 1e9+4;
int main()
{
    vector < pair < int,int > > v ;
    int n,k;
    cin >> n >> k ;
    vector < int > dp(n+4,inf);
    for(int i=0;i<k;i++)
    {
        int x,y;
        cin >> x >> y ;
        v.push_back(make_pair(x,y));
    }
    for(int i=1;i<=n;i++)
    {
          for(int j=0;j<v.size();j++)
          {
              int d = v[j].first;
              int p = v[j].second;
              if(i-d<=0)
              {
                  dp[i]=min(dp[i],p);
              }
              else
              {
                  dp[i]=min(dp[i],dp[i-d]+p);
              }
          }
    }
    cout << dp[n] << endl;
    return 0 ;
}

Measured memory_bytes: 256
module CharMap = Map.Make (Char)

let () =
  let s = read_line () in
  let m =
    Array.fold_left (fun m c ->
      CharMap.add c
        (1 + try CharMap.find c m with Not_found -> 0) m) CharMap.empty @@
    Array.init (String.length s) (String.get s) in
  print_endline @@ if 
    CharMap.cardinal m = 2 &&
    snd (CharMap.min_binding m) = snd (CharMap.max_binding m)
  then "Yes"
  else "No"

Measured memory_bytes: 2432
H,W=map(int, input().split())
N=int(input())
A=list(map(int, input().split()))
 
ans = []
for i, a in enumerate(A):
  ans.extend([str(i+1)] * a)
  
for i in range(H):
  l = ans[i*W : (i+1)*W ]
  if i%2:
    l.reverse()
  print(' '.join(l))

Measured memory_bytes: 9816
#include <iostream>
#include <vector>
using namespace std;
 
const int MX = 100005;
int n, m;
vector<vector<int> > adj(MX);
vector<int> dp(MX, 0);
int seen[MX];
 
void dfs(int v) {
    seen[v] = 1;
    for (auto p : adj[v]) {
        if (!seen[p]) 
           dfs(p);
        dp[v] = max(dp[v], dp[p] + 1);
    }
}
 
int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        x--; y--;
        adj[x].push_back(y);
    }
    for (int i = 0; i < n; i++) {
        if (!seen[i]) dfs(i);
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (dp[i] > res) res = dp[i];
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 12380
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll x;
  cin >> x;
  if (x % 100 == 0) {
    cout << 1 << endl;
    return 0;
  }
  int n = x / 100;
  int lim = 100*n + 5*n;
  if (x <= lim) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 3576
from heapq import heappop, heappush

N = int(input())
links = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b, c = map(int, input().split())
    links[a].append((b, c))
    links[b].append((a, c))

Q, K = map(int, input().split())

d = [float('inf')] * (N + 1)
d[K] = 0
#prev = [None] * (N + 1)
q = [(0, K)]
while q:
    _, u = heappop(q)
    for v, c in links[u]:
        alt = d[u] + c
        if d[v] > alt:
            d[v] = alt
            #prev[v] = u
            heappush(q, (alt, v))

result = []
for _ in range(Q):
    x, y = map(int, input().split())
    result.append(d[x] + d[y])
print('\n'.join(str(v) for v in result))


Measured memory_bytes: 55396
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <istream>
#include <assert.h>
#include <vector>
#include <cstdio>

using namespace std;

int main()
{
//    freopen("input.txt", "r", stdin);
    int n;
    scanf("%d", &n);
    vector<int> v(n+1);
    for(int i = 0; i < n; i++){
        scanf("%d", &v[i]);
    }
    if(n == 1){
        printf("Yes\n");
        return 0;
    }else{
        bool possible = true;
        for(int i = 1; i < n; i++){
            if(v[i] < v[i-1]){
                int diff = v[i-1] - v[i];
                if(diff == 1) v[i] += 1;
                else if(diff > 1) {
                    printf("No\n");
                    return 0;
                }

            }
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
L = list(map(int, input().split()))
dp = [-1 for k in range(K+1)]
dp[0] = 1
def fn(n):
	if dp[n] != -1:
		return dp[n]
	for i in L:
		if n >= i:
			if fn(n-i) == 1:
				dp[n] = 0
				return 0
	dp[n] = 1
	return 1
for l in range(1, 	K):
	fn(l)
if fn(K) == 0:
	print("First")
else:
	print("Second")

Measured memory_bytes: 44912
import sys
n, k = map(int, input().split())
lines = sys.stdin.readlines()
trees = [None] * n
for i in range(n):
    trees[i] = int(lines[i])



trees.sort()

#print(trees)
min_h = sys.maxsize
k_ = k-1
for i in range(n-k+1):
    tmp = trees[i+k_] - trees[i]
    if tmp < min_h:
        min_h = tmp

print(min_h)

Measured memory_bytes: 14560
#include <stdio.h>

int main(){
    int i, j;
    int h, w;
    
    while(scanf("%d %d", &h, &w), h > 0 && w > 0){
        for(i = 0; i < h; ++i){
            for(j = 0; j < w; ++j){
                putchar((i + j) % 2 == 0 ? '#' : '.');
            }
            
            putchar('\n');
        }
        
        putchar('\n');
    }
    
    return 0;
}


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

using namespace std;
typedef long long ll;

const ll INF = 1e18;
ll f(ll b, ll n) {
  ll res = 0;
  while (n) {
    res += n % b;
    n /= b;
  }
  return res;
}

int main(void) {
  ll n, s;
  cin >> n >> s;

  ll ans = n == s ? s + 1 : INF;
  for (ll i = 2; i * i <= n; i++) {
    if (f(i, n) == s) {
      ans = i;
      break;
    }
  }

  if (ans == INF) {
    for (ll p = 1; p * p < n; p++) {
      ll b = (n - s + p) / p;
      if (b == 0 || n - s + p <= 0) continue;
      if (n / b + n % b == s) {
        ans = min(ans, b);
      }
    }
  }

  cout << (ans != INF ? ans : -1) << endl;

  return 0;
}

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

using namespace std;

int main()
{
    string str;
    int q;
    cin>>str>>q;

    for(int i=0;i<q;i++)
    {
        string inst;
        cin>>inst;
        if(inst == "replace")
        {
            int a,b;
            string s;
            cin>>a>>b>>s;

            int count=0;
            for(int j=a;j<=b;j++)
            {
                str[j] = s[count];
                count++;
            }

        }else if(inst == "reverse")
        {
            int a,b;
            cin>>a>>b;
            string s = str;

            int count = b;
            for(int j=a;j<=b;j++)
            {
                str[j] = s[count];
                count--;
            }


        }else if(inst == "print")
        {
            int a,b;
            cin>>a>>b;

            for(int j=a;j<=b;j++)
            {
                cout<<str[j];
            }
            cout<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1216
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[MAX][MAX];

void dijkstra(){
    int minv;
    int d[MAX],color[MAX];

    for(int i=0;i<n;i++){
        d[i] = INFTY;
        color[i] = WHITE;
    }
    d[0] = 0; // スタート位置はノード0
    color[0] = GRAY;

    while(1){
        minv = INFTY;
        int u = -1;
        for(int i=0;i<n;i++){
            if(color[i] != BLACK && d[i] < minv){
                u = i;
                minv = d[i];
            }
        }
        if(u == -1)break; //例外処理
        color[u] = BLACK;

        for(int v =0;v<n;v++){
            if(M[u][v] != INFTY && color[v] != BLACK){
                if(d[v] > d[u] + M[u][v]){
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        cout << i <<" "<< (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            M[i][j] = INFTY;
        }
    }

    int k,c,u,v;
    for(int i =0;i<n;i++){
        cin >> u >> k;
        for(int j = 0;j<k;j++){
            cin >> v >> c;
            M[u][v] = c;
        }
    }
    dijkstra();
    return 0;
}


Measured memory_bytes: 3124
#include<stdio.h>
int main(void)
{
  double a, s;
  int i;

  while(scanf("%lf", &a) != EOF){
    s = a;
    for (i = 2; i <= 10; i++){
      if (i % 2){
	a = a / 3.0;
	s = s + a;

      }else{
	a = a * 2.0;
	s = s + a;
      }
    }

    printf("%lf\n", s);
  }
  return 0;
}

Measured memory_bytes: 644
#include"iostream"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"iomanip"
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;string s;
    cin>>n>>s;
    int curr=0;
    string ans="";
    int min1=1e7;
    for(int i=0;i<n;++i)
    {
        curr+=((s[i]=='(')?1:-1);
        min1=min(min1,curr);
    }
    int t=min1;
    while(t<0)
    {
        s="("+s;
        ++t;curr++;
    }
    t=curr;
    while(t>0)
    {
        s=s+")";
        --t;
    }
    if(min1<0)
    {

    }
    cout<<s<<'\n';
}

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

template<class VAL> struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<int> num_same;
	vector<VAL> diff_weight;

	UnionFind(int n = 1, VAL SUM_UNITY = 0) {
		init(n, SUM_UNITY);
	}

	void init(int n = 1, VAL SUM_UNITY = 0) {
		par.resize(n); rank.resize(n); num_same.resize(n); diff_weight.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, num_same[i] = 1, diff_weight[i] = SUM_UNITY;
	}

	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			int r = root(par[x]);
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = r;
		}
	}

	int calc_num_same(int x) {
		return num_same[root(x)];
	}

	VAL calc_weight(int x) {
		root(x);
		return diff_weight[x];
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y, VAL w) {
		w += calc_weight(x); w -= calc_weight(y);
		x = root(x); y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y), w = -w;
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		diff_weight[y] = w;
		num_same[x] += num_same[y];
		return true;
	}

	VAL diff(int x, int y) {
		return calc_weight(y) - calc_weight(x);
	}

	friend ostream& operator << (ostream& s, UnionFind uf) {
		map<int, vector<int> > res;
		for (int i = 0; i < uf.size_uf; ++i) {
			int r = uf.root(i);
			res[r].push_back(i);
		}
		for (map<int, vector<int> >::iterator it = res.begin(); it != res.end(); ++it) {
			s << endl;
			for (int j = 0; j < (int)it->second.size(); ++j) {
				s << it->second[j] << "(" << uf.calc_weight(it->second[j]) << "), ";
			}
		}
		return s << endl;
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	UnionFind<int> uf(N, 0);
	for (int i = 0; i < M; ++i) {
		int l, r, d;
		cin >> l >> r >> d;
		--l, --r;
		if (uf.issame(l, r)) {
			int diff = uf.diff(l, r);
			if (diff != d) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			uf.merge(l, r, d);
		}
	}
	cout << "Yes" << endl;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int A, B;
    cin >> A >> B;
    if (A == B) {
        cout << A + A << endl;
    } else {
        cout << max(A, B) + max(A, B) - 1 << endl;
    }
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INTINF = 1<<30;
const int MOD = 1000000007;

void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

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

int H,W,C[10][10], A[202][202];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    rep(i,10) rep(j,10) cin >> C[i][j];
    rep(y,H) rep(x,W) cin >> A[y][x];

    rep(k,10) rep(i,10) rep(j,10) C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
    int ans = 0;
    rep(y,H) rep(x,W) if( 0 <= A[y][x]) ans += C[A[y][x]][1];
    cout << ans << endl;

}


Measured memory_bytes: 384
program abc
	implicit none
	integer :: i,j,b
    integer(16) :: h,w,a

	read(*,*) h,w

	a = h * w
    
    if(mod(a,2) /= 0) then
    	a = (h * w + 1) / 2
    else
    	a = h * w / 2
    endif
    
    if(h == 1 .or. w == 1) a = 1
	
	write(*,*) a
    
end program abc


Measured memory_bytes: 256
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
/*---------------------------------------*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int sx,sy,tx,ty; cin>>sx>>sy>>tx>>ty;
  REP(i, ty-sy) cout << 'U';
  REP(i, tx-sx) cout << 'R';
  REP(i, ty-sy) cout << 'D';
  REP(i, tx-sx) cout << 'L';
  cout << 'L';
  REP(i, ty-sy+1) cout << 'U';
  REP(i, tx-sx+1) cout << 'R';
  cout << 'D' << 'R';
  REP(i, ty-sy+1) cout << 'D';
  REP(i, tx-sx+1) cout << 'L';
  cout << 'U';
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  IN(N,K);
  vll h(N);
  REP(i,N) IN(h[i]);
  sort(ALL(h));
  ll ans = INFLL;
  REP(i,N-K+1){
    chmin(ans, h[i+K-1]-h[i]);
  }

  OUT(ans);

  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

int main(){fastio
    ll n;cin>>n;
    string s[n];
    rep(i,0,n-1){
        string k;cin>>k;
        sort(k.begin(),k.end());
        s[i]=k;
    }
    sort(s,s+n);
    ll ans=0;
    ll pos=0;
    while(pos<=n-1){
        ll ne=pos;
        while(ne<=n-1){
            if(s[pos]==s[ne]){
                ne++;
            }else{
                break;
            }
        }
        ll x=ne-pos;
        ans+=x*(x-1)/2;
        pos=ne;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define debug(x) cout << #x << " = " << x << endl;
#define debret(x) debug(x) ; return 0;
#define pb(x) push_back(x)
#define MOD 1000000007

using namespace std;

int main(){

    int N,T;
    cin >> N >> T;

    int ans[N];

    REP(i,N){
        cin >> ans[i];
    }
    int min = ans[0];
    int max_diff = 0;
    REP(i,N){
        if(min > ans[i]){
            min = ans[i];
        }else{
            max_diff = max(ans[i]-min,max_diff);
        }
    }

    min = ans[0];
    int cnt = 0;
    REP(i,N){
        
        if(ans[i] - min == max_diff) cnt++;
        
        if(min > ans[i]){
            min = ans[i];
        }
    }

    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 640
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
a = []
b = []

for i in range(N):
    a.append(K-Q)

#print(a)



for i in A:
    a[i-1] += 1
    #print(a)
    

for i in a:
    if i <= 0:
        print("No")

    else:
        print("Yes")

Measured memory_bytes: 11764
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<string, int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

int main(){
	
	long long int n, m, d;
	cin >> n >> m >> d;
	
	long long int num, den;
	
	if(d == 0){
		num = n * (m - 1);
	}else{
		num = 2 * (n - d) * (m - 1);
	}
	den = n * n;
	
	printf("%.10f", ((double)num) / den);
	
	return 0;
}

Measured memory_bytes: 256
def solve():
  n, x, y = list(map(int, input().split()))

  dist_count = [0 for _ in range(n)]

  x -= 1
  y -= 1
  for i in range(n):
    for j in range(i + 1, n):
      min_dist = min(abs(i - j), min(abs(i - x) + 1 + abs(y - j), abs(i - y) + 1 + abs(x - j)))
      dist_count[min_dist] += 1
  
  dist_count.pop(0)
  for dist in dist_count:
    print(dist)

if __name__ == "__main__":
  solve()

Measured memory_bytes: 3444
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int N = nextInt();




		System.out.println(N%2==0?N:N*2);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

int main() {
  vector<int> vec(32);
  vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  int i;
  i = k - 1;
  cout << vec.at(i);
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

long long ans = 1e15;

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }

    for (int i = 0; i <= N - K; i++) {
        ans = min(ans, abs(x[i]) + abs(x[i + K - 1] - x[i]));
    }
    for (int i = N - 1; i >= K - 1; i--) {
        ans = min(ans, abs(x[i]) + abs(x[i] - x[i - K + 1]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import collections, itertools, copy


class MaximumFlow:
    def ford_fulkerson(self, G, s, t):
        G_residue = copy.deepcopy(G)

        def dfs(start, used):
            if start == t:
                return [start]
            for end, cap in G_residue[start].items():
                if cap > 0 and end not in used:
                    used.add(end)
                    ret = dfs(end, used)
                    if ret:
                        return ret + [start]
            return []

        flow_value = 0
        while True:
            root = dfs(s, set([s]))
            if root:
                root = root[::-1]
                residue = min(
                    [G_residue[a][b] for a, b in zip(root, root[1:])])
                flow_value += residue
                for a, b in zip(root, root[1:]):
                    G_residue[a][b] -= residue
                    G_residue[b][a] += residue
            else:
                return (flow_value, G_residue)


N = int(input())
AB = [[int(_) for _ in input().split()] for _ in range(N)]
CD = [[int(_) for _ in input().split()] for _ in range(N)]
G = collections.defaultdict(lambda: collections.defaultdict(int))
for a, b in AB:
    G[-1][1000 * a + b] = 1
for c, d in CD:
    G[1000 * c + d][-2] = 1
for ab, cd in itertools.product(AB, CD):
    a, b = ab
    c, d = cd
    if a < c and b < d:
        G[1000 * a + b][1000 * c + d] = 1
flow_value, G_residue = MaximumFlow().ford_fulkerson(G, -1, -2)
print(flow_value)
flow_dict = collections.defaultdict(lambda: collections.defaultdict(int))
for a in G:
    for b in G[a]:
        if G_residue[b][a] > 0:
            flow_dict[a][b] = G_residue[b][a]


Measured memory_bytes: 10176
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
tmp = a[0] + 1
satisfactions = []
for i in a:
    satisfaction = b[i-1]
    if i == tmp:
        satisfaction = satisfaction + c[i-2]
    satisfactions.append(satisfaction)
    tmp = i + 1

print(sum(satisfactions))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int i , j , n;
		int cnt1 = 0 , cnt2 = 0 , cnt3 = 0;
		n = scan.nextInt();
		for (i = 0;i < n;i ++) {
			int value = scan.nextInt();
			if (value % 4 == 0) {
				cnt3 ++;
			} else if (value % 2 == 0) {
				cnt2 ++;
			} else {
				cnt1 ++;
			}
		}
		if (cnt1 > 0) {
			if (cnt2 > 0) {
				if (cnt3 >= cnt1) {
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			} else {
				if (cnt3 >= cnt1 - 1) {
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			}
		} else {
			System.out.println("Yes");
		}
		
	}
	
	
}



















Measured memory_bytes: 47564
//
// Created on 2020/05/15.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int n;
    int m;
    cin>>n>>m;
    int ans_l = 0;
    int ans_r = n;

    for (int i = 0; i < m; ++i) {
        int l;
        int r;
        cin>>l>>r;
        l--;
        ans_l = max(l,ans_l);
        ans_r = min(r,ans_r);
    }
    int ans = max(ans_r-ans_l,0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	string S; cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S.at(i) == ',')cout << ' ';
		else cout << S.at(i);
	}
	cout << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
A,B=map(int,input().split())
a=[["#"]*100 for i in range(50)]
b=[["."]*100 for i in range(50)]


for i in range(A-1):
    a[2*(i//50)][2*(i%50)]="."
for i in range(B-1):
    b[2*(i//50)+1][2*(i%50)]="#"
print(100,100)
for i in a:
    print("".join(i))
for i in b:
    print("".join(i))


Measured memory_bytes: 38384
def match(s, t, ls, lt, i):
    return all(s[i + j] == '?' or t[j] == '?' or s[i + j] == t[j] for j in range(min(ls - i, lt)))


a = input()
b = input()
c = input()
la, lb, lc = len(a), len(b), len(c)

ab = [match(a, b, la, lb, i) for i in range(0, la)] + [True] * 8000
ac = [match(a, c, la, lc, i) for i in range(0, la)] + [True] * 8000
bc = [match(b, c, lb, lc, i) for i in range(0, lb)] + [True] * 8000
ba = [match(b, a, lb, la, i) for i in range(1, lb)] + [True] * 8000
ca = [match(c, a, lc, la, i) for i in range(1, lc)] + [True] * 8000
cb = [match(c, b, lc, lb, i) for i in range(1, lc)] + [True] * 8000
ab.extend(reversed(ba))
ac.extend(reversed(ca))
bc.extend(reversed(cb))

ans = la + lb + lc

for db in range(-lb - lc, la + lc + 1):
    ab_ok = ab[db]
    if not ab_ok:
        continue
    for dc in range(-lb - lc, la + lb + 1):
        ac_ok = ac[dc]
        bc_ok = bc[dc - db]
        if ac_ok and bc_ok:
            ans = min(ans, max(la, db + lb, dc + lc) - min(0, db, dc))

print(ans)


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

const int M=2000,N=200009;
const int mod=1e9+7;
const int inv2=500000004;

int dp[(M<<1)+9][(M<<1)+9];
int fac[(M<<2)+9],inv[(M<<2)+9];
int zero=M+2,a[N],b[N],n,ans;

inline int read(){
	int res=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		res=(res<<1)+(res<<3)+ch-'0';
		ch=getchar();
	}
	return res*f;
}

inline void Init()
{
	fac[0]=inv[0]=inv[1]=1;
	for(int i=1;i<=M*4;i++) fac[i]=1ll*fac[i-1]*i%mod;
	for(int i=2;i<=M*4;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1;i<=M*4;i++) inv[i]=1ll*inv[i-1]*inv[i]%mod;
}

inline int C(int n,int m)
{
	return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read(),b[i]=read(),dp[zero-a[i]][zero-b[i]]++;	
	Init();
	for(int i=1;i<=M*2+2;i++)
		for(int j=1;j<=M*2+2;j++)
		{
			dp[i][j]=(dp[i][j]+(dp[i-1][j]+dp[i][j-1])%mod)%mod;
		}
	for(int i=1;i<=n;i++)
	{
		ans=(ans+dp[zero+a[i]][zero+b[i]])%mod;
		ans=(ans-C(2*a[i]+2*b[i],2*a[i])+mod)%mod;
	}
	ans=1ll*ans*inv2%mod;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 64512
n = int(input())
As = []
for _ in range(2):
    r = [int(s) for s in input().split()]
    As.append(r)
ss = []
for i in range(2):
    r = [0]
    s = 0
    for j in range(n):
            a = As[i][j]
            s += a
            r.append(s)
    ss.append(r)
ans = 0
for i in range(1, n + 1):
    ans = max(ans, ss[0][i] + ss[1][n] - ss[1][i - 1])
print(ans)

Measured memory_bytes: 3064