akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		String s = fs.next();
		int n = s.length();
		String t = s.substring(0,n/2);
		for(int i=0;i<t.length();i++) {
			if(t.charAt(i)!=t.charAt(t.length()-1-i)) {
				System.out.println("No");
				return;
			}
		}
		//System.out.println(s.substring(n/2+1));
		if(s.substring(n/2+1).equals(t)) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");			
		}
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 21844
n = list(map(int,input()))
if(n[0]+n[1]+n[2]+n[3] == 7):
    print(str(n[0])+"+"+str(n[1])+"+"+str(n[2])+"+"+str(n[3])+"=7")
elif(n[0]+n[1]+n[2]-n[3] == 7):
    print(str(n[0])+"+"+str(n[1])+"+"+str(n[2])+"-"+str(n[3])+"=7")
elif(n[0]+n[1]-n[2]+n[3] == 7):
    print(str(n[0])+"+"+str(n[1])+"-"+str(n[2])+"+"+str(n[3])+"=7")
elif(n[0]+n[1]-n[2]-n[3] == 7):
    print(str(n[0])+"+"+str(n[1])+"-"+str(n[2])+"-"+str(n[3])+"=7")
elif(n[0]-n[1]+n[2]+n[3] == 7):
    print(str(n[0])+"-"+str(n[1])+"+"+str(n[2])+"+"+str(n[3])+"=7")
elif(n[0]-n[1]+n[2]-n[3] == 7):
    print(str(n[0])+"-"+str(n[1])+"+"+str(n[2])+"-"+str(n[3])+"=7")
elif(n[0]-n[1]-n[2]+n[3] == 7):
    print(str(n[0])+"-"+str(n[1])+"-"+str(n[2])+"+"+str(n[3])+"=7")
elif(n[0]-n[1]-n[2]-n[3] == 7):
    print(str(n[0])+"-"+str(n[1])+"-"+str(n[2])+"-"+str(n[3])+"=7")

Measured memory_bytes: 3192
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)

typedef pair<int, int> Edge;
typedef pair<int, int> P;

int main() {
  int n; cin >> n;
  vector<Edge> G[100000];
  loop(i,0,n-1) {
    int a, b, c; cin >> a >> b >> c;
    a--;b--;
    G[a].emplace_back(b, c);
    G[b].emplace_back(a, c);
  }
  int q, k; cin >> q >> k; k--;
  const ll INF = 100000000000000000;
  vector<ll> D(n, INF);
  {
    vector<bool> done(n, false);
    priority_queue<P> Q;
    Q.push({ 0, k });
    D[k] = 0;
    while (Q.size()) {
      auto p = Q.top(); Q.pop();
      int v = p.second;
      if (done[v]) continue;
      done[v] = true;
      for (auto &&edge: G[v]) {
        int u = edge.first, w = edge.second;
        if (done[u]) continue;
        if (D[u] > D[v] + w)  {
          D[u] = D[v] + w;
          Q.push({ D[u], u });
        }
      }
    }
  }
  
  while (q--) {
    int x, y; cin >> x >> y; x--;y--;
    cout << D[x] + D[y] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 11556
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N,A,B = map(int,input().split())
miN = min(N*A,B)
print(miN)


Measured memory_bytes: 5052
N = int(input())
B = [0] + [int(input()) for _ in range(N)]

x = 1
cnt = 0
dic = {x}
while True:
  x = B[x]
  cnt += 1
  if x == 2:
    break
  if {x} <= dic:
    cnt = -1
    break
  dic.add(x)
print(cnt)


Measured memory_bytes: 13720
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 long x,a,b,c,d;
	   cin>>x;
	   a=x/1000;b=x/100%10;c=x/10%10;d=x%10;
	     if(a+b+c+d==7){cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;return 0;}
	     if(a+b+c-d==7){cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;return 0;}
	     if(a+b-c+d==7){cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;return 0;}
	     if(a+b-c-d==7){cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;return 0;}
	     if(a-b+c+d==7){cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;return 0;}
	     if(a-b+c-d==7){cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;return 0;}
	     if(a-b-c+d==7){cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;return 0;}
	     if(a-b-c-d==7){cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;return 0;}
}

Measured memory_bytes: 256
numN = int(input())
input_line = input().split(' ')
brick = [int(i) for i in input_line]

seq = 0

for i, b in enumerate(brick):
  if b == 1:
    seq += 1
    cur = 2
    for c in brick[i + 1:]:
      if c == cur:
        seq += 1
        cur += 1
    break

if seq == 0:
  print(-1)
else:
  print(numN - seq)


Measured memory_bytes: 27548
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left

def main():
	N = int(input())
	V = input().split(" ")
	
	K = []
	G = []
	for i, val in enumerate(V):
		if i % 2 == 0:
			G.append(val)
		else:
			K.append(val)
	
	k = collections.Counter(K)
	k = sorted(k.items(), key=lambda x:x[1], reverse=True)
	g = collections.Counter(G)
	g = sorted(g.items(), key=lambda x:x[1], reverse=True)
	
	aaa, bbb = k[0]
	ccc, ddd = g[0]
	eee = -1
	fff = -1
	ggg = -1
	hhh = -1
	if len(k) > 1:
		eee, fff = k[1]
	if len(g) > 1:
		ggg, hhh = g[1]
	
	if aaa == ccc:
		if bbb > ddd and ggg != -1:
			g[0] = (ggg, hhh)
			g[1] = (ccc, ddd)
		elif bbb < ddd and eee != -1:
			k[0] = (eee, fff)
			k[1] = (aaa, bbb)
		elif ggg != -1:
			if fff >= hhh:
				k[0] = (eee, fff)
				k[1] = (aaa, bbb)
			else:
				g[0] = (ggg, hhh)
				g[1] = (ccc, ddd)
	
	#print(k)
	#print(g)
		
	ans = 0
	sono1 = 0
	sono2 = 0
	for a, b in enumerate(k):
		i, j = b
		if a == 0:
			sono1 = i
			continue
		ans += j
	
	for a, b in enumerate(g):
		i, j = b
		if a == 0:
			sono2 = i
			continue
		ans += j
		
	if ans > 0:
		print(ans)
	elif sono1 != sono2:
		print(ans)
	else:
		print(len(K))
		
		
	
if __name__ == "__main__":
	main()


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

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	double n, d;
	cin >> n >> d;
	cout << ceil(n / (d * 2.0 + 1.0)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N;
	int a,A[100000];
	int pre;
	cin>>N;
	for(int i=1;i<=N;i++){
		cin>>a;
		A[a]=i;
	}
	for(int i=1;i<=N;i++){
		cout<<A[i]<<" ";
	}
	cout<<endl;
	return 0;
}

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

using namespace std;

using ll = long long;

int n, ans;

void Solve(ll x, char flag) {
    if (n < x) return ;
    if (flag == 7) ++ans;
    Solve(10 * x + 3, flag | 1);
    Solve(10 * x + 5, flag | 2);
    Solve(10 * x + 7, flag | 4);
}

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

    cin >> n;
    Solve(0, 0);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m, h, w;
int s[200][200];

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin >> n;
    vi v(n);
    REP(i, n) cin >> v[i];
    sort(ALL(v));
    int x = v.back(); v.pop_back();
    int y = v[0];
    for(int t : v) {
        if (min(y, x - y) < min(t, x - t)) y = t;

    }
    cout << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
#define M 60001
int main(){
  char p[M]={1,1};
  int i,j,n;
  for(i=0;i*i<M;i++){
    if(p[i])continue;
    for(j=i*i;j<M;j+=i)p[j]=1;
  }
  while(scanf("%d",&n)!=EOF){
    for(i=n-1;p[i];i--);
    printf("%d ",i);
    for(i=n+1;p[i];i++);
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 660
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{
 
  int n; cin>>n; int i,j;int a[n];
  for(i=0;i<n;i++)
    	cin>>a[i];
   sort(a,a+n);
  long double ans=(long double)a[0];
  for(i=1;i<n;i++)
  {
 		ans=(long double) (ans+a[i])/2;
	}  

  //cout<<ans<<endl;
  cout<<setprecision(15)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
c = [list(map(int,input().split())) for x in range(3)] 
if c[0][0]-c[1][0]==c[0][1]-c[1][1]==c[0][2]-c[1][2] and c[0][0]-c[2][0]==c[0][1]-c[2][1]==c[0][2]-c[2][2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
ans = 0
for i in range(1, K-1):
    for j in range(i+1, K):
        for k in range(j+1, K+1):
            ans += gcd(i, j, k)*6
for i in range(1, K):
    for j in range(i+1, K+1):
        ans += math.gcd(i, j)*6
for i in range(1, K+1):
    ans += i
    
print(ans)

Measured memory_bytes: 69508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=10005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<int> cnt(N+1);
    
    for(int i=1;i<=N;i++){
        for(int j=i;(i+j)*(j-i+1)/2<=N;j++){
            cnt[(i+j)*(j-i+1)/2]++;
        }
    }
    
    ll ans=0;
    
    for(int i=1;i<=N;i++){
        if(N%i==0) ans+=cnt[i]*cnt[N/i];
    }
    
    cout<<ans<<endl;
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (b % a == 0) {
        cout << a + b << endl;
    } else {
        cout << b - a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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

  cout << A[0];
  for (int i = 1; i < n; i++) {
    cout << " " << A[i];
  }
  cout << endl;

  for (int i = 1; i < n; i++) {
    int v = A[i];

    int j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;

    cout << A[0];
    for (int k = 1; k < n; k++) {
      cout << " " << A[k];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long int
#define pi 3.1415926535897
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug 0
#define loop(a,b) for(a=0;a<b;a++)
#define test() while(t--)
 
using namespace std;
 

 


int ar[105][105];


int main()
{
	int m,a,b,i,j,q,v,home,k,t,n,c,d,p;
	ll w;
	
string str;

cin>>n>>m;

cin>>a;


for(i=1;i<=a;i++)
{
	cin>>b;
	
	k=i;
	p=1;
	q=1;
	c=1;
	d=0;
	while(1)
	{
		if(ar[p][q]==0)
		{
			ar[p][q]=k;
			d++;
		}
	    
	    
	    if(d==b)
	    break;
	    
	    if(c%2)
	    q++;
	    else
	    q--;
	    
	    if(q>m && c%2==1)
	    {
	    	p++;
	    	q=m;
	    	c++;
		}
		else if(q<1 && c%2==0)
		{
			p++;
			q=1;
			c++;
		}
		
		if(p>n)
		break;
	}
}


for(i=1;i<=n;i++)
{
	for(j=1;j<=m;j++)
	{
		cout<<ar[i][j]<<" ";
	}
	
	cout<<"\n";
}


  
  return 0;
}

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

void solve(){
    int a,b;
    cin >> a >> b;
    if(a%2!=b%2) cout << "IMPOSSIBLE" << endl;
    else cout << (a+b)/2 << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    int N, M;
    cin >> N >> M;
    priority_queue<int> q;
    int A;
    lpn(i, N)
    {
        cin >> A;
        q.push(A);
    }
    lpn(i, M)
    {
        q.push(q.top() / 2);
        q.pop();
    }
    ll ans = 0;
    while(!q.empty())
    {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, sum;
  sum = 0;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    
    if (x - 0 > K - x) sum += 2 * (K - x);
    else if (x - 0 <= K - x) sum += 2 * (x - 0);
  }
  cout << sum << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int , int > P;




int main()
{
    int n;
    cin >> n;
    int cnt=0;
    string arr;
    cin >> arr;
    int i=0, j=arr.length()-1;
    while(i<j)
    {
        while(arr[i]!='W'&&i<j)
            i++;
        while(arr[j]!='R'&&i<j)
            j--;
       if(i<j) cnt++;
               i++;j--;
    }
    cout <<cnt;

}


Measured memory_bytes: 3752
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
const int INF=1e9;

int main(){
    int n;cin>>n;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];
    ll ans=0;
    for(int i=n-1;i>=0;i--){
        ans+=((a[i]+ans+b[i]-1)/b[i])*b[i] - (a[i]+ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2040
/// Bismillahir Rahmanir Rahim
/// S. M. Shakir Ahsan Romeo

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

const double PI = acos(-1.0);

typedef long long lng;
typedef unsigned long long ulng;
typedef double db;
typedef pair < int, int >  pii;
typedef vector < pii >  vpii;
//typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

inline int getint()
{
    int x;
    scanf("%d", &x);
    return x;
}
#define II getint()

inline long long getlng()
{
    long long x;
    scanf("%lld", &x);
    return x;
}
#define LL getlng()

int dx4[] = {-1, 0, 1, 0};
int dy4[] = {0, 1, 0, -1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};


void solve();
#define theromeo421 main()
#define segtree int lft = node << 1, rgt = lft | 1, mid = (b + e) >> 1;
#define mem(x, y) memset((x), (y), sizeof (x));
#define sz(x) ((int)x.size())
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define pr1(x) cout << x << endl
#define pr2(x,y) cout << x << ' ' << y << endl
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep1(i, n) for(int i = 1; i <= n; ++i)
#define repstl(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define forcon(pp , qq) for(const auto& pp : qq)
#define all(x) (x).begin(), (x).end()
#define Unique(x) sort(all(x)); x.erase(unique(all(x)), x.end()); /// x needs to be sorted first
#define pb push_back
#define wait system("pause")
#define xx first
#define yy second
#define dbg(x) cerr << #x << "=" << x << endl;
#define dbg2(x, y) cerr << #x << "=" << x << ", " << #y << "=" << y << endl;
#define read(a) freopen(a, "r", stdin);
#define write(a) freopen(a, "w", stdout);
#define prv(v) rep(i, sz(v)) cout << v[i] << " \n"[i + 1 == v.size()];
#define Case int T; scanf("%d", &T); for(int cas = 1; cas <= T; ++cas)
#define pf printf
#define sf scanf
#define MP make_pair
#define endl '\n'
const double eps = (double)1e-9;


int theromeo421
{
    /// PLEASE HACK my code, I am error prone.
    /// Your hack can save me from the cruel hand of system testing. :) :P ;)
    solve();
#ifdef romeo
    cerr << "\nElapsed time: " << 1.0 * clock() / CLOCKS_PER_SEC << '\n';
#endif // romeo
    return 0;
}


void solve()
{
    int n, tot;
    while(cin >> n >> tot)
    {
        int a1 = -1, a2 = -1, a3 = -1;
        for(int x = 0; x * 10000 <= tot && a1 == -1; ++x)
        {
            for(int y = 0; x * 10000 + y * 5000 <= tot; ++y)
            {
                int baki = tot - (x * 10000 + y * 5000);
                if(baki % 1000 == 0 && x + y + baki / 1000 == n)
                {
                    a1 = x, a2 = y, a3 = baki / 1000;
                    break;
                }
            }
        }
        pf("%d %d %d\n", a1, a2, a3);
    }
}


Measured memory_bytes: 256
N, x = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [0 for _ in range(N)]

A.sort()

ans = 0
for i in range(len(A)):
    if i == N - 1:
        B[i] = x
        break
    if x - A[i] >= 0:
        B[i] = A[i]
        x -= A[i]
    else:
        B[i] = 0
for i in range(len(A)):
    if A[i] == B[i]:
        ans += 1

print(ans)

Measured memory_bytes: 3064
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||(require'rubygems';exec({Z=>'50000000'},Gem.ruby,$0));def f(i)a=H[i].map{|e|-f(e)}.sort;r=0;a.size.times{|i|x=i+1-a[i];r<x&&r=x};r end;N=gets.to_i;H=Hash.new{|h,k|h[k]=[]};(N-1).times{|i|H[gets.to_i-1]<<i+1};p f 0

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

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

int col, row;
vector<vector<char>> field;

const pii dir[] = {
    {-1, 0},
    {1, 0},
    {0, -1},
    {0, 1},
};

bool is_in_field(const pii p) {
  const int c = p.second;
  const int r = p.first;
  return (0 <= c && c < col) && (0 <= r && r < row);
}

int wfs(const pii start, const pii goal) {
  vector<vi> memo;
  for (int i = 0; i < row; ++i) {
    vi v(col, 0);
    memo.push_back(v);
  }

  queue<pii> q;
  q.push(start);

  while (!q.empty()) {
    pii cur = q.front();
    q.pop();

    if (cur == goal) {
      return memo[cur.first][cur.second];
    }

    for (const auto d : dir) {
      pii next = cur;
      next.first += d.first;
      next.second += d.second;
      if (is_in_field(next)) {
        const char s = field[next.first][next.second];
        if (s == '.' || s == 'g') {
          if (memo[next.first][next.second] == 0) {
            q.push(next);
            memo[next.first][next.second] = memo[cur.first][cur.second] + 1;
          }
        }
      }
    }
  }
  return -1;
}

void solve() {
  cin >> row >> col;
  vector<vector<char>> tmp;
  for (int i = 0; i < row; ++i) {
    vector<char> v(col, 0);
    for (int j = 0; j < col; ++j) {
      cin >> v[j];
    }
    tmp.push_back(v);
  }

  int ans = 0;
  for (int i = 0; i < row; ++i) {
    for (int j = 0; j < col; ++j) {
      for (int k = 0; k < row; ++k) {
        for (int l = 0; l < col; ++l) {
          if ((k != i || l != j) && tmp[i][j] == '.' && tmp[k][l] == '.') {
            field = tmp;
            field[k][l] = 'g';
            pii start = make_pair(i, j);
            pii goal = make_pair(k, l);
            ans = max(ans, wfs(start, goal));
          }
        }
      }
    }
  }
  cout << ans << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
K = int(input())
if K == 1:
    print("ACL")
elif K == 2:
    print("ACLACL")
elif K == 3:
    print("ACLACLACL")
elif K == 4:
    print("ACLACLACLACL")
elif K == 5:
    print("ACLACLACLACLACL")

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

const long long MOD = 998244353;

int main() {
    int N;
    cin >> N;
    vector<long long> cnt(100001);
    int maxD = 0;
    for (int i = 0; i < N; i++) {
        int d;
        cin >> d;
        if (i == 0 && d != 0) {
            cout << 0 << endl;
            return 0;
        }
        cnt[d]++;
        maxD = max(maxD, d);
    }

    if (cnt[0] != 1) {
        cout << 0 << endl;
        return 0;
    }

    long long res = 1;
    for (int i = 1; i <= maxD; i++) {
        if (cnt[i] == 0) {
            cout << 0 << endl;
            return 0;
        }

        for (int j = 0; j < cnt[i]; j++) {
            res = res * cnt[i - 1] % MOD;
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(){

  int h,m,s,H,M,S,rh,rm,rs;
  int i,j;

  for(i = 0; i < 3; i++){

    scanf("%d %d %d %d %d %d",&h,&m,&s,&H,&M,&S);

    if(S < s){

      rs=S+60-s;
      M--;

    } else {

      rs=S-s;

    }

    if(M < m){

      rm=M+60-m;
      H--;

    } else {

      rm=M-m;

    }

    rh=H-h;

    printf("%d %d %d\n",rh,rm,rs);

  }

  return 0;

}
    

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) REP(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    rep(i, s.length()) {
        rep(j, t.length()) {
            if (t[j] != s[(i + j) % s.length()])
                break;
            if (j == t.length() - 1) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long a, b, c, d;
    scan(a, b, c, d);
    if (a + b == c + d)
    {
        writeln("Balanced");
        return;
    }
    if (a + b < c + d)
    {
        writeln("Right");
        return;
    }
    writeln("Left");
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	string s;
	cin >> s;
	string s1 = s;
	int n = s.size();
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= n - i; j++) {
			string key = s.erase(i, j);
			if (key == "keyence") {
				cout << "YES" << endl;
				return 0;
			}
			s = s1;
		}
	}
	cout << "NO" << endl;
	return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  vector<int> ans(s.size(), 0);
  vector<int> a;
  char prev = s[0];
  int cnt = 1;
  for (int i = 1; i < (int)s.size(); ++i) {
    if (s[i] != prev) {
      if (prev == 'R') {
	a.push_back(cnt);
      } else {
	a.push_back(-cnt);
      }
      cnt = 1;
      prev = s[i];
    } else {
      cnt++;
    }
  }
  if (prev == 'R') {
    a.push_back(cnt);
  } else {
    a.push_back(-cnt);
  } 
  int cur = 0;
  for (int i = 0; i < a.size(); ++i) {
    if (a[i] > 0) {
      ans[cur + a[i] - 1] += ceil((double)a[i] / 2);
      ans[cur + a[i]] += a[i] / 2;
    } else {
      ans[cur - 1] += -a[i] / 2;
      ans[cur] += ceil((double)-a[i] / 2);
    }
    cur += abs(a[i]);
  }

  for (int i = 0; i < s.size(); ++i) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 1528
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
N = len(s)
print("x"*N)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<62;
constexpr double eps = (1e-9);

set<ll> enum_divisor(ll m) {
  set<ll> divisors;
  for (ll i = 1; i*i <= m; ++i) {
    if (m % i != 0) continue;
    divisors.insert(i);
    if (i * i != m) divisors.insert(m / i);
  }
  return divisors;
}

ll solve(const ll& n) {
  auto ans = enum_divisor(n-1);
  ans.erase(1);

  auto divs = enum_divisor(n);
  divs.erase(1);
  for (auto& v : divs) {
    ll m = n;
    while (m % v == 0) {
      m /= v;
    }
    if (m % v == 1) ans.insert(v);
  }

  return ans.size();
}

ll solve2(ll n) {
  set<ll> ans;
  for (int i = 2; i < 200; i++) {
    ll m = n;
    while (m > 1) {
      if (m % i == 0) m /= i;
      else m -= i;
    }
    if (m == 1) ans.insert(i);
  }
  for (auto& x : ans) cerr << x << " "; cerr << endl;
  return ans.size();
}

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

  ll n;
  cin >> n;

  ll ans = solve(n);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3800
a,b,c = (int(x) for x in input().split())
half_pack = int((a+b+c)/2)
if(a == half_pack) and ((b+c) == half_pack):
    print("Yes")
elif(b == half_pack) and ((a+c) == half_pack):
    print("Yes")
elif(c == half_pack) and ((b+a) == half_pack):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int k = sc.nextInt();

		System.out.println(getSubstring(s,k));
	}

	private static String getSubstring(String s, int k){
		Set<String> set = new HashSet<>();
		String str = s;
		for(char c = 'a'; Character.isAlphabetic(c); c++){
			Queue<String> queue = new ArrayDeque<>();

			List<String> list = new ArrayList<>();
			for(int i = 0;i < str.length(); i++){
				if(str.charAt(i) == c) list.add(s.substring(i));
			}
			Collections.sort(list);
			queue.addAll(list);

			String subS;
			while((subS = queue.poll()) != null){
				for(int i = 1; i <= subS.length(); i++){
					set.add(subS.substring(0, i));
					if(set.size() == k) break;
				}
				if(set.size() == k) break;
			}
			if(set.size() == k) break;
		}
		return set.stream().sorted().collect(Collectors.toList()).get(k-1);
	}
}

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

int main(int argc, char const *argv[])
{
	int a,b,x;
	cin>>a>>b>>x;
	if (a<=x&&x<=a+b)
	{
		cout<<"YES\n";
	}
	else
	{
		cout<<"NO\n";
	}
	return 0;
}


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

int main(){
  std::string s;
  std::cin >> s;
  std::vector<int> v;
  for(const auto &i : s)
    v.push_back(i - '0');
  int former, latter;
  former = 10*v[0] + v[1];
  latter = 10*v[2] + v[3];
  if(0 < former && former < 13)
    if(0 < latter && latter < 13)
      std::cout << "AMBIGUOUS" << std::endl;
    else
      std::cout << "MMYY" << std::endl;
  else
    if(0 < latter && latter < 13)
      std::cout << "YYMM" << std::endl;
    else
      std::cout << "NA" << std::endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

def main():
    n = int(sys.stdin.readline().rstrip())
    ab = map(int, sys.stdin.read().split())
    ab = list(zip(ab, ab))

    G = [[] for _ in range(n + 1)]
    for a, b in ab:
        G[a].append(b)
        G[b].append(a)
    
    q = deque([1]) # root = 1
    parent = [None] * (n + 1)
    color = [None] * (n + 1) # color of the edge(parent[y], y)

    while q:
        x = q.popleft()
        ng = color[x]
        c = 1
        for y in G[x]:
            if y == parent[x]:
                continue
            parent[y] = x
            if c == ng:
                c += 1
            color[y] = c
            q.append(y)
            c += 1
            
    print(max(color[2:]))

    for a, b in ab:
        if a == parent[b]:
            print(color[b])
        else:
            print(color[a])

if __name__ == '__main__':
    main()

Measured memory_bytes: 31440
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		//数列
		ArrayList<Long> list = new ArrayList<Long>();
		long a, b;
		
		//数列の数
		long count = 0;
		
		//数値取得
		Long x = scan.nextLong();
		Long y = scan.nextLong();
		
		
		long t = 0, i;
		//1,2は無視
		if (y - x == 1 || y - x == 2) {
			System.out.println(x);
			
		}else {
		
			a = x;
			b = x * 2;
			t = b;
			for (i = 2; t <= y; i++) {
				t *= 2;
			}
			System.out.println(i-1);
		}
	}
}


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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int k,a,b;cin>>k>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
      cout<<"NG"<<endl;
  
  return 0;
}


Measured memory_bytes: 3652
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
cnt = defaultdict(int)
ans = 0

for _ in range(N):
    s = input()[:-1]
    s = list(s)
    s.sort()
    s = ''.join(s)
    ans += cnt[s]
    cnt[s] += 1

print(ans)

Measured memory_bytes: 58972
#include<stdio.h>
int main(void) {
	int N,i,P[10],max=0,sum=0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &P[i]);
		if (max < P[i])
			max = P[i];
	}
	for (i = 0; i < N; i++) {
		sum = sum + P[i];
	}
	sum = sum - max / 2;
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const long long N = 55;
long long n, dp[N], p, a;

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n >> p;
	dp[0] = 1;
	for(long long i = 1; i <= n; i++) {
		cin >> a;
		if(a % 2 == 0) {
			dp[0] *= 2;
			dp[1] *= 2;
		} else {
			long long t = dp[0];
			dp[0] += dp[1];
			dp[1] += t;
		}
		dbg(dp[0], dp[1]);
	}

	cout << dp[p] << '\n';
}	

	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    if(k==0){
        cout << n*n << endl;
        return 0;
    }
    for(ll i=k+1;i<=n;i++){
        ll tmp = n/i;
        if(n%i==0){
            ans += tmp*(i-k);
        }else{
            ans += (i-k)*tmp;
            ll x = n-tmp*i;
            if(x>=k){
                ans += x-k+1;
            }
        }
        //cout << i <<" " << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;

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

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	string s;
	cin >> s;
	FOR(i,0,(int)(s.size()+1)/2)cout << s[i*2];
	cout << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[0]==s[1] && s[1]==s[2])
    {
        cout<<"No"<<'\n';
        
    }
    else
    {
        cout<<"Yes"<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3588
n = int(input())
c = []
s = []
f = []
for i in range(n-1):
    ci, si, fi = map(int, input().split())
    c.append(ci)
    s.append(si)
    f.append(fi)


for i in range(n-1):
    ans = s[i]
    for j in range(i, n-1):
        if ans < s[j]:
            ans = s[j] + c[j]
        elif ans % f[j] == 0:
            ans += c[j]
        else:
            ans += f[j] - ans % f[j] + c[j]
    print(ans)
print(0)


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

int main(){
  int N;
  cin >> N;
  string A;
  int count = 0;
  for(int i = 0; i < N; i++){
    cin >> A;
    if(A == "Y"){
      count++;
      cout << "Four" << endl;
      break;
    }
  }
  if(count == 0){
    cout << "Three" << endl;
  }
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()  
#define sz(x) int(x.size()) 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=63;
const int mxn=0;
bool DEBUG=0;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
   ll x,k,d;
   cin>>x>>k>>d;
   ll need = abs(x)/d;
   if(k>=need){
	   k-=need;
	   if(x>0){
		   x-=need*d;
			if(k%2==0)cout<<abs(x);
			else{
				x-=d;
				cout<<abs(x);
			}
	   }
	   else{
		   x+=need*d;
		   if(k%2==0)cout<<abs(x);
			else{
				x+=d;
				cout<<abs(x);
			}
	   }
	}else{
		if(x>0)x-=k*d;
		else x+=k*d;
		cout<<abs(x);
	}
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int x,n;
  cin>>x>>n;
  int j=1010;
  int ans;
  int w;
  vector<int> p(n+2);
  p[0]=-10;
  p[n+1]=110;
  rep(i,n){
    cin>>p[i+1];
  }
  so(p);
  rep(i,n+1){
    for(int k=p[i]+1;k<p[i+1];k++){
      if(j>max(k-x,x-k)){
        j=max(k-x,x-k);
        ans=k;
      }
      //cout<<k<<" "<<ans<<endl;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(void){
    int time,hour,minute,second;
    cin >> time ;
    second = time % 60;
    time /= 60;
    minute = time % 60;
    time /=60;
    hour = time % 60;

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

    return 0 ;

}


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


using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;


int main() {
    int n, k;
    while (1) {
        cin>>n>>k;
        if(n==0){
            break;
        }
        vector<int> a(n);
        rep(i, n)cin >> a[i];
        vector<int> cum(n + 1, 0);
        rep(i, n)cum[i + 1] = cum[i] + a[i];
        ll ans = 0;
        rep(i, n - k) {
            ll cnt = cum[i + k] - cum[i];
            ans = max(ans, cnt);
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

#define MAXN (1 << 10)
#define N 100
#define M 50

int v[MAXN][MAXN];

void fill(int x, int y, int col, int num) {
	while (num--) {
		v[x][y] = col;
		if (y + 2 < N) {
			y += 2;
		} else {
			y = 1;
			x += 2;
		}
	}

}

int main() {
	cout << fixed << setprecision(12);	
	int a, b;	
	cin >> a >> b;
	a--;
	b--;
	for (int i = M; i < N; i++) {
		for (int j = 0; j < N; j++) {
			v[i][j] = 1;
		}
	}
	fill(1, 1, 1, b);
	fill(51, 1, 0, a);
	cout << N << " " << N << endl;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (v[i][j]) {
				cout << "#";
			} else {
				cout << ".";
			}
		}
		cout << endl;
	}
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 3832
#include<bits/stdc++.h> 
using namespace std;
int main()
{
	int n,m,a[51],s=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=n;i>=n-m+1;i--)s+=a[i];
    cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int
#define pp pair<pii,pii>
const int hell =1000000007;



int power(int a,int b)
{
  if(b==0)return 1;
  if(b==1)return a;
  int t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}

int gcd(int a,int b)
{   
  
  if(b==0)return a;
  return gcd(b-a%b,a%b);
}

int digitsum(int x)
{
  while(x>9)
    {  int ans=0;
       while(x!=0)
       {
        ans+=x%10;
        x/=10;
       }
       x=ans;
    }
    return x;
}

int pw(int a,int b)
{
  int x=a;
  rep(i,1,b){a=a*x;}
  return a;
}

int solve( ){

int r,b,g,n;
cin>>r>>g>>b>>n;

int ans=0;

  rep(i,0,3001)
  {
    rep(j,0,3001)
    {
        int x=r*i,y=g*j;
        if(x+y>n)continue;
        else
        {
          int  z=n-x-y;
          if(z%b==0)ans++;
        }

    }
  }
 
 cout<<ans;

return 0;
}

signed main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);



  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;

    int k=1;
   while(t--)
     {
       //cout<<"case #"<<k<<":"<<" ";k++;
      solve();
     }

         time_req = clock() - time_req;
 // cout << "Processor time taken is "
   // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,b,a) for(int i=(b);i>=(a);i--)
#define len(a) int((a).size())
using namespace std;
using LL = long long;
using PII = pair<int, int>;

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    int t = 1900 * m + 100 * (n-m);
    printf("%d\n", t * (1<<m));
}

Measured memory_bytes: 256