akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define mod 1000000007
#define N 2005
#define M 4000005
void Add(int &x,int y)
{
	x += y;
	if (x >= mod)
		x -= mod;
}
int n, k, m, f[N][N];
int fac[M], inv[M];
int C(int n, int m){return (ll)fac[n] * inv[m] % mod * inv[n - m] % mod;}
int Pow(int a, int k)
{
	int ret = 1;
	while (k)
	{
		if (k & 1)
			ret = (ll)ret * a % mod;
		a = (ll)a * a % mod;
		k >>= 1;
	}
	return ret;
}
int main()
{
	scanf("%d%d", &n, &k);
	m = n * k;
	if (k == 1)
	{
		puts("1");
		return 0;
	}
	fac[0] = 1;
	for (int i = 1; i <= m; i++)
		fac[i] = (ll)fac[i - 1] * i % mod;
	inv[m] = Pow(fac[m], mod - 2);
	for (int i = m; i >= 1; i--)
		inv[i - 1] = (ll)inv[i] * i % mod;
	f[0][0] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j <= i; j++)
		{
			Add(f[i][j], f[i - 1][j]);
			if(j)
				Add(f[i][j], (ll)f[i][j - 1] * (n - j + 1) % mod * C((n - i) + (n - j + 1) * (k - 1) - 1, k - 2) % mod);
		}
	printf("%d\n", f[n][n]);
}


Measured memory_bytes: 47104
import math
import itertools
N, D = map(int, input().split())
 
count = 0
all_list = []
for _ in range(N):
    p_list = list(map(int, input().split()))
    all_list.append(p_list)

comb_list = list(itertools.combinations(all_list, 2))
for f_list, l_list in comb_list:
    diff_list = [(i-j)**2 for i, j in zip(f_list, l_list)]
    dist = math.sqrt(sum(diff_list))
    if dist == int(dist):
        count += 1

print(count)

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

int main(){
	int num;
 	int counter[26] = {0};
	char ch, ch2, ch3; 
	
	
	while ( cin >> ch ){
		ch2 = tolower(ch);
		num = ch2 - 'a';
		
		counter[num]++;
	}
    
	for(int i=0; i<26; i++){
		ch3 = 'a' + i;
		cout << ch3 <<" : " << counter[i] << endl;
	}
	return 0;	
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()
    

    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin>>s;

    int l=s.size();
    string rev=s;
    reverse(INS(rev));

    if (rev!=s) {cout<<"No\n"; return 0;}

    string sub=s.substr(0,(l-1)/2);
    string sub2=rev.substr(0,(l-1)/2);
    
    string sub3=sub;
    string sub4=sub2;

    reverse(INS(sub3));
    reverse(INS(sub4));

    if (sub==sub3&&sub2==sub4) cout<<"Yes\n";
    else cout<<"No\n";


    
    return 0;
}

Measured memory_bytes: 256
a,b,c,d,e,f = map(int, input().split())
mx=0
swmx=100*a
smx=0
 
for i in range(0,31):
    for j in range(0,31):
        for k in range(0,51):
            for l in range(0,51):
                w=0
                s=0
                w+=100*a*i+100*b*j
                s+=c*k+d*l
                if w+s<=f and s<=e*w/100 and w!=0 and mx<100*s/(w+s):
                    mx=100*s/(w+s)
                    swmx=w+s
                    smx=s
print(swmx,smx)

Measured memory_bytes: 73876
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
	int W,H,N,side=0,high=0;
	cin >> W >> H >> N;
	int x[N+10],y[N+10],a[N+10];
	for(int i=1; i<=N; i++){
		cin >> x[i] >> y[i] >> a[i];
	}
	for(int i=1; i<=N; i++){
		if(a[i]==1 && side<=x[i])
			side=x[i];
		if(a[i]==2 && W>=x[i])
			W=x[i];
		if(a[i]==3 && high<=y[i])
			high=y[i];
		if(a[i]==4 && H>=y[i])
			H=y[i];
	}
	if((W-side)>0 && (H-high) > 0)
	cout << (W-side)*(H-high) << endl;
	else
	cout << '0' << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
//TbTaYnA
int main()
{ 
int t,flag=1;scanf("%d",&t);
    char c[t];
    scanf("%s",c);if(t&1){ printf("No"); goto g;}
  //  printf("%c",c[t-1]);
    
    for(int a=0;a<t/2;a++)
    {//printf("%c %c\n",c[a],c[a+t/2]);
        if(c[a]==c[a+t/2]) continue;
        else {flag=0;break;}}
    printf((flag==1)?"Yes":"No");
    
    
    g:
    
    
return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())

xyz = [[], [], [], [], [], [], [], []]
for i in range(N):
    x, y, z = map(int, input().split())
    xyz[0].append(x+y+z)
    xyz[1].append(x+y-z)
    xyz[2].append(x-y+z)
    xyz[3].append(x-y-z)
    xyz[4].append(-x+y+z)
    xyz[5].append(-x+y-z)
    xyz[6].append(-x-y+z)
    xyz[7].append(-x-y-z)
ans = 0
for i in range(8):
    s = sum(sorted(xyz[i], reverse=True)[0:M])
    ans = max(ans, s)
print(ans)


Measured memory_bytes: 3316
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

a, b, c, d, e, f = MAP()
a *= 100
b *= 100
per = 0
ans = [str(a), '0']
for i in range(f // a + 1):
    for j in range((f - a * i) // b + 1):
        wtr = a * i + b * j
        rmn = f - wtr
        for k in range(rmn // c + 1):
            for l in range((rmn - c * k) // d + 1):
                sgr = c * k + d * l
                if wtr // 100 * e < sgr:
                    continue
                if wtr + sgr == 0:
                    continue
                tmp = 100 * sgr / (wtr + sgr)
                if wtr // 100 * e >= sgr and tmp > per:
                    per = tmp
                    ans = [str(wtr + sgr), str(sgr)]
print(' '.join(ans))

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

namespace ARounding
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var x = inputs[0];
            var a = inputs[1];

            var answer = x < a ? 0 : 10;
            
            // 解答の出力
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
using namespace std;

const int MAX = 1000000;
const int MOD = 1000000007;

const double PI = acos(-1);
const double Rad2Deg = 180.0 / PI;
const double Deg2Rad = PI / 180.0;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int N;
string S;

char ab[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};

char convert(char s) {
    for (int i = 0; i < 26; i++) {
        if (s == ab[i]) {
            return ab[(i + N) % 26];
        }
    }
}

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

    for (int i = 0; i < S.size(); i++) {
        S[i] = convert(S[i]);
    }
    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,s,t) for(int i=s;i<t;i++)
typedef pair<long long, int> pli;
typedef long long ll;
const int maxn = 2222;
const ll inf = 1e18;
struct edge {
    int v, f, c, rev;
};
int nodenum,stnode,ednode, prep[maxn + 5], pree[maxn + 5];ll dis[maxn+5],h[maxn+5];
vector<edge> e[maxn + 5];
void addedge(int from, int to, int cap, int cost) {
    e[from].push_back({to, cap, cost, (int)e[to].size()});
    e[to].push_back({from, 0, -cost, (int)e[from].size() - 1});
}

ll flow,cost;
void mincostflow() {
    fill(h, h + 1 + nodenum, 0);
    flow=cost=0;
    while (1) {
        priority_queue <pli, vector<pli>, greater<pli> > q;
        fill(dis, dis + 1 + nodenum, inf);
        dis[stnode] = 0; q.push({0,stnode});
        while (!q.empty()) {
            pli now = q.top(); q.pop();
            int v = now.se;
            if (dis[v] < now.fi)continue;
            for (int i = 0; i < e[v].size(); ++i) {
                edge& ee = e[v][i];
                if (ee.f > 0 && dis[ee.v] > dis[v] + ee.c + h[v] - h[ee.v]) {
                    dis[ee.v] = dis[v] + ee.c + h[v] - h[ee.v];
                    prep[ee.v] = v;pree[ee.v] = i;
                    q.push({dis[ee.v], ee.v});
                }
            }
        }
        if (dis[ednode] == inf)break;
        for (int i = 1; i <= nodenum; ++i)h[i] += dis[i];
        ll d = inf;
        for (int v = ednode; v != stnode; v = prep[v])
            d = min(d, (ll)e[prep[v]][pree[v]].f);
        flow += d; cost += d*h[ednode];
        for (int v = ednode; v != stnode; v = prep[v]) {
            edge& ee = e[prep[v]][pree[v]];
            ee.f -= d;
            e[v][ee.rev].f += d;
        }
    }
}
int dir[4][2]={1,1,-1,-1,1,-1,-1,1};
int main()
{
    int n,a,b,c;scanf("%d",&n);
    int tmp=n*2;
    nodenum=n*2+2+4,stnode=nodenum,ednode=nodenum-1;
    rep(i,1,n+1)
    {
        scanf("%d%d%d",&b,&c,&a),addedge(stnode,i,a,0);
        rep(j,0,4)addedge(i,tmp+j+1,a,b*dir[j][0]+c*dir[j][1]);
    }
    rep(i,1,n+1)
    {
        scanf("%d%d%d",&b,&c,&a),addedge(i+n,ednode,a,0);
        rep(j,0,4)addedge(tmp+j+1,i+n,a,-b*dir[j][0]-c*dir[j][1]);
    }
    mincostflow();
    printf("%lld\n",-cost);
}

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

class D
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var n = int.Parse(Console.ReadLine());
		var rs = new int[n - 1].Select(_ => read()).ToArray();
		var c = read(); Array.Sort(c);

		var ps = Enumerable.Range(1, n).Select(i => new { i, ps = new List<int>() }).ToArray();
		for (var i = 0; i < rs.Length; i++)
		{
			ps[rs[i][0] - 1].ps.Add(rs[i][1]);
			ps[rs[i][1] - 1].ps.Add(rs[i][0]);
		}
		var sorted_ps = ps.OrderBy(_ => _.ps.Count).ToArray();

		var M = 0L;
		var d = new int[n + 1];
		var ended = 0;
		while (ended < n - 1)
			for (var i = 0; i < n; i++)
			{
				if (sorted_ps[i].ps.Count != 1) continue;

				M += (d[sorted_ps[i].i] = c[ended++]);
				if (ended < n - 1)
				{
					ps[sorted_ps[i].ps[0] - 1].ps.Remove(sorted_ps[i].i);
					sorted_ps[i].ps.RemoveAt(0);
				}
				else
				{
					d[sorted_ps[i].ps[0]] = c[n - 1];
					break;
				}
			}
		Console.WriteLine(M);
		Console.WriteLine(string.Join(" ", d.Skip(1)));
	}
}


Measured memory_bytes: 22876
n, a, b = map(int, input().split())
s = str(input())

#cur_a = 0
cur_b = 0
cur = 0

for i in range(n):
    if s[i] == 'a':
        if cur < a+b:
            print('Yes')
        else:
            print('No')
        cur += 1
    elif s[i] == 'b':
        if cur < a+b and cur_b+1 <= b:
            print('Yes')
            cur += 1
        else:
            print('No')
        cur_b += 1
    else:
        print('No')


Measured memory_bytes: 53592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            int[] s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int A = s[0];
            int B = s[1];
            int K = s[2];

            for(int i = 1; i <= B; i++)
            {
                if(A<=i && i <= B)
                {
                    if (i - A < K || B - i< K)
                    {
                        Console.WriteLine(i);
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 13268
/*  
#include<bits/stdc++.h>
typedef unsigned long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    //freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
             ll n,ans;
           // std::vector<ll> v;
            cin>>n;n--;
            ans=n%26;
            n=n/26;
            char c='a'+ans;
            string s=c+s;
            while(n>0){
              n--;
              ans=n%26;
              n=n/26;
              c='a'+ans;
              s=c+s;     
            }
            cout<<s;
            


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}*/
#include <bits/stdc++.h>
using namespace std;

int main() {
   ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    //freopen("error.txt", "w", stderr);
    #endif
  //long long K=1000000000000001;
  long long N;
    int p;
    string s;
    char c;

  cin >> N;
  N--;
  s="";
  if (N==0){
    cout << "a" << endl;
        return 0;
    }
  p=N%26;
  N=N/26;
    c='a'+p;
  s=c+s;
  while(N>0){
        N--;
    p=N%26;
    N=N/26;
      c='a'+p;
    s=c+s;
    }
  cout << s << endl;
    return 0;
}



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

int main(){
    map<string, int>m={};
    int n;
    cin >>n;
    string s;
    rep(i, n){
        cin >>s;
        m[s] += 1;
    }
    
    cout << "AC x "<<m["AC"] <<endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define MaxN 100010
//#define MOD 998244353
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define endl '\n'
#define LL long long
#define PII pair<int,int>
#define rint register int 
#define ULL unsigned long long
const int MOD=1e9+7;
//int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
//int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
template<class T> inline void read(T& x){
    x=0;int f=0;char ch=getchar();
    while( !isdigit(ch) ) f|=( ch == '-' ) , ch=getchar();
    while( isdigit(ch) )  x = ( x<<1 ) + ( x<<3 ) + ( ch^48 ) , ch=getchar();
    x = f ? -x : x;
}
template<class T> inline void print(T x){
	if ( x < 0 ) { putchar('-'); x = -x; }
	if ( x >= 10 ) print( x / 10 );
	putchar(x % 10 + '0');
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    LL n,m;
    cin>>n>>m;
    int ans=0;
    for(int i=1; i<=n; i++){
        LL x,y;
        cin>>x>>y;
        if( x*x+y*y <= m*m ){
            ans++;  
        } 
    }
    cout<<ans;
	return 0; 
}


Measured memory_bytes: 3600
// 2014/09/08 Tazoe

#include <iostream>
using namespace std;

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

	for(int i=0; i<N; i++){
		double xa, ya, ra, xb, yb, rb;
		cin >> xa >> ya >> ra >> xb >> yb >> rb;

		double d2 = (xa-xb)*(xa-xb)+(ya-yb)*(ya-yb);
		double rp = (ra+rb)*(ra+rb);
		double rm = (ra-rb)*(ra-rb);

		if(d2<rm && ra>rb){
			cout << 2 << endl;
		}
		else if(d2<rm && ra<rb){
			cout << -2 << endl;
		}
		else if(d2<=rp){
			cout << 1 << endl;
		}
		else{
			cout << 0 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1232
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();

		int h = sc.nextInt();
		int w = sc.nextInt();

		System.out.println((H - h)*(W - w));
	}
}


Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class42
    {
        static void Main()
        {
            var nmxy = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int X = nmxy[2], Y = nmxy[3];
            var x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var y = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int xmax = Math.Max(X, x.Max());
            int ymin = Math.Min(Y, y.Min());
            Console.WriteLine(xmax < ymin ? "No War" : "War");
        }
    }
}


Measured memory_bytes: 13396
s = input()
i = len(s) - 1
res = ''
while i >= 0:
    while i >= 0 and s[i] != 'B':
        res += s[i]
        i -= 1
    cnt = 0
    while i >= 0 and s[i] == 'B':
        i -= 1
        cnt += 1
    i -= cnt
print(res[::-1])


Measured memory_bytes: 9020
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


int GCD(int a,int b){
  int r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


int LCM(int a,int b){
  int c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  int n;
  cin>>n;
  map<int,int> mp;
  rep(i,n){
    int a;
    cin>>a;
    mp[a]++;;
  }
  int ans=0;
  for(auto c:mp){
    if(c.first==c.second){
      
    }else if(c.first>c.second){
      ans+=c.second;
    }else{
      ans+=c.second-c.first;
    }
    
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 4736
#include <stdio.h>
#include <stdlib.h>

typedef struct cards_ {
   int num,to;
} cards;
/*
int compar_up(const int *val1, const int *val2) {//昇順並び替え(0,1,..)
    if ( *val1 < *val2 ) {
        return -1;
    } else if ( *val1 == * val2 ) {
        return 0;
    } else {
        return 1;
    }
}*/

int cmp_card( const void *q, const void *p ) {//降順
    return ((cards*)p)->to - ((cards*)q)->to;
}

int min(int a, int b){
  if(a > b) return b;
  else return a;
}

int main(){
  int n,m;
  scanf("%d %d\n",&n,&m);
  //int a[n];
  cards card[m+n];
  for(int i=0; i < n; ++i){
    scanf("%d",&card[i].to);
    card[i].num = 1;
  }
  for(int i=0; i < m; ++i) scanf("\n%d %d",&card[i+n].num,&card[i+n].to);
  //qsort(a, n, sizeof(int),(int (*)(const void *, const void *))compar_up);
  qsort(card, m+n, sizeof(cards), cmp_card);
  long answer = 0;
  long bin_to;
  int count = 0;
  int bin_num;
  for(int i = 0; i < n+m; ++i){
    if(count == n) break;
    bin_to = (long) card[i].to;
    bin_num = min(n - count, card[i].num);
    bin_to = bin_to * (long) bin_num;
    answer += bin_to;
    count += bin_num;
  }
  printf("%ld\n",answer);
  return 0;
}

Measured memory_bytes: 3324
/* ex 7_1
   KKOO */

#include <stdio.h>

typedef struct point{
    int x_elem;
    int y_elem;
}point;

int main(void){
    point p1, p2, p3, p4;

    scanf("%d%d%d%d", &p1.x_elem, &p1.y_elem, &p2.x_elem, &p2.y_elem);

    //p2を中心にp1を時計回りに90度回転させた点がp3
    //{(x1+y1i)-(x2+y2i)}*(-i)+(x2+y2i) = (y1-y2+x2)+(-x1+x2+y2)i
    p3.x_elem = p1.y_elem - p2.y_elem + p2.x_elem;
    p3.y_elem = -p1.x_elem + p2.x_elem + p2.y_elem;

    //p1を中心にp2を反時計回りに90度回転させた点がp4
    //{(x2+y2i)-(x1+y1i)}*i+(x1+y1i) = (-y2+y1+x1)+(x2-x1+y1)i
    p4.x_elem = -p2.y_elem + p1.y_elem + p1.x_elem;
    p4.y_elem = p2.x_elem - p1.x_elem + p1.y_elem;

    printf("%d %d %d %d\n", p3.x_elem, p3.y_elem, p4.x_elem, p4.y_elem);

    return 0;
}


Measured memory_bytes: 1700
#include<iostream>
using namespace std;
int main()
{
    long long int h,n;
    cin>>h>>n;
    long long int a;
    for(int i=0;i<n;i++)
    { cin>>a;
      h=h-a;
        
    }
    if(h>0)
    cout<<"No";
    else
    cout<<"Yes";
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 15
#define INF 1e9
 
int N;
int G[MAX][MAX],bit;
int len[MAX];
int dp[1<<MAX][MAX];
string s[MAX];
 
int calc(int a,int b){
    string s1 = s[a],s2 = s[b];
    int l1 = len[a],l2 = len[b];
 
    if(s2.find(s1) != string::npos &&
       s1.find(s2) == string::npos){
	bit |= (1<<a);
	return 0;
    }else if(s1.find(s2) != string::npos &&
	     s2.find(s1) == string::npos){
	bit |= (1<<b);
	return 0;
    }
   
    for(int i = min(l1,l2) ; i >= 0 ; i--){
	string subs1 = s1.substr(l1-i,i);
	string subs2 = s2.substr(0,i);
	if(subs1 == subs2){
	    return subs1.size();
	}
    }
    return 0;
}
 
int solve(int S,int v){
    if(S == (1<<N)-1) return 0;
    if(dp[S][v] != -1) return dp[S][v];
    int res = INF;
    for(int i = 0 ; i < N ; i++){
	if((S >> i) & 1) continue;
	res = min(res,solve(S|(1<<i),i)+len[i]-G[v][i]);
    }
    return dp[S][v] = res;
}
 
int main(){
    while(cin >> N,N){
	bit = 0;
	memset(dp,-1,sizeof(dp));
	fill(G[0],G[0]+MAX*MAX,INF);
	for(int i = 0 ; i < N ; i++){
	    cin >> s[i];
	    len[i] = s[i].size();
	}
	for(int i = 0 ; i < N ; i++){
	    for(int j = 0 ; j < N ; j++){
		if(i == j) continue;
		G[i][j] = calc(i,j);
	    }
	}
	int res = INF;
	for(int i = 0 ; i < N ; i++){
	    if((bit >> i) & 1) continue;
	    res = min(res,solve(bit|(1<<i),i)+len[i]);
	}
	cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 4904
def calc(a):
    if a < 0:
        return 0
    a += 1

    ans = 0

    for i in range(50):
        loop = 1 << (i + 1)
        cnt = (a // loop) * (loop // 2)
        cnt += max(0, (a % loop) - (loop // 2))
        if cnt % 2 == 1:
            ans += 1 << i

    return ans

if __name__ == '__main__':

    a, b = list(map(int, input().split(" ")))

    ans = calc(b) ^ calc(a - 1)
    print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>

int main() {
    std::string S;
    std::cin >> S;

    int N = S.size();

    std::vector<int> ans(N);

    int i = 0;
    while (i < N) {
        int r = 0, l = 0;

        while (S[i + r] == 'R') r++;
        while (S[i + r + l] == 'L') l++;

        ans[i + r - 1] = (r + 1) / 2 + l / 2;
        ans[i + r] = r / 2 + (l + 1) / 2;

        i += r + l;
    }

    for (int i = 0; i < N; i++)
        std::cout << ans[i] << (i < N - 1 ? " " : "\n");
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> v(n,0);
    int m = 0;
    for(int i = n;i>=1; i--) {
        int tmp = i;
        int total = 0;
        while(tmp <= n) {
            total += v[tmp-1];
            tmp += i;
        }
        if(total%2 != a[i-1]){
            v[i-1] = 1;
            m++;
        }
    }
    cout << m << endl;
    bool isfirst = true;
    for(int i = 0; i<n;i++){
        if(v[i]==1){
            if(isfirst){
                cout << i+1;
                isfirst = false;
            } else {
                cout << " " << i+1;
            }
        }
    }
    if(!isfirst)
        cout << endl;
}


Measured memory_bytes: 2432
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
// Problem : F - Pond Skater
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_f
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define fi first
#define se second
#define pb push_back
 
#define ll long long
#define pii pair<int, int>
//#define int ll
const int MOD = 1000000007;

queue<pii> b;
vector<vector<int>> mat;
vector<vector<int>> weig;
int n, m, K;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

void w(int x1, int y1) {
	weig[x1][y1] = 0;
	b.push({x1, y1});
	while(!b.empty()) {
		pii t = b.front(); b.pop();
		rep(d, 4) {
			int px = t.fi, py = t.se;
			px += dx[d]; py += dy[d];
			if(!(0 <= px && px < n && 0 <= py && py < m) || mat[px][py] == -1) continue;
			if(weig[px][py] == -2 || weig[px][py] > weig[t.fi][t.se] + 1) {
				weig[px][py] = weig[t.fi][t.se] + 1;
				b.push({px, py});
			}
		}
	}
}

struct qel {
	pii v;
	const bool operator<(const qel& o) const {
		return weig[v.fi][v.se] > weig[o.v.fi][o.v.se];
	}
};
priority_queue<qel> b2;

int bfs(int x1, int y1, int x2, int y2) {
	mat[x1][y1] = 0;
	b2.push({{x1, y1}});
	int itt = 0, ans = -1;
	while(!b2.empty()) {
		pii t = b2.top().v; 
		b2.pop();
		if(t.fi == x2 && t.se == y2) {
			if(ans == -1 || mat[x2][y2] < ans) ans = mat[x2][y2];
		}
		itt++;
		if(itt == 10000000) break;
		rep(d, 4) {
			int px = t.fi, py = t.se, ocu = 0;
			rep1(p, K) {
				px += dx[d]; py += dy[d];
				if(!(0 <= px && px < n && 0 <= py && py < m) || mat[px][py] == -1) break;
				if(mat[px][py] == -2 || mat[px][py] > mat[t.fi][t.se] + 1) {
					mat[px][py] = mat[t.fi][t.se] + 1;
					b2.push({{px, py}});
				} else {
					ocu++;
					if(ocu == 100) break;
				}
			}
		}
	}
	return ans;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m >> K;
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    x1--; x2--; y1--; y2--;
    rep(i, n) {
    	string s; cin >> s;
    	vector<int> p, k;
    	rep(j, m) {
    		if(s[j] == '.') p.pb(-2);
    		else p.pb(-1);
    		k.pb(-2);
    	}
    	mat.pb(p);
    	weig.pb(k);
    }
    w(x1, y1);
    cout << bfs(x1, y1, x2, y2) << endl;
}



Measured memory_bytes: 27852
using System;

namespace B___81
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            for (int i = 1; i <= 9; i++)
            {
                if (N % i == 0)
                {
                    if (N / i <= 9)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
#include<cstdio>
#include<vector>
#define REP(i,a,n) for(int i = a;i < n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int in(){int x; scanf("%d",&x); return x;}
int main(void){
   int front[5001] = {0};
   int n,m; scanf("%d%d",&n,&m);
   vector<vector<int> > back(5001);
   rep(i,m){
      int x,y;
      scanf("%d%d",&x,&y);
      back[x].push_back(y);
      front[y] += 1;
   }
   bool flag = false;
   REP(i,1,n+1){
      int idx = 0;
      int zero_cnt = 0;
      REP(j,1,n+1){
         if(front[j] == 0){
            zero_cnt += 1;
            idx = j;
         }
      }
      if(zero_cnt != 1) flag = true;
      printf("%d\n",idx);
      front[idx] = -1;
      rep(j,back[idx].size()){
         front[back[idx][j]] -= 1;
      }
   }
   if(flag){
      printf("1\n");
   }
   else printf("0\n");
   return 0;
}

Measured memory_bytes: 1840
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(x==3||x==5||x==7){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 21588
#include <iostream>

using namespace std;

int main() {
    string a;
    cin >> a;
    string first = a.substr(0,2);
    string second = a.substr(2,2);
    int A = stoi(first);
    int B = stoi(second);
    if (A>0 && A<=12 && B>0 && B<=12) {
        cout << "AMBIGUOUS" << endl;
    } else if (A>0 && A<=12) {
        cout << "MMYY" << endl;
    } else if (B>0 && B<=12) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

class Main{
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int hp = fs.nextInt();
        int n = fs.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i=0;i<n;i++){
            a[i] = fs.nextInt();
            b[i] = fs.nextInt();
        }
        int inf = 100000000;
        int[][] dp = new int[n+1][hp+1];
        Arrays.fill(dp[0],inf);
        dp[0][0] = 0;
        for(int i=0;i<n;i++){
            for(int j=1;j<=hp;j++){
                if(j-a[i]>=0){
                    dp[i+1][j] = Math.min(dp[i][j],dp[i+1][j-a[i]]+b[i]);
                }else{
                    dp[i+1][j] = Math.min(dp[i][j],b[i]);
                }
            }
        }
        System.out.println(dp[n][hp]);
        System.out.flush();

    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte(){
        if(ptr < buflen){
            return true;
        }else{
            ptr = 0;
            try{
                buflen = in.read(buffer);
            }catch(IOException e){
                e.printStackTrace();
            }
            if(buflen <=0){
                return false;
            }
        }
        return true;
    }

    private int readByte(){
        if(hasNextByte())return buffer[ptr++];
        else return -1;
    }

    private static boolean isPrintableChar(int c){
        return 33<=c && c<=126;
    }
    public boolean hasNext(){
        while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;
        return hasNextByte();
    }

    public String next(){
        if(!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)){
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong(){
        if(!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if(b == '-'){
            minus = true;
            b = readByte();
        }
        if(b < '0' || '9' < b){
            throw new NumberFormatException();
        }
        while(true){
            if('0' <= b && b<='9'){
                n*=10;
                n+=b-'0';
            }else if(b==-1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt(){
        long nl = nextLong();
        if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDoutble(){return Double.parseDouble(next());}
}

Measured memory_bytes: 79824
#include <stdio.h>          // printf(), scanf()
#define MAX_N 500000

typedef struct node_tbl
{
	int key;
	int parent;
	int left;
	int right;
} node;

const int nil = -1;
node t[MAX_N + 1];
int root;
int ix;

int
find(int u, int k)
{
	while (u != nil && k != t[u].key)
	{
		if (k < t[u].key)
			u = t[u].left;
		else
			u = t[u].right;
	}

	return u;
}

void
insert(int k)
{
	int y = nil;
	int x = root;
	int z = ix++;

	t[z].key = k;
	t[z].left = nil;
	t[z].right = nil;

	while (x != nil)
	{
		y = x;
		if (t[z].key < t[x].key)
			x = t[x].left;
		else
			x = t[x].right;
	}

	t[z].parent = y;
	if (y == nil)
		root = z;
	else
	{
		if (t[z].key < t[y].key)
			t[y].left = z;
		else
			t[y].right = z;
	}
}

void
inorder(int u)
{
	if (u == nil)
		return;

	inorder(t[u].left);
	printf(" %d", t[u].key);
	inorder(t[u].right);
}

void
preorder(int u)
{
	if (u == nil)
		return;

	printf(" %d", t[u].key);
	preorder(t[u].left);
	preorder(t[u].right);
}

int
main(int argc, char** argv)
{
	char command[8];
	int n;
	int x;
	int i;

	root = nil;
	ix = 0;
	scanf("%d", &n);
	for (i = 0; i < n; ++i)
	{
		scanf("%s", command);
		switch (command[0])
		{
		case 'f':
			scanf("%d", &x);
			printf("%s\n", find(root, x) != nil ? "yes" : "no");
			break;

		case 'i':
			scanf("%d", &x);
			insert(x);
			break;

		case 'p':
		default:
			inorder(root);
			printf("\n");

			preorder(root);
			printf("\n");
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 6872
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define ET cout << "\n"
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef bbq
#define debug(...) {\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}
#define DB(a,s,e) {for(int _i=s;_i<e;++_i) cerr << a[_i] << " ";cerr << "\n";}
template<typename T>void _do(T &&x){cerr<<x<<endl;}
template<typename T,typename ...S> void _do(T &&x,S &&...t){cerr<<x<<", ";_do(t...);}
template<typename a,typename b> ostream& operator << (ostream &s,const pair<a,b> &p){return s<<"("<<p.X<<","<<p.Y<<")";}
#else
#define debug(...)
#define DB(a,s,e)
#endif

int arr[100005];

int main()
{
    IOS();
    int n,l,flag=-1;
    cin >> n >> l;
    for(int i=0;i<n;++i)
        cin >> arr[i];
    for(int i=1;i<n&&!~flag;++i)
        if(arr[i-1]+arr[i]>=l)
            flag=i;
    if(!~flag)
        return cout << "Impossible\n",0;
    cout << "Possible\n";
    for(int i=1;i<flag;++i)
        cout << i << "\n";
    for(int i=n-1;i>=flag;--i)
        cout << i << "\n";
}

Measured memory_bytes: 1280
local mod = 1000000007
local mfl = math.floor

local function bmul(x, y)
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  local x0, y0 = x - x1 * 31623, y - y1 * 31623
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local s = io.read()
local n = #s
local ret = 0
local acnt = 0
local abcnt = 0
local mul = 1
for i = 1, n do
  local ss = s:sub(i, i)
  if ss == "A" then
    acnt = badd(acnt, mul)
  elseif ss == "B" then
    abcnt = badd(abcnt, acnt)
  elseif ss == "C" then
    ret = badd(ret, abcnt)
  else
    ret = badd(bmul(ret, 3), abcnt)
    abcnt = badd(bmul(abcnt, 3), acnt)
    acnt = badd(bmul(acnt, 3), mul)
    mul = bmul(mul, 3)
  end
end
print(ret)


Measured memory_bytes: 512
s = input()

def ismonth(s):
	return int(s) in range(1, 13)

flag = 0
if ismonth(s[2:]):
	flag |= 1
if ismonth(s[:2]):
	flag |= 2
a = ["NA", "YYMM", "MMYY", "AMBIGUOUS"]
print(a[flag])


Measured memory_bytes: 2940
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

void saiki(int maxi, int zan, vector<int>& bin){
	
	
	if(zan==0){
		for(int i=0;;i++){
			if(i>=bin.size())break;
			printf("%d",bin[i]);
			if(i+1>=bin.size())break;
			printf(" ");
		}printf("\n");
		return;
	}
	
	for(int i=min(zan,maxi); i>=1; i--){
		bin.push_back(i);
		saiki(min(maxi,i), zan-i, bin);
		bin.pop_back();
	}
}

int main(void){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		vector<int> bin;
		saiki(n,n,bin);
	}
}

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

using namespace std;

int main(void) {
  int N;
  cin >> N;
  int count = 0;
  string ans = "No";
  for (int i = 0; i < N; i++) {
    int d1, d2;
    cin >> d1 >> d2;
    if (d1 == d2) {
      count++;
    } else {
      count = 0;
    }
    if (count >= 3) {
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3592
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)

#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
const ll INF = 1LL << 60;
// const double PI = 3.14159265358979;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Short Functions ---------- */

template <typename T>
T square(T a) {
    return a * a;
}


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
#define testP(p) cout << GET_VAR_NAME(p) << " = (" << (p).fst << ", " << (p).snd << ")" << endl;


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */


/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

    ll edge[3];
    REP(i, 3) {
        cin >> edge[i];
    }

    ll ans = INF;
    REP(i, 3) {
        if (edge[i] % 2 == 0) {
            ans = 0;
            break;
        } else {
            ans = min(ans, edge[(i + 1) % 3] * edge[(i + 2) % 3]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ALL(a)  (a).begin(),(a).end()
const int MOD = 1000000007;
int n, a, h, k, c,t; string s;
vector<int> d;
queue<int> q;
bool dig(int n) {
    int res = 0;
    while (n > 0) {
        if (binary_search(d.begin(), d.end(), n % 10)) return false;
        n /= 10;
    }
    return true;
}
int main() {
    cin >> n >> k;
    rep(i, k) {
        cin >> c; d.push_back(c);
    }
    for (int i = n; i <= 10 * n; i++) {
        if (dig(i)) {
            cout << i << endl; break;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int K;
  scanf("%d", &K);
  int even = K / 2;
  int odd = K - even;
  int ans = even * odd;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python2
from __future__ import division, print_function

import itertools
import os
import sys
from atexit import register
from cStringIO import StringIO

range = xrange

sys.stdout = StringIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = StringIO(os.read(0, os.fstat(0).st_size)).readline

MOD = 10**9 + 7
MODF = float(MOD)

MAGIC = 6755399441055744.0
SHRT = 65536.0

MODF_INV = 1.0 / MODF
SHRT_INV = 1.0 / SHRT

fround = lambda x: (x + MAGIC) - MAGIC
fmod = lambda a: a - MODF * fround(MODF_INV * a)


def main():
    n = int(input())
    c = [int(input()) for _ in range(n)]

    c = [x[0] for x in itertools.groupby(c)]
    n = len(c)

    res, prev = [1.0] * (n + 1), [0] * (2 * 10**5 + 1)
    for i in range(n):
        res[i + 1] = res[i] if prev[c[i]] == 0 else fmod(res[i] + res[prev[c[i]]])
        prev[c[i]] = i + 1

    print(int(res[-1]) % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45212
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int b;
    cin >> b;
    vector<int> a(4, 0);
    for(int i = 0; i < 4; i++)
    {
        a[i] = b%10;
        b /= 10;
    }
    reverse(a.begin(), a.end());
    for(int bit = 0; bit < (1<<3); bit++)
    {
        int num=a[0];
        for(int i = 0; i < 3; i++)
        {
            if(bit&(1<<i)){
                num+=a[i+1];
            }
            else{
                num -= a[i+1];
            }
        }
        if(num==7){
            cout <<a[0];
            for(int i = 0; i < 3; i++)
            {
                if(bit&(1<<i)){
                    cout << '+' << a[i+1];
                }
                else{
                    cout << '-' << a[i+1];
                }
            }
            cout << "=7" << endl;
            return 0;
        }
    }
    
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int mod = 1e9+7;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  long long ans = 0; 
  long long b = A.at(N-1);
  for(int i=1; i<N; i++){
    ans += b*A.at(N-1-i);
    ans %= mod;
    if(i<N-1) b += A.at(N-1-i);
    b %= mod;
  }
  cout << ans;
  return 0;
}

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

int a[3][3];


string sol(map<int,int> hash){
	int flag = 0;

	//1
	
	

	//2 
	if(hash[a[0][0]] and hash[a[0][1]] and hash[a[0][2]]){
		return "Yes";
	}
	//3 
	if(hash[a[0][0]] and hash[a[1][0]] and hash[a[2][0]]){
		return "Yes";
	}
	//4 
	if(hash[a[2][0]] and hash[a[1][1]] and hash[a[0][2]]){
		return "Yes";
	}
	// 5
	if(hash[a[1][0]] and hash[a[1][1]] and hash[a[1][2]]){
		return "Yes";
	}
	//6
	if(hash[a[0][1]] and hash[a[1][1]] and hash[a[2][1]]){
		return "Yes";
	}
	// 7
	if(hash[a[0][2]] and hash[a[1][2]] and hash[a[2][2]]){
		return "Yes";
	}
	// 8
	if(hash[a[2][0]] and hash[a[2][1]] and hash[a[2][2]]){
		return "Yes";
	}

	if(hash[a[0][0]] and hash[a[1][1]] and hash[a[2][2]]){
		return "Yes";
	}

	return "No";
}

int main(){
	
	map<int,int> hash;

	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			int x; cin>>x;
			a[i][j] = x; 

		}
	}

	int n; cin>>n;
	for(int i = 0; i < n; i++){
		int x; cin>>x;
		hash[x]++;
	}
	cout<<sol(hash);


}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: String = read();
    let count = s.chars().filter(|x| *x == 'x').count();
    match count {
        8 ... 15 => println!("NO"),
        _        => println!("YES"),
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
/*
 * Problem Description: Heaps - Priority Queue
 * Category:
 * Author: Khan
 * Date: 17th October, 2017
 */

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
#define MAXN 2000000
#define INF (1 << 30)

int H, A[MAXN + 1];

void maxHeapify(int i)
{
    int l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;

    if(l <= H && A[l] > A[i])
        largest = l;
    else
        largest = i;
    if(r <= H && A[r] > A[largest])
        largest = r;

    if(largest != i)
    {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int extract()
{
    int maxv;
    if(H < 1)
        return -INF;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key)
{
    if(key < A[i])
        return;
    A[i] = key;
    while(i > 1 && A[i / 2] < A[i])
    {
        swap(A[i], A[i / 2]);
        i /= 2;
    }
}

void insert(int key)
{
    H++;
    A[H] = -INF;
    increaseKey(H, key);
}

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int key;
    char cmd[10];
    while(true)
    {
        scanf("%s", cmd);
        if(cmd[0] == 'e' && cmd[1] == 'n')
            break;
        if(cmd[0] == 'i')
        {
            scanf("%d", &key);
            insert(key);
        }
        else
        {
            printf("%d\n", extract());
        }
    }
    return 0;
}

Measured memory_bytes: 6976
import std.conv;
import std.stdio;
import std.string;

void main()
{
	auto s = readln.strip;
	writeln( solve( s ) );
}

auto solve( in string s )
{
	auto r = 0;
	foreach( c; s )
	{
		if( c == '+' ) r++;
		else           r--;
	}
	
	return r;
}

unittest
{
	assert( solve( "+-++" ) == 2 );
	assert( solve( "-+--" ) == -2 );
	assert( solve( "----" ) == -4 );
}


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

using namespace std;

int main() {
	long n,x,k;
	cin>>n>>x;
	vector<long>v(n+1);
	for(int i=0;i<n;i++)cin>>v.at(i);
	v.at(n)=x;
	sort(v.begin(),v.end());
	k=v.at(1)-v.at(0);
	for(int i=0;i<n;i++){
		
	k=__gcd(k,(v.at(i+1)-v.at(i)));	
	}
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 1024