akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <iomanip>
#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 <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;

int main()
{
    int x, y;
    cin >> x >> y;

    vector<int> a = {1,3,5,7,8,10,12};
    vector<int> b = {4,6,9,11};
    vector<int> c = {2};

    rep(i, 7)
    {
        if(x == a.at(i))
            x = -1;
        if(y == a.at(i))
            y = -1;
    }
    rep(i, 4)
    {
        if(x == b.at(i))
            x = -2;
        if(y == b.at(i))
            y = -2;
    }
    rep(i, 1)
    {
        if(x == c.at(i))
            x = -3;
        if(y == c.at(i))
            y = -3;
    }
    if(x == y) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
/*input

*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits>
#include <random>

using namespace std; 

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

int const MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	if(s[n-1]=='s') s+="es";
	else s+="s";
	cout << s;
	return 0;	
}

Measured memory_bytes: 3648
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#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 + 3;
const int MOD = (int)1e9 + 7;

int n, ile[27], res;
string s;

signed main() {
  init_ios();
  cin >> n >> s;
  for (char c: s) {
    int tmp = 1;
    for (int i = 0; i < 26; ++i)
      if (i != (int)(c-'a'))
        tmp = (tmp*(1+ile[i]))%MOD;
    res = (res+tmp)%MOD;
    ++ile[c-'a'];
  }
  cout<<res<<"\n";
}

Measured memory_bytes: 512
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

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

  if(a <= c && c <= b)
  {
    cout << min(b - c,d - c) << endl;
  }
  else if(a <= d && d <= b)
  {
    cout << min(d - a,d - c) << endl;
  }
  else if(c <= a && a <= d && c <= b && b <= d)
  {
    cout << b - a << endl;
  }
  else
  {
    cout << 0 << endl;
  }
  



  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
//
//  main.cpp
//  c
//
//  Created by 13B10694 on 2015/06/01.
//  Copyright (c) 2015????´ 13B10694. All rights reserved.
//

#include <iostream>
#include <vector>
#include<stdio.h>
#include <algorithm>
#include<string.h>
using namespace std;

int now=1;

class team{
    
public:
    int id, pen, sol;
    int wrong[12];
    vector <int> solved;
    team(){
        memset(wrong, 0, sizeof(wrong));
        id=now++;
        pen=0;sol=0;
    }
    ~team(){
        solved.clear();
    }
    
    bool operator < (const team& b) const
    {
        return solved.size()==b.solved.size() ? pen== b.pen ? id<b.id : pen<b.pen : solved.size()>b.solved.size();
    }
};

int main() {
    int t,p,r;
    while(cin>>t>>p>>r,t){
        now=1;
        vector<team> tea(t);

        for(int i=0;i<r;i++){
            int ti, pi, tim;
            string mes;
            cin>>ti>>pi>>tim>>mes;
            ti-=1;
            if(mes=="WRONG"){
                tea[ti].wrong[pi]++;
                continue;
            }
            if(find(tea[ti].solved.begin(),tea[ti].solved.end(),pi)!=tea[ti].solved.end()){
                continue;
            }
            tea[ti].solved.push_back(pi);
            tea[ti].pen += tea[ti].wrong[pi]*1200+tim;
  
        }
        sort(tea.begin(),tea.end());
        for(int i=0;i<t;i++){
            cout<<tea[i].id<<" "<<tea[i].solved.size()<<" "<<tea[i].pen<<endl;
        }
       tea.clear();
    }
    
    return 0;
}

Measured memory_bytes: 1252
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    long N = sc.nextLong();
    long ans = 10000000000000L;
    for(long i=1; i*i<=N; i++){
      if(N % i == 0) ans = Math.min(ans, N / i + i - 2);
    }
    out.println(ans);
  }
}

Measured memory_bytes: 23124
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int l[10],v1,v2,i,len=0,j;
    double time,d;
    
    while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v1,&v2)!=EOF){
        for(i=0;i<10;i++){
            len+=l[i];
        }
        //printf("len:%d\n",len);
        time=(double)len/((double)v1+(double)v2);
        d=time*(double)v1;
        //printf("time:%lf\n",time);
        //printf("d:%lf\n",d);
        len=0;
        for(j=0;j<10;j++){
            len+=l[j];
            if(len>=d){
                printf("%d\n",j+1);
                break;
            }
        }
        len=0;
    }
    return 0;
}

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

int main() {
    int N;
    int B[100];
    int ans = 0;
    
    cin >> N;
    
    for (int i = 0; i < (N - 1); i++) {
        cin >> B[i];
    }
    
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            ans += B[i];
        }
        else if (i == (N - 1)) {
            ans += B[i - 1];
        }
        else {
            ans += min(B[i], B[i - 1]);
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

int main() {
  int p,q,r;
  cin>> p >> q >> r ;
  vector<int> vec(3);
  vec.at(0)=p+q;
  vec.at(1)=p+r;
  vec.at(2)=q+r;
  int min=vec.at(0);
  for(int i=1;i<=2;i++){
  	if(min>vec.at(i)){
  		min=vec.at(i);
  		}
  	}
	cout<< min <<endl;
  return 0;
}


Measured memory_bytes: 256
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]

ans = min(a) + min(b)
for i, (xi, yi, ci) in enumerate(xyc):
    ans = min(ans, max(0, a[xi - 1] + b[yi - 1] - ci))

print(ans)

Measured memory_bytes: 38564
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//https://www.youtube.com/watch?v=zG1L4vYuGrg&feature=youtu.be 


//-----CODE------//
void solve(void)
{
  int n;cin>>n;
  vector<int> a (n,0);  
  vector<int> b (n,0);  
  int sum = 0;
  int mm = INF;
  int flg = 1;
  for (int i = 0; i < n; i++)
  {
    int x,y;cin>>x>>y;
    a[i] = x;
    b[i] = y;
    sum += x;
    if(x != y)flg = 0;
    if(x > y)
    {
      chmin(mm,y);
    }
  }
  if(flg)
  {
    cout<<0<<endl;
    return;
  }
  cout<<sum -mm<<endl;
  


  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) a[i]--;
  dump(a);
  int ans = 0;
  int j = 0;
  rep(i, n) {
    dump(i, j);
    while (j < n && a[j] != i) {
      j++;
      ans++;
    }
    if (j >= n) break;
    dump(i, j);
    if (a[j] == i) j++;
  }
  if (ans == n) ans = -1;
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N, R;
	cin >> N >> R;
	if(N>=10) cout << R << endl;
	else {
		cout << R + 100 * (10 - N) << endl;;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  int min=n;
  int sum[n];
  for(int i=0;i<n;i++){
    if(i!=0){
      sum[i]=sum[i-1];
    }else{
      sum[i]=0;
    }

    if(i==0){
      string x,y;
      x=s.substr(0,i);
      y=s.substr(i+1,n);
      for(int j=0;j<x.size();j++){
        if(x[j] == 'W'){
          sum[i]++;
        }
      }
      for(int j=0;j<y.size();j++){
        if(y[j] == 'E'){
          sum[i]++;
        }
      }
    }else{
      if(s[i-1] == 'W'){
        sum[i]++;
      }
      if(s[i] == 'E'){
        sum[i]--;
      }
    }
    if(min>sum[i]){
      min=sum[i];
    }
    //cout << x<< " "<< y<<" "<<sum[i] << endl;
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 1884
s = gets.chomp
n = s.length
ans = [0]*(n+1)

i = 0
while i < n
  if s[i] == "<"
    while i < n && s[i] == "<"
      ans[i+1] = ans[i] + 1
      i += 1
    end
  else
    i += 1
  end
end

i = n-1
while i >= 0
  if s[i] == ">"
    while i >= 0 && s[i] == ">"
      ans[i] = [ans[i],ans[i+1] + 1].max
      i -= 1
    end
  else
    i -= 1
  end
end

#p ans
p ans.inject(:+)

Measured memory_bytes: 6796
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N, K := getInt(), getInt()

	ans := math.MaxInt64
	n := 1 << uint(N)
	for i := 0; i < n; i++ {
		cnt := 1
		for j := 0; j < N; j++ {
			if (i>>uint(j))%2 == 0 {
				cnt *= 2
			} else {
				cnt += K
			}
		}
		ans = min(ans, cnt)
	}

	out(ans)
}


Measured memory_bytes: 640
#include<stdio.h>
#define N 101


int main(){

  int M[N][N],n,i,j,a,b,k;


  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&a,&k);
    for(j=0;j<k;j++){
      scanf("%d",&b);
      M[a-1][b-1]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      printf("%d ",M[i][j]);
    }
    printf("%d\n",M[i][j]);
  }

  return 0;
}



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

using namespace std;

int main(){
    string str;
    cin >> str;
    string from = ",";
    string to = " ";
    string::size_type pos = str.find(from);
    while(pos != string::npos){
        str.replace(pos, from.size(), to);
        pos = str.find(from, pos + to.size());
    }

    cout << str << endl;  // "aa bbbbb cc aa bbbbb cc"
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace B
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var an = Console.ReadLine().Split().Select(int.Parse).ToList();

			for (var i = 0;; i++)
			{
				if (an.Any(a => a % 2 != 0))
				{
					Console.WriteLine(i);
					return;
				}

				an=an.ConvertAll(a => a /= 2);
			}
		}
	}
}

Measured memory_bytes: 13268
//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;
 
using ll = long long;
 
const ll inf = 1e18;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N], dp[N];

void solve(){
	ll n;
	cin >> n;
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
	}
	dp[2] = abs(a[2] - a[1]);
	for(int i = 3; i <= n; ++i){
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i - 2] - a[i]));
	}
	cout << dp[n];
}
 
int main(int argc, char const *argv[]){
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
    	solve();
    }
}
// nEro

Measured memory_bytes: 1792
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

int N, Z, W;
int flag = 0;

int main()
{
	scanf("%d %d %d", &N, &Z, &W);
	int arr[N];

	for(int i = 0; i < N; i++)
	{
		scanf("%d", &arr[i]);
	}
	if(N == 1)
	{
		printf("%d", abs(arr[N - 1] - W));
	}
	else
	{
		// int ans1 = abs(arr[N - 1] - arr[N - 2]);
		// int ans2 = abs(arr[N - 1] - W);
		// cout << ans1 << " " << ans2 << " ";
		int finalAns = max(abs(arr[N - 1] - arr[N - 2]), abs(arr[N - 1] - W));
		printf("%d\n", finalAns);
	}

	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll l, r;
    cin >> l >> r;
    if(r-l >= 2025){
        cout << 0 << "\n";
    }else {
        ll ans = 2019;
        for (ll i = l; i <= r; ++i) {
            for (ll j = i+1; j <= r; ++j) {
                ans = min(ans, i*j%2019);
            }
        }
        cout << ans << "\n";
    }
    return 0;
}

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


#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";

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



template <class T> inline T biton(T n, T pos)
{
	return n | ((T)1 << pos);
}
template <class T> inline T bitoff(T n, T pos)
{
	return n & ~((T)1 << pos);
}
template <class T> inline T ison(T n, T pos)
{
	return (bool)(n & ((T)1 << pos));
}
template <class T> inline T gcd(T a, T b)
{
	while (b)
	{
		a = a % b;
		swap(a, b);
	}
	return a;
}
template <class T> inline T bigmod(T p, T e, T m)
{
	T ret = 1;
	for (; e > 0; e >>= 1)
	{
		if (e & 1)
			ret = (ret * p) % m;
		p = (p * p) % m;
	}
	return (T)ret;
};



#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " is " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define debug(...)
#endif




void solve()
{
	long long n, k;
	cin >> n >> k;

	long long one = n % k;
	long long another = k - one;

	cout << min(one, another);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);
	cout.tie(nullptr);
	cin.tie(nullptr);

	int t = 1;

	while (t--)
	{
		solve();
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main()
{
    int a=0,b=0,i,j;
    string n;
    cin >> n;
    for(i=0;i<n.size();i++)
        a+=n[i]-'0';
    for(i=0;i<n.size();i++)
        b=b*10+(n[i]-'0');
    if(b%a==0)
        cout << "Yes"<< endl;
    else
        cout << "No" <<endl;
    return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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 (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int r, d, x;
  cin >> r >> d >> x;
  FOR(i, 1, 11) {
    x = r * x - d;
    print(x);
  }
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n){
    ll ans = 0,sum = 0;
    vector<ll> v(n);
    rep(i,n){
      cin >> v[i];
    }
    sort(all(v));
    rep(i,n){
      sum += v[i];
      ans += sum;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	string s;
	cin >> s;
	int ans = 0;
	for(auto &it:s)
	{
		if(it == '?')
			it = 'D';	
	}
	for(int i = 0; i < s.size(); i++)
	{
		ans += (s[i] == 'D');
		if(i >= 1)
			ans += (s[i - 1] == 'P' && s[i] == 'D');
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 3740
n = int(input())
a = list(map(int, input().split()))

x = min(a)
y = max(a)
if y - x > 1:
    print('No')

elif y == x:
    if n == x + 1 or 2 * x <= n:
        print('Yes')
    else:
        print('No')

else:
    x_cnt = a.count(x)
    y_cnt = a.count(y)

    if y > x_cnt and 2 * (y - x_cnt) <= y_cnt:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 14008
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
long long V[60];
long long B[60];
long long calc(int a,long long b){
	long long ret=0;
	b--;
	if(b==0)return ret;
	if(b>=V[a-1]){
		b-=V[a-1];
		ret+=B[a-1];
	}else{
		ret+=calc(a-1,b);
		return ret;
	}
	if(b==0)return ret;
	ret++;b--;
	if(b==0)return ret;
	if(b>=V[a-1]){
		b-=V[a-1];
		ret+=B[a-1];
	}else{
		ret+=calc(a-1,b);
		return ret;
	}
	return ret;
}
int main(){
	int a;
	V[0]=1;
	B[0]=1;
	for(int i=1;i<55;i++)V[i]=V[i-1]*2+3;
	for(int i=1;i<55;i++)B[i]=B[i-1]*2+1;
	long long b;scanf("%d%lld",&a,&b);
	printf("%lld\n",calc(a,b));
}

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

int main(){
  int n;
  cin >> n;
  bool oddis = false;
  for(int i=0; i<n; ++i){
    int x;
    cin >> x;
    if(x%2){
      oddis = true;
      break;
    }
  }
  if(oddis) cout << "first" << endl;
  else cout << "second" << endl;
}

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

#define debug(a) cerr << #a << ": " << a << '\n'
#define endl '\n'

typedef long long ll;
const ll maxn = 200010;

void solve(ll case_no)
{
    ll n;
    cin >> n;

    vector<ll> a(n), b(n);
    for (ll i = 0; i < n; i++)
        cin >> a[i] >> b[i];

    ll res = 0;
    for (ll i = n - 1; i >= 0; i--)
    {
        a[i] += res;
        if (a[i] % b[i])
            res += b[i] - a[i] % b[i];
    }

    cout << res << endl;
}

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

    ll test_cnt = 1, case_no = 1;
    // cin >> test_cnt;
    while (case_no <= test_cnt)
        solve(case_no++);

    return 0;
}

Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cstring>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;


int main()
{
	FAST;
	int row,column;
	
	cin >> row >> column;
	char ch[200][200];
	
	memset(ch , '#', sizeof(ch));

    for(int i=1 ; i<=row ; i++)
    {
        for(int j=1 ; j<=column ; j++)
            cin >> ch[i][j];
    }

	for(int i=0 ; i<=row+1 ; i++)
	{
		for(int j=0 ; j<=column+1 ; j++)
			cout << ch[i][j];
		cout << "\n";
	}
	return 0;
}

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

int main(){
  long r,c;
  cin >> r >> c;

  long long  v[102][102] = {0};

  rep(i,r){
    rep(j,c){
      cin >> v[i][j];
    }
  }

  rep(i,r){
    rep(j,c){
        v[i][c] += v[i][j];
    }
  }

  rep(j,c+1){
    rep(i,r){
        v[r][j] += v[i][j];
    }
  }

  rep(i,r+1){
    rep(j,c+1){
      if(j!=c) cout << v[i][j] << " ";
      else cout << v[i][j] ;
    }
    cout << endl;
  }
    
}


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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#define db(x) cout << "> " << #x << " = " \
	<< (x) << '\n'
#define db2(x, y) cout << "> " << #x << " = " \
	<< (x) << ", " << #y << " = " << (y) << '\n'
#define db3(x, y, z) cout << "> " << #x << \
	" = " << (x) << ", " << #y << " = " << \
	(y) << ", " << #z << " = " << (z) << '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
typedef map<int, int> mii;
typedef set<int> si;

const int MX = 2e5 + 5, MX2 = 100000;
int n, x, y;
vvi adj(MX);
vi L, R;
bool vis[MX];

void dfs(int node, int dep = 0) {
	if (dep % 2 == 0)
		L.pb(node);
	else
		R.pb(node);
	vis[node] = true;
	for (auto& child : adj[node])
		if (!vis[child])
			dfs (child, dep + 1);
}

int main() {
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> x >> y;
		--x, --y;
		adj[x].pb(y + MX2);
		adj[y + MX2].pb(x);
	}
	ll ans = 0;
	for (int i = 0; i < MX; ++i) {
		if (!vis[i]) {
			L.clear(), R.clear();
			dfs(i);
			for (auto& l : L) {
				ans += sz(R) - sz(adj[l]);
			}
		}
	}
	cout << ans << '\n';
	return 0;
}


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

int main()
{
	int N;
	string cmd, param;
	map<string, int> d;
	
	cin >> N;
	for(int i = 0; i < N; ++i)
	{
		cin >> cmd >> param;
		if(cmd == "insert")
		{
			d[param] = 1;
		}
		else
		{
			if(d.find(param) == d.end())
			{
				cout << "no" << endl;
			}
			else
			{
				cout << "yes" << endl;
			}
		}
	}

    return 0;
}



Measured memory_bytes: 36892
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int SX, SY, TX, TY;
    cin >> SX >> SY >> TX >> TY;
    rep(i, 0, TY - SY) {
        cout << "U";
    }
    rep(i, 0, TX - SX) {
        cout << "R";
    }
    rep(i, 0, TY - SY) {
        cout << "D";
    }
    rep(i, 0, TX - SX + 1) {
        cout << "L";
    }
    rep(i, 0, TY - SY + 1) {
        cout << "U";
    }
    rep(i, 0, TX - SX + 1) {
        cout << "R";
    }
    cout << "D";
    cout << "R";
    rep(i, 0, TY - SY + 1) {
        cout << "D";
    }
    rep(i, 0, TX - SX + 1) {
        cout << "L";
    }
    cout << "U" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long n,k,ma=-1e9;
long a[10001],dd[100000001];
string b[100000001];
int kt(long j)
{
    for(long i=1;i<=n;i++)
        if(dd[j-a[i]]==0) return 0;
    return 1;
}
int main()
{
    cin>>n>>k;
    for(long i=1;i<=n;i++)
        {
            cin>>a[i];
            ma=max(ma,a[i]);
            dd[a[i]]=1;
        }
   for(long i=1;i<=k;i++)
   {
       for(long j=1;j<=n;j++)
           if(i>=a[j])
       {
           if(dd[i-a[j]]==0) dd[i]=1;
       }
   }
   if(dd[k]==1) cout<<"First";
   if(dd[k]==0) cout<<"Second";
}


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
#define PRINT_ENTER() cout << endl;

int main() {
    /* code */
    int n;
    cin >> n;
    int a;
    int bit{};
    REP(i, n) {
        cin >> a;
        bit = (a | bit);
    }
    int counter{};
    while ((bit & 1) == 0) {
        bit = bit >> 1;
        counter++;
    }
    PRINT(counter);
    return 0;
}

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

int main()
{
	int n, k, c = 0;
	std::string s;
	std::vector<std::pair<int, int>> v;
	
	std::cin >> n >> k;
	std::cin >> s;
	
	int  l = n;
	char p = s[0];
	
	for (int i = 1; i < n; ++i)
	{
		if (s[i] == p)
		{
			if (l != n)
			{
				v.push_back(std::make_pair(l, i));
				l = n;
				
				if (v.size() == k)
				{
					break;
				}
			}
		}
		else
		{
			if (l == n)
			{
				l = i;
			}
		}
	}
	
	if (l != n && v.size() < k)
	{
		v.push_back(std::make_pair(l, n));
	}
	
	for (int i = 0; i < v.size(); ++i)
	{
		
		for (int l = v[i].first, r = v[i].second; l < r; ++l)
		{
			s[l] = p;
		}
	}
	
	for (int i = 1; i < n; ++i)
	{
		if (s[i - 1] == s[i])
		{
			++c;
		}
	}
	
	std::cout << c << std::endl;
	
	return 0;
}


Measured memory_bytes: 956
from itertools import product
def main():
    n, m, x = map(int, input().split())
    bk = [list(map(int, input().split())) for _ in range(n)]
    f = False
    ans = float("inf")
    for arr in product([True, False], repeat=n):
        mon = 0
        t = [0]*m
        for i in range(n):
            if arr[i]:
                mon += bk[i][0]
                for j in range(1, m+1):
                    t[j-1] += bk[i][j]
        sf = True
        for i in range(m):
            if t[i] < x:
                sf = False
                break
        if sf:
            f = True
            if mon < ans:
                ans = mon
    if f:
        print(ans)
    else:
        print("-1")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9244
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#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 FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int a,b;
    while (cin >> a >> b) {
        int ans = 0;
        FOR(i,0,2) { 
            if  (a < b)
                swap(a,b);
            ans += a;
            a --;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//
// Created by moono on 2018/10/27.
//

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define ull long long

ull a, b, x;

ull f(ull i){
    if( i == -1) return 0;
    else return i / x + 1;
}


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

    //
    cout << f(b) - f(a-1) << endl;


    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;

class Program
{
    static void Main(string[] args)
    {
        //入力を受け取る
        //var N = long.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        
        if(A.Sum() >= 22){
          Console.WriteLine("bust");
        }else{
          Console.WriteLine("win");
        }
        
    }
}


Measured memory_bytes: 13396
#include<cstdio>
#include<string.h>
char aa[10];int bb[450];
main()
{
	scanf("%s",aa);
	memset(bb,0,sizeof(bb));
	int i;
	for(i=0;i<4;i++)
	{
		bb[aa[i]]++;
	}
	int num=0;
	for(i=0;i<=400;i++)
	{
	if(bb[i]==2)
	num++;
	}
	if(num==2)
	printf("Yes\n");
	else
	printf("No\n");
	
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

#include <random>
vector<int> edg[100003];
bool used[100003];
int deg[100003];
vector<int> ans;
random_device rnd;
mt19937 mt(rnd());

bool func(int start, int pos) {
	for (int i = 0; i < (int)edg[pos].size(); ++i) --deg[edg[pos][i]];

	if (deg[start] == 0 && deg[pos] == 0) {
		ans.push_back(pos);
		return true;
	}
	used[pos] = true;
	for (int i = 0; i < (int)edg[pos].size(); ++i) {
		if (used[edg[pos][i]]) continue;
		if (func(start, edg[pos][i])) {
			ans.push_back(pos);
			return true;
		}
	}
	used[pos] = false;
	for (int i = 0; i < (int)edg[pos].size(); ++i) ++deg[edg[pos][i]];
	return false;
}

int main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b;
		--a; --b;
		edg[a].push_back(b);
		edg[b].push_back(a);
		++deg[a]; ++deg[b];
	}
	set<int> s;
	int pos;
	do {
		do {
			pos = mt() % n;
		} while (s.count(pos));
		s.insert(pos);
	} while (!func(pos, pos));
	cout << ans.size() << endl;
	for (int i = ans.size() - 1; i >= 0; --i) cout << ans[i] + 1 << (i == 0 ? "\n" : " ");
	return 0;
}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define MOD 1000000007
#define pb push_back
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
typedef unsigned long long int ull;
typedef long long int ll;

int a[500005];
int main()
{
    int n;
    cin>>n;
    int co=0,c1=0,c2=0,c3=0;
    for(int i=0;i<n;i++)
    {string s;
        cin>>s;
        if(s=="AC")
            co++;
        else if(s=="WA")
            c1++;
        else if(s=="TLE")
            c2++;
        else
            c3++;
    }
    cout<<"AC x "<<co<<endl;
    cout<<"WA x "<<c1<<endl;
    cout<<"TLE x "<<c2<<endl;
    cout<<"RE x "<<c3<<endl;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
  public static void main(String... args) {
	Scanner sc = new Scanner(System.in);
	String a = sc.nextLine();
	int b = 0;
	for (int index = 0; index < a.length() ; index++) {
		String c = a.substring(index, index + 1);
		if (c.equals("1")) {
			b = b + 1;
		}
	}
	System.out.println(b);
  }
}


Measured memory_bytes: 21844
function Main(inp) {
  
  inp = inp.split('\n').map( x => x.split(' '));
  inp = inp.map(x => x.map(y => parseInt(y, 10)) );

  const N = inp[0][0], M = inp[0][1], X = inp[0][2], Y = inp[0][3];
  var x = inp[1], y = inp[2];

  var maxX = X, minY = Y;
  for(var i=0;i<N;++i)maxX = Math.max(maxX, x[i]);
  for(var i=0;i<M;++i)minY = Math.min(minY, y[i]);

  if(maxX < minY)console.log('No War');
  else console.log('War');
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 20808
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

class UnionFind {
public:
  UnionFind(ll n) : par(n, -1), rnk(n, 0), cnt(n, 1), _size(n) {}

  bool same(ll x, ll y) {
    return root(x) == root(y);
  }
  void unite(ll x, ll y) {
    x = root(x); y = root(y);
    if (x == y) return;

    --_size;

    if (rnk[x] < rnk[y]) { swap(x, y); }
    par[y] = x;
    cnt[x] += cnt[y];
    if (rnk[x] == rnk[y]) { ++rnk[x]; }
  }
  ll root(ll x) {
    if (par[x] < 0) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
  ll count(ll x) {
    return cnt[root(x)];
  }
  ll size() {
    return _size;
  }

private:
  vector<ll> par;
  vector<ll> rnk;
  vector<ll> cnt; // The number of vertices in each connected components.
  ll _size; // The number of connected components. Decreases by unite.
};

int main(int argc, char** argv) {
  ll N, M;
  cin >> N >> M;

  UnionFind tree(N);
  rep(i, M) {
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    --X; --Y; // 0-indexied.
    tree.unite(X, Y);
  }

  cout << tree.size() << endl;
}


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

int main()
{
    int n, ans;
    cin >> n;
    vector<int> b(n - 1);
    for (int i = 0; i < n - 1; i++)
        cin >> b[i];

    ans = b[0];
    for (int i = 1; i < n - 1; i++)
    {
        ans += min(b[i - 1], b[i]);
    }
    ans += b[n - 2];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
const ll INF_LL = 1000000000000;
#define fir first
#define sec second
using namespace std;


int main()
{
    int n;
    cin >> n;
    if(n == 1)cout << "Hello World" << endl;
    else{
        int a,b; cin >> a >> b;
        cout << a + b << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define mod 1000000007


char matrix[1002][1002];
long long dp[1002][1002];
int n,m;



long long solution(){
    
    for(int i=0 ; i<n ; i++){
        if(matrix[i][0] == '#'){
            break;
        }
        dp[i][0] = 1;
    }


    for(int i=0 ; i<m ; i++){
        if(matrix[0][i] == '#'){
            break;
        }
        dp[0][i] = 1;
    }

    for(int i=1 ; i<n ; i++){
        for(int j=1 ; j<m ; j++){
            if(matrix[i][j] != '#'){
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
            }
        }
    }
    
    // for(int i=0 ; i<n ; i++){
    //     for(int j=0 ; j<m ; j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    
    return dp[n-1][m-1];

}


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

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

    cout<<solution()<<endl;


    

}

Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int sx = scan.nextInt();
		int sy = scan.nextInt();
		int tx = scan.nextInt();
		int ty = scan.nextInt();
		int x = tx - sx;
		int y = ty - sy;
		int x2 = (tx+1) - sx;
		int y2 = (ty+1) - sy;
		for (int i = 1; i <= x; i++) {
			System.out.print("R");
		}
		for (int i = 1; i <= y; i++) {
			System.out.print("U");
		}
		for (int i = 1; i <= x; i++) {
			System.out.print("L");
		}
		for (int i = 1; i <= y; i++) {
			System.out.print("D");
		}
		System.out.print("L");
		for (int i = 1; i <= y2; i++) {
			System.out.print("U");
		}
		for (int i = 1; i <= x2; i++) {
			System.out.print("R");
		}
		System.out.print("D");
		System.out.print("R");
		for (int i = 1; i <= y2; i++) {
			System.out.print("D");
		}
		for (int i = 1; i <= x2; i++) {
			System.out.print("L");
		}
		System.out.println("U");
	}
}
//RUULDDDRRUUULULLDDDR
//UURDDLLUUURRDRDDDLLU

Measured memory_bytes: 23488
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int a,b,c,d;
  	cin>>a>>b>>c>>d;
    
    while(1){
			c = c-b;
			a = a-d;
			if(a<=0 || c<=0)break;
		}
    if(c<=0)cout<<"Yes";
    else cout<<"No";
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    vector<bool> visited(n, false);
    visited.at(0) = true;
    int now = 1;
    int res = 0;
    while (now != 2)
    {
        now = a.at(now - 1);
        res++;
        if (visited.at(now - 1))
        {
            cout << -1 << endl;
            return 0;
        }
        visited.at(now - 1) = true;
    }
    cout << res << endl;
}

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

int main() {

  int input;
  cin >> input;
  int hour = input / 60 / 60;
  int minute = (input / 60) % 60;
  int second = input % 60;

  cout << hour << ":" << minute << ":" << second << endl;

  return 0;
}

Measured memory_bytes: 1164
n, m, x = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(n)]
ans = 10 ** 9
for i in range(2 ** n):
    sumA = [0 for i in range(m)]
    cost = 0
    for j in range(n):
        if ((i >> j) & 1):
            cost += C[j][0]
            for k in range(m):
                sumA[k] += C[j][k + 1]
    flag = True
    for l in range(m):
        if sumA[l] < x:
            flag = False
            break
    if flag:
        ans = min(ans, cost)
        
if ans == 10 ** 9:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9228
#!/usr/bin/python3

import os
import sys


def main():
    X, Y = read_ints()
    print(solve(X, Y))


MOD = 10 ** 9 + 7


def mpow(a, n):
    p = a
    v = 1
    while n > 0:
        if n & 1:
            v *= p
            v %= MOD
        n >>= 1
        p *= p
        p %= MOD
    return v


def solve(X, Y):
    s = X + Y
    if s % 3 != 0:
        return 0
    s //= 3

    a = 2 * s - X
    b = 2 * s - Y
    if a < 0 or b < 0:
        return 0

    c = a + b

    facts = [0] * (c + 1)
    facts[0] = 1
    for i in range(1, c + 1):
        facts[i] = (facts[i - 1] * i) % MOD

    return (facts[c] * mpow(facts[a], MOD - 2) * mpow(facts[b], MOD - 2)) % MOD


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43632