akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
using namespace std;

long long  gcd(long long  a, long long  b){
  if(b == 0){
    return a;
  }

  return gcd(b, a%b);
}

long long  lcm(long long  a, long long b){
  return a*b/gcd(b, a%b);
}



int main() {
  int ans=0;
  long long acd, bcd;
  long long a,b,c,d,cxd, cd, cc, dd;
  
  cin >> a >> b >> c >> d;
  
  cxd = lcm(c,d);
  //  cout << "cxd = " << cxd <<endl;
  //  cxd = c * d;
  bcd = b/cxd;
  acd = (a-1)/cxd;
  //cでもdでも割り切れるもの
  cd = bcd - acd;
  //  cout << "cd = " << cd << endl;

  bcd = b/c;
  acd = (a-1)/c;
  //  cout << "---" << endl;
  //  cout << "bcd = "<< bcd << endl;
  //  cout << "acd = "<< acd << endl;

  //cでわりきれるもの　
  cc = bcd - acd - cd;
  //  cout << "cc = " << cc << endl;
  //  cout << "---" << endl;
  
  bcd = b/d;
  acd = (a-1)/d;
  //dでわりきれるもの　
  dd = bcd - acd - cd;
  //  cout << "dd = " << dd << endl;

  //  cout << "b-a = " << b-(a-1) << endl;

  cout << b - (a-1) - (cd + cc + dd) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define ll long long
#define bg begin

namespace IO{

cs int RLEN=1<<22|1;
char ibuf[RLEN],*ib,*ob;
inline char gc(){
	(ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob)?EOF:*ib++;
}
inline int read(){
	char ch=gc();
	int res=0;bool f=0;
	while(!isdigit(ch))f=ch=='-',ch=gc();
	while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
	return f?-res:res;
}
inline ll readll(){
	char ch=gc();
	ll res=0;bool f=0;
	while(!isdigit(ch))f=ch=='-',ch=gc();
	while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
	return f?-res:res;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	s[top+1]='\0';return top;
}

}
using IO::read;
using IO::readll;
using IO::readstring;

template<typename tp>inline void chemx(tp &a,tp b){(a<b)?(a=b):0;}
template<typename tp>inline void chemn(tp &a,tp b){(a>b)?(a=b):0;}

cs int N=1000005;
int n,lmn,a[N];
char str[N];
int main(){
	#ifdef Stargazer
	freopen("lx.in","r",stdin);
	#endif
	n=readstring(str);
	for(int i=1,s=0;i<=n;i++){
		s+=(str[i]=='1')?1:-1;
		chemx(lmn,s),a[i]=s;
	}int res=1e9;
 	for(int i=n-1;i>=1;i--)chemx(a[i],a[i+1]);               
	for(int t=0;t<2;t++){
		lmn+=t;int f=0;
		for(int i=1,s=0,del=0;i<=n;i++){
			if(str[i]=='?'&&a[i]+s+2<=lmn)s+=2;
			del+=(str[i]=='1')?1:-1;
			chemn(f,del+s);
		}
		chemn(res,lmn-f);
	}cout<<res<<'\n';return 0;
}

Measured memory_bytes: 9516
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

void solve() {
    int N; cin >> N;
    vector<int> s(N);
    int sum = 0;
    set<int> se;
    rep(i, N) {
        cin >> s[i];
        sum += s[i];
        if(s[i] % 10 != 0)se.insert(s[i]);
    }
    if(sum % 10 != 0) {
        cout << sum << endl;
    } else {
        if(se.size() == 0) {
            cout << 0 << endl;
        } else {
            cout << sum - *se.begin() << endl;
        }
    }

}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $a, $b);
if ($a >= 13) {
    echo $b.PHP_EOL;
} elseif ($a >= 6 && $a <= 12) {
    echo($b /2).PHP_EOL; 
} else {
    echo(0).PHP_EOL;
}

Measured memory_bytes: 5112
import java.util.*;
public class Main {
	Scanner sc;
	int N;
	int[] H;

	public Main() {
		sc = new Scanner(System.in);
	}
	
	private void calc() {
		N = sc.nextInt();
		H = new int[N];
		for (int i = 0; i < H.length; i++) H[i] = sc.nextInt();
		
		int max = 0;
		int c = 0;
		for (int i = H.length-1; i > 0; i--) {
			if (H[i-1] >= H[i]) {
				c++;
				if (c > max) max = c;
			} else {
				c = 0;
			}
		}
		System.out.println(max);
		System.out.flush();
	}

	public static void main(String[] args) {
		new Main().calc();
	}

}

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

ll n;
vector<ll> d;

void Build() {
  d.push_back(0);
  d.push_back(1);
  ll p = 1;
  while (d.back() < 1e16) {
    p *= 26;
    d.push_back(d.back() + p);
  }
}

void Process() {
  int letters = 0;
  while (letters < d.size() && d[letters + 1] <= n)
    letters++;
  n -= d[letters];
  ll p = 1;
  for (int i = 0; i < letters - 1; i++)
    p *= 26;
  string ans;
  for (int i = 0; i < letters; i++, p /= 26) {
    char c = 'a';
    while (n >= p) {
      c++;
      n -= p;
    }
    ans.push_back(c);
  }
  cout << ans << "\n";
}

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

  Build();

  while (cin >> n) {
    Process();

    if (cin.eof())
      break;
  }

  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

typedef unsigned long long ull;

int main(){
  ull s;
  int T;
  cin >> T;
  for(int cs = 1 ; cs <= T ; cs++){
    ull ans[10];
    cin >> s;
    
    ull tmp = s*s;
    tmp /= 100;
    tmp %= 10000;
    
    ans[0] = tmp;
    
    for(int i = 1 ; i < 10 ; i++){
      ans[i] = ans[i-1]*ans[i-1];
      ans[i] /= 100;
      ans[i] %= 10000;
    }
    
    printf("Case %d:\n", cs);
    for(int i = 0 ; i < 10 ; i++){
      cout << ans[i] << endl;
    }
  }
  return 0;
}

    

Measured memory_bytes: 0
use proconio::input;
 
fn main() {
  input! {
    s: String,
  }
  
  let chars: Vec<char> = s.chars().collect();
  let mut result: Vec<String> = vec![String::from("0");chars.len()];  
  let mut index = 0;
  while index < chars.len() {
    let mut r_count = 0;
    let mut l_count = 0;
    while chars[index] == 'R' {
      index += 1;
      r_count += 1;
    }
    let r_index = index - 1;
    while let Some(char) = chars.get(index) {
      if char != &'L' {
        break
      }
      index += 1;
      l_count += 1;
    }
    
    let r_val = if r_count % 2 == 1 {
      r_count / 2 + 1
    } else {
      r_count / 2
    };
    
    let l_val = if l_count % 2 == 1 {
      l_count / 2 + 1
    } else {
      l_count / 2
    };

    result[r_index] = (r_val + l_count - l_val).to_string();
    result[r_index + 1] = (r_count - r_val + l_val).to_string();
  }
  println!("{}", result.join(" "));
}

Measured memory_bytes: 8172
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
ll dp[100005];
int main()
{
    memset(dp,-1,sizeof(dp));
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(ll i=1;i<=n;i++)
        cin>>arr[i];
    dp[1]  = 0;
    for(int i=2;i<=n;i++)
    {
        ll mini = 1000000000;
        for(int j=1;j<=k;j++)
        {
            if(i-j >= 1 && (dp[i-j] + abs(arr[i] - arr[i-j]) < mini))
                mini = dp[i-j] + abs(arr[i] - arr[i-j]);
        }
        dp[i] = mini;
    }
    cout<<dp[n]<<endl;
}

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

int main() {

    int n, a;

    std::cin >> n;

    int         min = INT_MAX;
    int         max = INT_MIN;
    long long   sum =       0;

    for ( int i = 0; i < n; i++ ) {

        std::cin >> a;

        if ( a < min ) min =  a;
        if ( a > max ) max =  a;
                       sum += a;
    }

    std::cout << min << " " << max << " " << sum << std::endl;

    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define f first
#define s second
using namespace std; using namespace __gnu_pbds;
using ll = long long;
using ii = pair<int, int>;
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
constexpr int MX = 2e5+5;

int main() {
	if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
	ios_base::sync_with_stdio(0), cin.tie(0);

	string S; cin >> S;
	deque<int> oc[26];
	ordered_set<int> os;
	for (int i = 0; i < S.size(); ++i) oc[S[i]-'a'].push_back(i), os.insert(i);
	int cnt = 0;
	for (int i = 0; i < 26; ++i) if (oc[i].size()&1) ++cnt;
	if (cnt > 1 || cnt != S.size()%2) {
		cout << -1;
		return 0;
	}
	ll ans = 0;
	for (int i = 0; i < S.size()/2; ++i) {
		int best = MX, idx;
		for (int i = 0; i < 26; ++i) if (oc[i].size() > 1) {
			int x = os.order_of_key(oc[i].front())+os.size()-os.order_of_key(oc[i].back()+1);
			if (x < best) best = x, idx = i;
		}

		ans += os.order_of_key(oc[idx].front())+os.size()-os.order_of_key(oc[idx].back()+1);
		os.erase(oc[idx].front()), os.erase(oc[idx].back());
		oc[idx].pop_front(), oc[idx].pop_back();
	}
	cout << ans;
}


Measured memory_bytes: 13876
#include <stdio.h>
int main(void)
{
	char s[101];
	long long int k,i;
	scanf("%s%lld",s,&k);
	if(k==1){
		printf("%c\n",s[0]);
		return 0;
	}else{
		if(s[0]!='1'){
			printf("%c\n",s[0]);
			return 0;
		}else{
			for(i=0; i<k; i++){
				if(s[i]!='1'){
					printf("%c\n",s[i]);
					return 0;
				}
			}
			printf("1\n");
			return 0;
		}
	}
}

Measured memory_bytes: 128
//#include "pch.h"
//#include "stdafx.h"
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define MIN(a, b)		((a) < (b) ? a : b)
#define MAX(a, b)		((a) > (b) ? a : b)
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)		/* 奇数 */
#define IsEven(x)		(!IsOdd((x)))					/* 偶数 */
#define ArrayLength(x)	(sizeof(x) / sizeof(x[0]))
#define DWORD_MAX		(0xFFFFFFFF)

typedef short SWORD;
typedef unsigned short WORD;
typedef long SDWORD;
typedef unsigned long DWORD;
typedef long long int QWORD;
typedef pair<int, int> P;

#define N_MAX	(100000)
#define M_MAX	(1000)
#define H_MAX	(1000)
#define W_MAX	(1000)

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
typedef struct {
	string name;
	int point;
	int number;
} REST_INFO;

bool cmp(REST_INFO &a, REST_INFO &b)
{
	if (a.name == b.name) {
		return (a.point > b.point);
	} else {
		int result = a.name.compare(b.name);
		return (0 < result) ? false : true;
	}
}

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

	vector<REST_INFO> restInfo(N);
	REP(i, N) {
		cin >> restInfo[i].name;
		cin >> restInfo[i].point;
		restInfo[i].number = i + 1;
	}
	sort(restInfo.begin(), restInfo.end(), cmp);
	
	REP(i, N) {
		cout << restInfo[i].number << endl;
	}
	cout << endl;
}


Measured memory_bytes: 256
"use strict";

function main(input) {
  input = input
    .split("\n")[0]
    .split(" ")
    .map(i => parseInt(i));
  let A = input.shift();
  let B = input.shift();
  if (A < 10 && B < 10) {
    console.log(A * B);
  } else {
    console.log("-1");
  }
}
main(require("fs").readFileSync("/dev/stdin", "UTF-8"));


Measured memory_bytes: 7496
using System;

namespace ConsoleApp108
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());
            int e = int.Parse(Console.ReadLine());
            int k = int.Parse(Console.ReadLine());

            if (e - a <= k)
            {
                Console.WriteLine ("Yay!");
            }
            else
            {
                Console.WriteLine (":(" );

            }
        }

    }
}


Measured memory_bytes: 27384
N = int(input())
A = [0] + list(map(int,input().split())) + [0]
SUM = 0
for i in range(1,N+2):
    SUM += abs(A[i-1]-A[i])
for i in range(1,N+1):
    print(SUM - (abs(A[i-1]-A[i])+abs(A[i]-A[i+1]))+abs(A[i-1]-A[i+1]))

Measured memory_bytes: 14048
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
  int a ,b, c, d, e, X, Y;
//  long long  b, c, d, e, X, Y;
  //  double  c;
  long long  A[200003]={};
  int  B[100003]={};
  int  C[100003][11]={};

  int  flag[1003]={};

//  long long  a, b, c, d, X, Y;
  char s[101][101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
//  int flag=0;
//  int tmp=0;
  char tmp[101]={};
//  int min=1000000;
  long long min=100000001;
  int len=0;
  int l=0;
  int r=1000001;
  int cnt=0;
  int num=0;
  int ans=0;
  int max=0;
  int addr=0;
  int ptn=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
//  scanf("%d%d", &a,&c);
//  cnt = strlen(t);
// printf("%d\n",a);
    scanf("%d%d%d", &a,&b,&c);
  
  max=a+b;
  if(a+c<max) max=a+c;
  if(b+c<max) max=b+c;
  printf("%d",max);

    
//    printf("%s %d %d\n", s[i],C[i][0],C[i][1]);
   // printf("%d\n", C[i][1]);
/*  for(i=0;i<addr;i++){
//  scanf("%lld%lld", &B[0][i],&B[1][i]);
//    ans=ans+A[i];
    printf("%lld ", A[i]);
  }
*/
//    printf("%d ", cnt);
   
//  ans=a*3;
//  ans=(ans+b)/2;
//  printf("%d\n", ans);

  
//  printf("%lf\n",ans);
  //  //  if(flag==0)   printf("TLE\n");
//    if(max < cnt - max)  printf("Yes\n");
//    else  printf("No\n");
  
return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main(){
   ld w,h;cin >>w>>h;
   ld x,y;cin >>x>>y;
   int t=0;
   if(w/2==x&&h/2==y)t=1;
   ld ans=h*w/2;
   cout <<setprecision(20)<<ans<<" "<<t<<endl;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define PI 3.1415926535897932

using namespace std;
int main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);


  double a,b;
  long long x;
  cin>>a>>b>>x;
  long double result1=(atan(2*(b/a-x/(a*a*a))))*180/PI;
  long double result2=(atan((a*b*b)/(2*x)))*180/PI;
  
  if(double(x/(a*a))>double(b/2)){
    cout<<fixed<<setprecision(13)<<result1;
  }else{
    cout<<fixed<<setprecision(13)<<result2;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	long long int a;
	scanf("%lld",&a);
	long long int b = a;
	int ans = 0;
	
	for(int i=2;(long long int)i*i<=a;i++)
	{
		if(b%i==0)
		{
			int count = 0;
			while(b%i==0) count++,b/=i;
			
			int C = 0;
			for(int j=1;;j++)
			{
				if(C+j<=count) ans++,C+=j;
				else break;
			}
		}
	}
	if(b>1) ans++;
	printf("%d",ans);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define ld long double
#define mkp make_pair
#define sz(x) (int)x.size()
#define pi pair<long long, long long>
#define watch(x) cout << (#x) << " is " << (x) << endl; cout.flush()
#define endl '\n'
#define _ << ' '
#define FAST_LOG2(x) (sizeof(unsigned long)*8 - 1 - __builtin_clzl((unsigned long)(x)))
#define clog2(x) (((x) - (1 << FAST_LOG2(x))) ? FAST_LOG2(x) + 1 : FAST_LOG2(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e9+1;

int n, a[2001], ans=0;

int f(int x){
    int l=0, r=n;
    int ret=-1;
    while(l<r){
        int mid = (l+r)/2;
        if(a[mid]<x){
            ret = mid;
            l = mid+1;
        }
        else{
            r = mid;
        }
    }
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            int x = f(a[i]+a[j]);
            if(x>j) ans += x-j;
        }
    }
    cout << ans;
}


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

anses = [min(a) + min(b)]

for x, y, c in xyc:
  x -= 1
  y -= 1
  anses.append(a[x] + b[y] - c)

print(min(anses))


Measured memory_bytes: 42408
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int a,b;
  cin>>a>>b;
  Int ans=0;
  for(Int i=a;i<=b;i++){
    string s=to_string(i);
    string t(s.rbegin(),s.rend());
    ans+=s==t;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	for(string s;cin>>s && s!="#";){
		int n=s.size();
		
		vector<string> res;
		string t=s;
		array<char,26> first;
		for(int i=0;i<(1<<n);i++){
			bool ok=true;
			for(int j=0;j<n;j++) if(i>>j&1) ok&=s[j]!='z';
			if(!ok) continue;
			
			for(int j=0;j<n;j++) t[j]=s[j]+(i>>j&1);
			first.fill(-1);
			for(int j=s.size();j--;) first[t[j]-'a']=j;
			for(int j=1;j<26;j++) if(first[j]!=-1) t[first[j]]--;
			
			if(t==s){
				for(int j=0;j<n;j++) t[j]=s[j]+(i>>j&1);
				res.push_back(t);
			}
		}
		sort(begin(res),end(res));
		
		cout<<res.size()<<endl;
		if(res.size()>10) res.erase(begin(res)+5,end(res)-5);
		for(string t:res) cout<<t<<endl;
	}
}

Measured memory_bytes: 2356
#include<bits/stdc++.h>
using namespace std;
int inf=1e9;
int main(){
	int n,m;cin>>n>>m;
	vector<int>a(n),b(n),c(m),d(m);
    vector<int>ans(n,-1);
  	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
  	for(int i=0;i<m;i++)cin>>c[i]>>d[i];

	for(int i=0;i<n;i++){
		int dst=inf;
		for(int j=0;j<m;j++){
			if(dst>abs(a[i]-c[j])+abs(b[i]-d[j])){
              ans[i]=j+1;
              dst=abs(a[i]-c[j])+abs(b[i]-d[j]);
	}
	}
    }
	for(auto&& u:ans)cout<<u<<endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 1000000000000000000
#define N 1000000007
#define mp make_pair
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}

//edge cases when n=1 , m=1. wrong variable in loop. if<->while;merge resize;LLONG_MAX
signed main()
{ 
	speed
	//global var
	int n,x;cin>>n>>x;
	std::vector<int> vec={0};
	int pres=0;
	for (int i = 0; i < n; ++i)
	{
		int tmp;cin>>tmp;
		pres+=tmp;
		vec.push_back(pres);
	}
	auto it=upper_bound(vec.begin(),vec.end(),x);
	cout<<it-vec.begin();
}

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

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

	string s;
	cin>>s;
	if(s[1]==s[0] || s[2]==s[1] || s[3]==s[2]) cout<<"Bad\n";
	else cout<<"Good\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a/2.0 == c && b/2.0 == d){
    printf("%.10f 1\n",(a*b/2));
  }else{
 printf("%.10f 0\n",(a*b/2));
 //cout<<(ll)(a*b/2)<<" "<<0<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int a ;
    cin >> a ;

    if(a < 1200 ){
        cout << "ABC" <<endl;
    } else if(a < 2800) {
        cout << "ARC" <<endl;
    } else {
        cout << "AGC" <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
X,Y,A,B,C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P = sorted(P, reverse=True)[:X]
Q = sorted(Q, reverse=True)[:Y]
R = sorted(P+Q+R, reverse=True)[:X+Y]
print(sum(R))

Measured memory_bytes: 23840
import java.util.Scanner;



public class Main {
	final int[][] ofs = {
			{1, 0}, {0,-1}, {-1, 0}, {0, 1}
	};
	int dfs(boolean map[][], int y, int x, int c){
		int max = c+1;
		map[y][x] = false;
		
		for(int i=0; i<4; ++i){
			int nx = x + ofs[i][0];
			int ny = y + ofs[i][1];
			if((0<=ny && ny<map.length) && (0<=nx && nx<map[0].length)){
				if(map[ny][nx]){
					int tmp = dfs(map, ny, nx, c+1);
					if(max<tmp){
						max = tmp;
					}
				}
			}
		}
		map[y][x] = true;
		
		return max;
	}
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		while(true){
			final int m = sc.nextInt();
			final int n = sc.nextInt();
			if(m==0 && n==0){return;}
			boolean[][] map = new boolean[n][m];
			for(int y=0; y<n; ++y){
				for(int x=0; x<m; ++x){
					map[y][x] = 1==sc.nextInt();
				}
			}
			
			int max = 0;
			for(int y=0; y<n; ++y){
				for(int x=0; x<m; ++x){
					if(map[y][x]){
						int tmp = dfs(map, y, x, 0);
						if(max<tmp){ max = tmp; }
					}
				}
			}
			System.out.println(max);
		}
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}

Measured memory_bytes: 12000
N=int(input())
a=[]
a.append(N)
x=N
index=2
while(True):
  if (x%2==0):
    x//=2
  else:
    x=3*x+1
  if(x in a):
    break
  else:
    index+=1
    a.append(x)
    
print(index)
      
  

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

int main() {
  string s;
  cin >> s;
  map<char,int> count;
  for(int i=0;i<4;i++) {
    count[s[i]]++;
  }
  if(count.size()==2) {
    for(auto p:count) {
      if(p.second!=2) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
# ABC 118: B – Foods Loved by Everyone
N, M = [int(s) for s in input().split()]
tmp = [[int(s) for s in input().split()] for _ in range(N)]
a = [tmp[i][1:] for i in range(N)]

kind = 0

for i in range(1, M + 1):
    everyone = True

    for j in range(N):
        if i not in a[j]:
            everyone = False
            break

    if everyone:
        kind += 1

print(kind)

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
char cal(char c,int A,int B){
	for(;B-A>0;B--){
		if(c=='z')c='a';
		else c++;
	}
	return c;
}
int main(){
	int n,a[100],b[100];
	string s;
	while(cin>>n,n){
		cin>>s;
		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i];
			a[i]--;
			b[i]--;
		}
		for(int i=n-1;i>-1;i--){
			swap(s[a[i]],s[b[i]]);
			s[a[i]]=cal(s[a[i]],a[i],b[i]);
			s[b[i]]=cal(s[b[i]],a[i],b[i]);
		}
		cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 1204
n,m=gets.split.map(&:to_i)
as=gets.split.map(&:to_i).sort
bcs=m.times.map{gets.split.map(&:to_i)}.sort{|a,b| b[1]<=>a[1]}
new=[]

i=0
while i<m && new.size<n
  [bcs[i][0],n-new.size].min.times{new.push(bcs[i][1])}
  i+=1
end

x=0
while x<n && x<new.size
  if as[x]<new[x]
    x+=1
  else
    break
  end
end

if x==0
  puts as.inject(:+)
else
  puts (as[x..-1]+new[0..x-1]).inject(:+)
end


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

class Dice{
    int top;
    int bottom;
    int S;
    int W;
    int E;
    int N;
    
    Dice(int a,int b, int c,int d,int e,int f){
        this.top = a;
        this.bottom = b;
        this.S = c;
        this.W = d;
        this.E = e;
        this.N = f;
    }

    public void RollS(){
        //W = W;
        //E = E; 
        int tmp = this.bottom;
        this.bottom = this.S;
        this.S = this.top;
        this.top = this.N;
        this.N = tmp;
    }

    public void RollW(){
        //this.S = S;
        //this.N = N;
        int tmp =this.top;
        this.top = this.E;
        this.E = this.bottom;
        this.bottom = this.W;
        this.W = tmp;
    }
   
    public void RollE(){
        int tmp = this.top;
        this.top = this.W;
        this.W = this.bottom;
        this.bottom = this.E;
        this.E = tmp;
   }

   public void RollN(){
        int tmp = this.top;
        this.top = this.S;
        this.S = this.bottom;
        this.bottom = this.N;
        this.N = tmp;
   }
}

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
                    
        str = br.readLine();
        String[] nums = str.split("\\s");
        int[] temp = new int[6];
        for(int i=0;i<6;i++){
            temp[i] = Integer.parseInt(nums[i]);
        }

        Dice D = new Dice(temp[0],temp[5],temp[1],temp[3],temp[2],temp[4]);
        str = br.readLine();
        String[] rolls = str.split("");                    
        for(int i=0;i<rolls.length;i++){
            if(rolls[i].equals("S")){
                D.RollS(); 
            }else if(rolls[i].equals("W")){
                D.RollW();
            }else if(rolls[i].equals("E")){
                D.RollE();
            }else{
                D.RollN();
            }
        }
        System.out.println(D.top);

        br.close();
    }
}


Measured memory_bytes: 24588
import java.util.Scanner;

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

		if(u.equals(s)) {
			a--;
		}else if(u.equals(t)) {
			b--;
		}

		System.out.println(String.format("%d %d", a, b));
	}
}


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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())
int main(){
    string s;
    vector<string> ans;
    int K;
    cin>>s>>K;
    rep(i,len(s)){
        FOR(j,i,min(len(s),i+5)){
            auto it=s.begin();
            string x;
            it+=i;
            while(len(x)!=(j-i+1)){
                x+=*it;
                it++;
            }
            auto itr=find(ans.begin(),ans.end(),x);
            if (itr==ans.end() && len(x)<=5){
                ans.push_back(x);
            }
        }
    }
    sort(ans.begin(),ans.end());
    cout<<ans[K-1]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N, M;
    cin >> N >> M;
    vector<int> H(N+1);
    set<int> s;
    for (int i = 1; i <= N; i++) {
        cin >> H[i];
        s.insert(i);
    }
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        if (H[A] == H[B]) {
            s.erase(A);
            s.erase(B);
        }
        else if (H[A] > H[B]) {
            s.erase(B);
        }
        else {
            s.erase(A);
        }
    }
    cout << s.size() << endl;
}

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

using namespace std;

const int maxn = 2e5 + 5;


struct SHIT
{
    int x, y;
}shit[maxn];
bool cmp(SHIT a, SHIT b)
{
    if(a.x!=b.x) return a.x<b.x;
    return a.y<b.y;
}
int main() {
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    for(int i=0;i<k;i++)
    {
        scanf("%d%d",&shit[i].x,&shit[i].y);
    }
    sort(shit,shit+k, cmp);
    int shit_cnt=0;
    int ans=n;
    int now=1;
    for(int i=2;i<=n;i++)
    {
        //printf("%d %ds\n",i, now);
        while(shit[shit_cnt].x < i && shit_cnt<k){
            shit_cnt++;
        }
        if(shit_cnt==k) break;
        if(shit[shit_cnt].x!=i){
            now++;
            continue;
        }
        if(shit[shit_cnt].y<=now){
            //printf("%d %d %d\n", shit[shit_cnt].x, shit[shit_cnt].y, now);
            ans=i-1;break;
        }
        else if(shit[shit_cnt].y==now+1){
            continue;
        }
        else{
            //printf("%d is ++ %d %d\n",i,shit[shit_cnt].x, shit[shit_cnt].y);
            now++;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#define MOD 1000000007
unsigned long long int sum=1; 
using namespace std;

unsigned long long int fast_power_with_mod(long long base, long long power) {
    long long result = 1;
    while(power > 0) {

        if(power % 2 == 1) { // Can also use (power & 1) to make code even faster
            result = (result%MOD*base%MOD) % MOD;
        }
        base = (base * base) % MOD;
        power = power / 2; // Can also use power >>= 1; to make code even faster
    }
   	return result%MOD;
}

unsigned long long int fast_power(long long base, long long power) {
    long long result = 1;
    while(power > 0) {

        if(power % 2 == 1) { // Can also use (power & 1) to make code even faster
            result = (result%MOD*base%MOD);
        }
        base = (base * base);
        power = power / 2; // Can also use power >>= 1; to make code even faster
    }
   	return result;
}
/*int find_ind(int a[],int n,int elem)
{
	int ret_ind=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==elem)
			ret_ind = i;
	}
	a[ret_ind]=-1;
	return ret_ind;
}*/
int arraySortedOrNot(int arr[], int n) 
{ 
    // Array has one or no element or the 
    // rest are already checked and approved. 
    if (n == 1 || n == 0) 
        return 1; 
  
    // Unsorted pair found (Equal values allowed) 
    if (arr[n - 1] < arr[n - 2]) 
        return 0; 
  
    // Last pair was sorted 
    // Keep on checking 
    return arraySortedOrNot(arr, n - 1); 
}


void implement()
{
	int a,b,c,d;
	cin >> a >> b >> c >>d;
	int flag=0;
	while(true)
	{
		if(flag==0)
		{
			c=c-b;
			if(c<=0)
			{
				cout << "Yes" << endl;
				break;
			}
			flag=1;
		}
		else
		{
			a=a-d;
			if(a<=0)
			{
				cout << "No" << endl;
				break;
			}
			flag=0;

		}

	}


	

}

void multi_test(){
	int t;
	cin >> t;
	for(int i=0;i<t;i++)
	{
		implement();
	}
}

void single_test()
{
	implement();
}

int main()
{
	//multi_test();
	single_test();
	return 0;
}



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

int main()
{
    int n,m;
    string a,b,c;
    string a1,b1,c1;
    cin>>a;
    n=a.size();
    m=n/2;
    b=a.substr(0,m);
    c=a.substr(m+1,m);
    a1=a;
    c1=c;
    b1=b;
    reverse(a.begin(),a.end());
    reverse(c.begin(),c.end());
    reverse(b.begin(),b.end());
    if(a1==a&&b1==b&&c1==c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

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

	sort(a.begin(), a.end());
	int ai = a[n - 1];
	int aj = 0;
	int mid = ceil(ai / 2.0);
	for(int i = 0; i < n - 1; i++) {
		if(abs(mid - a[i]) < abs(mid - aj)) {
			aj = a[i];
		}
	}

	cout << ai << ' ' << aj << endl;

	return 0;
}


Measured memory_bytes: 640
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
else:
  ps = list(map(int, input().split()))
counters = [0 for _ in range(len(ps)+1)]
counters[0] = 1

for i,p in enumerate(ps):
  distance = abs(x - p)
  if distance < len(ps):
    counters[distance] += 1

for i,counter in enumerate(counters):
  if counter == 0:
    print(x-i)
    break
  elif counter == 1:
    if x-i in ps:
      print(x+i)
    else:
      print(x-i)
    break

Measured memory_bytes: 9224
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main(){
    string str;
    
    while(getline(cin,str),str!="0"){
        int sum = 0,num,cnt=0;
        stringstream s;
        s << str;
        
        while(s >> num){
            if(2 <= num && num <= 9) sum += num;
            else if(num >= 10) sum += 10;
            else{
                sum++;
                cnt++;
            }
        }
        if(sum <= 11 && cnt){
            sum += 10;
            cnt--;
        }
        if(sum > 21) cout << '0' << endl;
        else cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
/*
ソートして半分に割って
大きいほう小さいほうに分けて
交互に要素を並べればいい
この時大きいほうの最大値は内側に最小値は外側に
小さいほうの最小値は内側に最大値は外側に
 */
int n;
ll calc(ll *a){
    ll ret=0;
    for(int i=1;i<n;i++){
        ret+=abs(a[i]-a[i-1]);
    }
    return ret;
}
int main(){
    cin>>n;
    ll a[n];
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    
    if(n%2==0){
        ll b[n/2],s[n/2];
        for(int i=0;i<n/2;i++){
            s[i]=a[i];
        }
        for(int i=n/2;i<n;i++){
            b[i-n/2]=a[i];
        }
        ll ans[n];
        //s[n-1]とb[0]を端
        ans[n-1]=s[n/2-1];ans[0]=b[0];
        rep(i,n){
            if(i==0||i==n-1) continue;
            if(i%2==0){
                ans[i]=b[i/2];
            }
            else{
                ans[i]=s[i/2];
            }
        }
        cout<<calc(ans)<<endl;
    }   
    else{
        //問題はこっちじゃんね
        //中央値は必ず端か
        //もう一方の端はsmallの最大値かbigの最小値
        ll s[n/2]={},b[n/2]={},mid;
        int index=0;
        for(;index<n/2;index++){
            s[index]=a[index];
        }
        mid=a[index];
        index++;
        for(;index<n;index++){
            b[index-n/2-1]=a[index];
        }
        ll ans1[n],ans2[n];
        ans1[n-1]=mid;ans2[n-1]=mid;
        //0,2,4,..をbigにするかsmallにするかで分ける。
        sort(s,s+n/2,greater<ll>());
        for(int i=0;i<n-1;i++){
            if(i%2==0){
                ans1[i]=s[i/2];
                ans2[i]=b[i/2];
            }
            else{
                ans1[i]=b[i/2];
                ans2[i]=s[i/2];
            }
        }
        cout<<max(calc(ans1),calc(ans2))<<endl;
    }
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    int n;
    cin>>n;
    int f[n][10],p[n][11];
    rep(i,n){
        rep(j,10){
            cin>>f[i][j];
        }
    }
    rep(i,n){
        rep(j,11){
            cin>>p[i][j];
        }
    }
    int ans =-INF;
    rep(bit,(1<<10)){
        if(bit==0)continue;
        vi cnt(n,0);
        rep(i,10){
            if(bit&(1<<i)){
                rep(j,n){
                    if(f[j][i]==1)cnt[j]++;
                }
            }
        }
        int sum=0;
        rep(i,n){
            sum+=p[i][cnt[i]];
        }
        //cout<<sum<<' '<<bit<<endl;
        ans =max(ans,sum);
    }
    cout<<ans<<endl;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q;
string S;
int size;
vector<vector<int>> w, b, W, B;

int get_sum(const vector<vector<int>> &S, int i1, int j1, int i2, int j2) {
    return S[i2][j2] - S[i1][j2] - S[i2][j1] + S[i1][j1];
}

int main() {
    cin >> N >> K;
    vector<int> x(N), y(N);
    vector<char> c(N);
    for (int i = 0; i < N; i++) {
        cin >> x.at(i) >> y.at(i) >> c.at(i);
    }

    size = K * 2;
    w = make_vec<int>(size, size);
    b = make_vec<int>(size, size);
    W = make_vec<int>(size + 1, size + 1);
    B = make_vec<int>(size + 1, size + 1);
    for (int i = 0; i < N; i++) {
        if (c[i] == 'W') {
            x[i] %= 2 * K;
            y[i] %= 2 * K;
            w[x[i]][y[i]]++;
        } else if (c[i] == 'B') {
            x[i] += K;
            x[i] %= 2 * K;
            y[i] %= 2 * K;
            w[x[i]][y[i]]++;
        }
    }

    for (int i = 0; i < size; i++) {
        for (int j = 0; j < size; j++) {
            W[i + 1][j + 1] = W[i][j + 1] + W[i + 1][j] - W[i][j] + w[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K; j++) {
            int sum = 0;
            sum += get_sum(W, i, j, i + K, j + K);
            sum += get_sum(W, 0, 0, i, j);
            sum += get_sum(W, 0, j + K, i, size);
            sum += get_sum(W, i + K, 0, size, j);
            sum += get_sum(W, i + K, j + K, size, size);
            chmax(ans, sum);
        }
    }
    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K; j++) {
            int sum = 0;
            sum += get_sum(W, 0, j, i, j + K);
            sum += get_sum(W, i, 0, i + K, j);
            sum += get_sum(W, i + K, j, size, j + K);
            sum += get_sum(W, i, j + K, i + K, size);
            chmax(ans, sum);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 64000
#include <stdio.h>
int main(void)
{
int S,h,m,s;
scanf("%d",&S);
if (S>=0 && S<86400){
h=S/3600;
m=(S-h*3600)/60;
s=S-(h*3600+m*60);
printf ("%d:%d:%d\n",h,m,s);
}
return 0;
}

Measured memory_bytes: 2672
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N,h[100000];
  cin>>N;
  for (int i(0);i<N;i++) cin>>h[i];
  int next(h[N-1]);
  for (int i(N-2);i>=0;i--){
    if (h[i]==next+1) next = h[i]-1;
    else if (h[i] <= next) next = h[i];
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
#define mp make_pair
#define pb push_back
#define f(a,b) for(ll i=a;i<b;i++)
#define F first 
#define S second
typedef long long int ll;
//const long long int MAX 1000000
//const long long int MOD 1e9+7



/************************************


 
*************************************/


int main() {
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	ll dp[n];
	dp[0]=0;
	if(k<=n){
	for(ll i=1;i<=k;i++){
		dp[i] = INT_MAX;
		for(ll j=0;j<i;j++){
			dp[i] = min(dp[i],dp[j]+abs(a[j]-a[i]));
		}
	}
	
	
	// cout<<k<<endl;
	// for(ll i=0;i<=k;i++){
	// 	cout<<dp[i]<<" kk";
	// }
	for(ll i=k+1;i<n;i++){
		dp[i] = INT_MAX;
		for(ll j=i-1;j>=i-k;j--){
			dp[i] = min(dp[i],dp[j]+abs(a[j]-a[i]));
		}
	}
	}
	else{
		for(ll i=1;i<n;i++){
		dp[i] = INT_MAX;
		for(ll j=0;j<i;j++){
			dp[i] = min(dp[i],dp[j]+abs(a[j]-a[i]));
		}
	}
	}
	// for(ll x:dp)
	// 	cout<<x<<" ";
	cout<<dp[n-1];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1792
// Problem : F - Knapsack for All Subsets
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z)                                                       \
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define dbp(x) \
  cout << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define dbv(v)                         \
  {                                    \
    cout << #v << " : ";               \
    for (auto x : v) cout << x << ' '; \
    cout << endl;                      \
  }
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
#define die(x) return cout << x << '\n', 0;

using namespace std;

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

vvi dp;
vi a;
const int MOD = 998244353;
int n, s;
int solve(int i, int j) {
  if (i == n) return (j == 0) ? 1 : 0;
  if (dp[i][j] != -1) return dp[i][j];
  if (a[i] <= j) {
    return dp[i][j] =
               (solve(i + 1, j - a[i]) + ((2 * solve(i + 1, j)) % MOD)) % MOD;
  } else {
    return dp[i][j] = (2 * solve(i + 1, j)) % MOD;
  }
}

int32_t main() {
  fastio;
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  int testcases;
  testcases = 1;
  // cin >> testcases;

  while (testcases--) {
    cin >> n >> s;
    dp.assign(n + 1, vector<int>(s + 1, -1));
    a.resize(n);
    rep(i, 0, n - 1) cin >> a[i];
    cout << solve(0, s) << '\n';
    /*   rep(i, 0, n) {
         db1(i);
         dbv(dp[i]);
       }*/
  }

  return 0;
}


Measured memory_bytes: 73948
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var input string
	if sc.Scan() {
		input = sc.Text()
	}
	tmp := strings.Split(input, " ")
	a, _ := strconv.Atoi(tmp[0])
	b, _ := strconv.Atoi(tmp[1])

	if (a*b)%2 == 0 {
		fmt.Print("No")
	} else {
		fmt.Print("Yes")
	}
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll x, y; cin >> x >> y;
    ll ans;
    if(x * y >= 0){
        if(y >= x){
            ans = abs(abs(x) - abs(y));
        }else{
            if(x == 0 || y == 0) ans = abs(abs(x) - abs(y)) + 1;
            else ans = abs(abs(x) - abs(y)) + 2;
        }
    }else{
        ans = abs(abs(x) - abs(y)) + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    n = int(input())
    a = list(map(int, input().split()))
    x = 0
    y = sum(a)
    res = 10**20
    for i in range(n-1):
        x += a[i]
        y -= a[i]
        res = min(res, abs(x-y))
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 25436
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef long long int ll;

#define INF (1e9)

int main() {
    int x[] = {0, 0, 0, 0}, A, B;
    for (int i = 0; i < 3; i++) {
        cin >> A >> B;
        x[A - 1]++;
        x[B - 1]++;
    }
    int cnt1 = 0;
    int cnt2 = 0;
    for (int i = 0; i < 4; i++) {
        if (x[i] == 1) cnt1++;
        if (x[i] == 2) cnt2++;
    }

    if (cnt1 == 2 and cnt2 == 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A + B > C + D)
	{
		cout << "Left" << endl;
     }
	else if (A + B == C + D)
	{
		cout << "Balanced" << endl;
	}
	else
	{
		cout << "Right" << endl;
	}
	

	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define f first
#define s second
#define N 100000
using namespace std;
typedef pair <int,int> P;
typedef long long ll;

int main(){
  int n,m,hp[101];
  
  while(cin>>n,n){
    for(int i=0;i<n;i++) cin>>hp[i];

    vector <P> mg[2];  
    cin>>m;
    for(int i=0,cost,dam;i<m;i++){
      string name,type;
      cin>>name>>cost>>type>>dam;
      if(dam)mg[type=="All"].push_back(P(dam,cost));
    }

    int dp[2][N+10]={};
    for(int i=0;i<2;i++)for(int j=1;j<N+10;j++)dp[i][j]=INF;
 
    for(int k=0;k<2;k++)
      for(int i=0;i<mg[k].size();i++)
	for(int j=mg[k][i].f;j<=(N/mg[k][i].f+1)*mg[k][i].f;j++)
	  dp[k][min(N,j)]=min(dp[k][min(N,j)],dp[k][j-mg[k][i].f]+mg[k][i].s);

    for(int i=0;i<2;i++)
      for(int j=N;j>=0;j--)dp[i][j]=min(dp[i][j],dp[i][j+1]);
      
    ll ans=INF;
    for(int i=0;i<=N;i++){
      ll cost=dp[1][i];
      for(int j=0;j<n;j++)cost+=dp[0][max(0,hp[j]-i)];
      ans=min(ans,cost);
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

using namespace std;
using int64 = long long;

int main() {
    int64 n, a, b;
    cin >> n >> a >> b;

    int64 ans = a * (n / (a+b));
    ans += min(n%(a+b), a);

    cout << ans << endl;
}


Measured memory_bytes: 888
import sys
from collections import deque

n = int(sys.stdin.readline())

que = deque()

for i in range(n):
    query = sys.stdin.readline().split()
    if query[0] == '0': # push
        if query[1] == '1':
            que.append(query[2])
        else:
            que.appendleft(query[2])
    elif query[0] == '1':
        print(que[int(query[1])])
    elif query[0] == '2':
        if query[1] == '1':
            que.pop()
        else:
            que.popleft()
    else:
        raise ValueError


Measured memory_bytes: 34576
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if (a<b){
    cout << "a < b" << endl;
  }else if (a>b){
    cout << "a > b" << endl;
  }else{
    cout << "a == b" << endl;
  }
  return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    if (x >= 30) {
        cout << "Yes"
             << "\n";
    } else
        cout << "No"
             << "\n";
    return 0;
}

Measured memory_bytes: 3640