akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long int ll;

int main()
{
	while (1)
	{
		int H, W;
		ll L;
		char C[100][100];

		cin >> H >> W >> L;
		if (H == 0) return 0;

		int sx, sy, sd;

		rep(y, 0, H) rep(x, 0, W)
		{
			char c; cin >> c;
			if (c != '.' && c != '#')
			{
				sx = x;
				sy = y;
				switch (c)
				{
				case 'N': sd = 0; break;
				case 'E': sd = 1; break;
				case 'S': sd = 2; break;
				case 'W': sd = 3; break;
				}
				C[y][x] = '.';
			}
			else
				C[y][x] = c;
		}

		ll memo[100][100][4];
		rep(y, 0, H) rep(x, 0, W) rep(i, 0, 4) memo[y][x][i] = -1;
		bool noloop = true;

		int dx[4] = { 0, 1, 0, -1 };
		int dy[4] = { -1, 0, 1, 0 };

		for (ll l = 0; l < L;l++)
		{
			rep(i, 0, 4)
			{
				int d = (sd + i) % 4;
				if (noloop)
				{
					if (memo[sy][sx][d] < 0)
					{
						memo[sy][sx][d] = l;
					}
					else
					{
						int dl = l - memo[sy][sx][d];
						l = l + ((L - 1 - l) / dl) * dl;
						noloop = false;
					}
				}
				int x = sx + dx[d];
				int y = sy + dy[d];
				if (x < 0 || W <= x) continue;
				if (y < 0 || H <= y) continue;
				if (C[y][x] == '#') continue;

				sx = x;
				sy = y;
				sd = d;
				break;
			}
		}

		cout << (sy + 1) << " " << (sx + 1) << " ";
		switch (sd)
		{
		case 0: cout << "N"; break;
		case 1: cout << "E"; break;
		case 2: cout << "S"; break;
		case 3: cout << "W"; break;
		}
		cout << endl;
	}
}

Measured memory_bytes: 3324
#include <iostream>
#include <algorithm>
#include <string>
// #include <cstring>
using namespace std;

const int MAXN = 310;
string map[MAXN];
int rn, cn, kpiece;
int ans[MAXN][MAXN];
int main() {
	cin>>rn>>cn>>kpiece;
	for (int i=0; i<rn; i++)
		cin>>map[i];
	bool isfirstline = 1;
	int kid = 0;
	for (int r=0; r<rn; r++) {
		bool have = 0;
		for (int c=0; c<cn; c++)
			if (map[r][c] == '#') {
				ans[r][c] = ++kid;
				if (have == 0)
					for (int j=0; j<c; j++)
						ans[r][j] = kid;
				have = 1;
			}else if (have){
				ans[r][c] = ans[r][c-1];
			}
		if (have && isfirstline) {
			for (int i=r-1; i>=0; i--)
				for (int j=0; j<cn; j++)
					ans[i][j] = ans[i+1][j];
			isfirstline = 0;
		}
		if (!have && isfirstline == 0)
			for (int j=0; j<cn; j++)
				ans[r][j] = ans[r-1][j];
	}
	for (int r=0; r<rn; r++, cout<<endl)
		for (int c=0; c<cn; c++)
			cout<<ans[r][c]<<" ";
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 

 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

typedef tuple<ll, ll, ll> T;

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

    int n,q; cin >> n >> q;
    vector<T> xst(n);
    for(int i=0; i<n; ++i){
        int x,s,t; cin >> s >> t >> x;
        s -= x; t -= x;
        xst[i] = make_tuple(x, s, t);
    }
    sort(xst.begin(), xst.end());

    set<pair<int, int>> di;
    for(int i=0; i<q; ++i){
        int d; cin >> d;
        di.insert(make_pair(d, i));
    }

    vector<int> ans(q, -1);

    for(int i=0; i<n; ++i){
        int x, l, r;
        tie(x, l, r) = xst[i];
        auto itr = di.lower_bound(make_pair(l, -1));
        while(itr != di.end() && itr->first < r) {
            ans[itr->second] = x;
            di.erase(itr++);
        }
    }

    for(int i=0; i<q; ++i) cout << ans[i] << endl;


	return 0;
}

Measured memory_bytes: 16768
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String s = sc.next();
      String t = sc.next();
      String ans="";
      for(int i=0;i<n;i++){
        ans+=String.valueOf(s.charAt(i))+String.valueOf(t.charAt(i));
      }
      System.out.println(ans);
    }
}

Measured memory_bytes: 39472
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#define REP(i,n) for(int i = 0; n > i; i++)
#define MOD 1000000007
using namespace std;
typedef vector<int> Ivec;
typedef pair<int, int> pii;

int main() {
	int n;
	long long int res = 0;
	int rest = 0;
	scanf("%d", &n);
	REP(i, n) {
		int a;
		scanf("%d", &a);
		res += (a+rest) / 2;
		rest = (a+rest*(a>0))%2;
	}

	printf("%lld\n", res);

	return 0;
}

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

typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll r = 0;
    ll b = 0;
    ll g = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R')
            r++;
        else if (s[i] == 'G')
            g++;
        else
            b++;
    }
    ll mn = 0;
    for (int d = 1; d <= n; d++) {
        for (int i = 0; i < n; i++) {
            set<char> cs;
            if (i + d + d >= n)
                continue;
            cs.insert(s[i]);
            cs.insert(s[i + d]);
            cs.insert(s[i + d + d]);
            if ((int)cs.size() == 3)
                mn++;
        }
    }
    cout << r * g * b - mn;
    return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  cout << a * b << " " << (a + b) * 2 << endl;
  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
template<typename T> using pq = std::priority_queue<T>;
#define REP(i,b,e) for(ll i=b; i<e; i++)

int main(){
	int x, y, a, b, c;
	scanf("%d %d %d %d %d", &x, &y, &a, &b, &c);
	ll p, q, r;
	pq<P> que;
	REP(i, 0, a){
	    scanf("%ld", &p);
	    que.emplace(p, 0);
	}
	REP(i, 0, b){
	    scanf("%ld", &q);
	    que.emplace(q, 1);
	}
	REP(i, 0, c){
	    scanf("%ld", &r);
	    que.emplace(r, 2);
	}

	ll non = 0, ans = 0;
	while(!que.empty() && non<x+y){
	    auto [v, t] = que.top();
	    que.pop();
	    if(t==0 && x) x--;
	    else if(t==1 && y) y--;
	    else if(t==2 && non<x+y) non++;
	    else continue;
	    ans += v;
	}
	printf("%ld\n", ans);
	return 0;
}



Measured memory_bytes: 11648
n = int(input())
s = input()
rl = s.count('R')
gl = s.count('G')
bl = s.count('B')
rr = 0
gr = 0
br = 0
if s[0] == 'R':
    rl -= 1
    rr += 1
elif s[0] == 'G':
    gl -= 1
    gr += 1
else:
    bl -= 1
    br += 1

ans = 0
for i in range(1, n-1):
    for j in range(1, n//2+1):
        if i-j < 0 or i+j > n-1:
            break
        if s[i+j] != s[i-j] and s[i+j] != s[i] and s[i-j] != s[i]:
            ans -= 1
    if s[i] == 'R':
        ans += bl*gr + br*gl
        rl -= 1
        rr += 1
    elif s[i] == 'G':
        ans += rr*bl + rl*br
        gl -= 1
        gr += 1
    else:
        ans += gr*rl + gl*rr
        bl -= 1
        br += 1
print(ans)


Measured memory_bytes: 73532
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
   string y;
   long long int a,b=0;
   cin>>a>>y;
   b=(b*10)+(y[0]-48);
   b=(b*10)+(y[2]-48);
   b=(b*10)+(y[3]-48);
   cout<<(a*b)/100<<endl;
   return 0;
}


Measured memory_bytes: 3620
W , H , x , y , r  = map(int,input().split()) 

if ( x >= 0) and (y >= 0):
    if 0 <= ( x + r ) <=  W and 0  <= ( y + r ) <= H:
            print("Yes")
    else:
            print("No")
elif ( x < 0) and (y >= 0) :
    if 0 <= ( x - r ) <=  W and 0  <= ( y + r ) <= H:
            print("Yes")
    else:
            print("No")
elif ( x >= 0) and (y < 0) :
    if 0 <= ( x + r ) <=  W and 0  <= ( y - r ) <= H:
            print("Yes")
    else:
            print("No")
else:
    if 0 <= ( x - r ) <=  W and 0  <= ( y - r ) <= H:
            print("Yes")
    else:
            print("No")




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

int p[51];
int a[51];
int main() {
	int n; cin >> n;
	for (int i=1; i<=n; ++i) {
		cin >> p[i];
		a[i] = i;
	}

	int cnt = 0;
	for (int i=1; i<=n; ++i) {
		if (p[i]==a[i]) cnt++;
	}
	if ((cnt == n) || (cnt == (n-2)))
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	
	return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n;
    string s;
    cin >> n >> s;
    vector<int> r, g, b;
    ll num[3] = {};
    rep(i, n) {
        if (s[i] == 'R') {
            r.push_back(i);
            num[0]++;
        } else if (s[i] == 'G') {
            g.push_back(i);
            num[1]++;
        } else {
            b.push_back(i);
            num[2]++;
        }
    }

    ll sum = num[0] * num[1] * num[2];
    if (sum == 0) {
        cout << 0 << endl;
        return 0;
    }

    for (ll i : r) {
        for (ll j : g) {
            ll k = 2 * j - i;
            if (k<0 | k> n) {
                continue;
            }
            if (s[k] == 'B') {
                sum--;
            }
        }
    }
    for (ll i : g) {
        for (ll j : b) {
            ll k = 2 * j - i;
            if (k<0 | k> n) {
                continue;
            }
            if (s[k] == 'R') {
                sum--;
            }
        }
    }
    for (ll i : b) {
        for (ll j : r) {
            ll k = 2 * j - i;
            if (k<0 | k> n) {
                continue;
            }
            if (s[k] == 'G') {
                sum--;
            }
        }
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s,front,back;
    char c;
    int q,t,f,now=0;
    cin>>s>>q;
    rep(i,0,q){
        cin>>t;
        if(t==1){now = 1-now;}
        else{
            cin>>f>>c;
            if((f-now)%2==1){front = c + front;}
            else{back = back + c;}
        }
    }
    s = front + s + back;
    if(now){
        reverse(s.begin(),s.end());
    }
    cout<<s;
}


Measured memory_bytes: 1320
class Integer
  def divisor_list
    require 'prime'

    return [] if self <= 0
    return [1] if self == 1

    prime_division.map.with_index { |(base, k), i|
      s = i.zero? ? 0 : 1
      (s..k).map { |n| base ** n }
    }.inject { |res, e| res + res.flat_map { |t| e.map { |v| t * v } } }.sort
  end
end

A, B = gets.split.map(&:to_i)

a = A.divisor_list.select(&:prime?)
b = B.divisor_list.select(&:prime?)

puts (a & b).size + 1


Measured memory_bytes: 2808
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }

int s[3][3] = {
 {0, 1, 0},
 {1, 1, 1},
 {0, 1, 0}
};

int m[3][3] = {
	{1, 1, 1},
	{1, 1, 1},
	{1, 1, 1}
};

int l[5][5] = {
	{0, 0, 1, 0, 0},
	{0, 1, 1, 1, 0},
	{1, 1, 1, 1, 1},
	{0, 1, 1, 1, 0},
	{0, 0, 1, 0, 0}
};

int area[10][10];

int main() {
	minit(area, 0);
	
	int x, y, size; char c;
	while (cin>>x>>c>>y>>c>>size) {
		switch (size) {
			case 1:
				for_(i, -1, 2) {
					for_(j, -1, 2) {
						if (x+i<0  || 9<x+i || y+j<0 || 9<y+j) continue;
						area[x+i][y+j] += s[i+1][j+1];
					}
				}
				break;
			case 2:
				for_(i, -1, 2) {
					for_(j, -1, 2) {
						if (x+i<0  || 9<x+i || y+j<0 || 9<y+j) continue;
						area[x+i][y+j] += m[i+1][j+1];
					}
				}
				break;
			case 3:
				for_(i, -2, 3) {
					for_(j, -2, 3) {
						if (x+i<0  || 9<x+i || y+j<0 || 9<y+j) continue;
						area[x+i][y+j] += l[i+2][j+2];
					}
				}
				break;
			default:
				break;
		}
	}
	
	int n0 = 0, m = 0;
	for (int i=0; i<10; i++) {
		for (int j=0; j<10; j++) {
			m = max(m, area[i][j]);
			if (area[i][j]==0) n0++;
		}
	}
	
	cout << n0 << endl << m << endl;
	
	return 0;
}

Measured memory_bytes: 1164
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, M = map(int, input().split())
res = 0
res += combinations_count(N, 2) if(N >= 2) else 0
res += combinations_count(M, 2) if(M >= 2) else 0
print(res)

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
int S,h,H,m,s = 0;

scanf("%d",&S);

if(0<=S && S<86400){

h = S/3600;
H = S%3600;

m = H/60;
s = H%60;

printf("%d:%d:%d\n",h,m,s);
}

return 0;

}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define FOR(n) for(int i=0;i<n;i++)
#define MOD 1e9+7
#define INF 1e9
#define F first
#define S second
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll ks(ll a){
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}
int main(void){
  ll a,n,m,j;
  cin>>a>>n>>m;
  int ans=0;
  for(ll i=1;(ll)pow(i,n)<=m;i++){
    ll j=(ll)pow(i,n);
    if(ks(j)+a==i)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3280
sharpNum = 20
roomNum = 10
height = 15
dataNum = int(input())
#building = [[0]*sharpNum] * height
building = [[0] * sharpNum for i in range(height)]

for data in range(dataNum):
    actBuilding = 1
    actRoom = 0
    actFloor = 0
    b,f,r,v = map(int, input().split())
    for floor in range(height):
        actRoom = 0
        if floor%4 == 3:
            actFloor = 0
            actBuilding = actBuilding + 1
            for room in range(sharpNum):
                building[floor][room] = "#"
        else:
            actFloor = actFloor + 1
            
            for room in range(sharpNum):
                if room%2 == 0:
                    building[floor][room] = " "
                else:
                    actRoom = actRoom + 1 
                    if actBuilding == b and actFloor== f and actRoom == r:
                        building[floor][room] = building[floor][room] + v

for floor in range(height):      
    for i in range(len(building[0])):
        print(building[floor][i],end="")
    print("")


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

using ll = long long;
using namespace std;

int main() {
    ll n;
    cin >> n;
    if (n % 2) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    ll fact = 2;
    while (n / fact) {
        while (n / fact / 5) {
            fact *= 5;
            ans += ll(n / fact);
        }
        fact *= 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){

	int a, b;
	char op;

	while (std::cin >> a >> op >> b){
		if (op == '+')std::cout << a + b << std::endl;
		else if (op == '*')std::cout << a * b << std::endl;
		else if (op == '-')std::cout << a - b << std::endl;
		else if (op == '/')std::cout << a / b << std::endl;
		else break;
	}
	return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var NAB = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            var aSum = NAB[0] * NAB[1];
            Console.WriteLine(aSum > NAB[2]?NAB[2]:aSum);
        }
    }
}


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

using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
struct edge{int nxt,to,w;}e[MAXN<<2];
ll l=0,r=1ll<<40,dif[MAXN],fst=0;
int n,m,x,y,z,head[MAXN],mk[MAXN],vis[MAXN],tot=0;

void add(int from,int to,int w)
{e[++tot].nxt=head[from];e[tot].to=to;e[tot].w=w;head[from]=tot;}

void dfs(int x,ll cur,int mark,int anc)
{
	if(!vis[x])
	{
		mk[x]=mark;dif[x]=cur;vis[x]=1;
		if(fst&&dif[x]+mk[x]*fst<=0)
			puts("0"),exit(0);
		
		if(mk[x]>0) l=max(l,-dif[x]+1);
		else r=min(r,dif[x]-1);
	}
	else
	{
		if(cur==dif[x]&&mark==mk[x]) return;
		if(cur!=dif[x]&&mark==mk[x])
			puts("0"),exit(0);
		
		ll t=(dif[x]-cur)/(mark-mk[x]);
		if(t*(mark-mk[x])==dif[x]-cur && ((!fst)||fst==t)) fst=t;
		else puts("0"),exit(0);
		return;
	}
	for(int i=head[x];i;i=e[i].nxt)
		if(e[i].to!=anc) dfs(e[i].to,e[i].w-cur,-mark,x);
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d%d%d",&x,&y,&z),add(x,y,z),add(y,x,z);
	dfs(1,0,1,0);
	
//	for(int i=1;i<=n;i++)
//		cout<<dif[i]<<" "<<mk[i]<<endl;
	
	if(fst) printf("1");
	else printf("%lld",max(0ll,r-l+1));
	return 0;
}

Measured memory_bytes: 11008
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <ctime>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <climits>
#include <set>
#include <vector>
#include <bitset>
using namespace std;
inline int read(){
	int k=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
	return k*f;
}
inline void write(int x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
inline void writeln(int x){
	write(x);puts("");
}
bitset<5000000>b;
int main()
{
	int n=read();int sum=0;
	b[0]=1;
	for(int i=1;i<=n;i++){
		int x=read();sum+=x;
		b|=b<<x;
	}
	for(int i=sum/2;i>=0;i--)if(b[i]){
		writeln(sum-i);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 2048
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, A, B, C, D = MAP()

# Aを起点に対称に広がるのでとりあえずAを起点とする
B = abs(A - B)
for i in range(N):
    # i回足して、j回引く
    j = N - i - 1
    # 小さく足して大きく引く
    mn = C * i - D * j
    # 大きく足して小さく引く
    mx = D * i - C * j
    # 範囲内なら自由に調節が効くのでOK
    if mn <= B <= mx:
        YES()
        exit()
NO()


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

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

    int l=0, r=0;
    string ls, rs;
    for(int i=0; i<str.size(); i++) {
        if(str[i]=='(') {
            if(l>0) {
                for(int j=0; j<l; j++) {
                    ls += "(";
                }
                l=0;
            }
            
            r++;
        } else {
            if(r==0) {
                l++;
            } else {
                r--;
            }
        }
    }
    for(int j=0; j<r; j++) {
        rs += ")";
    }
    for(int j=0; j<l; j++) {
        ls += "(";
    }
    
    cout << ls << str << rs << endl;

    return 0;
    
}

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

namespace AGC008
{
    public class C
    {
        private void Run()
        {
            checked
            {
                var A = Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
                var I = A[0];
                var O = A[1];
                //var T = A[2];
                var J = A[3];
                var L = A[4];
                //var S = A[5];
                //var Z = A[6];

                long t1 = O;
                t1 += I / 2 * 2;
                t1 += J / 2 * 2;
                t1 += L / 2 * 2;
                if (I % 2 == 1 && J % 2 == 1 && L % 2 == 1) { t1 += 3; }

                long t2 = O;
                if (I > 0 && J > 0 && L > 0)
                {
                    t2 += 3;
                    I--;
                    J--;
                    L--;
                }
                t2 += I / 2 * 2;
                t2 += J / 2 * 2;
                t2 += L / 2 * 2;

                Console.WriteLine(Math.Max(t1, t2));
            }
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new C().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


Measured memory_bytes: 2904
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<EntryPoint>]
let main _ =
    let [|x;y|] = reada int

    let ans =
        let a =
            if x < 4 then 400000 - (x * 100000)
            else 0
        let b =
            if y < 4 then 400000 - (y * 100000)
            else 0
        let c = if x = 1 && y = 1 then 400000 else 0
        a + b + c

    printfn "%d" ans
    0 // return an integer exit code


Measured memory_bytes: 14044
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iiii tuple<int, int, int, int>
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define fi first
#define vi vector<int>
#define vvi vector<vector<int>>
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
    char c;
    cin >> c;
    cout << ++c << '\n';    
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i >= 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define INFD 1e18
#define PI 3.14159265358979
#define MOD 1000000007
// #define MOD 998244353
#define VL vector<ll>

vector<ll> dx = {-1, 1, 0,  0, -1, -1,  1, 1};
vector<ll> dy = { 0, 0, 1, -1, -1,  1, -1, 1};

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



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; }
};

template< typename T >
using Edges = vector< edge< T > >;
/*
WeightedGraph<ll> g(V);
g[a].emplace_back(b, c);
*/
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

int main()
{
	ll N, M;
	cin >> N >> M;
	UnWeightedGraph G(N);
	REP(i, M) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}
	queue<P> que;
	que.push(P(0, -1));
	vector<bool> vi(N);
	vi[0] = true;
	vector<ll> ans(N, -1);
	while(!que.empty()) {
		P t = que.front();
		que.pop();
		ans[t.first] = t.second;
		REP(i, G[t.first].size()) {
			if (!vi[G[t.first][i]]) {
				vi[G[t.first][i]] = true;
				que.push(P(G[t.first][i], t.first));
			}
		}
	}
	PRINT("Yes");
	REP(i, N-1) {
		cout << ans[i+1]+1 << endl;
	}
	return 0;
}


Measured memory_bytes: 11800
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    while(cin >> n >> m, n or m)
    {
        vector<int> s(n), t(m);
        for(int i = 0; i < n; i++) cin >> s[i];
        for(int i = 0; i < m; i++) cin >> t[i];
        pair<int, int> ans = make_pair(-1, -1);
        int minSum = INF;
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
            {
                swap(s[i], t[j]);
                int sumA = 0, sumB = 0;
                for(int k = 0; k < n; k++) sumA += s[k];
                for(int k = 0; k < m; k++) sumB += t[k];
                if(sumA == sumB and sumA < minSum)
                {
                    minSum = sumA;
                    ans = make_pair(s[i], t[j]);
                }
                swap(s[i], t[j]);
            }
        }
        if(minSum == INF) cout << -1 << endl;
        else cout << ans.second << " " << ans.first << endl;
    }
    return 0;
}




Measured memory_bytes: 3236
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-09 20:13:23
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  string s; cin >> s;
  int n = s.size();

  string ans(n, 'x');

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
a, b, c, d, e, f = map(int, input().split())


cap = e / (100 + e)
max_noudo = 0
sugar_ans, water_ans = 0, 0
for i in range(f//(100*a)+1):
    for j in range((f - (100 * a * i)) // (100 * b) + 1):
        water = 100 * (i * a + j * b)
        for k in range(((i * a + j * b)*e)//c+1):
            for l in range(((i * a + j * b)*e - k*c)//d+1):
                sugar = k * c + l * d
                if f < water + sugar or water == 0:
                    continue
                else:
                    noudo = sugar / (water + sugar)
                    if max_noudo <= noudo <= cap:
                        max_noudo = noudo
                        sugar_ans = sugar
                        water_ans = water
print(water_ans+sugar_ans, sugar_ans)


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

signed main () {
    int n, l;
    cin >> n >> l;
    vector < int > a(n + 1, 0);
    int j = 0;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    for (int i = 1; i < n; ++i) {
        if (a[i] + a[i + 1] >= l) {
            j = i;
            break;
        }
    }
    if (j == 0)
        cout << "Impossible\n";
    else {
        cout << "Possible\n";
        for (int i = 1; i < j; ++i)
            cout << i << '\n';
        for (int i = n - 1; i > j; --i)
            cout << i << '\n';
        cout << j << '\n';
    }
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main(){
    int s;
    
    cin >> s;
    int N[1000005];
    N[0] = s;
    int i = 1;
    bool flag = false;
    while(flag != true){
        if(s % 2 == 0){
            s = s / 2;
            N[i] = s;
        }else{
            s = (3 * s) + 1;
            N[i] = s;
        }
        for(int j = 0; j < i; j++){
            if(s == N[j]){
                flag = true;
            }
        }
        i++;
    }
    cout << i << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>
#define VI vector<int>
#define VII vector<VI>

using namespace std;

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

	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i*j == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}
*/



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

	if (10 <= a || 10 <= b) {
		cout << -1 << endl;
	}
	else {
		cout << a*b << endl;
	}


	return 0;
}


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

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

    auto adjacency_list = vector<vector<int>>(N);
    for (auto i = 0; i < N-1; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        adjacency_list[a].push_back(b);
        adjacency_list[b].push_back(a);
    }

    auto matched = vector<bool>(N);
    const function<void(int, int)> dfs = [&](const int v, const int parent)
    {
        for (const auto child : adjacency_list[v]) if (child != parent)
        {
            dfs(child, v);
            if (!matched[child] && !matched[v])
                matched[child] = matched[v] = true;
        }
    };
    dfs(0, -1);

    auto all_matched = true;
    for (const auto x : matched) all_matched &= x;
    cout << (all_matched ? "Second" : "First") << endl;
}


Measured memory_bytes: 5888
/*****************************************************
 *     created by: nayakashutosh9
 * "Winners Never Quit and Quitters Never Win".
*****************************************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 300005;
/**********************************************************************************************/


void solve() {
	int n; cin >> n;
	double ans = double(n * n * n * 1.0) / 27.0;
	cout << fixed << setprecision(10) << ans << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<P> b(M);
    vector<int> dest;
    rep(i,M){
        cin >> b[i].second;
        cin >> b[i].first;
        b[i].second--;
        b[i].first--;
    }
    sort(b.begin(), b.end());
    int cnt = 0;
    rep(i,M){
        bool dest_flag = false;
        for(auto& e:dest){
            if(b[i].second < e && e <= b[i].first){
                dest_flag = true;
                break;
            }
        }
        if(!dest_flag){
            dest.push_back(b[i].first);
            cnt++;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 200005;
const int MM = 1000000007;

vector<pii> G[MX];
vector<int> H[MX];
int ans[MX*2];
int N, M, a, b;

int dist[2005][2];
void get_answer(int x){
	queue<pii> Q;
	memset(dist, 0, sizeof dist);
	for(pii c : G[x]){
		if(c.second&1) continue;
		Q.emplace(c.first, c.second);
		dist[c.first][0] = c.second;
	}
	dist[x][0] = dist[x][1] = -1;
	while(Q.size()){
		pii p = Q.front(); Q.pop();
		int c = p.first, lab = p.second;
		for(int d : H[c]){
			if(dist[d][0] && dist[d][1] || dist[d][0] == lab) continue;
			if(!dist[d][0]) dist[d][0] = lab;
			else dist[d][1] = lab;
			Q.emplace(d, lab);
		}
	}
	for(pii c : G[x]){
		if(dist[c.first][1] || dist[c.first][0] && dist[c.first][0] != c.second) ans[c.second] = 1;
	}
}

int main()
{
	scanf("%d%d", &N, &M);
	for(int i = 1; i <= M; i++){
		scanf("%d%d", &a, &b);
		G[a].emplace_back(b, i*2);
		G[b].emplace_back(a, i*2+1);
		H[a].emplace_back(b);
	}
	for(int i = 1; i <= N; i++){
		get_answer(i);
	}
	for(int i = 1; i <= M; i++){
		if(ans[i*2] ^ ans[i*2+1]) printf("diff\n");
		else printf("same\n");
	}
}


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

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var A = input[0];
            var B = input[1];

            if (A < 6)
            {
                Console.WriteLine(0);
            }
            else if (6 <= A && A <= 12)
            {
                Console.WriteLine(B / 2);
            }
            else
            {
                Console.WriteLine(B);
            }
        }
    }
}

Measured memory_bytes: 11220
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        HashMap<String,Integer> map=new HashMap<>();
        String[] arr={"AC", "WA" ,"TLE", "RE" };
        for(int i=0;i<n;i++){
            String str=sc.next();
            if(map.containsKey(str)){
                int value=map.get(str)+1;
                map.put(str, value);
            }
            else
            map.put(str,1);
        }
        for(int i=0;i<4;i++){
            if(map.containsKey(arr[i]))
            System.out.println(arr[i]+" x "+map.get(arr[i]));
            else
            System.out.println(arr[i]+" x "+0);
        }
        
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define loop(i, a, b) for(int i = a; i < b; i++)


const int maxn = 1e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

int slen, tlen;
int dp[3001][3001] = {};
vector<char> v;
map<int, char> subsequence;

int sub(string s, string t, int si, int ti)
{	
	loop(i, 1, slen + 1)
	loop(j, 1, tlen + 1)
	{
		if(s[i - 1] == t[j - 1])
		{
			dp[i][j] = max(1 + dp[i - 1][j - 1], dp[i][j]);
			// subsequence.insert(pair<int, char> (i, s[i - 1]));
			// cout << "i = " << i << " j = " << j << " s[i] = " << s[i] << " t[j] = " << t[j] << "\n";
			
		}
		else
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
	}
	return dp[slen][tlen];
}

int main()
{
	// char s[3000], t[3000];
	fastIO;
	string s,t;
	cin >> s;
	cin >> t;

	slen = s.length(), tlen = t.length();
	// memset(dp,0,sizeof(dp));
	int ans = sub(s, t, 0, 0), x = slen, y = tlen;

	while(ans)
	{
		if(s[x - 1] == t[y - 1])
		{
			ans--;
			subsequence.insert(pair<int, char> (x, s[x - 1]));
			x--;
			y--;
		}
		else
		{
			if(dp[x - 1][y] > dp[x][y - 1])
				x--;
			else 
				y--;
		}



	}
	// for(int i = 0; i < v.size(); i++)
	// 	cout << v[i];
	map<int, char>::iterator itr;
	for(itr = subsequence.begin(); itr != subsequence.end(); ++itr)
	{
		cout << itr -> second;
	}

	return 0;
}

Measured memory_bytes: 35584
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 36


main(){

  char nul;
  char C1[N],C2[N];
  char tmpc;


  int A1[N],A2[N];
  int n,i,j,k=0;
  int tmp;
  int flag,mini,min;



  /* input */
  scanf("%d%c",&n,&nul);
  if(n<1||n>36)return 0;

  for(i=0;i<n;i++){
    scanf("%c%d%c",&C1[i],&A1[i],&nul);
    C2[i]=C1[i];
    A2[i]=A1[i];
  } 

  /*---------------  bubble sort  ------------------ */
 for(i=0;i<n;i++){
   for(j=1;j<n;j++){

     if(A1[j]<A1[j-1]){
       tmp=A1[j];
       tmpc=C1[j];
       A1[j]=A1[j-1];
       C1[j]=C1[j-1];
       A1[j-1]=tmp;
       C1[j-1]=tmpc;
     }
   }
 }
 
 for(i=0;i<n;i++){
   printf("%c%d",C1[i],A1[i]);
   if(i<n-1)printf(" ");
   if(i==n-1)printf("\n");
 }
 printf("Stable\n");


 
 /*----------------- selection sort ------------------*/
 
  min=A2[0];

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(min>A2[j]){
	min=A2[j];
	mini=j;
	flag=1;
      }
    }

    if(flag==1){
	tmp=A2[i];
	tmpc=C2[i];
	A2[i]=A2[mini];
	C2[i]=C2[mini];
	A2[mini]=tmp;
	C2[mini]=tmpc;
	flag=0;
      }
    min=A2[i+1];
  }

for(i=0;i<n;i++){
   printf("%c%d",C2[i],A2[i]);
   if(i<n-1)printf(" ");
   if(i==n-1)printf("\n");
   if(C1[i]!=C2[i]){
     k=1;
   }
 }

 if(k==1)printf("Not stable\n");
 else printf("Stable\n");
 return 0;
}/*main*/

Measured memory_bytes: 612
n = int(input())
cand = []
output = []
for i in range(1, n + 1):
    cand.append(i)
for i in range(len(cand)):
    for j in range(len(cand)):
        if cand[i] % 2 == 0 and cand[j] % 2 == 1:
            output.append((cand[i], cand[j]))
        elif cand[i] % 2 == 1 and cand[j] % 2 == 0:
            output.append((cand[i], cand[j]))
print(int(len(output) / 2))

Measured memory_bytes: 3316
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string o, e;
    cin >> o >> e;
    string ans;
    REP(i, min(o.size(), e.size())){
        ans += o[i];
        ans += e[i];
    }
    if(e.size() < o.size()){
        ans += o.back();
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
int main(void){
 
    char x[1001];
    int sum;
    int i;
 
    while(scanf("%s",x)!=EOF){
 
        if(x[0] == '0' && x[1] == '\0')
            break;
 
        sum = 0;
 
        for(i=0;i<strlen(x);i++){
            sum += x[i]%'0';
        }
 
        printf("%d\n",sum);
 
    }
 
    return 0;
 
}


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

int main () {
    int K,S;
    scanf("%d %d", &K, &S);

    int res = 0;
    for(int i = 0; i<=K; i++) {
       for(int j = 0; j<=K; j++) {
           int c = S - (i + j);
           if(i + j + c == S && c >= 0 && c <= K) res++;
       }
    }
    printf("%d", res);
}

Measured memory_bytes: 256
s = gets
flg = 1
cnt = 0
if(s[0] != "A")then
	s[0] = s[0].downcase
	flg = 0
end
s[0] = s[0].downcase
for i in 2..s.length-3
	if(s[i] == "C")then
		if(cnt == 0)then
			s[i] = s[i].downcase
		end
		cnt += 1
	end
end
if(cnt != 1)then
	flg = 0
end
if(s.downcase! != nil)then
	flg = 0
end
if(flg == 1)then
	puts "AC"
else
	puts "WA"
end


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

using namespace std;

typedef long long lint;
const lint N = 1e5+100;
lint n, h[N], cost[N];

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	scanf("%lld", &n);

	for (int i = 1; i <= n; i++)
		scanf("%lld", &h[i]);

	h[0] = h[1];
	cost[1] = 0;

	for (int i = 2; i <= n; i++){
		cost[i] = min(cost[i-1] + abs(h[i] - h[i-1]), cost[i-2] + abs(h[i] - h[i-2]));
	}

	printf("%lld\n", cost[n]);

	return 0; 
}

Measured memory_bytes: 5320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, j, n) for (int i = j; i < (int)(n); i++)
#define brep(i, n) for (int i = n; i > 0; i--)
#define BREP(i, j, n) for(int i = n; i > j; i--)
#define TEST cout << "PASS" << endl
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 1e6 + 1e3 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
    int d, g;
    cin >> d >> g;
    g /= 100;
    int p[10], c[10];
    rep(i, d) cin >> p[i] >> c[i];
    rep(i, d) c[i] /= 100;
    int ans = INF;
    for(int i = 0; i < (1 << d); i++){
        bitset<10> s(i);
        int cnt = 0;
        int point = 0;
        int m0 = 0;
        rep(j, d){
            if(s.test(j)){
                cnt += p[j];
                point += (j+1) * p[j] + c[j];
            }else{
                m0 = j+1;
            }
        }
        if(point < g){
            if(m0 == 0 || (g - point + m0 - 1)/m0 > p[m0-1]) continue;
            cnt += (g - point + m0 - 1)/m0;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program{
	const int mod=1000000007;
	const long o=1;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I,i=2,m=30000;
		int[] ans=new int[n];
		for(;i<m/2&&i<=((n-2)&-2);i+=2) {
			ans[i-2]=i;
			ans[i-1]=m-i;
		}
		i-=2;
		if(n%2==1){ans[i]=m;i++;}
		for(int j=3;j<m&&i<n;j+=3){
			if(j%2==1){ans[i]=j;i++;}
		}
		if(n==20000){
			ans[i]=m;
			ans[i+1]=(m/2);
		}
		else if(n==3){
			ans[0]=2;ans[1]=5;ans[2]=63;
		}
		Console.WriteLine(String.Join("\n",ans));
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 13268
#B問題
n=int(input())

oto_list=[input().split() for i in range(n)]
cnt = 0

for j in range(n):
    if oto_list[j][1]=="JPY":
        cnt+=float(oto_list[j][0])
    else:
        cnt+=380000.0 * float(oto_list[j][0])
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
typedef long long Int;
 
int main(){
Int n;
        cin >> n;
  vector<Int> a(3*n);    
  for(Int i = 0; i < 3*n; i++) {cin >> a[i];}
        sort(a.begin(),a.end());
 
        Int ans = 0;
        int cnt = 0;
        for(Int i = 3*n-2; i >= 0; i -= 2){
                if(cnt == n) break;
                ans += a[i];
                cnt++;
        }
 
        cout << ans << endl;
        return 0;
}

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

using namespace std;

int main() {
    

    
    long long n;
    cin >> n;
    
    long long ret = 0;
    
    for (long long i = 1; i <= sqrt(n); ++i)
    {
        if (n % i == 0)
        {
            long long add = (n / i) - 1;
            if (add >= sqrt(n))
            {
                ret += add;
            }
        }
    }
    
    cout << ret << endl;
    
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<endl;

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    while(cin >> n,n){
        string s[1100];
        rep(i,n) cin >> s[i];
        int a[1100] = {};
        rep(i,n){
            rep(j,s[i].size()){
                if(s[i][j]=='.') a[i]++;
                else break;
            }
        }
        bool b[1100] = {};
        rrep(i,n){
            rep(j,a[i]-1){
                if(b[j]) s[i][j] = '|';
            }
            REP(j,a[i],1000) b[j] = false;
            if(a[i] > 0) {
                s[i][a[i]-1] = '+';
                if(!b[a[i]-1]) b[a[i]-1] = true;
            }
        }
        rep(i,n)rep(j,s[i].size()) if(s[i][j]=='.') s[i][j]=' ';
        rep(i,n) cout << s[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3616