akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//万合以致，向阳而生——背叛时代，忠于时间//
#pragma GCC optimize(3,"Ofast","inline")
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef unsigned long long ull;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define forn(i, n) for(register int i=0; i<n; i++)
#define Forn(i, n) for(register int i=1; i<=n; i++)
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)
#define mid l+r>>1
#define lid id<<1|1
#define rid (id<<1)+2
#define lson lid, l, mid
#define rson rid, mid, r

inline int in()
{
    char c=getchar();
    int neg=1, x=0;
    while(!isdigit(c)) (c=='-')?neg=-1, c=getchar():c=getchar();
    while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48), c=getchar();
    return neg*x;
}
inline int lcm(int a, int b){return a*b/__gcd(a, b);}

const int MAX=20e5+5;

int N, M, ret, ptr, mark[MAX], fail[MAX], dp[MAX];
char tt[MAX];
set<int> tmp;
string s, t;
vi v;

inline void kmp()
{
    fail[0]=ptr=-1;
    Forn(i, M)
    {
        while(ptr>-1&&t[ptr]!=t[i-1]) ptr=fail[ptr];
        fail[i]=++ptr;
    }
    
    ptr=0;
    forn(i, s.size())
    {
        while(ptr>-1&&s[i]!=t[ptr])
            ptr=fail[ptr];
        ptr++;
        if(ptr>=M) mark[i-M+1]=1;
    }
}

inline int dfs(int x)
{
    int &ret=dp[x];
    if(~ret) return 1;
    ret=0;
    if(!mark[x]) return 1;
    ret=-2;
    if(dp[(x+M)%N]==-2) return 0;
    if(!dfs((x+M)%N)) return 0;
    ret=dp[(x+M)%N]+1;
    return 1;
}

int main()
{
    memset(dp, -1, sizeof(dp));
    scanf("%s", tt); s=tt;
    scanf("%s", tt); t=tt;
    while(s.size()<t.size()) s+=s;
    N=s.size(), M=t.size();
    s+=s;
    
    kmp();
    int ret=0;
    forn(i, N) if(dp[i]==-1)
    {
        if(!dfs(i))
        {
            ret=-1;
            break;
        }
        ret=max(ret, dp[i]);
    }
    printf("%d\n", ret);
    return 0;
}
// baaab
//abaaba


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

int main(){
	ll  n;cin>>n;
map<ll,ll>m;
	for(ll i=0;i<n-1;i++){
		ll x;cin>>x;
		m[x]++;
	}
for(ll i=1;i<=n;i++)
cout<<m[i]<<endl;
}

Measured memory_bytes: 16108
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    
    String[] s = br.readLine().split(" ");
    int h = Integer.parseInt(s[0]);
    int w = Integer.parseInt(s[1]);
    int n = Integer.parseInt(br.readLine());
    int[] arr = new int[n];
    s = br.readLine().split(" ");
    for (int i=0; i<n; i++) {
      arr[i] = Integer.parseInt(s[i]);
    }
    int[][] out = new int[h][w];
    int index = 0;
    int colourCount = 0;
    for (int i=0; i<n; i++) {
      for (int j=0; j<arr[i]; j++) {
        int[] cell = getCell(index, h, w);
        out[cell[0]][cell[1]] = i+1;
        index++;
      }
    }
    for (int i=0; i<h; i++) {
      for (int j=0; j<w; j++) {
        sb.append(out[i][j]);
        sb.append((j==w-1) ? "\n" : " ");
      }
    }
    System.out.print(sb);
  }
  static int[] getCell(int index, int h, int w) {
    int row = index/w;
    int col = ((index/w)%2==0) ? index%w : w-1-(index%w);
    return new int[]{row,col};
  }
}


Measured memory_bytes: 23124
n,t=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l=[[j for j in i] for i in l if i[1]<=t]
s=0
for i in l:
  s+=i[1]
if s!=0:
  print(min(l)[0])
else:
  print('TLE')

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

using namespace std;


int main() {
    string s;
    cin >> s;
    int ans = 0,counter = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'A' || s[i] == 'T' or s[i] == 'G' or s[i] == 'C') {
            counter++;
        } else {
            ans = max(ans,counter);
            counter = 0;
        }
    }
    ans = max(ans,counter);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3548
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	cin >> N;
	if (N < 1000) cout << "ABC" << endl;
	else cout << "ABD" << endl;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

n, m = map(int, input().split())
a = list(map(int, input().split()))

h = []

for x in a:
    heappush(h, -x)

for i in range(m):
    temp = heappop(h)
    p = -((-temp) // 2)
    heappush(h, p)

print(- sum(h))

Measured memory_bytes: 14180
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1),i=new(r(2))(n.readFileSync("/dev/stdin","utf8").trim().split(/\s+/g));r(4)(i)},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3);t.exports=class{constructor(t){this.inp=new n(t)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=new Array(e),n=0;n<e;n++){var i=t.in(),o=t.in(),s=i+o;r[n]={A:i,B:o,C:s}}r.sort(function(t,e){return e.C-t.C});for(var u=0,c=0;c<e;c++)c%2==0?u+=r[c].A:u-=r[c].B;console.log(u)}}]);

Measured memory_bytes: 56584
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
const ll INF=1e18;
int main()
{
	int n;
	int ind[1001];
	cin>>n;
	int w[1001], s[1001]; ll v[1001];
	for(int i=1; i<=n; i++){
		ind[i]=i;
		cin>>w[i]>>s[i]>>v[i];
	}
	sort(ind+1, ind+n+1, [&](int i, int j){ return w[i]+s[i]<w[j]+s[j];});
	ll dp[1001][20001];
	for(int j=0; j<=20000; j++){
		dp[0][j]=-INF;
	}
	dp[0][0]=0;
	for(int i=0; i<n; i++){
		for(int j=0; j<=20000; j++){
			dp[i+1][j]=dp[i][j];
		}
		for(int j=0; j<=s[ind[i+1]]; j++){
			if(dp[i][j]<0) continue;
			dp[i+1][w[ind[i+1]]+j]=max(dp[i+1][w[ind[i+1]]+j], dp[i][j]+v[ind[i+1]]);
		}
	}
	ll ans=0;
	for(int i=0; i<=20000; i++){
		ans=max(dp[n][i], ans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 156672
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 15
using namespace std;
using LL = long long;
int n;
char in[M];
LL getnum(int x,int y) {
    LL re = 0;
    REP(i,x,y) {
        re = re*10 + in[i]-48;
    }
    return re;
}
int main()
{
    while (~scanf("%s", in+1)) {
        LL ans = 77777777;
        n = strlen(in+1);
        REP(i,3,n) {
            LL x = getnum(i-3+1,i);
            ans = min(ans, abs(753-x));
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int N,K;
    string S,T="";
    cin >> N >> S >> K;
    for (int i=0; i<N; i++) {
        if (S[i] == S[K-1])
            T += S[i];
        else
            T += '*';
    }
    cout << T << endl;
    return 0;
}


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

using namespace std;

const int mxn = 1e6;

bool flag[mxn + 11];

int main(){
	int k;
	scanf("%d", &k);
	int cur = 0;
	for (int i = 1; i; i++){
		cur *= 10;
		cur += 7;
		if (cur % k == 0){
			printf("%d\n", i);
			return 0;
		}
		cur %= k;
		if (flag[cur]){
			puts("-1");
			return 0;
		}
		flag[cur] = true;
	}
}


Measured memory_bytes: 4796
n = int(raw_input())
s = raw_input()

def caesar_encrypt(realText, step):
    outText = ""
    cryptText = []

    uppercase = ['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']
    for eachLetter in realText:
        index = uppercase.index(eachLetter)
        crypting = (index + step) % 26
        cryptText.append(crypting)
        newLetter = uppercase[crypting]
        outText+=newLetter
    return outText
  
print(caesar_encrypt(s,n))

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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf("%.12lf\n",mid);
// __builtin_popcount(int) count 1's in binary
// get decimal pert of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = "And I feel fine...";
    istringstream iss(sentence);
*/  

double eps = .000000001;

int main ()
{
  prep();
  int n;
  cin >> n;
  int arr[n];
  for (int i=0; i<n; i++){
      cin >> arr[i];
  }
  
  int arr2[n];
  for (int i=0; i<n; i++){
      arr2[i] = arr[i];
  }
  sort(arr2, arr2+n);
  int num1, num2, num3, num4;
  int cnt = 0;
  for (int i=0; i<n; i++){
      
      if (arr[i] != arr2[i] && cnt == 0){
          num1 = arr[i];
          num2 = arr2[i];
          cnt++;
      }else if (arr[i] != arr2[i] && cnt == 1){
          num3 = arr[i];
          num4 = arr2[i];
          cnt++;
      }else if (arr[i] != arr2[i]){
          cnt++;
      }
      
  }
  if (cnt > 2){
      cout << "NO";
      return 0;
  }
  if (cnt == 0){
      cout << "YES";
      return 0;
  }
  //cout << num1 << " " << num2 << " " << num3 << " " << num4 << endl;
  if (num1 != num4 || num2 != num3){
      cout << "NO";
      return 0;
  }
  cout << "YES";
  return 0; 
 
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
n = int(input())
a = [int(i) for i in input().split()]
current = a[0]
good = True
for i in range(1,n):
    if a[i] < a[i-1]:
        good = False
        break
    if a[i] == a[i-1]:
        continue
    if a[i] > a[i-1]:
        a[i] = a[i] - 1
if good:
    print("Yes")
else:
    print("No")

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

int main(){
  int d,m,n,L=142,ans;
  cin>>d;
  while(d--){
    cin>>m>>n;
    ans=0;
    for(int i=-L;i<L;i++)
      for(int j=-L;j<L;j++){
	if(!i&&!j)continue;
	int a=i*i+j*j;
	if(!((i*m+j*n)%a)&&!((i*n-j*m)%a))ans++;
      }
    if(ans==8)cout<<"P"<<endl;
    else cout<<"C"<<endl;
  }
  return 0;
}

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

#define ll long long

int main() {

    string s,t;
    cin>>s>>t;
    ll n1=s.size();
    ll n2=t.size();
    ll ans=n1;
    for(ll k=0;k<(n1-n2+1);k++) {
        ll cnt=0;
        for(ll i=0;i<n2;i++) {
            if(s[i+k]!=t[i])
            cnt++;
        }
        ans=min(ans,cnt);
    }

    cout<<ans<<endl;   

    return 0;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;

const int mod = 1e9+7;
int dp[2000][2000];
string str, s;
signed main(){
	cin >> str >> s;
	str = " "+str;s = " "+s;
	int n = str.size(), m = s.size();
	rep(i,2000)dp[i][0] = 1;
	rrep(i,n){
		rrep(j,m){
			dp[i][j] = dp[i-1][j];
			if(s[j] == str[i])ADD(dp[i][j], dp[i-1][j-1]);
		}
	}
	
	printf("%lld\n", dp[n][m]);
	return 0;
}





Measured memory_bytes: 19148
n, m = map(int, input().split()) 
hlist = list(map(int, input().split())) 
num = [0]*n
for j in range(m): 
    a, b = map(int, input().split())
    if hlist[a-1] > hlist[b-1]:
        num[b-1] = 1
    elif hlist[a-1] < hlist[b-1]:
        num[a-1] = 1
    elif hlist[a-1] == hlist[b-1]:
        num[a-1] = 1
        num[b-1] = 1
print(num.count(0))

Measured memory_bytes: 20088
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli, lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout << (x ? "Yes" : "No") << endl;
#define YES(x) cout << (x ? "YES" : "NO") << endl;
#define out(s) cout << s << endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " "
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(), s.end()
void vout(vi v)
{
    for (lli i = 0; i < v.size(); i++)
        cout << v.at(i) << endl;
}
int main()
{
    cout << std::fixed << std::setprecision(10);
    lli n, x, m, ans = 0;
    cin >> n >> x >> m;
    set<lli> ch;
    vi rec;
    lli last = x;
    lli tmp = 0;
    ch.insert(x);
    rec.push_back(x);
    rep(i, 2 * m)
    {
        x = ((x * x) % m);
        if (ch.count(x))
        {
            last = x;
            break;
        }
        else
        {
            ch.insert(x);
            rec.push_back(x);
        }
    }
    lli lasti;
    rep(i, rec.size())
    {
        if (rec[i] == last)
        {
            lasti = i;
        }
    }
    for (lli i = 0; i < lasti;i++)
    {
        ans += rec[i];
    }
    for (lli i = lasti; i < rec.size();i++){
        tmp += rec[i];
    }
    n -= lasti;
    ans += tmp*(n / (rec.size() - lasti));
    tmp = n % (rec.size() - lasti);
    for (lli i = 0; i < tmp;i++){
        ans += rec[lasti + i];
    }
        out(ans);
}

Measured memory_bytes: 5884
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,sum=0;
  cin>>n>>k;
  vector<int> v(n);
  for(int i=0;i<n;i++)
  {
      cin>>v[i];
  }
    
 sort(v.begin(),v.end());
 for(int i=0;i<k;i++)
 {
     sum+=v[i];
 }
 
 cout<<sum<<"\n";
 return 0;
}

Measured memory_bytes: 3636
n,k=map(int,input().split())
W=[int(input()) for _ in range(n)]

def ok(p):
    t=1
    c=p
    for w in W:
        if w>p: return False
        if w<=c: c-=w
        else:
            t+=1
            c=p-w
            if t>k: return False
    return True
  
L=0
U=sum(W)
while U-L>1:
    x=(U+L)//2
    if ok(x): U=x
    else: L=x
print(U)


Measured memory_bytes: 9564
#!/usr/bin/env python3
import sys

INF = 10 ** 10
def solve(N: int, K: int, h: "List[int]"):
    l = sorted(h)

    res = INF
    for i in range(0, N):
        if i + K - 1 == N:
            break
        res = min(l[i + K - 1] - l[i], res)
    
    print(res)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)

if __name__ == '__main__':
    main()


Measured memory_bytes: 8280
#include <iostream>
#include <algorithm>
#include<vector>
#include<string>
using namespace std;
int main() {
int n,p[100],i=0,j=0,k[100],m;
string city[100],buffer;
cin>>n;
while(i<n){
cin>>city[i];cin>>p[i];
k[i]=i+1;
i++;
}
i=0;
while(i<n){
	j=i+1;
	while(j<n){
		if(city[i]>city[j]){
			buffer=city[i];
			m=k[i];
			city[i]=city[j];
			k[i]=k[j];
			city[j]=buffer;
			k[j]=m;
			m=p[i];
			p[i]=p[j];
			p[j]=m;
		}
		j++;
	}
	i++;
}
i=0;
while(i<n){
	j=i+1;
	while(j<n){
		if(city[i]==city[j]){
			if(p[i]<p[j]){
            m=k[i];
			k[i]=k[j];
			k[j]=m;
			m=p[i];
			p[i]=p[j];
			p[j]=m;
			}
		}
		j++;
	}
	i++;
}
i=0;
while(i<n){
cout<<k[i]<<"\n";
i++;
}
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
int main(){
    int a,b;
    cin>>a>>b;
    rep(i,3)if(i+1!=a&&i+1!=b) cout<<i+1;
}

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

class Program
{
    static void Main(string[] args)
    {
        int k = int.Parse(Console.ReadLine());
        int[] ab = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int a = ab[0];
        int b = ab[1];
        for (int i = a; i <= b; i++)
        {
            if (i % k == 0)
            {
                Console.WriteLine("OK");
                return;
            }
        }
        Console.WriteLine("NG");
    }
}

Measured memory_bytes: 28236
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
void binarySearch(int f,int l,vi array){

}
int main(){
  
  while(true){
    int n;
    cin >> n;
    if(n == 0)return 0;
    int min = 1000001;

    for(int i = 0;i*i*i <=1000000;i++){
      for(int j = 0;j*j <= 1000000;j++){
	int x = n-i*i*i-j*j;
	if(x<0)break;
	if(min >x+i+j)min = x+i+j;
      }
    }
    cout << min << endl;

  }
  
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
using namespace std;
constexpr char nl = '\n';
using ll = long long;
using boost::irange;
using boost::adaptors::reversed;
struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    cin >> a;
    for (int i : irange(0, n) | reversed) {
        int bit = 0;
        for (int j = 2; (i+1) * j <= n; j++) {
            bit ^= b[(i+1) * j - 1];
        }
        b[i] = a[i] ^ bit;
    }
    vector<size_t> ans;
    for (int i : irange(0, n)) {
        if (b[i]) ans.push_back(i+1);
    }
    cout << ans.size() << nl << ans << nl;
}


Measured memory_bytes: 3700
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define MAXK 26
#define MAXX 15000006
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, L[MAXN], len[MAXN], ans;
priority_queue <ll> lefty;
priority_queue <ll, vector<ll>,greater<ll>> righty;
ll l_shift, r_shift;
int main()
{
	FAST
	cin>>n;
	FOR(i,0,n) {
		ll l,r;cin>>l>>r;
		L[i]=l;len[i]=r-l;
	}
	lefty.ph(L[0]); righty.ph(L[0]);
	FOR(i,1,n) {
		l_shift += len[i];
		r_shift += len[i-1];
		ll left_line = lefty.top() - l_shift;
		ll right_line = righty.top() + r_shift;
		ll x=L[i];
		if(x<left_line) { // throw one from left to right
			lefty.ph(x+l_shift); lefty.ph(x+l_shift);
			ans += left_line - x;
			righty.ph(left_line-r_shift); lefty.pop();
		} else if(x>right_line) { // right to left
			righty.ph(x-r_shift); righty.ph(x-r_shift);
			ans += x-right_line;
			lefty.ph(right_line+l_shift); righty.pop();
		} else {
			lefty.ph(x+l_shift);
			righty.ph(x-r_shift);
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 4972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		int N = S.length();

		StringBuilder s = new StringBuilder();
		for(int i=0; i<N; i++) {
			s.append('x');
		}


		System.out.println(s.toString());
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n,y,b,num;
    double r,t,moto,ma;
    
    while(cin >> n,n!=0){
        cin >> y;
        num = 1;
        ma = 0;
        for(int i=0;i<n;i++){
            cin >> b >> r >> t;
    
            if(t == 1){
                moto = 1+y*r/100;
                if(ma < moto){
                    ma = moto;
                    num = b;
                }
            }
        
            if(t == 2){
                moto = pow(1+r/100,y);
                if(ma < moto){
                    ma = moto;
                    num = b;
                }
            }
        
        }
    
        cout << num << endl;
    }
    
    return 0;
}



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

int main() {
    string s;
    cin >> s;
    int count = 0;
    int ans = 0;
    for(char c : s) {
        if(c == 'A' || c == 'T' || c == 'G' || c == 'C') {
            count ++;
        } else {
            ans = max(ans, count);
            count = 0;
        }
    }
    ans = max(ans, count);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a[3][3];
    rep(i,3){
        rep(j,3){
            cin>>a[i][j];
        }
    }
    int n;
    cin>>n;
    vec b(n);
    rep(i,n) cin>>b[i];
    vvec c(3,vec (3));
    rep(i,n){
        rep(j,3){
            rep(k,3){
                if(a[j][k]==b[i]){
                    c[j][k]=1;
                }
            }
        }
    }
    int ans=0;
    rep(i,3){
        int cnt=0;
        rep(j,3){
            if(c[i][j]==1){
                cnt++;
            }
        }
        if(cnt==3) ans++;
    }
    rep(i,3){
        int cnt=0;
        rep(j,3){
            if(c[j][i]==1){
                cnt++;
            }
        }
        if(cnt==3) ans++;
    }
    int cnt=0;
        rep(j,3){
            if(c[j][j]==1){
                cnt++;
            }
        }
        if(cnt==3) ans++;
     cnt=0;
        rep(j,3){
            if(c[2-j][j]==1){
                cnt++;
            }
        }
        if(cnt==3) ans++;

        if(ans==0){
            cout<<"No"<<endl;
        }
        else{
            cout<<"Yes"<<endl;
        }
    
    
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	int W[100];
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> W[i];
		sum += W[i];
	}
	int suma = sum / 2;
	int sum2 = 0;
	int sum3, sum4;
	for (int i = 0; i < N; i++) {
		sum2 += W[i];
		if (sum2 > suma) {
			sum3 = sum - sum2;
			sum4 = sum - sum2 + W[i];
			sum3 = abs(sum3 - sum2);
			sum4 = abs(sum4 - sum2 + W[i]);
			if (sum3 < sum4) cout << sum3 << endl;
			else cout << sum4 << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 384
loop do
    n = gets.to_i
    break if n == 0
    s = gets.split.map(&:to_i)
    m = s.sum / n.to_f
    ax2 = s.inject(0) {|sum, x| sum + (x-m)**2 / n.to_f }
    a = Math.sqrt(ax2)
    puts a
end



Measured memory_bytes: 6936
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    val mod = 1000000007

    val dp = Array(n + 1) { Array(4) { Array(4) { Array(4) { 0 } } } }
    dp[0][3][3][3] = 1

    // A = 0, G = 1, C = 2, T = 3と対応づける
    for (len in 0 until n) {
        for (c1 in 0..3) {  // 最後から1文字目
            for (c2 in 0..3) {  // 最後から2文字目
                for (c3 in 0..3) {  // 最後から3文字目
                    if (dp[len][c1][c2][c3] == 0) {
                        continue
                    }
                    // 新しく末尾に追加する文字x
                    for (x in 0..3) {
                        // 5つのNGパターン
                        val ng1 =            c2 == 0 && c1 == 1 && x == 2  // ?AGC
                        val ng2 =            c2 == 1 && c1 == 0 && x == 2  // ?GAC
                        val ng3 =            c2 == 0 && c1 == 2 && x == 1  // ?ACG
                        val ng4 = c3 == 0            && c1 == 1 && x == 2  // A?GC
                        val ng5 = c3 == 0 && c2 == 1            && x == 2  // AG?C
                        if (ng1 || ng2 || ng3 || ng4 || ng5) {
                            continue
                        }

                        dp[len + 1][x][c1][c2] += dp[len][c1][c2][c3]
                        dp[len + 1][x][c1][c2] %= mod
                    }
                }
            }
        }
    }

    var ans = 0
    for (c1 in 0..3) {
        for (c2 in 0..3) {
            for (c3 in 0..3) {
                ans += dp[n][c1][c2][c3]
                ans %= mod
            }
        }
    }
    println(ans)
}

Measured memory_bytes: 33900
from heapq import heappush, heappop, heapify
N,M = map(int, input().split())
A = list(map(int, input().split()))
heap = [-a for a in A]
heapify(heap)
for i in range(M):
    hmax = heappop(heap)
    heappush(heap, hmax/2)
print(sum(map(lambda x: int(-x), heap)))

Measured memory_bytes: 14180
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	if(n % 10 == 3){
            System.out.println("bon");
        }else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8){
            System.out.println("pon");
        }else{
          	System.out.println("hon");
        }
    }
}

Measured memory_bytes: 35656
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <queue>
#include <sstream>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), a + n
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)

using namespace std;

typedef long long ll;

const double EPS = 1e-10;
const double PI = acos(-1.0);

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	char s[4];
	char t[4];
	scanf("%s", s);
	scanf("%s", t);
	int result = 0;
	REP(i, 3) {
		if(s[i] == t[i]) {
			result++;
		}
	}
	printf("%d\n", result);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm> 
#include <queue>
using namespace std;

int main(void){

    int n;
    long a[301][301];
    long d[301][301];

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


    for (int k = 0; k < n; k++){
        for (int i = 0; i < n; i++){
            for (int j = 0; j < n; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    
    long total = 0;
    bool flag1 = true;

    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            
            if (d[i][j] < a[i][j]){
                flag1 = false;
                continue;
            }
            
            bool flag2 = true;
            for (int k = 0; k < n; k++){
                
                if (k == i || k == j)continue;
                
                if (a[i][j] == d[i][k] + d[k][j]) flag2 = false;

            }
            
            if(flag2) total += a[i][j]; 
        }
    }
    
    if (!flag1){
        cout << -1 << endl;
    }
    else{
        cout << total << endl;
    }
   

}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	ll N, ans = 0, sum = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		ll tmp;
		cin >> tmp;
		sum += tmp;
		if (tmp == 0) {
			ans += sum / 2;
			sum = 0;
		}
	}
	ans += sum / 2;

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

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

int main()
{
  int h,m,s, Sec;

  cin >> Sec;   

  s= Sec % 60;  
  Sec /= 60;    
  m= Sec % 60;  
  h = Sec / 60; 

  cout << h << ":"<< m << ":" << s << endl;

  return 0;
}


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

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}




int main() {
  long long x,y,n,k,p,l,daisu;
  l=1;
  p=1000000007;
  cin>>x>>y;
  if(y<x){
    k=y;
    y=x;
    x=k;
  }
  if(y<=2*x && (2*x-y)%3==0){
    n=(x+y)/3;
    k=(2*x-y)/3;
    
    for(long long i=1; i<k+1; i++){
      daisu=modinv(i,p);
      l=l*daisu%p;
      daisu=(n+1-i)%p;
      l=l*daisu%p;
    }
    cout<<l;
    
  }
  else{
    k=0;
    cout<<k;
  }
    
}

Measured memory_bytes: 256
while 1:
    w,d=map(int,input().split())
    if w==d==0:break
    a=[0]*21
    ans=0
    b=list(map(int,input().split()))
    for i in range(w):
        a[b[i]]+=1
    ans=sum(b)
    b=list(map(int,input().split()))
    for i in range(d):
        if a[b[i]]:a[b[i]]-=1
        else: ans+=b[i]
    print(ans)

Measured memory_bytes: 7644
private fun getInts(): IntArray {
    return readLine()!!.split(" ").map {it.toInt()}.toIntArray()
}

private fun solver(d:Int,t:Int,s:Int):String {
    return if (s*t >= d) { "Yes"} else { "No"}
}

fun main(){
    val v = getInts()
    println(solver(v[0],v[1],v[2]))
}

Measured memory_bytes: 36488
#include <bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(), (v).end()

int main()
{
  int N; cin >> N;
  vector<int> s(N);

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

  sort(ALL(s));

  int ssum = accumulate(ALL(s), 0);

  for (int i = 0; i < N; ++i) {
    if (ssum % 10 == 0) {
      ssum -= (s[i] % 10 == 0 ? 0 : s[i]);
    } else if (ssum % 10 != 0) {
      cout << ssum << endl;
      return 0;
    }
  }

  cout << 0 << endl;
}

Measured memory_bytes: 256
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

a,b,c,d=[int(x) for x in input().split()]

abletodiv=(b//c - (a-1)//c) + (b//d - (a-1)//d) -(b//lcm(c,d) - (a-1)//lcm(c,d))
#print(abletodiv)
#print((b//c - (a-1)//c),(b//d - (a-1)//d),(b//lcm(c,d) - (a-1)//lcm(c,d)))
print(b-a+1-abletodiv)

Measured memory_bytes: 38384
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    if(a-b > 0){
        printf("a > b\n");
    }else if(a-b < 0){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
}


Measured memory_bytes: 2688
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

typedef long long ll;

int count(int K, int rest, int sum){
    if(rest / K == 0){
        return sum + 1;
    }else{
        return count(K, rest / K, sum+1);
    }
}

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

    cout << count(K, N, 0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
#include <set>
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
int dx[]={0,1,1,0,-1,-1};
int dy[]={1,1,0,-1,-1,0};
int main()
{
	int t,n;
	while(cin>>t>>n,t!=0){
		vector<pii> jama;
		int sx,sy;
		for(int i=0;i<n;i++){
			int x,y;
			cin>>x>>y;
			jama.push_back(pii(x,y));
		}
		//for(int i=0;i<jama.size();i++)
	//		cout<<jama[i].first<<"\t"<<jama[i].second<<endl;
		cin>>sx>>sy;
		set<pii> visited;
		queue<piii> q;
		q.push(piii(pii(sx,sy),0));
		while(!q.empty()&&q.front().second<=t){
			piii fr=q.front();
			pii p=fr.first;
			int x=fr.first.first;
			int y=fr.first.second;
			int c=fr.second;
			q.pop();
			if(visited.find(p)!=visited.end())continue;
			visited.insert(p);
		//	cerr<<"data:\t"<<x<<"\t"<<y<<"\t"<<c<<"\t"<<endl;
			for(int i=0;i<6;i++){
				pii cur(x+dx[i],y+dy[i]);
				if(visited.find(cur)==visited.end()&&find(jama.begin(),jama.end(),cur)==jama.end()){
					q.push(piii(cur,c+1));
			//		cerr<<"\t\t\t\tpush:\t"<<cur.first<<"\t"<<cur.second<<"\t"<<c+1<<"\t"<<endl;
				}
			}
		}
		cout<<visited.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 1348
#include <iostream>

using namespace std;

int main(){
    int h1;
    int m1;
    int h2;
    int m2;
    int k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int a = (((h2 - h1) * 2) * 30) + (m2 - m1);
    if(a == k){
        cout << 0 << endl;
    }
    else{
        cout << a - k << endl;
    }
    return 0;
}

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

using namespace std;

bool isprimeDiv2(int n, int k = 2)
{
	if (n == 1) { return false; }

	if (n < k * k) { return true; }

	if (n % k == 0) { return false; }

	return isprimeDiv2(n, k + 1);
}

int main()
{
	vector<int> primes;

	for (int i = 1; i <= 10000000; i++)
	{
		if (isprimeDiv2(i))
		{
			primes.push_back(i);
		}
	}

	vector<int> consecutive(10000001,  0);

	for (int i = 0; i < primes.size(); i++)
	{
		for (int j = i; j < primes.size(); j++)
		{
			int sum = 0;

			for (int k = i; k <= j; k++)
			{
				sum += primes[k];

				if (sum > 1000000)
				{
					goto Exit;
				}
			}

			consecutive[sum]++;
		}

	Exit:;
	}

	int n;

	while (true)
	{
		cin >> n;

		if (n == 0) { break; }

		cout << consecutive[n] << endl;
	}

	return 0;
}

Measured memory_bytes: 42996
#include "bits/stdc++.h"
using namespace std;

//39
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	vector<int> pref(n);
	vector<int> suff(n);
	pref[0] = v[0];
	suff[n - 1] = v[n - 1];
	for (int i = 1; i < n; ++i) {
		pref[i] = __gcd(v[i],pref[i - 1]);
		suff[n - i - 1] = __gcd(v[n - i - 1],suff[n - i]);
	}
	int ans  = 0;
	for (int i = 0; i < n; ++i) {
		if (i == 0) {
			ans = max(ans,suff[i + 1]);
		}else if (i == n - 1) {
			ans = max(ans,pref[i - 1]);
		}else {
			ans = max(ans,__gcd(pref[i - 1],suff[i + 1]));
		}
	}
	cout << ans;
}


Measured memory_bytes: 4576
h,w = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]

ans = []
flag = False

for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            if a[i][j] % 2 == 1:
                flag = not flag
            if flag:
                if j != w - 1:
                    ans.append((i,j,i,j+1))
                else:
                    if i != h - 1:
                        ans.append((i,j,i+1,j))
    else:
        for j in range(w-1,-1,-1):
            if a[i][j] % 2 == 1:
                flag = not flag
            if flag:
                if j != 0:
                    ans.append((i,j,i,j-1))
                else:
                    if i != h - 1:
                        ans.append((i,j,i+1,j))

print(len(ans))
for i in ans:
    print(i[0]+1,i[1]+1,i[2]+1,i[3]+1)


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

using namespace std;
using ll = long long;


int main()
{
    string s;
    cin >> s;
    cout << ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import accumulate


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    A = [0] + A + [0]
    N = len(A)
    return N, A


def solve(N, A):
    D = [abs(A[i-1]-A[i]) for i in range(1, N)]
    S = sum(D)
    for i in range(1, N-1):
        ans = S - D[i] - D[i-1] + abs(A[i+1] - A[i-1])
        print(ans)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 20504
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

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




using namespace std;
int main() {
	int n;
	cin >> n;
	int a, b;
	cin >> a >> b;
	int t = 0;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		if (a <= x&&b <= y)t++;
	}
	cout << t << endl;

	return 0;
}

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

//Submission #3535255 - AtCoder Beginner Contest 113 | AtCoder 
// https://abc113.contest.atcoder.jp/submissions/3535255
public class Program_ABC113_C_kuuso1
{
    public static void Main()
    {
        int N, M;
        int[] P, Y;

        var d = ria();
        N = d[0];
        M = d[1];
        P = new int[M];
        Y = new int[M];
        for (int i = 0; i < M; i++)
        {
            d = ria();
            P[i] = d[0];
            Y[i] = d[1];
        }

        var di = new Dictionary<int, List<int[]>>();
        for (int i = 0; i < M; i++)
        {
            if (!di.ContainsKey(P[i]))
            {
                di.Add(P[i], new List<int[]>());
            }

            di[P[i]].Add(new[] { i, Y[i] });
        }

        var ans = new String[M];
        foreach (var pr in di.Keys)
        {
            //var l = di[pr].ToList();
            var l = di[pr];
            l.Sort((p, q) => p[1].CompareTo(q[1]));
            for (int i = 0; i < l.Count; i++)
            {
                ans[l[i][0]] = String.Format("{0:D06}{1:D06}", pr, i + 1);
            }
        }

        Console.WriteLine(String.Join("\r\n", ans));
    }  //main

    static int[] ria(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }

}


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

int func(string s, string t) {
    int cnt = 0;
    for (char c = 'a'; c <= 'z'; c++) {
        bool founds = false, foundt = false;
        for (int i = 0; i < s.length(); i++) {
            if (s[i] == c) {
                founds = true;
            }
        }
        for (int i = 0; i < t.length(); i++) {
            if (t[i] == c) {
                foundt = true;
            }
        }
        if (founds && foundt) cnt++;
    }
    return cnt;
}

int main() {
	int n; string s;
	cin >> n >> s;
	int ans = 0;
    for (int i = 0; i <= n; i++) {
        int tmp = func(s.substr(0, i), s.substr(i));
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

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

int n, s[10];

void back(int p, int l) {
    if(p == n) {
        for(int i = 0; i < n; i++) printf("%c", (s[i] - 1 + 'a'));
        printf("\n");
        return;
    }
    for(int i = 1; i <= l; i++) s[p] = i, back(p+1, l);
    if(p) s[p] = l+1, back(p+1, l+1);
}

int main() {
    scanf("%d", &n);
    back(0, 1);
}


Measured memory_bytes: 1536
// Contest: ACL Beginner Contest (https://atcoder.jp/contests/abl)
// Problem: A: Repeat ACL (https://atcoder.jp/contests/abl/tasks/abl_a)


// region boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion

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

    int n; cin >> n;
    rep(_, n)
        cout << "ACL";
    cout << '\n';

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a;
    long double sum =0;
    cin>>n;
    while(n--)
    {
        cin>>a;
        sum += (1.0/a);
    }
    cout<<fixed<<(setprecision(6))<<1/sum;
	return 0;
}

Measured memory_bytes: 256
import itertools

N,M = map(int,input().split()) # <=1000
xyz = [list(map(int,input().split())) for _ in range(N)]
if  M == 0:
    print(0)
    exit()
result = 0
L = [[0] * N for i in range(8)]
for i,j in enumerate(itertools.product((-1,1),repeat=3)):
    for k,l in enumerate(xyz):
        L[i][k] = l[0] * j[0] + l[1] * j[1] + l[2] * j[2]
    L[i] = sorted(L[i],reverse=True)
print(max([sum(i[:M]) for i in L]))


Measured memory_bytes: 3700