akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#include <time.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define SQR(X) ((X)*(X))
int test = 0;
/* ここからが本編 */
int main(void)
{
  int i,j,k,l;
  int a[3];
  int n;
  cin >> n;
  while(cin >> a[0] >> a[1] >> a[2]) {
    sort(a,a+3);
    if(SQR(a[0]) + SQR(a[1]) == SQR(a[2])) {
      puts("YES");
    }
    else puts("NO");
  }

  return 0;
}

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

int main(){
    int N;
    int i = 0;
    char S;
    cin>>N;
    for(int n =0;n < N;n++){
        cin>>S;
        if(S =='Y')
            i++;
        }
    if(i == 0){
        cout<<"Three"<<endl;
    }
    else {
        cout <<"Four"<<endl;
    }
    }



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

using namespace std;

using ll = long long int;

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

class UnionFind {
  private:
    vector<int> unumber; // 子ノードの場合は親ノードの番号、根ノードの場合は木のノード数*(-1)
  public:
    UnionFind(int N) : unumber(N, -1){} // 各ノードを全て親ノードとして初期化
    int findRoot(int x){ // 根ノードを見つけて返す
        if (unumber[x] < 0) return x;
        return unumber[x] = findRoot(unumber[x]); // 根を張り替えながら再帰的に根ノードを探す
    }
    int unite(int x, int y){ // xとyが含まれる木を結合して、新しい根ノードを返す
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) return x; // 既に同じ木に属しているなら何もしない
        if (unumber[y] < unumber[x]) swap(x, y); // xの木がyの木よりも大きくなるようにする（unumberは負であることに注意）
        // xがyの親ノードになるように連結する
        unumber[x] += unumber[y];
        unumber[y] = x;
        return x;
    }
    bool isSame(int x, int y){return findRoot(x) == findRoot(y);}
    int getSize(int x){return -unumber[findRoot(x)];} // xが含まれる木の大きさを返す
};

int main()
{
    scanInt(N); // 頂点の数
    scanInt(M); // 辺の数
    vector<pair<int, int>> node_pair; node_pair.reserve(M);
    REP(i, M){
        scanInt(ai); --ai;
        scanInt(bi); --bi;
        node_pair.emplace_back(ai, bi);
    }
    // vector<unordered_map<int, ll>> edges(N); // 各頂点から出る辺
    // REP(i, M){ // 辺の数はM
    //     scanInt(ai); --ai;
    //     scanInt(bi); --bi;
    //     edges[ai].emplace(bi, 1);
    //     edges[bi].emplace(ai, 1);
    // }
    UnionFind uf(N);
    vector<ll> result(M);
    ll temp_result = static_cast<ll>(N) * (N - 1) / 2;
    RREP(m, M){
        result[m] = temp_result;
        auto& ai = node_pair[m].first;
        auto& bi = node_pair[m].second;
        if (uf.isSame(ai, bi)) continue;
        ll size_a = uf.getSize(ai);
        ll size_b = uf.getSize(bi);
        temp_result -= size_a * size_b;
        uf.unite(ai, bi);
    }
    REP(m, M){
        cout << result[m] << endl;
    }
}


Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int divisors = 0;
  for (int i = a; i <= b; i++) {
    if (c % i == 0)
      divisors++;
  }
  cout << divisors << endl;
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int le[100005];
int ri[100005];
int a[100005];
int b[100005];
int n;
void solve(int i,int l,int r){
	int j;
	for(j=l;b[j]!=a[i];j++);
	le[i]=ri[i]=-1;
	if(j-l>0){// 存在左树 
		le[i]=i+1;
		solve(i+1,l,j-1);	
	}
	if(r-j>0){
		ri[i]=i+j-l+1;
		solve(i+j-l+1,j+1,r);
	}
}
vector<int>res;
void dfs(int i){
	if(le[i]!=-1)dfs(le[i]);
	if(ri[i]!=-1)dfs(ri[i]);
	res.push_back(a[i]);
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	solve(0,0,n-1);
	dfs(0);
	for(int i=0;i<res.size()-1;i++){
		cout<<res[i]<<' ';
	}cout<<res[res.size()-1]<<endl;
	return 0;
}


Measured memory_bytes: 3176
#include <iostream>
using namespace std;
int main () {
	int S, hour, min, sec;

	cin >> S;

	if ( (S >= 0) && (S < 86400) ) {
		hour = S / 3600;
		min = (S % 3600) / 60;
		sec = (S % 3600) % 60;
	    cout << hour << ":" << min << ":" << sec << "\n";
	} else {
		cout << "Input number is invalid.\n";
	}
	return 0;
}

Measured memory_bytes: 1168
program hrn;
 var
  s:string;
  i,l,sc,sf:longint;
 begin
  read(s);
  l:=length(s);sc:=maxlongint;
  for i:=1 to l do if s[i]='F'then sf:=i;
  for i:=l downto 1 do if s[i]='C'then sc:=i;
  if sc<sf then writeln('Yes')
           else writeln('No');
 end.

Measured memory_bytes: 128
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y", long, "z");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, m;
    scan(n, m);
    auto id = new Pair[](m);
    foreach (i; iota(m))
    {
        long p, y;
        scan(p, y);
        id[i] = Pair(p, y, i);
    }
    id.sort!"a.x == b.x ? a.y < b.y : a.x < b.x"();
    long iter;
    foreach (i; iota(n))
    {
        long tmp;
        while (iter < m && id[iter].x == i + 1)
        {
            id[iter].y = tmp++;
            iter++;
        }
    }
    // id.each!(x => x.writeln());
    id.sort!"a.z < b.z"();
    foreach (i; iota(m))
    {
        writef("%06s", id[i].x);
        writefln("%06s", id[i].y + 1);
    }
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

int main() {
  int n,m; cin>>n>>m;
  vector<P> x(m);
  rep(i, m) cin>>x[i].second>>x[i].first;

  sort(x.begin(), x.end());
  int ans=1;
  int tmp=x[0].first;
  rep(i, m) {
    if (tmp<=x[i].second) {
      tmp=x[i].first;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[6];
	cin>>s;
	for(int i=0;i<6;i++)
	{
		if(s[i]>='A' && s[i]<='Z')
		{
     		s[i]=s[i]+32;
     	}
	}
 	if(s[2]==s[3] && s[4]==s[5])
  		cout<<"Yes";
 	else
  		cout<<"No"; 	
	return 0;
}

Measured memory_bytes: 256
function main(input: string): void {
  const inputNumbers: number[] = input.split(' ').map(n => parseInt(n, 10))

  const N = inputNumbers[0]
  const A = inputNumbers[1]
  const B = inputNumbers[2]

  let result: number = 0

  for (let i: number = 0; i <= N; i++) {
    const sum: number = String(i).split('').map(n => parseInt(n, 10)).reduce((acc, arg) => {return acc + arg}, 0)
    
    if (sum >= A && sum <= B) {
      result += i
    }
  }

  console.log(result)

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 10976
#include <iostream>
#include <fstream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define len(a) ((int) (a).size())

#ifdef CUTEBMAING
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

using namespace std;

typedef long long int64;
typedef long double ld;
typedef unsigned long long lint;

const int inf = (1 << 30) - 1;
const int64 linf = (1ll << 62) - 1;
const int N = 100;

int n, m;
bool used[N][N];

int dfs(int x, int y) {
    if (used[x][y]) {
        return 0;
    }
    used[x][y] = true;
    int ans = 1;
    ans += dfs(n - x - 1, y);
    ans += dfs(x, m - y - 1);
    return ans;
}

int main() {
#ifdef XCODE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> m;
    map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        static char buf[100500];
        scanf("%s", buf);
        for (int j = 0; j < m; j++) {
            cnt[buf[j]]++;
        }
    }
    vector<int> sizes;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (!used[i][j]) {
                sizes.pb(dfs(i, j));
            }
        }
    }
    sort(all(sizes));
    reverse(all(sizes));
    multiset<int> ccnt;
    for (auto i : cnt) {
        ccnt.insert(i.sc);
    }
    for (int i : sizes) {
        auto it = ccnt.end();
        --it;
        int cnt = *it;
        if (cnt < i) {
            puts("No");
            return 0;
        } 
        ccnt.erase(it);
        cnt -= i;
        if (cnt != 0) {
            ccnt.insert(cnt);
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 256
//大文字と小文字は区別しない。
#include<iostream>
#include<string>

using namespace std;

string str[1050];
int type;

int cnt[1050];

int main(){
	int i;
	string input;
	
	while( cin >> input ){
		if( input[0] == '\n' )
			break;
		if( input[0] >= 'A' && input[0] < 'a' )
			input[0]+=32;
		
		for( i = 0;i < type;i++ ){
			if( str[i] == input ){
				cnt[i]++;
				break;
			}
		}
		if( i == type ){
			str[type] = input;
			cnt[type]++;
			type++;
		}
	}
	
	int mmax = 0;
	
	for( i = 0;i < type;i++ ){
		mmax = max( mmax, cnt[i] );
	}
	
	for( i = 0;i < type;i++ ){
		if( mmax == cnt[i] ){
			cout << str[i] << " ";
			break;
		}
	}
	
	int maxlen = 0;
	
	for( i = 0;i < type;i++ ){
		maxlen = max( maxlen, (int)str[i].length() );
	}
	
	for( i = 0;i < type;i++ ){
		if( maxlen == (int)str[i].length() ){
			cout << str[i] << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1208
import java.util.*;
import java.math.*;

public class Main {

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

    for (int i = 0; i < 10000; i++) {
      double asum = (double)i * 0.08;
      double bsum = (double)i * 0.1;
      if ((int)asum == a && (int)bsum == b) {
        System.out.println((int)i);
        return;
      }
    }

    System.out.println(-1);

  }
}


Measured memory_bytes: 23892
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int n,d,i,j,st,cc;
char sp[101][101];

int ismove(){
	if(st==0 && i>0 && sp[i-1][j]!=' ')return 1;
	if(st==1 && j<d-1 && sp[i][j+1]!=' ')return 1;
	if(st==2 && i<d-1 && sp[i+1][j]!=' ')return 1;
	if(st==3 && j>0 && sp[i][j-1]!=' ')return 1;
	return 0;
}

void move(){
	if(st==0)i--;
	if(st==1)j++;
	if(st==2)i++;
	if(st==3)j--;
}

void mark(){
	if(st==0)sp[i][j+1]=' ';
	if(st==1)sp[i+1][j]=' ';
	if(st==2)sp[i][j-1]=' ';
	if(st==3)sp[i-1][j]=' ';
}

int main(){
	for(scanf("%d",&n);n>0;n--){
		scanf("%d",&d);
		for(i=0;i<d;i++){for(j=0;j<d;j++)sp[i][j]='\0';}
		i=d-1;j=0;st=0;cc=0;
		sp[i][1]=' ';
		while(1){
			sp[i][j]='#';
			if(ismove()){
				if(cc>0)mark();
				cc++;
				move();
			}
			else{
				if(cc==0)break;
				st=(st+1)%4;
				cc=0;
			}
		}
		for(i=0;i<d;i++){{for(j=0;j<d;j++)printf("%c",sp[i][j]);}printf("\n");}
		if(n>1)printf("\n");
	}
	return 0;
}

Measured memory_bytes: 576
//C

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
//#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

struct uf_tree {
	std::vector<int> parent;
	int __size;
	uf_tree(int size_) : parent(size_, -1), __size(size_) {}
	void unite(int x, int y) {
		if ((x = find(x)) != (y = find(y))) {
			if (parent[y] < parent[x]) std::swap(x, y);
			parent[x] += parent[y];
			parent[y] = x;
			__size--;
		}
	}
	bool is_same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
	int size(int x) { return -parent[find(x)]; }
	int size() { return __size; }
};



//!!!問題をちゃんと読む!!!
//!!!問題をちゃんと読め!!!
//!!!問題は読みましたか？!!!


signed main() {
	int P, Q, R;
	int ans;
	cin >> P >> Q >> R;
	ans = min(P + Q, P + R);
	ans = min(ans, Q + R);

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
n = int(input())
lst = []
for i in range(n):
    a = input().split()
    a[1] = int(a[1])
    lst.append(a)
for i in ["S", "H", "C", "D"]:
    for j in range(1, 14):
        if [i, j] in lst:
            continue
        else:
            print(i, j)


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

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;

void solve() {
	int n,m; cin >> n>>m;
	vector<ll> dp(n + 1);
	vector<bool> exi(n + 1);
	dp[0] = 1;
	rep(i, m) {
		int a; cin >> a; exi[a] = true;
	}
	rep1(i, n) {
		if (exi[i])dp[i] = 0;
		else {
			dp[i] += dp[i - 1];
			if (i - 2 >= 0)dp[i] += dp[i - 2];
			dp[i] %= mod;
		}
	}
	cout << dp[n] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(9);
	//init();
	//while (cin >> n>>m>>l,n)solve();
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long ans = func(b);
    if(a > 0) ans = func(b) ^ func(a - 1);
    System.out.println(ans);
  }

  public static long func(long x) {
    if(x == 0) return 0;
    if(x == 1) return 1;
    long ret = 1;
    if((x % 2) == 0) {
      ret = x / 2;
      ret = (ret % 2);
      ret = (ret ^ x);
    } else {
      ret = (x + 1) / 2;
      ret = (ret % 2);
    }
    return ret;
  }
}

Measured memory_bytes: 23636
//#define _USE_MATH_DEFINES // for C++
//#include <cmath>
#include <stdio.h>
#include <vector>

using namespace std;

int out_put(vector<int> A){

	int N;
	N = A.size();

	printf("%d", A[0]);
	for (int i = 1; i < N; i++){
		printf(" %d", A[i]);
	}
	printf("\n");

	return 0;
}

int main(){
	
	int N, a, v, j;
	vector <int> A;

	scanf("%d", &N);

	for (int i = 0; i < N; i++){
		scanf("%d", &a);
		A.push_back(a);
	}
	out_put(A);

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

	return 0;
}

Measured memory_bytes: 1056
#include <bits/stdc++.h>
using namespace std;
int n,m;
long long k;
int main()
{
    cin>>n>>m>>k;
    long long a[n+1],b[m+1];
    a[0]=b[0]=0;
    for(int i=1;i<=n;++i)
    {
        cin>>a[i];
        a[i]+=a[i-1];
    }
    for(int j=1;j<=m;++j)
    {
        cin>>b[j];
        b[j]+=b[j-1];
    }
    int ans=0,j=m;

    for(int i=0;i<=n;++i)
    {
        if(a[i]>k)break;
        while(b[j]>k-a[i])--j;
        if(j<0)break;
        if(a[i]+b[j]<=k)
        ans=max(ans,i+j);
    }
    cout<<ans;
}


Measured memory_bytes: 6720
n = int(input())
a = list(map(int,input().split()))
counter = 0
for i in range(n):
	minj = i
	for j in range(i,n):
		if a[j] < a[minj]:
			minj = j
	if minj != i:
		k = a[i]
		a[i] = a[minj]
		a[minj] = k
		counter += 1
ans = list(map(str,a))
print(" ".join(ans))
print(counter)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
 int main(){
   int a,b,c,d; cin >>a >>b>>c>>d;
   
   while(true){
     c-=b;
     if(c<=0){cout <<"Yes"<<endl;break;}
     a-=d;
     if(a<=0){cout <<"No"<<endl;break;}
   }
   
 }

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int T, X;
	//long long N, M;
	//double d, e;
	//string s, t;
	//vector<int> v;
	//vector<pair<int, int>> pl;

	//while() {}
	//for(int i=0; i<N; i++) {}
	
	cin >> T >> X;

	double ans = (double)T/X;
	cout << ans;
	// cout << "[deb: val ]" << val <<endl;
	return 0;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-7
//#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main() 
{
    fastio
    int a, b, c, d;
    cin>>a>>b>>c>>d;

    bool tak = true;
    while(a>0 && c>0) {
        if(tak) {
            c -= b;
        }
        else {
            a -= d;
        }
        tak = !tak;
    }

    cout<<(a>0?"Yes":"No")<<endl;
}   

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

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

  cout << a * b - a - b + 1 << endl;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
 
using namespace std;
 
#define endl "\n"
typedef long long int ll;
#define f first
#define s second
 
#define SEND_HELP ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
inline void setPrecision(int n){cout.precision(n);}
 
//DEBUG
#define BR cerr<<endl
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
 
ll INF = 1e10;
int MOD = 1e9+7;

int main(){
	#ifndef ONLINE_JUDGE
        freopen("inputf.in", "r", stdin);
    #endif
    SEND_HELP

    set<int> x;
    x.insert(1);
    x.insert(2);
    x.insert(3);
    int a, b;
    cin >> a >> b;
    x.erase(a);
    x.erase(b);
    cout << *x.begin();

    return 0;
}

/*

*/

Measured memory_bytes: 3632
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int x = scan.nextInt();
		int y = scan.nextInt();
		
		for(int i=0;i<=x;i++) {
			if(2*i+4*(x-i)==y) {
				System.out.println("Yes");
				System.exit(0);
			}
		}
		
		System.out.println("No");
		
	}	
	
	
	
}
 


Measured memory_bytes: 35824
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;



const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int t1,t2,a1,a2,b1,b2,sa,res;
string str;
int main() {
	cout << fixed << setprecision(18);
	cin>>t1>>t2>>a1>>a2>>b1>>b2;
	if(t1*a1+t2*a2==t1*b1+t2*b2){
		cout<<"infinity";
		return 0;
	}
	if(t1*a1+t2*a2<t1*b1+t2*b2){
		swap(a1,b1);
		swap(a2,b2);
	}
	
	if((a1-b1)*t1+(a2-b2)*t2<0){
		cout<<0;
		return 0;
	}
	if(a1>b1){
		cout<<0;
		return 0;
	}
	sa=t1*a1+t2*a2-(t1*b1+t2*b2);
	res=(t1*(b1-a1))/sa;
	if(sa*res==t1*(b1-a1)){
		res=2*res;
	}else{
		res=2*res+1;
	}
	
	//cout<<"sa"<<sa<<endl;
	//cout<<"t1(b1-a1)"<<t1*(b1-a1)<<endl;
	if(res<=0){res=0;}
	cout<<res;
} 


Measured memory_bytes: 256
class UnionFind():
    # 0, 1, ..., n - 1を要素とするn個の集合
    def __init__(self, n):
        self.rank = [0] * n # 木の根のみが持つ値
        self.par = list(range(n))

    # 木の根を求める
    def find(self, x):
        children = []
        while self.par[x] != x:
            children.append(x)
            x = self.par[x]

        for c in children:
            self.par[c] = x
        return x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        if self.same(x, y):
            return
        rx = self.find(x)
        ry = self.find(y)
        if self.rank[rx] > self.rank[ry]:
            self.par[ry] = rx # yの根をxの根の子とする。
        elif self.rank[rx] == self.rank[ry]:
            self.par[ry] = rx
            self.rank[rx] += 1
        else:
            self.par[rx] = ry

n, q = [int(x) for x in input().split()]
uf = UnionFind(n)

for _ in range(q):
    cmd, x, y = [int(x) for x in input().split()]
    if cmd == 0: # unite
        uf.union(x, y)
    else: # same
        print(int(uf.same(x, y)))



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

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
int AscendingSort(const void *a,const void *b){return *(int*)a>*(int*)b?1:0;}

int main(void){
    int n,k,ans=1e9;
    scanf("%d%d",&n,&k);
    int h[n];
    for (int i=0; i<n; i++){
        scanf("%d",&h[i]);
    }
    qsort (h,n,sizeof(int),AscendingSort);
    for (int i=0; i<n-k+1; i++){
        ans=ans<(h[i+k-1]-h[i])?ans:(h[i+k-1]-h[i]);
    }
    printf("%d\n",ans);
	return 0 ;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

string s;
int ans;
int main() {
    cin >> s;
    int n = s.length();
    ans = n;
    for (int i = 1; i < n; ++i) {
        if (s[i] != s[i - 1])
            ans = min(ans, max(i, n - i));
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
const int N = 600000;

int n;
string s;
map<string, int> mm;
vector<pair<int, string> > c;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        mm[s]++;
    }
    for (auto it : mm)
    {
        c.push_back(make_pair(-it.second, it.first));
    }
    sort(c.begin(), c.end());
    for (int i = 0; i < c.size(); i++)
    {
        if (c[i].first == c[0].first)
        {
            cout << c[i].second << "\n";
        }
    }
}


Measured memory_bytes: 27888
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  bool flag=true;
  for(int i=0;i<3;i++){
    if(s[i]==s[i+1]){
      flag=false;
      break;
    }
  }
  cout<<((flag)? "Good":"Bad");
}


Measured memory_bytes: 256
n = int(input())
P = list(map(int, input().split()))

ntbs = []

for i in range(n):
  if i+1 == P[i]:
    ntbs.append(i+1)

res = len(ntbs)
cnt = 1
for i in range(res-1):
  if ntbs[i]+1 == ntbs[i+1]:
    cnt += 1
  else:
    res -= (cnt // 2)
    cnt = 1

res -= (cnt // 2)
print(res)


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

int main(){
  vector<int> vec(3);
  for(int i=0; i<3; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  
  cout << vec.at(0) * vec.at(1) /2 << endl;
}

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n,a,b;
    int ans = 0;
    cin >> n >> a >> b;
    for(int i = 1; i <= n; i++){
        int t = i;
        int ret = 0;
        while(t != 0){
            ret += t%10;
            t /= 10;
        }
        if(ret >= a && ret <= b) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

use std::io::Write;

fn run() {
    input! {
        s: chars,
    }
    if s.len() % 2 != 0 {
        println!("No");
        return;
    }
    let mut i = 0;
    while i < s.len() {
        if !(s[i] == 'h' && s[i + 1] == 'i') {
            println!("No");
            return;
        }
        i += 2;
    }
    println!("Yes");
}

fn main() {
    run();
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = (String)sc.next();
		String Ti;
		int cnt = 0;
		// proceed if T[i](next sc) does not equal to "END_OF_TEXT".
		while (!((Ti = (String)sc.next()).equals("END_OF_TEXT"))) {
			// not distinguish A/a.
			if (Ti.toLowerCase().equals(W.toLowerCase()))
				++cnt;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 26256
#include <bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define int long long
#include "string"

int32_t main() {
	boost;
	int n;
	cin>>n;
	vector<pi>g[n+1];
	for(int i=1,u,v,w;i<n;i++){
		cin>>u>>v>>w;
		g[u].push_back({v,w});
		g[v].push_back({u,w});
	}
	int ans[n+1];
	function< void(int,int,int) > dfs = [&](int u,int p,int s){
		ans[u] = s % 2;
		for(auto v:g[u]){
			if(v.ff == p)
				continue;
			dfs(v.ff,u,s+v.ss);
		}
	};

	dfs(1,0,0);
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<endl;
}

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

using namespace std;

int main(void){
    long n,k;
    cin >> n >> k;
    if(n%k==0)
        cout << 0;
    else{
        if(n>k)
            n=n%k;
        if(n>=k/2)
            cout << abs(n-k);
        else
            cout << n;
    }
    return 0;
}

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

int main(){
    int H , W , N , Count;
    scanf( "%d%d%d" , &H , &W , &N );
    Count = max( H , W );
    int Ans;

    if( N % Count == 0 ) Ans = N / Count;
    else Ans = ( N / Count + 1 );
    printf( "%d\n" , Ans );
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
int main(void){
  int N,M,C;
  int a[200],b[200];
  int i,j,count=0,temp=0;
  
  scanf("%d%d%d", &N, &M, &C);
  
  for(i=0; i<M; i++){
    scanf("%d", &b[i]);
    //printf("%d\n", b[i]);
  }
  
  for(i=0; i<N; i++){
    for(j=0; j<M; j++){
      scanf("%d", &a[j]);
      //printf("%d", a[j]);
      temp = temp + a[j]*b[j];
    }
    if(temp+C>0){
      count++;
    }
    temp=0;
  }
  
  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
}

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

int main(){
  int n;
  cin >> n;
  int m = n;
  int c = 0;
  while(m > 0){
    c += m % 10;
    m /= 10;
  }
  if(n % c == 0){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, y;
    cin >> n >> y;
    rep(i, n + 1) rep(j, n + 1) {
        int k = n - i - j;
        if (k < 0 || k > n || i * 10000 + j * 5000 + k * 1000 != y) continue;
        out(i << " " << j << " " << k);
        return 0;
    }
    out(-1 << " " << -1 << " " << -1);
}


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

int main() {
  int N, M, A;
  cin >> N >> M;
  map<int, int> MA;
  while (cin >> A) MA[A]++;
  for (auto [a, b] : MA) if (b % 2) return cout << "NO" << "\n", 0;
  cout << "YES" << "\n";
}

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

 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    map<int,int> order;
    rep(i,N) {
        order[--A[i]] = i + 1;
    }
    rep(i,N) {
        cout << order[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5888
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
constexpr ll mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    int x;cin>>x;
    int ans = 1;
    int tmp;

    for (int b = 1; b <= x; ++b)
    {   
        tmp = b;
        for (int p = 2; p <= x; ++p)
        {
            tmp *= b;
            if(tmp<=x) {
                ans = max(ans,tmp);

                // cout<<b<<"**"<<p<<'='<<ans<<endl;
            } else {
                break;
            }
        }
        
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3584
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = 0;
    int len = 0;
    for(int i=1; i<n; ++i){
        if(h[i] <= h[i-1]){
            ++ len;
            ans = max(ans, len);
        }
        else{
            len = 0;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <cstdio>

int main(){
  int a,  b;
  scanf("%d", &a);
  scanf("%d", &b);
  
  int ans = 1;
  if ((b - a) > 0) {
    ans += (b - a) / (a - 1);
    if (((b - a) % (a - 1)) > 0) {
      ans++;
    }
  }
  
  
  if (b == 1) {
    ans = 0;
    printf("%d\n", ans);
  }
  else {
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 128
# include<bits/stdc++.h>
# include<string>
using namespace std;
int main(){
	long int n;
  	cin >> n;
  	string s;
  	// std::string::iterator it;
  	// storing in string
  	cin >> s;
  	// body
  	long int res = 1;
  	for(int i = 1; i < n; i++){
    	if(s[i] != s[i-1])
          res += 1;
    }
  // printing output
  cout << res <<'\n';
  
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner s = new Scanner(System.in);
	int x = s.nextInt();
	int i = 1;

	while(x > 0){
	    System.out.println("Case "+i+": "+x);

	    x = s.nextInt();
	    i++;
	}
    }
}



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

int main()
{
  int d;

  cin >> d;

  if(d==25){
    cout << "Christmas";
  }
  else if (d == 24)
  {
    cout << "Christmas Eve";
  }
  else if (d == 23)
  {
    cout << "Christmas Eve Eve";
  }
  else if (d == 22)
  {
    cout << "Christmas Eve Eve Eve";
  }
}


Measured memory_bytes: 3596
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())

H,W,m=NM()
import collections
hl=collections.defaultdict(int)
wl=collections.defaultdict(int)
hwl=set()
for i in range(m):
    h,w=NM()
    hl[h]+=1
    wl[w]+=1
    hwl.add((h,w))
mh=0
mw=0
mhl=[]
mwl=[]
for k,v in hl.items():
    if mh<v:
        mh=v
        mhl=[k]
    elif mh==v:
        mhl.append(k)
for k,v in wl.items():
    if mw<v:
        mw=v
        mwl=[k]
    elif mw==v:
        mwl.append(k)
if len(mhl)*len(mwl)>m:
    print(min(m,mh+mw))
else:
    for i in mhl:
        for j in mwl:
            if not (i,j) in hwl:
                print(min(m,mh+mw))
                quit()
    print(mh+mw-1)

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N,M;
    string S;
    cin >> N>>M;

    vector<ll> a(N);
    vector<ll> b(N);
    vector<ll> c(M);
    vector<ll> d(M);

    REP(i, N)
        cin >> a.at(i) >> b.at(i);
    REP(i, M)
            cin >> c.at(i) >> d.at(i);

    vector<ll> cd(M);
    //ll genten = -100000000;
    vector<pair<ll, ll>> pairs(M);

    REP(i,N){
        REP(j,M){
            cd.at(j) = abs(c.at(j) - a.at(i)) + abs(d.at(j) - b.at(i));
            //cout << j << " " << cd.at(j) << endl;

            pairs.at(j) = make_pair(cd.at(j), j + 1);
            //cout << pairs.at(1).first << " " << pairs.at(1).second << endl;

            

            //cout << pairs.at(0).first << " " << pairs.at(0).second << endl;
        }
        sort(pairs.begin(), pairs.end());
        cout << pairs.at(0).second << endl;
    }
}


Measured memory_bytes: 256
// Tax Rate Changed
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int s = sc.nextInt();
			if ((x | y | s) == 0)
				break;
			int result = 0;
			for (int i = 1; i < s; i++)
				for (int j = 1; j < s; j++) {
					int m = i * (100 + x) / 100;
					int n = j * (100 + x) / 100;
					if (m + n == s)
						result = Math.max(result, i * (100 + y) / 100 + j
								* (100 + y) / 100);
				}
			System.out.println(result);
		}
		sc.close();
	}
}

Measured memory_bytes: 20908
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int L = int.Parse(str[1]);
		int min = 9999999;
		int ans = 0;
		int mina = 9999999;
		for(var i=0;i<N;i++){
			int a = L+i;
			ans += a;
			if(Math.Abs(min) > Math.Abs(a)){
				min = a;
			}
		}
		ans -= min;
		Console.WriteLine(ans);
	}
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<int> p(n); rep(i,n) cin >> p[i];

  vector<int> m(n,-1);
  m[0] = p[0];
  for(int i = 1;i<n;i++){
    m[i] = min(p[i-1],m[i-1]);
    //cout << i << " " << p[i] << " " << m[i] << endl;
  }
  
  ll ans = 0;
  rep(i,n){
    if(p[i]<=m[i]) ans++;
  }

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


Measured memory_bytes: 4844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
using namespace std;

#define LL long long
const int maxn = 100000 + 100;
struct Node {
    LL pos;
    LL num;
};

bool operator<(const Node &a, const Node &b) {
    return a.pos < b.pos;
}

int n;
LL c;
Node node[maxn];
LL Max[maxn];
int mn[maxn];
LL num[maxn], sum[maxn];

void Init() {
    Max[0] = 0;
    for(int i = 1; i <= n; ++i) {
        Max[i] = max(Max[i - 1], num[i]);
    }
}

void Reverse() {
    for(int i = 1; i <= n / 2; ++i) {
        swap(node[i], node[n - i + 1]);
        node[i].pos = c - node[i].pos;
        node[n - i + 1].pos = c - node[n - i + 1].pos;
    }
    if(n % 2 == 1) {
        node[n / 2 + 1].pos = c - node[n / 2 + 1].pos;
    }
}

LL solve() {
    LL ret = 0;
    sum[0] = 0;
    for(int i = 1; i <= n; ++i) {
        sum[i] = sum[i - 1] + node[i].num;
        num[i] = sum[i] - 2 * node[i].pos;
        ret = max(ret, num[i]);
    }
    Init();
    for(int i = n; i >= 1; --i) {
        ret = max(ret, Max[i - 1] + sum[n] - sum[i - 1] - (c - node[i].pos));
    }
    return ret;
}

int main() {
    #ifdef LOCAL
    freopen("test.txt", "r", stdin);
    #endif // LOCAL
    ios::sync_with_stdio(false);

    while(cin >> n >> c) {
        for(int i = 1; i <= n; ++i) {
            cin >> node[i].pos >> node[i].num;
        }
        sort(node + 1, node + 1 + n);
        LL ans = solve();
        Reverse();
        ans = max(ans, solve());
        cout << ans << endl;
    }

    return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=998244353;

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


int main(){
    ll N, X, M; cin >> N >> X >> M;
    ll tmp=X;
    vector<bool> check(M, 0);
    vi ord(M, -1);
    ll n, m, cnt=1;
    while(1){
        if(check[tmp]){
            n=ord[tmp];
            m=cnt;
            break;
        }
        check[tmp]=true;
        ord[tmp]=cnt;
        cnt++;
        tmp=tmp*tmp%M;
    }

    ll ans=0;
    if(N <= m){
        for(ll i=1; i<=N; i++){
            ans+=X;
            X=X*X%M;
        }
    }
    else{
        ll sum1=0, sum2=0, sum3=0;
        tmp=X;
        for(ll i=1; i<=n-1; i++){
            sum1+=tmp;
            tmp=tmp*tmp%M;
        }
        for(ll i=n; i<m; i++){
            sum2+=tmp;
            tmp=tmp*tmp%M;
        }
        for(ll i=1; i<=(N-n+1)%(m-n); i++){
            sum3+=tmp;
            tmp=tmp*tmp%M;
        }
        ans=sum1+sum2*((N-n+1)/(m-n))+sum3;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3716
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

LL check(vector<LL>& a,LL mid)
{
	LL mx=0,now=0,cnt=0;
	for(auto i:a) {
		now+=i;
		if (now>=mid) {
			mx=max(mx,now);
			++cnt;
			if (cnt<4)
			now=0;
		}
	}
	mx=max(mx,now);
	if (cnt<4) return LLONG_MAX;
	return mx;
}
LL sum[300010];
LL query(int l,int r)
{
	if (l<0) return LLONG_MAX/3;
	return sum[r+1]-sum[l];
}
LL q(int l,int mid,int r)
{
	return abs(query(l,mid)-query(mid+1,r));
}
void calc(vector<LL>& a,int pl,int pr,LL& x1,LL& x2)
{
	int l=pl,r=pr;
	while(l<r-1) {
		int mid1=l+(r-l)/3,mid2=l+(r-l)*2/3;
		if (q(pl,mid1,pr)<q(pl,mid2,pr)) {
			r=mid2-1;
		} else {
			l=mid1+1;
		}
	}
	if (q(pl,l,pr)<=q(pl,l+1,pr) && q(pl,l,pr)<=q(pl,l-1,pr)) {
		x1=query(pl,l);
		x2=query(l+1,pr);
	} else if (q(pl,l+1,pr)<=q(pl,l-1,pr)) {
		x1=query(pl,l+1);
		x2=query(l+2,pr);
	} else {
		x1=query(pl,l-1);
		x2=query(l,pr);
	}
}
void solve(long long N, vector<long long> A){
	for(int i=1; i<=N; ++i) {
		sum[i]=sum[i-1]+A[i-1];
	}
	LL ans=LLONG_MAX;
	for(int i=1; i<N-2; ++i) {
		LL x[5];
		calc(A,0,i,x[0],x[1]);
		calc(A,i+1,N-1,x[2],x[3]);
		sort(x,x+4);
		ans=min(ans,x[3]-x[0]);
	}
	cout<<ans<<endl;
}

int main(){	
#ifdef WAAUTOMATON
	freopen("in.txt","r",stdin);
#endif
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}



Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
typedef pair<double, P> P2;

int n, m;
int image[110][110];
int cut[55][55][4];
int nx, ny;
P tmp;
vector<P> xy;

void PRINT(int y, int x, int k){
  for(int i = y ; i < y+m ; i++){
    for(int j = x ; j < x+m ; j++){
      cout << image[i][j] << ' ';
    }
    cout << endl;
  }
  cout << endl;

  for(int i = 0 ; i < m ; i++){
    for(int j = 0 ; j < m ; j++){
      cout << cut[i][j][k] << ' ';
    }
    cout << endl;
  }
  cout << endl;

}


void make(){
  for(int k = 1 ; k < 4 ; k++){
    for(int i = 0 ; i < m ; i++){
      for(int j = 0 ; j < m ; j++){
	cut[m-i-1][j][k] = cut[j][i][k-1];
      }
    }
  }
}

bool check(int y, int x, int k){
  for(int i = y ; i < y+m ; i++){
    for(int j = x ; j < x+m ; j++){
      if(cut[i-y][j-x][k] == -1) continue;
      if(cut[i-y][j-x][k] != image[i][j]) return false;
    }
  }
  
  // PRINT(y,x,k);
 
  bool f = false;
  for(int i = y ; i < y+m ; i++){
    for(int j = x ; j < x+m ; j++){
      if(cut[i-y][j-x][k] == -1) continue;
      f = true;
      tmp.first = i, tmp.second = j;
      //      tmp.first = (double)sqrt((i*i)+(j*j));
      xy.push_back(tmp);
      break;
    }
    if(f) break;
  }
  return true;
}

int main(){
  while(cin >> n >> m){
    if(n == 0 && m == 0) break;
    xy.clear();
    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < n ; j++){
	cin >> image[i][j];
      }
    }
    
    for(int i = 0 ; i < m ; i++){
      for(int j = 0 ; j < m ; j++){
	cin >> cut[i][j][0];
      }
    }
    
    make();
    
    bool flag = false;
    
    for(int k = 0 ; k < 4 ; k++){
      for(int i = 0 ; i <= n-m ; i++){
	for(int j = 0 ; j <= n-m ; j++){
	  if(check(i, j, k)){
	    flag = true;
	  }
	}
      }
    }
    
    sort(xy.begin(), xy.end());
    /*
    for(int i = 0 ; i < xy.size() ; i++){
      cout << xy[i].first << ' ' << xy[i].second <<endl;
    }
*/
    if(flag){
      cout << xy[0].second+1 << ' ' << xy[0].first+1 << endl;
    }
    else cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 1420