akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

int mp[400005];

signed main(){
    FASTER;
    int n;cin>>n;
    string s;cin>>s;
    
    for(int i=0;i<400005;i++){
        int tmp=i;
        int ans=0;
        while(tmp){
            tmp=tmp%__builtin_popcountll(tmp);
            ans++;
        }
        mp[i]=ans;
    }
    
    int cnt=0;
    for(char c:s)cnt+=(c=='1');
    
    int Pp1=0,Pm1=0;
    for(int i=n-1,id=0;i>=0;i--,id++){
        if(s[i]=='1'){
            Pp1=(Pp1+poww(2,id,cnt+1))%(cnt+1);
            if(cnt>=2)Pm1=(Pm1+poww(2,id,cnt-1))%(cnt-1);
        }
    }
    
    vi cp1mod(n+n,1);
    for(int i=1;i<2*n;i++){
        cp1mod[i]=cp1mod[i-1]*2%(cnt+1);
    }
    vi cm1mod(n+n,1);
    for(int i=1;i<2*n && cnt>1;i++){
        cm1mod[i]=cm1mod[i-1]*2%(cnt-1);
    }
    
    for(int i=0;i<n;i++){
        if(s[i]=='0'){
            int rem=(Pp1+cp1mod[n-i-1])%(cnt+1);
            int cntt=1+mp[rem];
            cout<<cntt<<"\n";
        }else{
            if(cnt==1){
                cout<<0<<"\n";
            }else{
                int rem=(Pm1-cm1mod[n-i-1]+cnt-1)%(cnt-1);
                int cntt=1+mp[rem];
                cout<<cntt<<"\n";
            }
        }
    }
    
}


Measured memory_bytes: 12856
package main

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

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	bs := NewBufScanner(in)
	bw := NewBufWriter(out)
	defer bw.w.Flush()
	ans := "No"
	if strings.Index(bs.Scan(), "7") >= 0 {
		ans = "Yes"
	}
	bw.Printf(ans)
}

// BufScanner original scanner
type BufScanner struct {
	s *bufio.Scanner
}

// NewBufScanner constructer
func NewBufScanner(in io.Reader) *BufScanner {
	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 1024), 1e+9)
	s.Split(bufio.ScanWords)
	return &BufScanner{
		s: s,
	}
}

// Scan Scan Data
func (b *BufScanner) Scan() string {
	b.s.Scan()
	return b.s.Text()
}

// IntScan Scan Data
func (b *BufScanner) IntScan() int {
	v, err := strconv.Atoi(b.Scan())
	if err != nil {
		panic(err)
	}
	return v
}

// BufWriter original writer
type BufWriter struct {
	w *bufio.Writer
}

// NewBufWriter constructer
func NewBufWriter(out io.Writer) *BufWriter {
	w := bufio.NewWriter(out)
	return &BufWriter{
		w: w,
	}
}

// Printf Output file
func (b *BufWriter) Printf(format string, a ...interface{}) {
	fmt.Fprintf(b.w, format, a...)
}

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

const int64_t MOD=1e9+7;

int main(){

  int H,W,K;
  cin>>H>>W>>K;
  vector<int64_t> a(10,0);
  a[0]=1;
  a[1]=1;
  a[2]=2;
  for(int i=3;i<=10;++i) a[i]=a[i-1]+a[i-2];

  if(W==1) cout<<1<<endl;
  else{
  vector<vector<int64_t>> dp(W+1,vector<int64_t>(H+1));
  dp[1][0]=1;
  for(int j=1;j<=H;++j){
    for(int i=1;i<=W;++i){
      if(i==1) dp[1][j]=dp[1][j-1]*a[W-1]+dp[2][j-1]*a[W-2];
      else if(i==W) dp[W][j]=dp[W][j-1]*a[W-1]+dp[W-1][j-1]*a[W-2];
      else dp[i][j]=dp[i][j-1]*a[i-1]*a[W-i]+dp[i-1][j-1]*a[W-i]*a[max(0,i-2)]+dp[i+1][j-1]*a[W-i-1]*a[i-1];
      dp[i][j]%=MOD;
    }
  }
    cout<<dp[K][H]<<endl;
  }


}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {

		while(sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();

			System.out.printf("%d %d\n",gcd(a, b) ,lcm(a, b));
		}
		sc.close();

	}

	private static long lcm(int i, int j) {
		long lcm = i / gcd(i, j) * j;
		return lcm;
	}

	private static int gcd(int x, int y) {
		int x_tmp = 0;

		do {
			x_tmp = x;

			x = y;
			y = x_tmp % y;
		}while(y > 0);

		int gcd = x;

		return gcd;
	}

}


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

int main()
{
    int sum = 0;
    string s;
    cin >> s;
    for(char x : s){
        //i++;
        int a = x - '0';
        sum += a;
      //cout << i << " " << sum << " " << a << endl;
    }
    if(sum % 9 == 0){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

bool check(int x,int y,vector<string> a,vector<string> b ){
    for(auto i = 0; i<b.size();i++){
        for(auto j =0; j<b.size();j++){
            if(a[x+i][y+j]!= b[i][j]) return false;
        }
    }
    return true;
}


int main() {
    int n,a,b;cin>>n>>a>>b;
    int count = 0;
    rep(i,n){
        int sum =0;
        int temp = i+1;
        while(temp!=0){
            sum+=temp%10;
            temp/=10;
        }
        if(sum>=a && sum<=b)count+=i+1;
        
    }
    
    cout<<count<<endl;
    
    
    return 0;
}







Measured memory_bytes: 256
n = int(input())
INF = 10**9
csum = 0
min_b = INF
for _ in range(n):
    a,b = map(int, input().split())
    csum += a
    if a > b: min_b = min(min_b,b)

if min_b == INF: print(0)
else: print(csum-min_b)



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

#define ln                 '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e5;
int n, d, a[nsz + 5];
num w1[nsz + 5], w2[nsz + 5];
vector< pair<num, pair<int, int> > > e;

struct union_find {
	int sz, pr[nsz + 5];
	
	int inline operator [] (int id) { return qry(id); }
	
	void inline init(int sz = n) {
		this->sz = sz;
		cont (u, n)  pr[u] = u;
	}
	
	int qry(int u) {
		return pr[u] == u ? u : pr[u] = qry(pr[u]);
	}
	
	bool inline link(int u, int v) {
		int pu = qry(u), pv = qry(v);
		if (pu == pv)  return 0;
		pr[pv] = pu;
		return 1;
	}
};
union_find uf;

num inline w(int u, int v) {
	if (u < v)  swap(u, v);
	return w1[u] + w2[v];
}

void graph_init(int el = 1, int er = n) {
	if (el == er)  return;
	int md = (el + er) >> 1, ml = 1, mr = md + 1;
	circ (u, el, md) {
		w2[u] < w2[ml] && (ml = u);
	}
	circ (u, md + 1, er) {
		w1[u] < w1[mr] && (mr = u);
	}
	circ (u, el, md) {
		e.push_back({w(u, mr), {u, mr}});
	}
	circ (u, md + 1, er) {
		e.push_back({w(u, ml), {u, ml}});
	}
	graph_init(el, md);
	graph_init(md + 1, er);
}

num inline kruskal(vector< pair<num, pair<int, int> > > &e = ::e) {
	int cnt = 0;
	num res = 0;
	uf.init();
	sort(all(e));
	loop (i, e.size()) {
		int u = e[i].second.first, v = e[i].second.second;
		num w = e[i].first;
		if (uf.link(u, v)) {
			res += w;
			if (++cnt == n - 1)  break;
		}
	}
	return res;
}

int main() {
	scanf("%d%d", &n, &d);
	cont (i, n) {
		scanf("%d", &a[i]);
		w1[i] = (num) a[i] + (num) d * i;
		w2[i] = (num) a[i] - (num) d * i;
	}
	graph_init();
	printf("%lld\n", kruskal());
}

Measured memory_bytes: 71776
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,data[101];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&data[i]);
  }

  int cnt1,cnt2;
  cnt1 = 0;
  while(1){
    cnt2 = 0;
    for(int i=0;i<n;i++){
      if(data[i] >= cnt1){
	cnt2++;
      }
    }
    if(cnt2 < cnt1) break; 
    cnt1++;
  }
  
  cout << cnt1-1 << endl;

  return 0;
}

Measured memory_bytes: 3244
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    vector<P> T;
    for(int i = 0; i < n; i++){
        int x, y;
        cin >> x >> y;
        T.emplace_back(x, y);
    }

    double ans = 0;
    int allpat = 1;
    for(int i = 1; i <= n; i++)allpat *= i;
    int eachpat = 1;
    for(int i = 1; i <= n-2; i++)eachpat *= i;
    eachpat *= n-1;
    double w = (double)eachpat / (double)allpat;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if (i == j)continue;
            double dx = (double)T[i].first - T[j].first;
            double dy = (double)T[i].second - T[j].second;
            ans += sqrt(dx*dx + dy*dy) * eachpat;
        }
    }
    ans /= allpat;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BI18n {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string s;
	    in >> s;
	    string n = to_string(s.length() - 2);
	    out << s[0] << n << s[s.length()-1] << endl;
	}
};


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


Measured memory_bytes: 256
#include<iostream>
#include<ios>
using namespace std;
char c='A',a,b;
main()
{
    while(~scanf("%c,%c\n",&a,&b))
    {
        if(a==c)c=b;
        else if(b==c)c=a;
    }
    printf("%c\n",c);
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=405;
int n,c[N][4],a[N],v[4],ans;
map<int,int> Map;
int get(int a,int b,int c,int d){
	return (a<<30)+(b<<20)+(c<<10)+d;
}
void add(int x,int y){
	for (int i=4;i--;x=x>>10|(x&1023)<<30)Map[x]+=y;
}
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++){
		for (int j=0;j<4;j++){
			scanf("%lld",&c[i][j]);
			a[i]=(a[i]<<10)+c[i][j];
		}
		add(a[i],1);
	}
	for (int i=1;i<n;i++){
		add(a[i],-1);
		for (int j=i+1;j<=n;j++){
			add(a[j],-1);
			for (int k=4;k--;){
				v[0]=get(c[i][0],c[j][k],c[j][(k+3)&3],c[i][1]);
				v[1]=get(c[i][1],c[j][(k+3)&3],c[j][(k+2)&3],c[i][2]);
				v[2]=get(c[i][2],c[j][(k+2)&3],c[j][(k+1)&3],c[i][3]);
				v[3]=get(c[i][3],c[j][(k+1)&3],c[j][k],c[i][0]);
				if (!Map[v[0]]||!Map[v[1]]||!Map[v[2]]||!Map[v[3]])continue;
				int now=1;
				for (int k=4;k--;)now*=Map[v[k]],add(v[k],-1);
				ans+=now;
				for (int k=4;k--;)add(v[k],1);
			}
			add(a[j],1);
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 20352
#include <stdio.h>

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

int main(void){
	int x, y;
	scanf("%d %d", &x, &y);
	printf("%d\n", x>y ? gcd(x,y) : gcd(y,x));
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
using namespace std;
int n,m,h[100005],ans,s[100005];
int main()
{
	cin>>n>>m;
	ans=n;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
	}
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		if(h[a]<=h[b])
		{
			if(s[a]==0)
			{
				s[a]=1;
				ans--;
			}
		}
		if(h[b]<=h[a])
		{
			if(s[b]==0)
			{
				s[b]=1;
				ans--;
			}
		}
	}
	cout<<ans;
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	int ans;
	for (int i = 1; i < 10; i++) {
		if (n <= i * 111) {
			ans = i * 111; break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

const int NM = 101;
const int WM = 10001;
int dp[NM][WM];
int v[NM];
int w[NM];

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

    for (int i=1; i <= N; ++i) {
        cin >> v[i] >> w[i];
    }

    for (int i=0; i <= W; ++i) {
        dp[0][i] = 0;
    }

    for (int i=1; i <= N; ++i) {
        for (int j=0; j <= W; ++j) {
            if (j-w[i] < 0) {
                dp[i][j] = dp[i-1][j];
            }
            else {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
            }
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 7052
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
int main(){
	ll q,h,s,d,n;
	cin>>q>>h>>s>>d>>n;
	s = min(4*q, min(2*h,s));
	if( n%2==0 ){
		cout<<min( (n/2)*d, n*s)<<endl;
	}
	else{
		cout<<min( (n/2)*d + s, n*s)<<endl;
	}
	return 0;
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

bool is_yy(char a, char b){
  return true;
}

bool is_mm(char a, char b){
  if(a=='0'&&'1'<=b&&b<='9')return true;
  if(a=='1'&&'0'<=b&&b<='2')return true;
  return false;
}

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

  string s;cin>>s;

  bool mmyy=(is_mm(s[0], s[1])&&is_yy(s[2], s[3]));
  bool yymm=(is_yy(s[0], s[1])&&is_mm(s[2], s[3]));

  if(mmyy&&yymm){
    cout<<"AMBIGUOUS"<<endl;
  } else if(mmyy){
    cout<<"MMYY"<<endl;
  } else if(yymm){
    cout<<"YYMM"<<endl;
  } else {
    cout<<"NA"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;


int main(){
  ll N,A[200000],ans=1;
  int color=0;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int i=0;i<N-1;i++){
    if(A[i+1]>A[i]){
      if(color==0) color=1;
      else if(color==1) continue;
      else if(color==-1){
        ans++;
        color=0;
      }
    }else if(A[i+1]<A[i]){
      if(color==0) color=-1;
      else if(color==-1) continue;
      else if(color==1){
        ans++;
        color=0;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var bingo = new int[9];
            for (var i = 0; i < 3; i++)
            {
                var vals = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                var step = 3 * i;
                bingo[step] = vals[0];
                bingo[step + 1] = vals[1];
                bingo[step + 2] = vals[2];
            }

            var result = new bool[9];
            var n = int.Parse(Console.ReadLine());
            for (var i = 0; i < n; i++)
            {
                var val = int.Parse(Console.ReadLine());
                for (var j = 0; j < 9; j++)
                {
                    if (val == bingo[j])
                    {
                        result[j] = true;
                        break;
                    }
                }
            }

            var isBingo = false;
            for (var i = 0; i < 3; i++)
            {
                var step = 3 * i;
                if (result[step] && result[step + 1] && result[step + 2])
                {
                    isBingo = true;
                    break;
                }
                if (result[i] && result[i + 3] && result[i + 6])
                {
                    isBingo = true;
                    break;
                }
            }
            if (result[4])
            {
                if ((result[0] && result[8]) || (result[2] && result[6]))
                {
                    isBingo = true;
                }
            }
            Console.WriteLine(isBingo ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13396
n = int(input())
a0 = list(map(int, input().split()))
a1 = list(map(int, input().split()))
pmax = 0
k = 0
for i in range(n):
    psum = sum(a0[:i+1]) + sum(a1[i:])
    if psum > pmax:
        pmax = psum
        k = i
print(pmax)

Measured memory_bytes: 3064
N = int(input())
T = 0
X, Y = 0, 0
for i in range(N):
  t, x, y = map(int, input().split())
  d = abs(X-x) + abs(Y-y)
  if t-T < d or (d - (t-T)) % 2 == 1:
    print ("No")
    break
  else:
    X, Y = x, y
    T = t    
else:
  print ("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long n;
    cin>>n;
    if(n%1000==0)
     cout<<"0";
    else 
     cout<<1000-n%1000;
    return 0;
}
     
   




Measured memory_bytes: 3608
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    void solve(){
        int n;
        cin>>n;
        if(n>=30)
            cout<<"Yes";
        else
            cout<<"No";
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }
 

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;
typedef vector<double> VD;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VD p(n);
    REP(i, n) cin >> p[i];
    vector<VD> dp(n + 1, VD(n + 1));
    dp[1][0] = 1 - p[0];
    dp[1][1] = p[0];
    FOR(i, 2, n)FOR(j, 0, i) 
        dp[i][j] = dp[i - 1][j] * (1 - p[i - 1]) 
                 + dp[i - 1][j - 1] * p[i - 1];

    double ans = 0;
    FOR(j, n / 2 + 1, n) ans += dp[n][j];
    cout << fixed << setprecision(10) << ans << ln;
    return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <unordered_map>
#include <algorithm> // std::sort(begin,end)
#include <utility> // std::swap

using namespace std;

int visited[100001] = {}; // all false
int pos[100001] = {}; 
vector<pair<int, int>> edges[100001];


bool search(int i){

  visited[i] = 1;
  for (auto e : edges[i]){
    if(visited[e.first] && pos[e.first] != pos[i] + e.second){
        return false;
    }
    pos[e.first] = pos[i] + e.second;
    if(visited[e.first])
      continue;
    if( search(e.first) == false )
      return false;
  } 
  return true;
}

int main(int argc, char const* argv[])
{
  int n,m,l,r,d;
  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    cin >> l >> r >> d;
    edges[l].push_back(make_pair(r,d));
    edges[r].push_back(make_pair(l,-d));
  }

  for (int i = 0; i < n; i++) {
    if(search(i) == false){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 11392
(defun rotate (char n)
  (let ((code (+ n (char-code char))))
    (code-char
      (if (< (char-code #\Z) code)
          (+ (- code (char-code #\Z) 1)
             (char-code #\A))
          code))))

(defun solve (n s)
  (with-output-to-string (*standard-output*)
    (do ((i 0 (1+ i)))
        ((<= (length s) i))
      (write-char (rotate (aref s i) n)))))

#-swank
(let* ((n (read))
       (s (read-line)))
  (format t "~A~%" (solve n s)))


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

static const int INF = 1000000000;

struct Card {
    char suit;
    int value;
};

void merge(vector<Card> &A, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    vector<Card> L(n1 + 1), R(n2 + 1);
    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1].value = INF, R[n2].value = INF;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        if (L[i].value <= R[j].value) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void merge_sort(vector<Card> &A, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        merge_sort(A, left , mid);
        merge_sort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int partition(vector<Card> &A, int p, int r) {
    Card x = A[r];
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (A[j].value <= x.value) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

void quick_sort(vector<Card> &A, int p, int r) {
    if (p < r) {
        int q = partition(A, p, r);
        quick_sort(A, p, q - 1);
        quick_sort(A, q + 1, r);
    }
}

int main() {
    int n;
    cin >> n;
    vector<Card> A(n), B(n);
    for (int i = 0; i < n; i++) {
        char s;
        int x;
        cin >> s >> x;
        A[i].suit = s, A[i].value = x;
        B[i].suit = s, B[i].value = x;
    }

    merge_sort(A, 0, n);
    quick_sort(B, 0, n - 1);

    bool is_stable = true;
    for (int i = 0; i < n; i++) {
        if (A[i].suit != B[i].suit) {
            is_stable = false;
            break;
        }
    }

    if (is_stable) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    for (int i = 0; i < n; i++) {
        cout << B[i].suit << " " << B[i].value << endl;
    }
    return 0;
}


Measured memory_bytes: 5040
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int x; scanf("%d", &x);
	for(ll i = 1;; i++){
		if(x*i % 360 == 0){
			printf("%lld\n", i);
			return 0;
		}
	}
}


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



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

    int cnta = 0;
    int cntb = 0;

    rep(i,n){
        char ch = s[i];
        if(ch == 'a'){
            if(cnta+cntb < a+b) {
                cout << "Yes" << endl;
                cnta++;
            }else cout << "No" << endl;
        }else if(ch == 'b'){
            if(cnta+cntb < a+b && cntb < b){
                cout << "Yes" << endl;
                cntb++;
            }else cout << "No" << endl;
        }else cout << "No" << endl;
    }
}

Measured memory_bytes: 3708
#include <stdio.h>
int main(void){
    int hantei[1000000],n,i,j,count;
    while(1){
        scanf("%d",&n);
        if(feof(stdin))break;
        count=0;
        if(n==2)count=0;
        for(i=0;i<=n;i++){
            hantei[i]=i;
        }
        for(i=2;i<=n;i++){
            if(hantei[i]!=0){
                for(j=2*i;j<=n;j+=i){
                    if(hantei[j]!=0){
                        hantei[j]=0;
                        count++;
                    }
                }
            }
        }
        printf("%d\n",n-(count+1));
    }
    return(0);
}

Measured memory_bytes: 4316
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;

int main() {
  int N;
  cin >> N;
  N = N % 10;
  if (N == 3) {
    cout << "bon" << endl;
    return 0;
  }
  if (N == 0 || N == 1 || N == 6 || N == 8) {
    cout << "pon" << endl;
    return 0;
  } else {
    cout << "hon" << endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		sc.close();

		int start = Math.max(A, C);
		int end = Math.min(B, D);

		if(start <= end) {
			System.out.println(end - start);
		}else {
			System.out.println(0);
		}
	}

}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n;
  cin >> n;
  vi l(n);
  rep(i,n) cin >> l[i];
  sort(rall(l));
  int mx = l[0];
  int sum = 0;
  REP(i,n) sum += l[i];
  YesorNo(mx < sum); 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long l;
 
int main(){
    ll n,k, temp;
    vector<ll> ai;
    cin >> n >> k;
    for(ll i=0;i<n;i++){
        cin >> temp;
        ai.push_back(temp);
    }
    vector<ll> scores;
    for(ll i=k;i<n;i++){
            if(ai.at(i-k)<ai.at(i)) cout << "Yes" << endl;
            else cout << "No" << endl;
    }
}

Measured memory_bytes: 5372
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e5 + 7;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

int main() {
    string s, t;
    cin >> s >> t;

    if ((int)t.length() <= (int)s.length()) {
        cout << "No" << "\n";
        return 0;
    }

    int n = s.length();
    if (s.substr(0, n) != t.substr(0, n)) {
        cout << "No" << "\n";
        return 0;
    }
    cout << "Yes" << "\n";

    return 0;
}

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

int k, s;
int ans;

int main(){
	scanf("%d %d", &k, &s);
	for(int i=0; i<=k; ++i)
		for(int j=0; j<=k; ++j)
			if(i+j<=s&&i+j>=s-k) ++ans;
	printf("%d\n", ans);
}


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

int main() {
	int a;
    cin >> a;
    
    int tmpA = a;
    int modNum = 0;
   	while(tmpA > 0) {
    	modNum += tmpA % 10;
        tmpA /= 10;
    }
    
    string ans = "Yes";
    if(modNum == 0 || (a % modNum != 0)) {
		ans = "No";
    }
    cout << ans << endl;
}


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

using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	cout << (a > b ? b : a) + (c > d ? d : c) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a=n;
  n*=100;
  int c=n;
  n/=108;
int b=n+1;
n=b*1.08;
int N=n;
  if(c%108==0){
    cout<<c/108<<endl;
  }

else if(N==a){
  cout<<b<<endl;

}
  else{
    cout<<":("<<endl;
  }

}




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

int main(){
  string s;
  cin >> s;
  int g_num = 0, p_num = 0;
  for (int i=0; i<s.size(); i++){
    if (s[i] == 'g') g_num++;
    else p_num++;
  }

  cout << (g_num + p_num) / 2 - p_num << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
  ll n, s = 0;
  cin >> n;
  ll a[n], c[n] = {};
  REP(i, n) {
    cin >> a[i];
    a[i]--;
    c[a[i]]++;
  }
  REP(i, n) s += c[i] * (c[i] - 1) / 2;
  REP(i, n) cout << s - (c[a[i]] - 1) << endl;
  return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    long long N, A, B;
    cin >> N >> A >> B;
    if(A==0&&B==0){
        cout << 0 << endl;
        return 0;
    }
    long long num = N /(A+B);
    num *= A;
    long long a = N % (A + B);
    if(A<a){
        num += A;
    }else{
        num += a;
    }
    cout << num << endl;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    int sum = 0;
    rep(i, N) sum += A[i];
    double m = (double)sum / (4 * M);
    int cnt = 0;
    rep(i, N) if (A[i] >= m) cnt++;
    if (cnt >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;
#define int long long
#define double long double
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
typedef pair<int, int> pii;
#define l_b lower_bound
#define u_b upper_bound

int N;

signed main() {
    cin >> N;
    int ki = 1;
    rep(i, N) {
        int a;
        cin >> a;
        if (a % 2 == 0)ki *= 2;
    }
    int three_n = 1;
    rep(i, N) {
        three_n *= 3;
    }
    cout << three_n - ki << endl;
}

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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

using Graph = vector<vector<int>>;

Graph G;

vector<bool> seen;
void dfs(const Graph &G, int v)
{
    seen[v] = true;

    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v);
    }
}

int main()
{
    ll n, k, q;
    cin >> n >> k >> q;

    vector<ll> a(q);
    rep(i, q) cin >> a[i];

    vector<ll> cnt(n, 0);
    rep(i, q) cnt[a[i] - 1]++;

    rep(i, n)
    {
        ll temp = cnt[i];
        ll other = q - temp;
        if (k - other > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


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


using namespace std;


int main(){
    int a,b,c,d =0;
    int T_HP,A_HP;

    cin >> a>>b>>c>>d;
    int X = (a+d-1)/d;
    int Y = (c+b-1)/b;
    cout<<(X>=Y?"Yes":"No")<<endl;
}

Measured memory_bytes: 3556
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
int n,k;
int a[109];
int dp[100009];
int bt(int sum){
    if(sum < 0) return 1;
    int &ret = dp[sum];
    if(ret != -1) return ret;
    ret = 0;
    for(int i=0;i<n;i++){
        ret = max(ret,1-bt(sum-a[i]));
    }
    return ret;
}
int main(){
    fast,cin>>n>>k;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++) cin>>a[i];
    if(bt(k)) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}


Measured memory_bytes: 5376
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        long min = Long.MAX_VALUE;
        for (int i = 1; i <= 100; i++) {
            long sum = 0;
            for (int j = 0; j < n; j++) {
                sum += (arr[j] - i) * (arr[j] - i);
            }
            min = Math.min(min, sum);
        }
        System.out.println(min);
    }
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int a,b,c; cin >> a >> b >> c;
    cout << (a+b+c-max(a,max(b,c))-min(a,min(b,c)))*min(a,min(b,c))/2 << endl;
    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;
	map<string, int> conv;
	cout << 0 << endl;
	fflush(stdout);
	string ret; cin >> ret;

	if (ret == "Vacant") return;

	conv["Male"] = (int)(ret == "Female");
	conv["Female"] = (int)(ret == "Male");
	int ng = 0, ok = N;
	while (abs(ok-ng) > 1) {
		int query = (ng+ok)>>1;
		cout << query << endl;
		fflush(stdout);
		cin >> ret;
		if (ret == "Vacant") return;
		if (((query&1) ^ conv[ret]) == 0) ng = query;
		else ok = query;
	}
}

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


Measured memory_bytes: 3828
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	String S = sc.next();
    if (head(S) && containC(S) && lowerCase(S)) {
      System.out.println("AC");
    } else {
      System.out.println("WA");
    }
  }
  public static boolean head(String S) {
    if (S.charAt(0) == 'A') {
      return true;
    } else {
      return false;
    }
  }
  public static boolean containC(String S) {
    int length = S.length();
    String substringS = S.substring(2, length - 1);
    substringS = substringS.replace("C", "");
    if (length - 3 == substringS.length() + 1) {
      return true;
    } else {
      return false;
    }
  }
  public static boolean lowerCase(String S) {
    String substringFirst = S.substring(1, 2);
    String substringSecond = S.substring(2, S.length() - 1).replace("C", "");
    String substringThird = S.substring(S.length() - 1);
    if (substringFirst.equals(substringFirst.toLowerCase()) && 
        substringSecond.equals(substringSecond.toLowerCase()) &&
        substringThird.equals(substringThird.toLowerCase())) {
          return true;
    } else {
          return false;
    }
    
  }
}

Measured memory_bytes: 21716
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k,c = LI()
s = input()

cnt = 0
i = n-1
d = defaultdict(int)
tmp = k
while i >= 0:
    if s[i] == 'o':
        cnt += 1
        d[tmp] = i
        tmp -= 1
        i -= c
    i -= 1
i = 0
f = defaultdict(int)
tmp = 1
while i < n:
    if s[i] == 'o':
        f[tmp] = i
        tmp += 1
        i += c
    i += 1
for i,j in f.items():
    if d[i] == j:
        print(j+1)


     



Measured memory_bytes: 106072
// {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

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

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
// }}}

const int N=1000010;
int cnt[N],mp[N],p[N];
void main() {    
    int n;
    R(n);
    REP(i,n) {
        int a;
        R(a);
        cnt[a]++;
    }
    int ok=1,ok2=1;
    for ( int i=2; i<N; i++ ) {
        if ( p[i] ) continue;
        for ( int j=i; j<N; j+=i ) {
            p[j]++;
            mp[i]+=cnt[j];
        }
        if ( mp[i]>1 ) ok=0;
        if ( mp[i]==n ) ok2=0;
    }
    if ( ok ) {
        W("pairwise coprime");
    } else if ( ok2 ) {
        W("setwise coprime");
    } else {
        W("not coprime"); 
    }
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}


Measured memory_bytes: 15540
#include <stdio.h>

int main() {
    int a,b,c,x=0;
    scanf("%d %d %d", &a,&b,&c);
    
    while(1) {
        if(a > b){
            x = a;
            a = b;
            b = x;
        }
        if (b > c){
            x = b;
            b = c;
            c = x;
        }
        if ((a <= b) && (b <= c)){
            break;
        }
    }
    printf("%d %d %d\n",a,b,c);
    return 0;    
}


Measured memory_bytes: 2080
#print(chr(97))
N = int(input())
lenJudgeNum = [26, 702, 18278, 475254, 12356630, 321272406, 8353082582,
               217180147158, 5646683826134, 146813779479510, 3817158266467286]
alpLen = 0
tmp = N
for i in range(len(lenJudgeNum)):
    if N <= lenJudgeNum[i]:
        alpLen = i + 1
        break

ansStr = ''
prev = 'a'
for i in range(alpLen):
    #alpNum = N % 27
    N -= 1
    alpNum = N % 26
    ansStr = chr(alpNum + 97) + ansStr
    #alpNum = N % 26 if N % 26 != 0 else 26

    # print(alpNum)
    #print(chr(alpNum + 96))
    # print("prev")
    # print(prev)
    # print()
    '''
    cur = chr(alpNum + 96)
    if prev == 'z' and chr(alpNum + 96) == 'a':
        cur = 'z'
        ansStr = 'z' + ansStr
    else:
        cur = chr(alpNum + 96)
        ansStr = chr(alpNum + 96) + ansStr
    '''
    N = N//26
    # print(N)
    #prev = cur

print(ansStr)


Measured memory_bytes: 9112
from math import gcd

k = int(input())

ir = range(1, k+1)
jr = range(1, k+1)
lr = range(1, k+1)

count = 0
for i in ir:
  for j in jr:
    for l in lr:
      count += gcd(i, gcd(j, l))

print(count)

Measured memory_bytes: 9116