akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

typedef long long LL;
typedef vector<LL> VL;
#define REPD(i,a,b) for (LL i=(a);i<(b);i++)
#define REP(i,n) REPD(i,0,n)

LL inputValue(){
  LL a;
  cin >> a;
  return a;
};

string inputString(){
  string a;
  cin >> a;
  return a;
};

vector<LL> inputVector(LL a){
  vector<LL> rv;
  REP(i, a){
    LL input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}

vector<string> inputVectorString(LL a){
  vector<string> rv;
  REP(i, a){
    string input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}
vector<vector<LL>> inputVector2D(LL a, LL b){
  vector<vector<LL>> rv;
  REP(i, a){
    rv.push_back(vector<LL>());
    REP(j, b) {
      LL input;
      cin >> input;
      rv.at(i).push_back(input);
    }
  }
  return rv;
}

#if 1
#define debug(d) debug1(__LINE__,#d, d)
void debug1(LL line, const char* name, vector<LL>& v) {
  cout << line << ":" << name << ":vector<LL>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, LL i) {
  cout << line << ":" << name << ":LL " << i << endl;;
}
void debug1(LL line, const char* name, vector<string>& v) {
  cout << line << ":" << name << ":vector<string>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, vector<vector<LL>>& v) {
  cout << line << ":" << name << ":vector<vector<LL>>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    REP(j, (LL)v.at(i).size()) {
      cout << v.at(i).at(j) << " ";
    }
    cout << ", ";
  }
  cout << endl;
}
#else
#define debug(n)
#endif

int main(int argc, const char * argv[]) {
	cout.precision(16);
  // source code
  auto s = inputString();
  auto t = inputString();
  LL i=0;
  REP(x,3) {
    if (s.at(x) == t.at(x)) i++;
  }
  cout << i << endl;



  return 0;
}


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

int main() {
	int sum=0;
	string s;
	cin>>s;
	for(int i=0;i<4;i++){
		if(s.at(i)=='+'){
			sum++;
		}
		else{
			sum--;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(), a.end());

    int ans = INF;
    for (int i = 0; i + K - 1 < N; i++) {
        ans = min(ans, a[i + K - 1] - a[i]);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 640
a=-1,A=65,d;
char
*N="GKSOCNWLDFVTBRXHAJUPEMQI",
*E="PHLTIDOXQAGWECSUMBKVJFNR",
s[9];
main(c)
{
for(;c-48&&scanf("%s",s);a+=d/4+1)
(c=*s)<A?~a&&printf("%d\n",a),a=d=0:0,
d=(c==78?d=N[d]:
c==69?d=E[d]:
c==83?d=N[N[N[d]-A]-A]:
c==87?d=E[E[E[d]-A]-A]:d+A)-A,
d=c==82|c==76?d&28|d%4+3-c/80*2&3:d;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    cout<<3.1415*2*n<<endl;
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << (c >= a && c <= b?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
import sys
def f(h,i,j,k):
 z=(j-h)*(y-k)-(k-i)*(x-j);return([-1,1][z>0],0)[z==0]
for e in sys.stdin:
 p,q,r,s,t,u,x,y=map(float,e.split())
 g=[p,q,r,s,t,u]
 print(['NO','YES'][f(*g[:4])==f(*g[2:6])==f(*g[4:],*g[:2])])


Measured memory_bytes: 5588
#include <cstdio>

using namespace std;

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if (a==b && b==c) {
        printf("1\n");
    } else if (a!=b && b!=c && c!=a) {
        printf("3\n");
    } else {
        printf("2\n");
    }
    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
n, k = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(n)]
X, Y = zip(*XY)
def compress(arr):
    *XS, = set(arr)
    XS.sort()
    return {e: i+1 for i, e in enumerate(XS)}
Xlabel = compress(X)
Ylabel = compress(Y)
rX = {j:i for i,j in Xlabel.items()}
rY = {j:i for i,j in Ylabel.items()}
lX = len(Xlabel)
lY = len(Ylabel)
F = [[0]*(lX+1) for _ in range(lY+1)]
for x, y in XY:
  F[Ylabel[y]][Xlabel[x]] = 1
for i in range(lY):
  F[i+1] = list(accumulate(F[i+1]))
F = list(zip(*F))
for j in range(lY):
  F[j+1] = list(accumulate(F[j+1]))
F = list(zip(*F))
ans = float("inf")
for y1 in range(lY):
  for y2 in range(y1+1, lY+1):
    for x1 in range(lX):
      for x2 in range(x1+1, lX+1):
        count = F[y2][x2] - F[y1][x2] - F[y2][x1] + F[y1][x1]
        if count >= k:
          temp = (rX[x2]-rX[x1+1]) * (rY[y2]-rY[y1+1])
          ans = min(ans, temp)
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define ljc 1000000007
using namespace std;
#define gc getchar
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
vector<pair<int,int> > B[201010];
vector<int> clr,e[201010];
int n,col[201010],w[201010],X,Y,cnt[201010],fac[201010],inv[201010],_inv[201010];
bool vis[201010];
void dfs(int u){
	vis[u]=1;cnt[col[u]]++;
	clr.push_back(col[u]);
	for (auto v:e[u]){
		if (!vis[v]) dfs(v);
	}
}
signed main(){
	n=read(),X=read(),Y=read();
	fac[0]=inv[0]=inv[1]=_inv[0]=1;
	for (int i=1;i<=n;i++) fac[i]=fac[i-1]*i%ljc;
	for (int i=2;i<=n;i++) inv[i]=(ljc-(ljc/i)*inv[ljc%i]%ljc)%ljc;
	for (int i=1;i<=n;i++) _inv[i]=_inv[i-1]*inv[i]%ljc;
	for (int i=1;i<=n;i++){
		col[i]=read(),w[i]=read();
		B[col[i]].push_back(make_pair(w[i],i));
	}
	for (int i=1;i<=n;i++){
		if (B[i].size()) sort(B[i].begin(),B[i].end());
		for (int j=1;j<(int)B[i].size();j++){
			if (B[i][j].first+B[i][0].first<=X){
				e[B[i][j].second].push_back(B[i][0].second);
				e[B[i][0].second].push_back(B[i][j].second);
			}
		}
	}
	int minid=0,min2id=0;
	B[0].push_back(make_pair(1000000001,0));
	for (int i=1;i<=n;i++){
		if (B[i].size()){
			if (B[i].front().first<B[minid].front().first){
				min2id=minid,minid=i;
			}else if (B[i].front().first<B[min2id].front().first){
				min2id=i;
			}
		}
	}
	for (int i=1;i<=n;i++){
		if (i==minid){
			for (auto j:B[i]){
				if (j.first+B[min2id].front().first<=Y){
					e[j.second].push_back(B[min2id][0].second);
					e[B[min2id][0].second].push_back(j.second);
				}
			}
		}else{
			for (auto j:B[i]){
				if (j.first+B[minid].front().first<=Y){
					e[j.second].push_back(B[minid][0].second);
					e[B[minid][0].second].push_back(j.second);
				}
			}
		}
	}
	ll _=1;
	for (int i=1;i<=n;i++){
		if (!vis[i]){
			dfs(i);
			ll res=0,tmp=1;
			for (auto j:clr){
				res+=cnt[j];
				tmp=tmp*_inv[cnt[j]]%ljc;
				cnt[j]=0;
			}
			_=_*tmp%ljc*fac[res]%ljc;
			clr.clear();
		}
	}
	cout<<_;
    return 0;
}


Measured memory_bytes: 37284
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int N, Y;

    cin >> N >> Y;

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            if ((i * 10000) + (j * 5000) + ((N - i - j) * 1000) == Y) {
                if (N - i - j >= 0) {
                    cout << i << " " << j << " " << (N - i - j) << endl;
                    return 0;
                }
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int ans=0;
  int N[100]={0};
  for(int i=A;i<B;i++) N[i]++;
  for(int i=C;i<D;i++) N[i]++;
  for(int i=0;i<100;i++){
    if(N[i]==2) ans++;
  }
  cout<<ans<<endl;
}

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

using ll = long long; 

// dp[i] - no. of ways to match this subset of women
// ans - dp[1<<n-1]
int add(int a, int b) {
    const int mod = 1e9+7;
    
    return (a+b) % mod;
}

int main() {
    int n;
    
    scanf("%d", &n);
    
	vector<vector<int>> can(n, vector<int>(n));
	
	for (int i = 0; i < n; i++) {
	    for (int j = 0; j < n; j++) {
	        scanf("%d", &can[i][j]);
	    }
	}
	
	vector<int> dp(1<<n);
	
	dp[0] = 1;
	
	for (int mask = 0; mask < (1<<n)-1; mask++) {
	    int men = __builtin_popcount(mask);
	    for (int women = 0; women < n; women++) {
	        if (can[men][women] && !((1<<women)&mask)) {
	            int m2 = mask ^ (1<<women);
	            dp[m2] = add(dp[m2], dp[mask]);
	        }    
	    }
	}
	
	printf("%d\n", dp[(1<<n)-1]);
	
	return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int LMS(int n, int k) 
{ 
if (n == 1) 
	return 1; 
else
	/* The position returned by josephus(n - 1, k) is adjusted because the 
	recursive call josephus(n - 1, k) considers the original position 
	k%n + 1 as position 1 */
	return (LMS(n - 1, k) + k-1) % n + 1; 
} 
int main(){
	

	int t = 1;
	//cin >> t;
	while(t--){
		string s;
		cin >> s;
		int l = s.length();
		for(int i = 0; i < l; ++i){
			cout << 'x';
		}
	}
	return 0;
}

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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;



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

  ll a, b, n;
  cin >> a >> b >> n;
  if (n > b - 1) {
    n = b - 1;
  }
  a *= n;
  a /= b;
  cout << a << "\n";

  return 0;
}


Measured memory_bytes: 3652
import Data.List

main :: IO ()
main = do
    _ <- getLine :: IO String
    as <- map read . words <$> getLine :: IO [Int]
    print . (\(a,b) -> a-b) $ sim (reverse . sort $ as) 0 0

sim :: [Int] -> Int -> Int -> (Int, Int)
sim [] a b = (a, b)
sim (x:xs) a b = sim' xs (a+x) b

sim' :: [Int] -> Int -> Int -> (Int, Int)
sim' [] a b = (a, b)
sim' (x:xs) a b = sim xs a (b+x)

Measured memory_bytes: 1020
import java.util.*


fun main(args: Array<String>) {
    val (h, w) = readIntList()
    val s = (1..h).map { readLine()!! }
    val map = (1..w).mapIndexed { index, i -> s.map { it[index] }.joinToString("").map { it == '.' } }
    val dist = (1..w).map { (1..h).map { -1 }.toMutableList() }
    val queue = LinkedList<Pair<Int, Int>>()
    queue.offer(0 to 0)
    val end = Pair(h, w)
    val moveX = listOf(0, 0, 1, -1)
    val moveY = listOf(1, -1, 0, 0)
    while (queue.size > 0) {
        val point = queue.poll()
        if (point == end) {
            break
        }
        for (i in 0..3) {
            val tempX = point.first + moveX[i]
            val tempY = point.second + moveY[i]
            if (tempX >= 0 && tempY >= 0 && tempX < w && tempY < h && map[tempX][tempY] && dist[tempX][tempY] == -1) {
                queue.offer(tempX to tempY)
                dist[tempX][tempY] = dist[point.first][point.second] + 1
            }
        }
    }
    val out = dist[w - 1][h - 1] + 2
    if (dist[w - 1][h - 1] == -1) {
        println(-1)
    } else {
        println(s.sumBy { it.count { it == '.' } } - out)
    }
}

fun printYesOrNo(flag: Boolean) {
    println(if (flag) "Yes" else "No")
}

fun readIntList(): List<Int> = readLine()!!.split(' ').map { it.toInt() }

fun readInt(): Int = readLine()!!.toInt()

fun err(print: Any) {
    System.err.println(print)
}

Measured memory_bytes: 38076
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e6+3)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
	owo
	ll n,w;
	cin>>n>>w;
	vector<ll>dp(100005,INF);
	vector<ll>v(n),wi(n);
	vector<PII>knap(n);
	for(auto &x:knap)cin>>x.fi>>x.se;
	for(int i=0;i<n;i++)wi[i] = knap[i].fi;
	for(int i=0;i<n;i++)v[i] = knap[i].se;
	dp[0] = 0;
	ll ans = 0;
	for(int i=0;i<n;i++){
		for(int j=100005;j>0;j--)
			if(j-v[i] >= 0 && dp[j-v[i]] != INF)dp[j] = min(dp[j],dp[j-v[i]]+wi[i]);
			else if(j-v[i] < 0)break;
	}
	for(ll i=0;i<=100001;i++)if(dp[i] <= w && dp[i] != INF)ans = max(i,ans);
	cout<<ans;
}

Measured memory_bytes: 3996
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double t = sc.nextDouble();
        double a = sc.nextDouble();
        double min = Double.MAX_VALUE;
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            double h = sc.nextDouble();
            double tmp = t - h * 0.006;
            tmp = Math.abs(tmp - a);
            if(min > tmp) {
                min = tmp;
                ans = i + 1;
            }
        }
        System.out.println(ans);
    }
}

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

int main(){
	int n; cin >> n;
	set<int> s;
	for(int i = 0; i < n; ++i){
		int a; cin >> a;
		s.insert(a);
	}
	cout << s.size() - !(s.size() & 1) << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e5) + 7;
const int maxm = 300;

char s[maxn], t[maxn];

int main() {

	scanf("%s%s", s + 1, t + 1);
	int len = strlen(s + 1), res = 0;
	for (int i = 1; i <= len; i++) if (s[i] != t[i]) res++;
	printf("%d\n", res);

	return 0;
}

Measured memory_bytes: 4208
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var a = Console.ReadLine().ToCharArray().Select(x => int.Parse(x.ToString())).ToArray();
        var b = Console.ReadLine().ToCharArray().Select(x => int.Parse(x.ToString())).ToArray();
        if (a.Length > b.Length)
        {
            Console.WriteLine("GREATER");
            return;
        }
        if (b.Length > a.Length)
        {
            Console.WriteLine("LESS");
            return;
        }
        for (var i = 0; a.Length > i; i++)
        {
            if (a[i] > b[i])
            {
                Console.WriteLine("GREATER");
                return;
            }
            if (b[i] > a[i])
            {
                Console.WriteLine("LESS");
                return;
            }
        }
        Console.WriteLine("EQUAL");
    }
}

Measured memory_bytes: 13396
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,a,b;

int32_t main(){_
    //freopen("input","r",stdin);
    cin >> n >> a >> b;
    if((a - b) & 1) rc("Borys");
    rc("Alice");    
}

Measured memory_bytes: 256
ns=list(map(str,input().split()))
mp={}
for n in ns:
    if n in mp:
        mp[n] +=1
    else:
        mp[n]=1
long_word=""
freq_word=""
max_len=0
max_fre=0
for k,v in mp.items():
    if max_len<len(k):
        max_len=len(k)
        long_word=k
    if max_fre<v:
        max_fre=v
        fre_word=k
print(fre_word, long_word)



Measured memory_bytes: 5556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

string S;

int main(void){
	
	cin >> S;
	
	while(S.size()){
	    S.pop_back();
	    if(S.size() % 2 == 1) continue;
	    string a, b;
	    for(int i = 0; i < S.size() / 2; ++i) a.push_back(S[i]);
	    for(int i = S.size() / 2; i < S.size(); ++i) b.push_back(S[i]);
	    if(a == b){
	        printf("%d\n", (int)S.size());
	        return 0;
	    }
	}
	
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int N;cin>>N;
int V[50],C[50];
for (int i = 0; i <N; i++)
{
    /* code */
    cin>>V[i];
}
for (int i = 0; i <N; i++)
{
    /* code */
    cin>>C[i];
}
int ans=0;

for (int i = 0; i < N; i++)
{
    /* code */
    if (V[i]>C[i])
    {
        /* code */
        ans+=V[i]-C[i];
    }
    
}
cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int S;
	cin >> S;
	int h = S / 3600;
	int m = (S % 3600) / 60;
	int s = (S % 3600) % 60;
	cout << h << ":" << m << ":" << s << endl;

	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char a, b;  cin >> a >> b;
    if (a == 'H') {
      cout << b << '\n';
    } else {
      if (b == 'H') {
        cout << "D" << '\n';
      } else {
        cout << "H" << '\n';
      }
    }

    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve(current: usize, n: usize) -> bool {
    if current == n {
        return true
    } else if current > n {
        return false
    } else {
        solve(current+4, n) || solve(current+7, n)
    }
}

fn main() {
    input! {
        n: usize
    }
    println!("{}", if solve(0, n) { "Yes" } else { "No" })
}


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

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

  const int NMMAX = 100000;
  int a[NMMAX],r[NMMAX];

  for (int i=0; i < N; i++)  r[i] = 0;
  for (int i=0; i < N; ++i) cin >> a[i];

  int cnt =1;
  int s = a[0];
  
  while (s != 2) {
    s = a[s-1];
    cnt++;
    if (cnt > N) {cnt=-1;break;}
  }
    
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 640
#include <cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[100005];
int main() {
	int n;
	cin >> n;
	ll ans = 1;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << "0" << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		if (ans <= 1000000000000000000 / a[i]) {
			ans *= a[i];
		}
		
		else {
			cout << "-1" << endl;
			return 0;
		}
	}
	cout << ans << endl;

	return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    string t;
    cin>>t;
    string tt=t;
    string ttt=t;
    int ans=0;
    rep(i,0,t.size()){
        if(tt.at(i)!='P' and tt.at(i)!='D')tt.at(i)='D';
    }
    if(tt.at(0)=='D')ans++;
    rep(i,0,t.size()-1){
        if(tt.at(i+1)=='D')ans++;
        if(tt.at(i)=='P' and tt.at(i+1)=='D')ans++;
    }
    /*int ans2=0;
    rep(i,0,t.size()){
        if(ttt.at(i)!='P' and ttt.at(i)!='D')ttt.at(i)='D';
    }
    if(ttt.at(0)=='D')ans2++;
    rep(i,0,t.size()-1){
        if(ttt.at(i+1)=='D')ans++;
        if(ttt.at(i)=='P' and ttt.at(i+1)=='D')ans2++;
    }*/
        cout<<tt<<endl;

return 0;
}

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

int main(){
    int n;
    cin>>n;
    int a[100]={};
    for(int i=2;i<=n;i++){
        int t=i;
        for(int j=2;j<=t;j++){
            while(t%j==0){
                a[j]++;
                t/=j;
            }
        }
    }
    int ans=0;
    int x=0,y=0,z=0,k=0,h=0;
    for(int i=0;i<100;i++){
        if(a[i]>=2) k++;
        if(a[i]>=4) x++;
        if(a[i]>=14) h++;
        if(a[i]>=24) y++;
        if(a[i]>=74) z++;
    }
    cerr<<k<<" "<<x<<" "<<y<<" "<<z<<endl;

    ans+=z+y*(k-1)+x*(x-1)*(k-2)/2+h*(x-1);
    cout<<ans<<endl;


}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=12e4;

int a[N];
int p[N];
int n;

int main()
{
	scanf("%d",&n);
	fo(i,1,n)scanf("%d",&a[i]);
	int ok=1;
	fd(i,n,1){
		int po=0;
		fd(l,i,1)if(a[l]==l){
			po=l;
			break;
		}
		fo(l,po,i-1)a[l]=a[l+1];
		if(!po){
			ok=0; break;
		}
		p[i]=po;
	}
	if(!ok)puts("-1");
	else
	fo(i,1,n)printf("%d\n",p[i]);
}

Measured memory_bytes: 256
N=int(input())

coin=[1]

for _ in [6,9]:
    __=_
    while __ <= N:
        coin.append(__)
        __=__*_
coin.sort()

dp=[[0]*(N+1) for c in coin]

for n in range(N):
    n += 1
    for c_idx,c in enumerate(coin):
        
        if c_idx==0:#c=1のとき
            dp[c_idx][n] = dp[c_idx][n-c]+1
            
        elif n-c >= 0:
            dp[c_idx][n] = min(dp[c_idx-1][n],dp[c_idx][n-c]+1)
            
        else:
            dp[c_idx][n] = dp[c_idx-1][n]

ans=10**10
for c in range(len(coin)):
    if ans > dp[c][-1]:
        ans=dp[c][-1]
print(ans)

Measured memory_bytes: 82856
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int win = sc.nextInt();
    int cur = sc.nextInt();
    
    if (win < cur*2) {
      System.out.println(0);
    }else{
      System.out.println(win-cur*2);
    }
  }
}
      

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

int main(int, char**) {
        char c;
        std::cin >> c;
        if (c=='a' || c=='i' || c=='u'||c=='e'||c=='o') {
                std::cout << "vowel" << std::endl;
        } else {
                std::cout << "consonant" << std::endl;
        }
        return 0;
}


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

int main()
{
int N,k,ans=0;scanf("%d",&N);float num=0;
vector<int> X(N);for(int i=0;i<N;i++){scanf("%d",&X[i]);num+=X[i];}
num/=N;k=num;if(num-k>0.5)k++;
for(int i=0;i<N;i++)
{
  ans+=(X[i]-k)*(X[i]-k);
}
printf("%d\n",ans);
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
int h, w, c;
bool inrange(int i, int j) {
	return i >= 0 && i < h&&j >= 0 && j < w;
}
int count(const vvi &v) {
	vvi b(h, vi(w, 0));
	int ret = 1;

	if (v[0][0] == c) {
		queue<pii> q;
		q.push({ 0,0 });
		b[0][0] = 1;
		while (!q.empty()) {
			pii p = q.front(); q.pop();
			REP(k, 4) {
				int nx = p.first + dx[k * 2], ny = p.second + dy[k * 2];
				if (inrange(nx, ny) && b[nx][ny] == 0 && v[nx][ny] == c) {
					q.push({ nx,ny });
					b[nx][ny] = 1;
					ret++;
				}
			}
		}
		return ret;
	}
	return 0;
}

int dfs(vvi v, int cnt) {
	if (cnt == 5) {
		return count(v);
	}
	vvi b(h, vi(w, 0));
	queue<pii> q;
	q.push({ 0,0 });
	b[0][0] = 1;
	while (!q.empty()) {
		pii p = q.front(); q.pop();
		REP(k, 4) {
			int nx = p.first + dx[k * 2], ny = p.second + dy[k * 2];
			if (inrange(nx, ny) && b[nx][ny] == 0 && v[nx][ny] == v[0][0]) {
				q.push({ nx,ny });
				b[nx][ny] = 1;
			}
		}
	}
	int ret = 0;
	REP(k, 6) {
		vvi tmp = v;
		REP(i, h) {
			REP(j, w) {
				if (b[i][j]) {
					tmp[i][j] = k + 1;
				}
			}
		}
		ret = max(ret, dfs(tmp, cnt + 1));
	}
	return ret;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (cin >> h >> w >> c) {
		if (h == 0 && w == 0 && c == 0)break;
		vvi v(h, vi(w));
		REP(i, h)REP(j, w)cin >> v[i][j];
		cout << dfs(v, 0) << endl;
	}
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_K=1e5,INF=1e8;
int K;
struct edge{
	int to,cost;
	edge(int t=-1,int c=0):to(t),cost(c){}
};
vector<edge> G[MAX_K];
int dis[MAX_K];
bool used[MAX_K];
int main(){
	cin>>K;
	REP(k,K){
		G[k].push_back(edge((k+1)%K,1));
		G[k].push_back(edge((k*10)%K,0));
	}
	deque<int> deq;
	fill(dis,dis+K,INF);
	dis[1]=0;
	deq.push_back(1);
	while(!deq.empty()){
		int v=deq.front();
		deq.pop_front();
		if (used[v]) continue;
		used[v]=true;
		for(auto e:G[v]){
			if (dis[e.to]>dis[v]+e.cost){
				dis[e.to]=dis[v]+e.cost;
				if (e.cost==0){
					deq.push_front(e.to);
				}else{
					deq.push_back(e.to);
				}
			}
		}
	}
	cout<<dis[0]+1<<endl;
	return 0;
}

Measured memory_bytes: 6400
#include <stdio.h>

int main(){
    
    int x, y;

    while(1){
        scanf("%d %d", &x, &y);
        if((x==0) && (y==0)){
            break;
        }
        else{
            if(x<y){
                printf("%d %d\n", x, y);
            }
            else{
                printf("%d %d\n", y, x);
                
            }
        }
    }

   
    

    return 0;
}


Measured memory_bytes: 2040
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] t = new int[n];
		for(int i=0;i<n;i++) {
			t[i]=scan.nextInt();
		}
		int m = scan.nextInt();
		int[] p = new int[m];
		int[] x = new int[m];
		for(int i=0;i<m;i++) {
			p[i]=scan.nextInt();
			x[i]=scan.nextInt();
		}
		int zanteiSum = 0;
		for(int i : t) {
		zanteiSum = zanteiSum + i;
		}
		//System.out.println(zanteiSum);

		int[] byosu=new int[m];

		for(int i=0; i<m;i++) {
			for(int z=0;z<n;z++) {
				if(z==p[i]-1) {
					byosu[i]=byosu[i]+x[i];
				}else {
					byosu[i]=byosu[i]+t[z];
				}

			}
			System.out.println(byosu[i]);


		}
	}
}



Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    int n;
    cin>>n;
    vector<pair<string,pair<int,int>>>v(n);
    for(int i=0;i<n;i++)
    {cin>>v[i].first>>v[i].second.first;v[i].second.second=i+1;}
    sort(v.begin(),v.end(),compa);
    for(auto x:v)cout<<x.second.second<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3608
package main

import (
  "fmt"
)

func absInt(x int) int {if x >= 0 {return x}; return -x}

func main() {
  var x, a, b int
  fmt.Scan(&x, &a, &b)
  ans := "A"
  if absInt(a - x) > absInt(b - x) {ans = "B"}
  fmt.Println(ans)
  
}

Measured memory_bytes: 512
n = int(input())
for i in range(1, 1000):
    if i*(i+1)//2>n:
        print('No')
        exit(0)
    if i*(i+1)//2==n:
        break
q = list(range(n, 0, -1))
ans = []
for j in range(i+1):
    tmp = []
    for k in ans:
        tmp.append(k[j-1])
    for _ in range(i-j):
        tmp.append(q.pop())
    ans.append(tmp)
print('Yes')
print(i+1)
for j in ans:
    tmp = [i]+j
    print(*tmp)

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

vector<int> div(int x){
  vector<int> res;
  for(int i=1;i*i<=x;i++){
    if(!(x%i)){
      res.push_back(i);
      if(i!=x/i)res.push_back(x/i);
    }
  }
  return res;
}

int main(){
  int p,q,a,ans=1;
  vector<int> prime;
  set<int> s;
  cin>>p>>q;
  q/=__gcd(p,q);
  
  int Q=q;
  for(int i=2;i*i<=q;i++){
    while(Q%i==0){
      Q/=i;
      prime.push_back(i);
    }
  }
  if(Q>1)prime.push_back(Q);
  for(int i=0;i<prime.size();i++)
    s.insert(prime[i]);
  set<int>::iterator ite;
  for(ite=s.begin();ite!=s.end();ite++)
    ans*=(*ite);
  cout<<ans<<endl;
  return 0;
}

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

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;

    int cnt1 = 0;
    int cnt2 = 0;

    // 0101..., 1010...との距離を比較
    for (int i = 0; i < s.length(); i++)
    {
        if (i % 2 == 0)
        {
            if (s[i] == '0')
            {
                cnt1++;
            }
            else if (s[i] == '1')
            {
                cnt2++;
            }
        }
        else
        {
            if (s[i] == '0')
            {
                cnt2++;
            }
            else if (s[i] == '1')
            {
                cnt1++;
            }
        }
    }

    if (cnt2 < cnt1)
    {
        cnt1 = cnt2;
    }

    cout << cnt1 << '\n';

    return 0;
}


Measured memory_bytes: 512
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Ciniii(A, B, T);
    int ans = 0;
    int t = A;
    while (t <= T) {
        ans += B;
        t += A;
    }
    cout << ans << nn;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,a[100015],w[105],v[105];
int main(){
	memset(a,0x7f,sizeof(a));
	a[0]=0;
	cin>>n>>m;
	for(long long i=0;i<n;i++) cin>>w[i]>>v[i];
	for(long long i=0;i<n;i++){
		for(long long j=100010;j>=v[i];j--){
			a[j]=min(a[j],a[j-v[i]]+w[i]);
		}
	}
	long long ans=0;
	for(long long i=1;i<=100010;i++){
		if(a[i]<=m) ans=i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
s = input()

# 3桁の番号を作るにあたり、文字列から抽出して作るのではなく、000〜999までの組み合わせが存在するかを確認する。
ans = 0
for i in range(10):
  a = s.find(str(i))
  for j in range(10):
    b = s.find(str(j), a+1) # aの取得位置の次から検索を行う
    for k in range(10):
      c = s.find(str(k), b+1) # bの取得位置の次から検索を行う
      if a == -1 or b == -1 or c == -1: continue
      else: ans += 1
print(ans)

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

int main(){
  long n,x,kekka = 0;
  cin >> n >> x;
  long d = x;
  for(long i = 0;i < n+1;i++){
    long c = 1;
    for(long j = 0;j < n - i;j++){
      c *= 2;
    }
    long centr = 2*c - 1;
    if(centr == d){
      kekka += c;
      //cout << 1 << endl;
      break;
    }
    else if(centr > d){
      d -= 1;
      //cout << 2 << endl;
    }
    else if(centr < d){
      kekka += c;
      //cout << 3 << endl;
      d -= 2*c - 1;
    }
  }
  cout << kekka << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> P(N), Q(N);
  for (int i = 0; i < N; ++i) cin >> P[i];
  for (int i = 0; i < N; ++i) cin >> Q[i];
  
  int a, b;
  vector<int> S;
  for (int i = 1; i < N + 1; ++i) S.push_back(i);
  int cnt = 0;
  do {
    ++cnt;
    if (S == P) a = cnt;
    if (S == Q) b = cnt;
  } while (next_permutation(S.begin(), S.end()));
  
  cout << abs(a - b) << endl;
  return 0;
}

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

const int mxn = 1e6;
int spf[mxn+1];
void sieve() {
  spf[1] = 1;
  for(int i = 1;i <= mxn;i++) {
    if(i&1) {
      spf[i] = i;
    } else {
      spf[i] = 2;
    }
  }
  for(int i = 3;i*i <= mxn;i++) {
    if(spf[i] == i) {
      for(int j = i*i;j <= mxn;j+=i) {
        if(spf[j] == j) {
          spf[j] = i;
        }
      }
    }
  }
}

ull getFactorization(int n) {
  unordered_map<int,int> mp;
  while(n != 1) {
    mp[spf[n]]++;
    n /= spf[n];
  }
  ull ans = 1;
  for(auto& it : mp) {
    ans = ans*(it.second+1);
  }
  return ans;
}

int main() {
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  sieve();
  int n, ans = 0;
  cin>>n;
  for(int c = 1;c < n;c++) {
    ans += getFactorization(n-c);
  }
  cout<<ans<<"\n";
  return 0;
}

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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int counter = 0;
    for(int i = 0; i < n; i++) {
        if(a[i] < 0) {
            counter++;
        }
    }
    for(int i = 0; i < n; i++) {
        a[i] = abs(a[i]);
    }
    long long ans = 0;
    for(int i = 0; i < n; i++) {
        ans += a[i];
    }
    if(counter % 2 != 0) {
        ans -= 2 * *min_element(a.begin(), a.end());
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4036
#include <cstdio>

int n;
int A[21];

constexpr int mod = 1000000007;

int dp[1<<21];

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      int x;
      scanf("%d", &x);
      if(x) A[i] |= 1 << j;
    }
  }

  dp[0] = 1;
  for(int x = 1; x < (1<<n); x++){
    int i = __builtin_popcount(x);
    long long int r = 0;
    for(int y = x & A[i-1]; y; y &= y-1){
      int j = y & -y;
      r += dp[x & ~j];
    }
    dp[x] = r % mod;
  }
  printf("%d\n", dp[(1<<n)-1]);
  return 0;
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
// DP Solution
int frogDP(vector<int> &arr, int N)
{
    vector<int> dp(N+1);
    //dp[i] represents minimum cost to reach ith step
    dp[1] = 0;
    dp[2] = abs(arr[0] - arr[1]);
    for(int i=3; i<=N ;i++)
    {
        dp[i] = min(dp[i-1]+abs(arr[i-2]-arr[i-1]), dp[i-2]+abs(arr[i-3]-arr[i-1]));
    }
    return dp[N];
}

int main()
{
    int n;
    vector<int> arr;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int temp;
        cin>>temp;
        arr.push_back(temp);
    }
    
    cout<<frogDP(arr,n);
    return 0;
}

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

int main(){
  int n,m;cin >>n >>m;
  vector<vector<int>>a(n);
  int tmp1,tmp2;
  for(int i=0;i<m;i++){
    cin >>tmp1>>tmp2;
    tmp1--;tmp2--;
    a.at(tmp1).push_back(tmp2);
    a.at(tmp2).push_back(tmp1);
  }
  int v;
  queue<int>tmp;
  tmp.push(0);
  vector<int>pre(n,-1);
  pre.at(0)=0;
  while(!tmp.empty()){
    v=tmp.front();tmp.pop();
    for(auto k:a.at(v)){
      if(pre.at(k)!=-1)continue;
      pre.at(k)=v;
      tmp.push(k);
    }
  }
  cout<<"Yes"<<endl;;
  for(int i=1;i<n;i++){
    cout <<pre.at(i)+1<<endl;
  }
  cout <<endl;
}

Measured memory_bytes: 10136
#include<stdio.h>
#include<string.h>

int main()
{
    int n,k,i;
    scanf("%d %d",&n,&k);
    char str[51];
    scanf("%s",str);

    for(i=0;i<n;i++){
        if(i==(k-1)){
            printf("%c",str[i]+32);
        }
        else printf("%c",str[i]);
    }
    printf("\n");
    return 0;
}


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

int main() {
  vector<int> v(4, 0);
  rep(i, 6){
    int a;
    cin >> a;
    ++v[a-1];
  }
  int m = 0;
  rep(i, 4) m = max(m, v[i]);
  if(m < 3) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	string s;
	while(cin>>N) {
		cout<<0<<endl;
		cin>>s;
//		DD(s);
		if(s=="Vacant") break;
		string s0 = s;
		ll lo=1, hi=N-1;
		while(lo<=hi) {
//			DD(lo);DD(hi);
			ll mid = (lo+hi)/2;
//			DD(mid);
			cout<<mid<<endl;
			cin>>s;
//		DD(s);
			if(s=="Vacant") break;
			if((mid%2) ^ (s0==s)) lo=mid+1; else hi=mid-1;
		}
		break;
	}
	
	return 0;
}


Measured memory_bytes: 852
#include<iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;
typedef unsigned long long llong;
const int maxn=1*(1e5)+5;
//int arr[maxn];
int main(){
    int n;cin>>n;
    int even=0,odd=0;
    for(int i=0;i<n;++i){
        int a;scanf("%d",&a);
        if(a%2==0)even++;
        else odd++;
    }
    if(odd%2==1)printf("NO\n");
    else{
        printf("YES\n");
    }
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

inline int komi(int p, int x) {
  return p*(100+x)/100;
}

int main() {
  
  int x, y, s;
  while(cin >> x >> y >> s) {
    if(x == 0 && y == 0 && s == 0) { break; }
    int mx = 0;
    REP(i, 1, s) REP(j, 1, s) {
      if(komi(i, x)+komi(j, x) == s) {
        mx = max(mx, komi(i, y)+komi(j, y));
      }
    }
    cout << mx << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#define max_size (int)(1e5 + 1)

int main(){
	int N, i;
	char *S = (char *)malloc(sizeof(char) * max_size);
	scanf("%s", S);
	for(i = 0; S[i] != '\0'; i++){}
	N = i;
	for(i = (N + 1) / 2; i < N; i++){
		if(S[i] != S[i - 1] || S[N - 1 - i] != S[N - i]){
			printf("%d\n", i);
			return 0;
		}
	}
	printf("%d\n", N);
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define fs first 
#define sc second 
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
using namespace std;
ll n, m, k, t;

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


int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	char h;
	cin >> h;
	cout << char(h + 1);
}


Measured memory_bytes: 256
<?php
$A = $P = $L = [];
$P = array_pad(array(), 9, 0);
fscanf(STDIN, "%d %d %d", $A[], $A[], $A[]);
fscanf(STDIN, "%d %d %d", $A[], $A[], $A[]);
fscanf(STDIN, "%d %d %d", $A[], $A[], $A[]);
fscanf(STDIN, "%d", $N);
for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d", $b);
    $h = array_search($b, $A);
    if ($h !== false) {
        $P[$h] = 1;
    }
}
$L[] = $P[0] + $P[1] + $P[2];
$L[] = $P[3] + $P[4] + $P[5];
$L[] = $P[6] + $P[7] + $P[8];
$L[] = $P[0] + $P[3] + $P[6];
$L[] = $P[1] + $P[4] + $P[7];
$L[] = $P[2] + $P[5] + $P[8];
$L[] = $P[0] + $P[4] + $P[8];
$L[] = $P[2] + $P[4] + $P[6];
echo max($L) === 3 ? "Yes" : "No";


Measured memory_bytes: 4728
/*ATCoder ABC140 C:Attack Survival*/
/*Yuki Kamatani 2019/09/23*/
#include <iostream>
#include<string>

int N = 0;
int K = 0;
int Q = 0;
int ans;
int *Score;

//負けた数がK以下であれば敗退する。
//負けた数はQ-勝った数。勝数を数えれば勝ち残りが判定できる。
int main(void){
    std::cin >> N >> K >> Q;
    Score = new int[N]();

    //勝数カウント
    for (int i = 0; i < Q; i++){
        std::cin >> ans;
        Score[ans-1]++;
    }
    //敗退判定
    for (int i = 0; i < N; i++){
        if ( (Q-Score[i]) < K){
            std::cout << "Yes" << std::endl;
        } else {
            std::cout << "No" << std::endl;
        }

    }

    delete Score;
    return 0;
}

Measured memory_bytes: 1024