akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
using namespace std;

int main(){
  string S;
  int K;
  cin >> S >> K;
  int L=S.size();
  int N=min(L,K);
  char ans='1';
  for(int i=0; i<N; i++){
    if(S.at(i)!='1'){
      ans=S.at(i);
      break;
    }
  }
  cout << ans << endl;
}

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

int main(){
  int n,t,a;
  cin>>n>>t>>a;
  int h[n];
  rep(i,n){
    cin>>h[i];
  }
  double cnt=abs(a-(t-h[0]*0.006));
  int ans=1;
  for(int i=0;i<n;i++){
    double cnt1=abs(a-(t-h[i]*0.006));
    if(cnt1<cnt){
      cnt=cnt1;
      ans=i+1;
    }
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int T = sc.nextInt();
        
        int res;

        if(N%X==0){
            res = N*T/X;
        }else{
            res = T*(N/X+1);
        }
        
        System.out.println(res);
                
            
        
        
        
        
        
        }
    }

Measured memory_bytes: 35548
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n, m, x, y, a[105], b[105], maxm = -101, minn = 101;
	scanf("%d %d %d %d", &n, &m, &x, &y);
	for(int i = 1;i <= n;i++){
		scanf("%d", &a[i]);
		if(a[i] > maxm) maxm = a[i];
	}
	for(int i = 1;i <= m;i++){
		scanf("%d", &b[i]);
		if(b[i] < minn) minn = b[i];
	}
	int e = max(maxm, x);
	int f = min(minn, y);
	if(e < f) printf("No War\n");
	else printf("War\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner; 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a= sc.nextInt();
        int b = sc.nextInt();
        int available = 1 ;
        int ans =0;
        while(available<b){
            available += a - 1 ;
            ans++ ;
            
            
        }
        System.out.println(ans);
    }
    
  
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[100000],sum;
long long ans[100003];
int main(){
    int i,j;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    for(i=1;i<=n-1;i+=2){
        sum-=a[i]*2;
    }
    ans[n]=sum;
    for(i=n-1;i>=1;i--)ans[i]=a[i]*2-ans[i+1];
    for(i=1;i<=n;i++) printf("%lld ",ans[i]);
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6+7;
typedef long long ll;
int n, m, k;

int ar[maxn], in[maxn];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); //C++关同步
    cin >> n >> m;
    int s = 0;
    for(int i=1;i<=n;i++){
        cin >> ar[i];
        s += ar[i];
    }
    sort(ar + 1, ar + n + 1);
    if(ar[n - m + 1] * 4 * m >= s)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


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

using namespace std;
using lli = int_fast64_t;
using ulli = unsigned long long;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = copy(x);cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

constexpr lli MOD = (lli)1e9 + 7;
constexpr lli LIMIT = 1000000000000000000 * 5;


int main() {
	string s;
	cin >> s;
	if (s == "ABC")cout << "ARC" << endl;
	else cout << "ABC" << endl;

	return 0;
}



Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a!=1 && b!=1) {
            System.out.println(1);
        } else if (a!=2 && b!=2) {
            System.out.println(2);
        } else if (a!=3 && b!=3) {
            System.out.println(3);
        }
    }
}

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

const int N = 1e5 + 100, MOD = 1000 * 1000 * 1000 + 7;

int sum(int a, int b) {
	a += b;
	if(a < 0)
		a += MOD;
	else if(a >= MOD)
		a -= MOD;
	return a;
}

void _sum(int &a, int b) {
	a = sum(a, b);
}

int mul(int a, int b) {
	return 1LL * a * b % MOD;
}

void _mul(int &a, int b) {
	a = mul(a, b);
}

int n, u, v, dp[2][N];
vector<int> nei[N];

void dfs(int v, int par = -1) {
	dp[0][v] = dp[1][v] = 1;
	for (int u: nei[v])
		if(u != par) {
			dfs(u, v);
			_mul(dp[0][v], sum(dp[1][u], dp[0][u]));
			_mul(dp[1][v], dp[0][u]);
		}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n - 1; i++)
		cin >> u >> v, nei[--u].push_back(--v), nei[v].push_back(u);
	dfs(0);
	cout << sum(dp[0][0], dp[1][0]);
	return 0;
}

Measured memory_bytes: 13440
#17:09
n,k = map(int,input().split())
v = list(map(int,input().split()))
'''
左からa個
右からb個
k-a-b個以内捨てて良し
'''
can = []
nk = min(n,k)
for a in range(nk+1):
  if a != 0:
    x.append(v[a-1])
  else:
    x = []
  for b in range(nk+1-a):
    if b != 0:
      y.append(v[-b])
    else:
      y = []
    z = x + y
    z.sort()
    r = k - a - b
    tmp = 0
    if r < a+b:
      if z[r] < 0:
        for i in range(r,a+b):
          tmp += z[i]
      else:
        for i in range(a+b):
          if z[i] >= 0:
            tmp += z[i]
    else:
      for i in range(a+b):
        if z[i] >= 0:
          tmp += z[i]
    can.append(tmp)
print(max(can))

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

int main() {
  int n, p;
  long long int s = 0;
  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    scanf("%d", &p);
    s += p;
  }
  printf("%lld\n", s/n);
  return 0;
}

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


int main(void){

    string s; cin>>s;
    deque<char> que;
    int Bcount=0;
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='B')Bcount++;
        else{
            if(Bcount>0){
                Bcount--;
                continue;
            }
            que.push_front(s[i]);
        }
    }

    for(auto itr=que.begin();itr<que.end();itr++){
        cout<<*itr;
    }

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n;
	string s, t;
	cin >> n >> s >> t;
	string ans = "";
	for(int i=0;i<2*n;i++){
		if(i%2 == 0){
			ans += s.at(i/2);
		}else{
			ans += t.at(i/2);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
   int w,a,b;
   cin>>w>>a>>b;
   int p,q;
   p=min(a,b);
   q=max(a,b);

   if(p+w>=q)
   {
       cout<<"0";
   }
   else
    cout<<q-(p+w);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,count,k=1;
    
    cin >> A >> B;
    
    count = A;
    
    while(count < B){
        count += (A-1);
        k++;
    }
    if(B == 1) k = 0;
    cout << k << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  vector<ll> A(N+1), B(M+1);
  for (int i=1; i<=N; i++) cin >> A[i];
  for (int j=1; j<=M; j++) cin >> B[j];
  vector<ll> a(N+1), b(M+1);
  a[0] = 0, b[0] = 0;
  for (int i=1; i<=N; i++) a[i] = a[i-1]+A[i];
  for (int j=1; j<=M; j++) b[j] = b[j-1]+B[j];
  int res = 0, j = M;
  for (int i=0; i<=N; i++) {
    if (a[i]>K) break;
    while (b[j]>K-a[i]) j--;
    res = max(res, i+j);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 9592
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b,c;cin>>n;
    a = 0;//桁数
    b = n;
    c = 1;
    
    while(b>0){
        b /= 10;
        a++;
    }
    //cout <<a<<endl;
    b = n;
    //cout <<n<<endl;
    for(int i=2;i<a;i+=2){
        int d = 9;
        for(int j=1;j<i;j++){
            d*=10;
        }
        b-=d;
    }//a未満偶数桁の総数を抜いていく
    //cout << b<<endl;
    //cout <<a<<endl;
    if(a%2==0){
        //cout << a<<endl;
        for(int i=0;i<a-1;i++){
            c *= 10;
        }
        c--;
       //cout <<c<<endl;
        b += -n+c;
       // cout <<b<<endl;
    }
    cout << b <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll N,M,K;
  cin>>N>>M>>K;
  vector<vector<ll>> vec(N,vector<ll>(0));
  vector<ll> Q(N);
  for(ll i=0;i<M;i++) {
ll A,B;
   cin>>A>>B;
    vec[A-1].push_back(B);
    vec[B-1].push_back(A);
  }
  
  vector<vector<ll>> R(N,vector<ll>(0));
  for(ll i=0;i<K;i++) {
ll C,D;
    cin>>C>>D;
    R[C-1].push_back(D);
    R[D-1].push_back(C);
  }
 
  
  vector<bool> note(N,false);
  for(ll i=0;i<N;i++) {
if(note[i]) {
continue;
}
   set<ll> W;
    W.insert(i+1);
    queue<ll> S;
  
    note[i]=true;
    S.push(i+1);
    
    while(!S.empty()) {
ll k=S.front();
      S.pop();
      for(auto x:vec[k-1]) {
        if(note[x-1]) {
continue;
        }
        W.insert(x);
        note[x-1]=true;
        S.push(x);
      }
      
    }
    

    for(ll x:W) {
     ll ans=W.size()-1-vec[x-1].size();
  
  for(ll y:R[x-1]) {
if(W.count(y)) {
ans--;
}
  }
      Q[x-1]=ans;
      
  }
  }
  
  for(ll i=0;i<N;i++) {
cout<<Q[i]<<" ";
  }
  cout<<endl;
}
  
  
 
      

    
    
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  


Measured memory_bytes: 21608
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CLamps {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n, k; cin >> n >> k;
      vector<ll> a(n);
      rep(i, n) {
        cin >> a[i];
      }

      rep(j, k) {
        vector<ll> b(n);
        rep(i, n) {
          int s = max(0LL, i-a[i]);
          int t = min(i+a[i]+1, n);
          b[s]++;
          if (t < n) {
            b[t]--;
          }
        }
        for(int i=0; i<n-1; i++) {
          b[i+1] += b[i];
        }
        if (b == a) {
          break;
        }
        swap(b, a);
      }

      rep(i, n) {
        cout << a[i] << ' ';
      }
      cout << endl;





    }
};

signed main() {
  CLamps solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 6404
n = gets.to_s.to_i
a = gets.to_s.split.map{|t|t.to_i}.sort

h = Hash.new(0)
a.each do |k|
  h[k] += 1
end
# p h
v = h.values

l = 0
r = h.size - 1
d = 0
ans = v.reduce(0){|s,t|s+t}

(h.size).times do |i|
  
  if v[i] > 2 && v[i].even?
    t =  v[i] - 2
    v[i] -= t
    d += t/2
  elsif v[i] > 2 && v[i].odd?
    t =  v[i] - 1
    v[i] -= t
    d += t/2
  end
end
# p v
while l <= r

  x = v[l]
  y = v[r]
  
  if l == r
    d += (v[l] - 1)
    break
  end

  if x >= 2 && y >= 2
    d += [x, y].min - 1
    # ans += d
    l += 1 if (v[l] -= 1) == 1
    l -= 1 if (v[r] -= 1) == 1
    next
  end
  

  
  if x == 1
    l += 1
    next
  elsif y == 1
    r -= 1
    next
  end
end

# p v
# puts ans
# puts d
# puts d*2
puts ans - d * 2

# puts ans



Measured memory_bytes: 16144
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    int N;
    string s;
    cin >> N;
    cin >> s;

    // 0: S, 1: W
    REP(x, 2){
        REP(y, 2){
            bool check = true;
            vector<int> tmp(N, -1);
            tmp[0] = x;
            tmp[1] = y;
            REP(i, N){
                int j = (i+1) %N;
                int k = (i+2) %N;
                int c = s[j] == 'o';
                int next;
                if(tmp[j] == 0){
                    next = c ?tmp[i] : 1 - tmp[i];
                }else{
                    next = c ? 1 - tmp[i] : tmp[i];
                }
                if(tmp[k] != -1 && tmp[k] != next){
                    check = false;
                }
                tmp[k] = next;
            }
            if(check && tmp[0] == x && tmp[1] == y){
                string res;
                REP(i,N)res += "SW"[tmp[i]];
                cout << res << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 1052
<?php

// ????????????????????° = ???????????°??°
$set = intval(fgets(STDIN));

// ????????¢??????????????????????????????????????????
$ining = 1;
$out = 0;
$total = 0;

$first = false;
$second = false;
$third = false;

while($line = trim(fgets(STDIN))){
	if($line == "OUT"){
		$out++;
	}else if($line == "HIT"){
		// ?????????????????????
		if($third){
			// ???????????????
			$total++;
			$third = false;
		}

		// ??????????????????
		if($second){
			// ???????????????
			$third = $second;
			$second = false;
		}
		
		// ??????????????????
		if($first){
			// ???????????????
			$second = $first;
			$first = false;
		}

		// ???????????????????????????
		$first = true;
	}else if($line == "HOMERUN"){
		// ??????????????????
		if($third){
			$total++;
		}
		
		// ??????????????????
		if($second){
			$total++;
		}
		
		// ??????????????????
		if($first){
			$total++;
		}

		// ??????
		$total++;
		
		// ????????????
		$first = false;
		$second = false;
		$third = false;
	}
	
	if($out >= 3){
		// ???????????¢???????????§??????
		echo $total."\n";
		$ining++;
		$out = 0;
		$total = 0;
		$first = false;
		$second = false;
		$third = false;
	}

	if($ining > $set){
		// ????????£???
		exit();
	}
}

Measured memory_bytes: 15064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vi vector<int>
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pi 3.14159265359



int main() {
	ll A, B;
	cin >> A >> B;
	if ((A + B) % 3 == 0) {
		cout << "Possible";
	}
	else if (A % 3 == 0) {
		cout << "Possible";
	}
	else if(B % 3 == 0){
		cout << "Possible";
	}
	else
	{
		cout << "Impossible";
	}
	

	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int a, b;
	cin >> a >> b;
	cout << max( { a + b, a - b, a * b } );
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3580
h, w, n, *aa = map(int, open(0).read().split())

line = list()

order = False

for a, i in zip(aa, range(1, len(aa)+1)):
    if order:
        line = line + [i]*a
    else:
        line = [i]*a + line
        
    while len(line) >= w:
#         print(line, w)
        if order:
            p = line[:w]
            line = line[w:]
        else:
            p = line[-w:]
            line = line[:-w]
        order = not order
        print(*p)

Measured memory_bytes: 9348
K = int(input())
 
import math
 
ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      first = int(math.gcd(a, b))
      plus = int(math.gcd(first, c))
      ans += plus
      
print(ans)

Measured memory_bytes: 68108
#include <iostream>
using namespace std;
int main(void){
    
    int r;
    
    std::cin >> r;
    
    if(r < 1200){
        std::cout << "ABC" << std::endl;
        return 0;
    }
    else if(r < 2800)
    {
        std::cout << "ARC" << std::endl;
        return 0;
    }
    else{
        std::cout << "AGC" << std::endl;
        return 0;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

// x^n % MOD
template <long long MOD = 1000000007LL>
long long powmod(long long x, long long n) {
    long long ret = 1LL;
    long long t = x % MOD;
    while (n > 0) {
        if (n & 1LL) {
            ret *= t;
            ret %= MOD;
        }
        t *= t;
        t %= MOD;
        n >>= 1;
    }
    return ret;
}

int calc_digits(int n) {
    int cnt = 0;
    do {
        n /= 10;
        ++cnt;
    } while (n > 0);
    return cnt;
}

int calc_top(int n) {
    while (n >= 10) {
        n /= 10;
    }
    return n;
}

int main() {
    int n; cin >> n;
    int dn = calc_digits(n);
    int mn = calc_top(n);
    ll ans = 0;
    for (int a = 1; a <= n; ++a) {
        int l = a % 10;
        int m = calc_top(a);

        if (l == 0) continue;

        if (l == m) ++ans;

        for (int db = 2; db < dn; ++db) {
            ans += powmod<infl>(10, db - 2);
        }

        if (l < mn) ans += powmod<infl>(10, dn - 2);
        else if (l == mn) {
            int rem = n - mn * powmod<infl>(10, dn - 1);
            if (rem >= m) {
                ans += 1 + (rem - m) / 10;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int num=n+1;num>=0;num--){
        int cnt=0;
        for(int i=0;i<n;i++){
            if(num>=a[i] && num<=b[i])cnt++;
        }
        if(cnt>=num-1){
            cout<<num-1<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3860
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<pair<int,int>> a(n);
  rep(i,n){
    cin >> a[i].first;
    a[i].second = i+1;
  }
  sort(a.begin(), a.end());

  rep(i,n){
    cout << a[i].second << " ";
  }
  cout <<  "\n";
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define S(x) (int) x.size()
#define LB lower_bound
#define UB upper_bound
#define fp(x, y) fixed<<setprecision(y)<<x
#define M 100005
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884
using namespace std;

void solve()
{
	int x;
	f(i, 1, 6)
	{
		cin>>x;
		if(x == 0)
		{
			cout<<i<<endl;
			return;
		}
	}
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        solve();
    }
    return 0;
}

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

int w,h;
int mcnt=0;
char maps[22][22];
int dy[]={-1,0,1,0};
int dx[]={0,-1,0,1};

void bfs(int y,int x,int nowcnt){
  mcnt++;
  maps[y][x]='#';
  for(int i=0;i<4;i++){
    int ny=y+dy[i];
    int nx=x+dx[i];
    if(ny>=0 && ny<h && nx>=0 && nx<w && maps[ny][nx]!='#' ){
      bfs(ny,nx,nowcnt);
      //    maps[ny][nx]='.';
    }
  }
  return;
}
int main(){
  int sy,sx;
  while(1){
    mcnt=0;
    cin>>w>>h;
    if(!(w || h ))break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>maps[i][j];
	if(maps[i][j]=='@'){
	  sy=i;
	sx=j;
	}
      }
    }
    bfs(sy,sx,0);
    cout<<mcnt<<endl;
  }
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> upper(n);
    for (auto &x: upper) cin >> x;
    int q; cin >> q;
    vector<tuple<int,int,int>> query(q);
    for (auto &a: query) {
        int t,x,d; cin >> t >> x >> d;
        a = make_tuple(t,x-1,d);
    }
    vector<int> cases(n, 0);

    for (auto a: query) {
        if (get<0>(a) == 1) { // 収穫
            cases[get<1>(a)] += get<2>(a);
            if (cases[get<1>(a)] > upper[get<1>(a)]) {
                cout << get<1>(a)+1 << endl;
                return 0;
            }
        } else { // 出荷
            cases[get<1>(a)] -= get<2>(a);
            if (cases[get<1>(a)] < 0) {
                cout << get<1>(a)+1 << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 3880
#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);
  }
  
    sort(A.begin(), A.end());
  
  
for (int i = 0; i < N; i++) {
      
  if(A[i] == A[i+1]){
    cout << "NO" << endl;
  return 0;
  }
    
    }
    cout << "YES" << endl;
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const int INFI = 1000000000;
 const ll INFL = (1LL << 60);

 struct UnionFind {
   // コンストラクタ
     vector<int> par;
     UnionFind(int n) : par(n, -1) { } //初期化
     // メンバ関数
     void init(int n) { par.assign(n, -1); } //途中で初期化したいときに使う。
     int root(int x) {
         if (par[x] < 0) return x;
         else return par[x] = root(par[x]);
     }
     bool issame(int x, int y) {
         return root(x) == root(y);
     }
     void merge(int x, int y) {
         x = root(x); y = root(y);
         if (x == y) return; //root同じ場合
         if (par[x] > par[y]) swap(x, y); // merge technique
         par[x] += par[y];
         par[y] = x;
         return;
     }
     int size(int x) {
         return -par[root(x)];
     }
 };

 int main() {
   int N, M; cin >> N >> M;

   UnionFind uf(N);
   int ans = N;

   rep(i, 0, M) {
     int x, y, z; cin >> x >> y >> z;
     x--; y--;
     if (uf.issame(x, y)) continue;
     else {
       uf.merge(x, y);
       ans--;
     }
   }
   cout << ans << endl;
 }


Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};
const double pi=3.1415926535;

int main() {

	double a,b,h,m;
	cin>>a>>b>>h>>m;

	double c=abs(30*h+0.5*m-6*m);
	c=c*pi/180;
	double ans=a*a+b*b-2*a*b*cos(c);
	ans=sqrt(ans);
	cout<<setprecision(12)<<ans<<endl;

	return 0;
}


Measured memory_bytes: 4240
#include <stdio.h>

int main(void)
{
	int i, j, n, ball, b[10], k, c[10], l, NO;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		for (j = 0; j < 10; j++){
			b[j] = 0;
			c[j] = 0;
		}
		k = 0;
		l = 0;
		NO = 0;
		
		for (j = 0; j < 10; j++){
			scanf("%d", &ball);
			
			if (k == 0){
				b[k++] = ball;
			}
			else if (b[k-1] < ball){
				b[k++] = ball;
			}
			else if (l == 0){
				c[l++] = ball;
			}
			else if (c[l-1] < ball){
				c[l++] = ball;
			}
			else {
				NO = 1;
			}
						
			if (j == 9){
				if (NO == 0){
					printf("YES\n");
				}
				else {
					printf("NO\n");
				}
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 576
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque


def main():
    num = int(input())
    data = [int(input()) for i in range(num)]
    now_num = 0
    for i in range(num):
        a = data[i]
        now_num ^= a

    now_num = bin(now_num)[2:]
    now_num = list(now_num)
    now_num = list(map(int, now_num))

    # print(now_num)

    delete_list = [0 for i in range(len(now_num))]
    for i in range(num):
        bin_data = bin(data[i])[2:][::-1]

        for j in range(min(len(bin_data), len(now_num))):
            # print(data[j])
            if bin_data[j] == '1':
                delete_list[j] = 1
                break

    delete_list = delete_list[::-1]

    # print(now_num)
    # print(delete_list)

    ans = 0
    taberu = 0
    for i in range(len(now_num)):
        ele = now_num[i]
        if ele ^ taberu:
            if delete_list[i]:
                taberu ^= 1
                ans += 1
            else:
                print(-1)
                sys.exit()


    if ans > num or num == 1:
        print(-1)
    else:
        print(ans)




if __name__ == '__main__':
    main()
    # test()



Measured memory_bytes: 45016
#include<iostream>
#include<string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

char card(string* s){
	char tmp=(*s)[0];
	(*s).erase((*s).begin());
	return tmp;
}

int main(){
	string a,b,c;
	cin>>a>>b>>c;
	
	char turn='a';
	while(1){
		if(turn=='a'){
			if(a.empty()){
				cout<<'A'<<endl;
				return 0;
			}
			turn=card(&a);
		}else if(turn=='b'){
			if(b.empty()){
				cout<<'B'<<endl;
				return 0;
			}
			turn=card(&b);
		}else{
			if(c.empty()){
				cout<<'C'<<endl;
				return 0;
			}
			turn=card(&c);
		}
	}
}

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

int main() {
  ll n;
  cin >> n;
  map<string,ll> M;
  for(ll i=0; i<n; i++) {
    string S;
    cin >> S;
    M[S]++;
  }
  for(string k : vector<string>{"AC", "WA", "TLE", "RE"}) {
    cout << k << " x " << M[k] << endl;
  }
}


Measured memory_bytes: 3632
from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

def lcm(a,b):
    return (a * b // gcd(a, b))

def modpow(a, n, mod): # a^n mod
    result = 1
    while n > 0:
        if n & 1: result = result * a % mod
        a = a * a % mod
        n >>= 1
    return result

h = reduce(lcm, A)
B = [h * modpow(A[i], MOD-2, MOD) for i in range(N)]
print(sum(B) % MOD)


Measured memory_bytes: 264696
n = int(input())
s = input()

dp = [0] * n

for i in range(1,n):
  if s[i] == "E":
    dp[0] += 1

for i in range(1,n):
  dp[i] = dp[i-1]
  if s[i-1] == "W":
    dp[i] += 1
  if s[i] == "E":
    dp[i] -= 1

print(min(dp))

Measured memory_bytes: 20996
# coding: utf-8
# Your code here!

s = input()
# print(s)
# print(s[2:3])
# print(s[3:4])
# print(s[4:5])
# print(s[5:6])

if s[2:3] == s[3:4] and s[4:5] == s[5:6]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int m, k;
	cin >> m >> k;
	
	if(m == 0) {
		if(k == 0) cout << "0 0" << endl;
		else cout << -1 << endl;
		return;
	}
	
	if(m == 1) {
		if(k == 0) cout << "0 0 1 1" << endl;
		else cout << -1 << endl;
		return;
	}
	
	if(k >= (1 << m)) {
		cout << -1 << endl;
		return;
	}
	
	for(int i=(1<<m)-1; i>=1; --i)
		printf("%d ",i^k);
	printf("%d ", k);
	for(int i=1; i<=(1<<m)-1; ++i)
		printf("%d ",i^k);
	printf("%d ", k);
	puts("");
	return;
}

int main() {
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int K, T; cin >> K >> T;
	vector<int> a(T, 0);
	rep (i, T) cin >> a[i];

	int d = *max_element(ALL(a));
	int res = max(0, d  - (K - d + 1));
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 384
import java.io.*;

class Main
{
 
  public static void main(String[] args)
  {
    try{
    	// ??\???????????????
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      // ????????°???????????????
      int n = Integer.parseInt(br.readLine());
      String[] str = br.readLine().split(" ");
      int[] array = new int[n];
 
      for(int i = 0; i < n; i++){
        array[i] = Integer.parseInt(str[i]);
      }
      selectionSort(array, array.length);
 
    }catch(Exception e){
      System.out.println(e);
    }
  }
 
  public static void selectionSort(int[] A, int N)
  {
    int swapNum = 0;
 
    for(int i = 0; i < N; ++i){
    	int mini = i;
    	for(int j = i + 1;j < N;++j){
    		if(A[j] < A[mini]){
    			mini = j;
    		}
    	}
    	if(mini != i){
    		++swapNum;
			final int tmp = A[i];
			A[i] = A[mini];
			A[mini] = tmp;
    	}
    }
    
    System.out.print(show(A));
    System.out.println(Integer.valueOf(swapNum));
  }
 
  public static String show(int[] B)
  {
    StringBuilder sb = new StringBuilder();
 
    for(int i = 0; i < B.length; i++){
      sb.append(B[i]).append(" ");
    }
    sb.deleteCharAt(sb.length() - 1);
    sb.append("\n");
 
    return sb.toString();
  }
}

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

int main() {
  string t;
  cin >> t;
  vector<char> v(t.size());
  for (int i = t.size() - 1; i >= 0; i--)
    if (t.at(i) == '?') {
      //if (i = t.size() - 1)
        t.at(i) = 'D';
      //else if (t.at(i+1) == 'D')
    }
  cout << t << endl;
}

Measured memory_bytes: 3924
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = Array.fill(sc.nextInt)((sc.nextInt, sc.nextInt)).map(a => (a._1 - 1) % a._2 + 1).map(println(_))
  
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc)
  }
}

Measured memory_bytes: 45420
//TO CHANGE THE WORLD
#include <bits/stdc++.h>

using namespace std;

#define L first
#define R second
typedef long long ll;

const int maxn=1e5+10;

int n, a[maxn], ans;

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin>>n;
    for(int i=0; i<2*n; i++) cin>>a[i];
    sort(a,a+2*n);
    for(int i=0; i<n; i++) ans+=a[2*i];
    cout<<ans<<endl;
}


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

int main(){
	
	long long h;
	long long ans = 0;
	int cnt = 0;
	
	cin >> h;
	
	if (h == 1){
		ans = 1;
	} else {
		while (h > 0.99){
			ans+= pow(2, cnt);
			cnt++;
			h = h/2;
		}
	}
	
	cout << ans;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

//AOJ 1510

signed main(){
	int n, cnt = 0;
    while(cin >> n, n){
        cnt ++;
        if(cnt != 1) cout <<  endl;
        cout << "Case " << cnt << ":" << endl;
        string s[5][5];
        rep(i, 0, 5){
            rep(j, 0, 5){
                cin >> s[i][j];
            }
            //cout << endl;
            cin.ignore();
        }
        int m, t;
        vector<int> a, b;
        cin >> m;
        rep(i, 0, m){
            cin >> t;
            a. push_back(t);
        }
        cin >> m;
        rep(i, 0, m){
            cin >> t;
            b. push_back(t);
        }
        int d[15][15][15] = {0};
        rep(i, 5, 10){
            rep(j, 5, 10){
                rep(k, 5, 10){
                    d[i][j][k] = s[i - 5][j - 5][k - 5] - '0';
                    //cout << d[i][j][k];
                }
                // cout << endl;
            }
            // cout << endl;
        }
        rep(day, 0, n){
            int tmp[15][15][15] = {0};
            rep(x, 5, 10) rep(y, 5, 10) rep(z, 5, 10){
                int t = 0;
                rep(i, -1, 2) rep(j, -1, 2) rep(k, -1, 2){
                    if(i == 0 && j == 0 && k == 0) continue;
                    if(d[x + i][y + j][z + k]) t++;
                }
                if(d[x][y][z] == 0){
                    tmp[x][y][z] = 0;
                    rep(l, 0, a.size()){
                        if(a[l] == t){
                            tmp[x][y][z] = 1;
                            break;
                        }
                    }
                }else{
                    tmp[x][y][z] = 0;
                    rep(l, 0, b.size()){
                        if(b[l] == t){
                            tmp[x][y][z] = 1;
                            break;
                        }
                    }
                }
            }
            rep(x, 5, 10) rep(y, 5, 10) rep(z, 5, 10){
                d[x][y][z] = tmp[x][y][z];
            }
        }
        rep(i, 5, 10){
            rep(j, 5, 10){
                rep(k, 5, 10){
                    cout << d[i][j][k];
                }
                cout << endl;
            }
            if(i != 9) cout << endl;
        }
    }
}

Measured memory_bytes: 1288
#include<cstdio>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;

const ll INF=1LL<<61;

int main(){
	int n,m,L; scanf("%d%d%d",&n,&m,&L);
	int a[2002];
	rep(i,n) scanf("%d",a+i), a[i]--;
	static ll v[100001];
	rep(i,m) scanf("%lld",v+i+1), v[i+1]+=v[i];

	a[n]=*min_element(a,a+n); n++;
	a[n]=*max_element(a,a+n); n++;
	sort(a,a+n);

	static ll dp[2002][2002];
	rep(i,n) rep(j,n) dp[i][j]=INF;
	dp[0][1]=0;
	rep(i,n-1) rep(j,n-1) if(i!=j) {
		int next=max(i,j)+1;
		dp[next][j]=min(dp[next][j],dp[i][j]+abs(v[a[next]+1]-v[a[i]])/L);
		dp[i][next]=min(dp[i][next],dp[i][j]+abs(v[a[next]+1]-v[a[j]])/L);
	}

	printf("%lld\n",dp[n-2][n-1]);

	return 0;
}

Measured memory_bytes: 32000
<?php

fscanf(STDIN, "%d %d %d", $a, $b, $k);

if ($k >= $a + $b) {
    echo "0 0";
} elseif ($k >= $a) {
    $x = $b - ($k - $a);
    echo "0 $x";
} else {
    $y = $a - $k;
    echo "$y $b";
}



Measured memory_bytes: 4728
#include <iostream>
#include <vector>

using namespace std;

void selectionSort(vector<int> data) {
  int n = data.size();
  int cnt = 0;
  for (int i = 0; i < n; i++) { // i: 未ソート部分の先頭
    int minj = i;
    for (int j = i; j < n; j++) {
      if (data[minj] > data[j]) {
        minj = j;
      }
    }
    if (i != minj) {
      std::swap(data[i], data[minj]);
      cnt++;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << data[i] << (i == n-1 ? "\n" : " ");
  }
  cout << cnt << endl;
}

int main() {
  int n; cin >> n;
  vector<int> data(n);

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

  selectionSort(data);

  return 0;
}


Measured memory_bytes: 3152
#include<iostream>
#include<cstdio>
#include<vector>
#include<limits>
#include<cmath>
using namespace std;
long long a[3000],minn[3000],n,x,sum=0,t=0,sum1;
int main()
{
	cin>>n>>x;
	for(int i=0;i<n;++i)
	{
		scanf("%d",&a[i]);
		minn[i]=a[i];
		sum+=a[i];
	}
	for(int i=1;i<n;++i)
	{
		sum1=0;
		for(int j=0;j<n;++j)
		{
			minn[j]=min(minn[j],a[(i+j)%n]);
			sum1+=minn[j];
		}
		sum=min(sum,sum1+x*i);
	}
	cout<<sum;
	
	

}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline

N = int(input())
A = [int(x) for x in input().split()]

A.append(1)

def test(x):
    digit = [0]
    cnt = [0]
    for a in A:
        if digit[-1] < a:
            digit.append(a)
            cnt.append(1)
            continue
        if digit[-1] == a:
            cnt[-1] += 1
            continue
        while True:
            # 繰り上がり処理をしながら左に戻る
            if digit[-1] <= a:
                break
            n = digit.pop()
            k = cnt.pop()
            if k <= x:
                continue
            if digit[-1] == n-1:
                cnt[-1] += (k-1)//x
            else:
                digit.append(n-1)
                cnt.append((k-1)//x + 1)
        if digit[-1] == a:
            cnt[-1] += 1
        else:
            digit.append(a)
            cnt.append(2)
    return cnt[1] <= x+1

if all(x<y for x,y in zip(A[:-2],A[1:-1])):
    print(1)
    exit()

left = 1 # 無理
right = N # 可能
while right > left + 1:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid

answer = right
print(answer)

Measured memory_bytes: 102152
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

long long n, a[10000], ta = 0;

signed main(){
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		while (a[i] % 2 == 0) {
			ta++;
			a[i] /= 2;
		}
	}
	cout << ta << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int cnt = 25 - d;
		StringBuilder ans = new StringBuilder("Christmas");
		for (int i = 0; i < cnt; i++) {
			ans.append(" Eve");
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 19924
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;
#define ll long long int


ll gcd ( ll a, ll b ) {
  if ( a % b == 0 ) return b;
  else {
    return ( gcd( b, a % b ) );  
  }  
}
int main() {
  ll n, x, ans;
  cin >> n >> x;
  vector < ll > h(n);
  for ( int i = 0; i < n; ++i ) {
    cin >> h[i];
    if( h[i] - x != 0 ) {
      ans = abs( h[i] - x );  
    }  
  }

  for ( int i = 0; i < n; ++i ) {
    if ( h[i] == x ) continue;
    ll diff = abs( h[i] - x );
    ans = gcd ( ans, diff );  
  }

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



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000

int main(){
    ll n, k, x; cin >> n >> k;
    vector<ll> a(210000, 0);
    REP(i,n){
        cin >> x;
        a[x]++;
    }
    priority_queue<ll, vector<ll>, greater<ll>> q;
    ll cnt = 0;
    REP(i,210000){
        if (a[i]) {
            q.push(a[i]);
            cnt++;
        }
    }
    if (cnt<=k){
        cout << 0 << endl;
    }
    else{
        ll redu = cnt-k;
        ll ans = 0;
        while(redu>0){
            ans+=q.top();
            redu--;
            q.pop();
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 4084
x, k, d = map(int, input().split())
x = abs(x)
n = x // d

if k <= n:
    print(x-k*d)
    exit()

if (n-k) % 2 == 0:
    print(abs(x-n*d))
else:
    print(abs(x-(n+1)*d))




Measured memory_bytes: 61780
L = [0]*100501
for i in range(6):
    L[100+i] = 1
for i in range(100001):
    if L[i]==1:
        for j in range(6):
            if (L[i+j+100] == 0):
                L[i+j+100] = 1
print(L[int(input())])

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

int main(){
  int n, x, cnt;

  while(cin>>n>>x, n){
    cnt=0;
    for(int i=1;i<n;i++){
      for(int j=i+1;j<n;j++){
	for(int k=j+1;k<=n;k++){
	  if(i+j+k==x) cnt++;
	}
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}

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

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int A, B, ans;
  std::cin >> A >> B;
  ans = A + B;
  ans = std::max(ans, A - B);
  ans = std::max(ans, A * B);
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long tot,ans1,ans2;
int main(){
	cin>>tot;
	ans1=tot/500;
	long long now=tot-500*ans1;
	ans2=now/5;
	long long ans=1000*ans1+5*ans2;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep2(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

ll dp[100005][13];

void Main() {
    int a;
    cin >> a;
    string s;
    cin >> s;
    if (a >= 3200) {
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 256
#require 'prime'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
require 'bigdecimal'
a,b,c=gsmi
puts_yesno(a+b+2*BigDecimal.new(a*b).sqrt(100)<c)

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
int main() {
  char s; cin >> s;
  char ans;
  if (s == 'A') {
    ans = 'T';
  }
  else if (s == 'C') {
    ans = 'G';
  }
  else if (s == 'G') {
    ans = 'C';
  }
  else {
    ans = 'A';
  }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int h,w,i,j;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0&&w==0){
			break;
		}
		for(i=1;i<=h;i++){
			if(i==1||i==h){
				for(j=1;j<=w;j++){
					printf("#");
				}
			}
			else{
				for(j=1;j<=w;j++){
					if(j==1||j==w){
						printf("#");
					}
					else{
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    string s;
    cin >> s;

    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }

    return 0;
}


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

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

    long long Amax = -1e7;
    long long Amin = 1e7;
    long long Asum = 0;
    for (int i = 0; i < N; i++) {
        if (Amax < A[i]) Amax = A[i];
        if (Amin > A[i]) Amin = A[i];
        Asum += A[i];
    }
    cout << Amin << " " << Amax << " " << Asum << endl;
}


Measured memory_bytes: 3196
#include<cstdio>
#include<algorithm>

using namespace std;

int cnt[10];

int main(){
	for(int i = 0; i < 6; ++i){
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}
	int ma = 0;
	for(int i = 0; i < 10; ++i){
		ma = max(ma, cnt[i]);
	}
	if(ma == 2) printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>

#define Int register int

const int MAXN = 2000;
int n, m, F[MAXN * 3 + 5][MAXN * 6 + 5];
bool Vis[MAXN * 3 + 5][MAXN * 6 + 5];

inline int DFS ( const int s, const int d ) {
	if ( ! s ) return d >= 0 && ! ( d % 3 );
	if ( Vis[s][d + 3 * n] ) return F[s][d + 3 * n];
	int ret = DFS ( s - 1, d + 1 );
	if ( s > 1 ) ret = ( ret + ( s - 1LL ) * DFS ( s - 2, d - 1 ) ) % m;
	if ( s > 2 ) ret = ( ret + ( s - 1LL ) * ( s - 2LL ) * DFS ( s - 3, d ) ) % m;
	return Vis[s][d + 3 * n] = true, F[s][d + 3 * n] = ret;
}

inline void Work () {
	scanf ( "%d %d", &n, &m );
	printf ( "%d\n", DFS ( 3 * n, 0 ) );
}

int main () {
	Work ();
	return 0;
}


Measured memory_bytes: 350720
import numpy as np

H,W=map(int,input().split())
a=[list(input()) for i in range(H)]
#a=np.array(a)
b=[]
c=[]
count1=0
count2=0
#print(a)
for i in range(H):
    l=a[i]
    #print(set(l),l[0])
    if not((len(set(l))==1)and(l[0]==".")):
        b.append(l)
        count1=count1+1
b=np.array(b)
b=b.T
b=b.tolist()
#print(b)
for i in range(W):
    l=b[i]
    #print(set(l),l[0])
    if not((len(set(l))==1)and(l[0]==".")):
        c.append(l)
        count2=count2+1
#print(c)
c=np.array(c)
c=c.T
c=c.tolist()
#print(c)
for i in c:print(*i,sep='')

Measured memory_bytes: 13904