akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

    int ans = 0;
    for(int i = 1; i < n - 1; i++){
        vector<int> v(3);
        v[0] = p[i - 1];
        v[1] = p[i];
        v[2] = p[i + 1];
        sort(v.begin(), v.end());
        if(p[i] == v[1]) ans++;
    }

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


Measured memory_bytes: 256
from collections import deque
H,W=map(int,raw_input().split())
c=[]
for i in range(H):
	s=list(raw_input())
	for j in s:
		if j=="#":
			c.append(1)
		else:
			c.append(0)


nl=[ [] for i in range(H*W)]

p0=[-1,1,W]
p1=[-W,1,W]
p2=[-W,-1,W]
p3=[-W,-1,1]
p4=[-W,-1,1,W]
for i in range(H*W):
	if c[i]==0:
		if i==0:
			if c[i+1]==0:nl[i].append(i+1)
			if c[i+W]==0:nl[i].append(i+W)
		elif i==W-1:
			if c[i-1]==0:nl[i].append(i-1)
			if c[i+W]==0:nl[i].append(i+W)
		elif i==W*(H-1):
			if c[i-W]==0:nl[i].append(i-W)
			if c[i+1]==0:nl[i].append(i+1)		
		elif i==W*H-1:
			if c[i-W]==0:nl[i].append(i-W)
			if c[i-1]==0:nl[i].append(i-1)
		elif i<W-1:
			for j in p0:
				if c[i+j]==0:nl[i].append(i+j)			
		elif i%W==0:
			for j in p1:
				if c[i+j]==0:nl[i].append(i+j)	
		elif i%W==W-1:
			for j in p2:
				if c[i+j]==0:nl[i].append(i+j)
		elif i>W*(H-1):
			for j in p3:
				if c[i+j]==0:nl[i].append(i+j)
		else:
			for j in p4:
				if c[i+j]==0:nl[i].append(i+j)


V=[ None for i in range(H*W)]
d=[ float("inf") for i in range(H*W) ]

def bfs(start):
	q = deque([]) 
	V[start]=1
	d[start]=0
	q.append(start)

	while len(q)!=0:
		v=q.popleft()
		for i in nl[v]:
			if V[i] is None:
				V[i]=1
				q.append(i)
				d[i]=d[v]+1

bfs(0)

if V[H*W-1] is None:
	print -1
else:
	print H*W-(d[H*W-1]+1)-sum(c)




Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check(int n) {
    for(int i=2;i*i<=n;++i) {
        if(n%i==0)
        return false;
    }
    return true;
}


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    
    int n;
    string s,t;
    cin>>s>>t;
    int c=0;
    f1(i,3) {
        if(s[i]==t[i])++c;
    }
    cout<<c<<endl;
    // ()?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3520
import java.util.*; 
import java.lang.*; 


public class Main{
    
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
                String call = scan.next();
                char[] c = new char[N];
                
                for(int i=0; i<N; i++){
                    c[i] = call.charAt(i);
                }
                
                int l = 0;
                int r = N-1;
                
                int cnt = 0;
                
                while(l<r){
                    while(c[l]=='R' && l<r){
                        l++;
                    }
                    while(c[r]=='W' && l<r){
                        r--;
                    }
                    
                    if(c[l]=='W' && c[r]=='R'){
                        c[l]='R';
                        c[r]='W';
                        cnt++;
                        l++;
                        r--;
                    }
                }
                
                System.out.println(cnt);
        }
}

Measured memory_bytes: 41132
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str1 = sc.next();
        String str2 = sc.next();
        
        char c1 = str1.charAt(0);
        char c2 = str2.charAt(0);
        
        Character C1 = new Character(c1);
        Character C2 = new Character(c2);
        
        int a = C1.compareTo(C2);
        
        if(a<0){
            System.out.println("<");
        }else if(a>0){
            System.out.println(">");
        }else{
            System.out.println("=");
        }
        //System.out.println(a);
    }
}

Measured memory_bytes: 35580
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int N, K;
  string S;
  cin>>N>>K>>S;
  S.at(K-1)+=32;
  cout<<S<<endl;  
}

Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

def settify(j, n): #sが集合ラベル, nが多重度
  i = 0
  ans = [set() for _ in range(n)]
  while i < N:
    ans[j % n].add(i)
    i += 1
    j //= n
  return ans

def set_label(st): #setをlabel化する
  rtn = 0
  for j in st:
    rtn += 2**j 
  return rtn

def cost(s, L): #s:集合ラベル（使う竹）, L:目標長
  if s == 0:
    return 10**20
  st = settify(s, 2)[1]
  #print(st, s)
  l_first = 0
  for i in st:
    l_first += l[i] #とりあえず全部足す
  return 10*(len(st)-1) + abs(l_first - L) #最小コストを返す
  

#前準備
cost = [ 
  [cost(s2, A) for s2 in range(2**N)]
, [cost(s2, B) for s2 in range(2**N)]
, [cost(s2, C) for s2 in range(2**N)] ]

#print(cost)

mi = 10**20
for j in range(4**N):
  sets = settify(j, 4)
  q = [0, 0, 0]
  tmp = 0
  for p in range(3):
    tmp += cost[p][set_label(sets[p])]
  mi = min(mi, tmp)
  
print(mi)

Measured memory_bytes: 74604
#include <iostream>
#include <map>

using namespace std;

const int NUM = 52;
const int SPADE = 0;
const int HEART = 13;
const int CLUB = 26;
const int DAI = 39;

const string card[NUM] =
    {
        "S 1", "S 2", "S 3", "S 4", "S 5", "S 6", "S 7", "S 8", "S 9", "S 10", "S 11", "S 12", "S 13",
        "H 1", "H 2", "H 3", "H 4", "H 5", "H 6", "H 7", "H 8", "H 9", "H 10", "H 11", "H 12", "H 13",
        "C 1", "C 2", "C 3", "C 4", "C 5", "C 6", "C 7", "C 8", "C 9", "C 10", "C 11", "C 12", "C 13",
        "D 1", "D 2", "D 3", "D 4", "D 5", "D 6", "D 7", "D 8", "D 9", "D 10", "D 11", "D 12", "D 13",
};

int main()
{
    int h;
    int n;
    char mk;
    int num;
    while (cin >> h)
    {
        int fg[NUM] = {};

        for (int i = 0; i < h; i++)
        {
            cin >> mk >> n;
            if (mk == 'S')
            {
                num = SPADE;
            }
            else if (mk == 'H')
            {
                num = HEART;
            }
            else if (mk == 'C')
            {
                num = CLUB;
            }
            else
            {
                num = DAI;
            }
            fg[num + n - 1] = 1;
        }
        for (int j = 0; j < NUM; j++)
        {
            if (!fg[j])
                cout << card[j] << endl;
        }
    }
    return (0);
}

Measured memory_bytes: 3168
#include"bits/stdc++.h"
using namespace std;
int main(){
    char str[101][101];
    int h,w,mapp[101][101];
    memset(mapp,-1,sizeof(mapp));
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>str[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(str[i][j]=='c'){
                mapp[i][j]=0;
                for(int x=j+1;x<w&&mapp[i][x]==-1&&str[i][x]!='c';x++){
                    mapp[i][x]=x-j;
                }
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<mapp[i][j];
            if(j<w-1)cout<<" ";
        }
        cout<<endl;
    }
}

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

int main(){
    
    int N;cin>>N;
    vector<int> S;
    int cnt=0;
    for(int i=11;i<=55555;i+=10){
        bool check=true;
        for(int j=2;j<=sqrt(i);j++){
            if(i%j==0) check=false;
        }
        if(check){
            S.push_back(i);
            cnt++;
        }
        if(cnt==N) break;
    }
    for(int i=0;i<N;i++){
        if(i) cout<<" ";
        cout<<S[i];
    }
    cout<<endl;
}



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

int N;
int L[2 * 100];

int main() {
  cin >> N;
  for(int i = 0; i < 2 * N; ++i) cin >> L[i];
  sort(L, L + 2 * N, greater<int>());
  int res = 0;
  for(int i = 0; i < N; ++i) res += L[2 * i + 1];
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> H(n);
    int ans=0,l=0;
    for (int i = 0; i < n;i++){
        cin >> H[i];
    }
        for (int i = 0; i < n; i++)
        {
            if (H[i] >= l)
            {
                ans++;
                l = H[i];
            }
        }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
using Graph = vector<vector<int>>;
using Graph_Wei = vector<vector<pair<int,int>>>;
using ll = long long;



int main() {

    int s,t;
    cin >> s >> t;

    if(1 <= s && s<= 9 && 1<= t && t <= 9) cout << s*t << endl;
    else cout << -1 << endl;
    

    return 0;

}

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

int main()
{
    string s;
    cin >> s;
    cout << s.substr(0,3) << endl;
    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end

typedef pair<int,int> P;
vector<P> g[100010];
int d[100010];

int main(){
   int n,m; scanf("%d%d",&n,&m);
   rep(i,0,n)scanf("%d",&d[i]);
   rep(i,0,m){
      int u,v; scanf("%d%d",&u,&v);
      u--; v--;
      g[u].push_back({v,i});
      g[v].push_back({u,i});
   }
   map<int,vector<int>> mp;
   rep(i,0,n)mp[d[i]].push_back(i);
   vector<int> col(n,-1),res(m,1e9);
   for(auto p:mp){
      int val=p.first; vector<int> vs=p.second;
      for(auto v:vs)if(col[v]==-1){
         bool f=1;
         for(auto e:g[v]){
            int nxt=e.first;
            if(d[v]<d[nxt])continue;
            f=0; res[e.second]=val;
            if(col[nxt]==-1){
               col[v]=0; col[nxt]=1;
            }
            else col[v]=col[nxt]^1;
            break;
         }
         if(f){
            printf("-1\n");
            return 0;
         }
      }
   }
   rep(i,0,n)printf(col[i]==0?"W":"B"); puts("");
   rep(i,0,m)printf("%d\n",res[i]);
   return 0;
}

Measured memory_bytes: 22016
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

const INF: i64 = 100000_00000_00000;

fn get_index(x: usize, y: usize, dir: usize, w: usize, h: usize) -> usize {
    dir + x * 4 + y * 4 * w
}

fn decode(i: usize, w: usize) -> (usize, usize, usize) {
    let dir = i % 4;
    let i = i / 4;
    let x = i % w;
    let y = i / w;
    (dir, x, y)
}

fn main() {
    let v = read_vec::<usize>();
    let (h, w, k) = (v[0], v[1], v[2] as i64);
    let v = read_vec::<usize>();
    let (sy, sx, gy, gx) = (v[0] - 1, v[1] - 1, v[2] - 1, v[3] - 1);

    let mut grid = vec![vec![]; h];
    for i in 0..h {
        let s = read::<String>().chars().collect::<Vec<_>>();
        grid[i] = s;
    }

    let mut d = vec![INF; h * w * 4];
    let start_idx = get_index(sx, sy, 0, w, h);
    d[start_idx] = 0;
    let mut que = BinaryHeap::new();
    que.push((0, start_idx));

    while let Some((u, v)) = que.pop() {
        let u = -u;
        if d[v] < u {
            continue;
        }
        let (dir, x, y) = decode(v, w);
        let mut adjacent = None;

        if dir == 0 && x < w - 1 && grid[y][x + 1] == '.' {
            adjacent = Some(get_index(x + 1, y, dir, w, h));
        } else if dir == 2 && x > 0 && grid[y][x - 1] == '.' {
            adjacent = Some(get_index(x - 1, y, dir, w, h));
        } else if dir == 1 && y < h - 1 && grid[y + 1][x] == '.' {
            adjacent = Some(get_index(x, y + 1, dir, w, h));
        } else if dir == 3 && y > 0 && grid[y - 1][x] == '.' {
            adjacent = Some(get_index(x, y - 1, dir, w, h));
        }

        if let Some(to) = adjacent {
            if d[v] != INF && d[to] > d[v] + 1 {
                d[to] = d[v] + 1;
                que.push((-d[to], to));
            }
        }

        for next_dir in 0..4 {
            if dir == next_dir || dir + 2 == next_dir || dir == next_dir + 2 {
                continue;
            }
            let to = get_index(x, y, next_dir, w, h);
            let cost = (k - (d[v] % k)) % k;
            if d[v] != INF && d[to] > d[v] + cost {
                d[to] = d[v] + cost;
                que.push((-d[to], to));
            }
        }
    }
    let ans = (0..4)
        .map(|dir| d[get_index(gx, gy, dir, w, h)])
        .min()
        .unwrap();
    if ans == INF {
        println!("-1");
        return;
    }
    println!("{}", (ans + k - 1) / k);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 41004
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,f[200009],lef,rig,mid,k,pas,ans;
long long di(long long q, long long w){
	if(q>=0) return q/w;
	if(q%w!=0) return -(abs(q)/w+1); return -(abs(q)/w);
}
long long dii(long long q, long long w){
	if(q>=0){
		if(q%w==0) return -(q/abs(w)); else return -(q/abs(w));
	}
	//q<0
	q=abs(q);w=abs(w);
	if(q%w==0) return q/w; else return q/w+1;
}
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	lef=-1000000000000000001LL;
	rig=1000000000000000001LL;
	cin>>a>>k;
	for(b=1; b<=a; b++) cin>>f[b];
	sort(f+1,f+a+1);
	while(1){
		if(lef+1>=rig) break;
		mid=(lef+rig)/2;
		ans=0;
		for(b=1; b<=a; b++){
			if(f[b]<0){
				c=dii(mid,f[b]);
				d=lower_bound(f+1,f+a+1,c)-f;
				if(d<=a) ans+=a-d+1;
				if(f[b]*f[b]<=mid) ans--;
			}
			if(f[b]==0){
				if(mid>=0) ans+=a-1;
			}
			if(f[b]>0){
				c=di(mid,f[b]);
				d=lower_bound(f+1,f+a+1,c+1)-f-1;
				if(d>=1) ans+=d;
				if(f[b]*f[b]<=mid) ans--;
			}
		}
		ans/=2;
		if(ans>=k){
			pas=mid;
			rig=mid;
		}else{
			lef=mid;
		}
	}
	cout<<pas;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>

using namespace std;
static const int MAXV = 1000;

int main() {
  while(1) {
  int n, m, p, M[MAXV]={}, i=0;
  scanf("%d %d", &n, &m);
  if (n==0 && m==0) break;
  p=m;
  while(1) {
    //printf("%d   %d   %d\n", M[0], M[1], M[2]);
    if (p == 0) {
      p=M[i]; M[i]=0;
    } else{
      M[i]++; p--;
    }
    if(M[i] == m) break;
    i++;
    if(i == n) i=0;
  }
  printf("%d\n", i);
  }
}

Measured memory_bytes: 880
#include <iostream>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
typedef long long int ll;
int main()
{
    char s[200000];
    scanf("%s",s);
    ll sum=0;
    rep(i,strlen(s))
        sum+=s[i]-'0';
    if(sum%9==0)
        printf("Yes");
    else printf("No");
}

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

const int len = 3005, mod = 1e9+7;
int pref[len], dp[len];
char str[len];

int add(int a, int b){
    return (a+b)%mod;
}

int sub(int a, int b){
    return (mod+a-b)%mod;
}

int main(){
    int n;
    scanf("%d ", &n);
    for (int i = 1; i < n; i++)
        scanf("%c", &str[i]);
    str[n] = '<';

    dp[1] = 1;
    for (int i = 2; i <= n; i++){
        for (int j = 1; j <= n; j++){
            int temp = dp[j];
            if (str[i-1] == '<')
                temp = dp[j-1];
            pref[j] = add(pref[j-1], temp);
        }

        for (int j = 1; j <= n; j++){
            if (str[i] == '<'){
                dp[j] = pref[min(i, j)];
            }
            else{
                dp[j] = 0;
                if (j <= i)
                    dp[j] = sub(pref[i], pref[j-1]);
            }
        }
    }

    printf("%d\n", dp[n]);
    return 0;
}


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

int main(void){
    char s[101];
    scanf("%s",s);
    if(strcmp(s,"Sunny")==0)
        printf("Cloudy");
    else if(strcmp(s,"Cloudy")==0)
        printf("Rainy");
    else
        printf("Sunny");
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  map<ll, ll> mp;
  ll sum = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
    sum += a[i];
  }
  int q;
  cin >> q;
  for(int i = 0; i < q; i++) {
    ll tmp, t2;
    cin >> tmp >> t2;
    ll num = mp[tmp];
    sum -= num * tmp;
    mp[tmp] = 0;
    mp[t2] += num;
    sum += num * t2;
    cout << sum << '\n';
  }
  return 0;
}

Measured memory_bytes: 9700
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
using namespace std;


int main(){
  string s; cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(i%2==0) cout << s[i];
  }
  cout << endl;
}


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

int main() {
    ll N;
    cin >> N;
    map<ll, ll> mp;
    rep(i, N) {
        ll a;
        cin >> a;
        mp[a]++;
    }
    bool flag = false;
    if (N % 3 == 0) {
        if (mp.size() == 3) {
            ll xo = 0;
            vector<ll> c;
            for (auto e : mp) {
                xo = xo ^ e.first;
                c.push_back(e.second);
            }
            if (xo == 0 && c[0] == c[1] && c[1] == c[2]) flag = true;
        }

        if (mp.size() == 2) {
            vector<ll> c;
            for (auto e : mp)
                c.push_back(e.second);
            sort(all(c));
            if (mp[0] == N / 3 && c[0] * 2 == c[1]) flag = true;
        }
    }

    if (mp[0] == N) flag = true;
    cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

//#include "All.h"

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    if (K <= A) cout << K << endl;
    else if (K <= A + B) cout << A << endl;
    else cout << A - (K - (A + B)) << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    
//解説AC
  int main(){
   lint n,k;
   cin>>n>>k;
   lint ans=0;
    lint tot[k];
    repm(i,k){
        lint f=k/(i+1);
        lint g=modpow(f,n,MOD);
        lint h=i+1;
        while(1){
            h+=i+1;
            if(h>k)break;
            g-=tot[h-1];
            g+=MOD;
            g%=MOD;
        }
        tot[i]=g;
        ans+=g*(i+1);
        ans%=MOD;
    }
    cout<<ans;
  }
  
     


Measured memory_bytes: 4392
#include <iostream>

using namespace std;

int countDigits(int n)
{
	int digits = 0;
	while (n>0) {
		n /= 10; digits++;
	}
	
	return digits;
}

int main()
{
	int a, b;
	while ( (cin >> a) && (cin >> b) ) {
		cout << countDigits(a+b) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(){
    int n,k;
    cin >> n >> k;
    ll h[n];
    rep(i,n)cin >> h[i];
    sort(h,h+n,greater<ll>());
    ll ans=0;
    rep2(i,k,n)ans+=h[i];

    cout << ans;

    return 0;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
char st[112345];
int main(){
	scanf("%s",st);
	int n = strlen(st);
	int ans = 0;
	for (int i = 1; i < n; i++){
		if (st[i] != st[i - 1]) ans ++;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

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


		int count=0;
		for(int i=0;i<n;i++) {	
			if(a.charAt(i) == b.charAt(i)) {
				if(a.charAt(i) == c.charAt(i)) {
					continue;
				}else {
					count++;
					continue;
				}
			}else {
				count++;
				if(a.charAt(i) == c.charAt(i)) {
					continue;
				}else {
					if(b.charAt(i) == c.charAt(i)) {
						continue;
					}else {
						count++;
						continue;
					}
				}
			}
		}
		
		System.out.println(count);

		
	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >> n >> k;
	vector<int>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	ll ans = k;
	for (int i = 1; i < n; i++) {
		if (v[i] - v[i - 1] < k)
			ans += (v[i] - v[i - 1]);
		else
			ans += k;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
function Main(input) {
	tmp = input.split(" ");
	
	var a = parseInt(tmp[0]);
	var b = parseInt(tmp[1]);
	var c = parseInt(tmp[2]);
	
	if(a==b && b==c && c==a){
		console.log("Yes");
	}else{
		console.log("No");
	}
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
bingo = []
3.times do
  bingo << gets.chomp.split(' ').map(&:to_i)
end
n = gets.to_i

n.times do
    num = gets.to_i
    bingo.each do |b|
        if b.include?(num)
            b[b.index(num)] = true
            break
        end
    end
end

def check_vertical(i,ary)
    if (ary[0][i] == true) && (ary[1][i] == true) && (ary[2][i] == true)
        return true
    end
    false
end

def check_horizontal(i,ary)
    if (ary[i][0] == true) && (ary[i][1] == true) && (ary[i][2] == true)
        return true
    end
    false
end

def check_diagnal(ary)
    if (ary[0][0] == true) && (ary[1][1] == true) && (ary[2][2] == true)
        return true
    end
    if (ary[0][2] == true) && (ary[1][1] == true) && (ary[2][0] == true)
        return true
    end
    false
end

3.times do |i|
    if check_vertical(i,bingo) || check_horizontal(i,bingo) || check_diagnal(bingo)
        puts 'Yes'
        exit
    end
end
puts 'No'

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

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

    int a, b; cin >> a >> b;
    if (a <= 9 and b <= 9) cout << a*b;
    else cout << -1;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979323846
int main(){
double radius;
double area,circum;
scanf("%lf",&radius);
area = PI * radius * radius;
circum = 2 * PI * radius;
printf("%lf %lf\n",area,circum);
return 0;
}



Measured memory_bytes: 2116
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint N,K;
  cin>>N>>K;
  K+=1;
  int Y[40]={0};
  REP(i,40){
    Y[i]=K%2;
    K/=2;
  }
  int S[40]={0};
  REP(i,N){
    lint A;
    cin>>A;
    REP(i,40){
      S[i]+=A%2;
      A/=2;
    }
  }
  lint ans=0;
  for(int i=39;i>=0;i--){
    lint temp=0;
    if(Y[i]==0)continue;
    for(int j=39;j>i;j--){
      temp*=2;
      if(Y[j]==0)temp+=S[j];
      else temp+=N-S[j];
    }
    temp*=2;
    temp+=S[i];
    for(int j=i-1;j>=0;j--){
      temp*=2;
      temp+=max(S[j],(int)N-S[j]);
    }
    ans=max(temp,ans);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
def gcd(a,b):
    while b:
        a, b = b, a % b
    return a
N,X = map(int,input().split())
x = [int(i) for i in input().split()]
ans = abs(X-x[0])
now = X
for i in x:
    if abs(now - i) % ans:
        ans = gcd(ans, abs(now-i))
    now = i

print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	string S = res();
	long bigger = 0;
	long sma = 1;
	for(int i=S.length()-1;i>=0;i--){
		long nb,ns;
		if(S[i] == '0'){
			nb = (bigger*3 + sma*2) % mod;
			ns = sma;
		}
		else{
			nb = bigger * 2 % mod;
			ns = (bigger + sma*3) % mod;
		}
		bigger = nb;
		sma = ns;
	}
	cout << sma << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <map>           // sorted map so O(logn)
#include <unordered_map> // O(1)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

int main()
{
    string s;
    cin >> s;
    bool flag = false;
    for (int i = 0; i < s.length(); ++i)
    {
        if (s[i] != 'U' && s[i] != 'D')
        {

            if ((i + 1) % 2 != 0)
            {
                if (s[i] != 'R')
                {
                    flag = true;
                    break;
                }
            }
            else
            {
                if (s[i] != 'L')
                {
                    flag = true;
                    break;
                }
            }
        }
    }
    if (flag)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3560
#入力した文書の中にアルファベット数字をいくつはいっているかをわかるプログラム
text = gets("").downcase    #テキストに小文字をとる

for alphabet in "a".."z"           #sをA から　Zまで２６回繰り返す
  puts "#{alphabet} : #{text.count(alphabet)}"      #まずAからZまで繰り返して　テキストの中のアルファベットをカウントする
end


Measured memory_bytes: 6880
#include<iostream>
#include<stdlib.h>
  
using namespace std;
  
struct Node{
  int key;
  Node* next;
  Node* prev;
};
  
struct List{
  Node* nil;
  
  void init(){
    nil=(Node*)malloc(sizeof(Node));
    nil->next=nil;
    nil->prev=nil;
    nil->key=0;
  }
  
  Node* find(int key){
    for(Node* i=nil->next;i!=nil;i=i->next){
      if(i->key==key)return i;
    }
    return nil;
  }
  
  void insert(Node *x){
    x->next=nil->next;
    nil->next->prev=x;
    nil->next=x;
    x->prev=nil;
  }
   
  void add(int x){
    Node* p = (Node*)malloc(sizeof(Node));
    p->key=x;
    insert(p);
  }
    
  void delete_x(int key){
    Node* x=find(key);
    if(x==nil)return;
    x->prev->next=x->next;
    x->next->prev=x->prev;
    free(x);
  }
    
  void deleteFirst(){
    Node* x = nil->next;
    x->prev->next=x->next;
    x->next->prev=x->prev;
    free(x);
  }
    
  void deleteLast(){
    Node* x = nil->prev;
    x->prev->next=x->next;
    x->next->prev=x->prev;
    free(x);  
  }
  
  void output(){
    int flg=0;
    for(Node* i=nil->next;i!=nil;i=i->next){
      if(flg)cout<<' ';
      cout<<i->key;
      flg=1;
    }
    cout<<endl;
  }
};
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  List list;
  list.init();
  int n,x;
  string str;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>str;
    if(str=="insert"){
      cin>>x;
      list.add(x);
    }else if(str=="delete"){
      cin>>x;
      list.delete_x(x);
    }else if(str=="deleteFirst"){
      list.deleteFirst();
    }else {
      list.deleteLast();
    }
  }
  //cout<<'-'<<endl;
  list.output();
}



Measured memory_bytes: 34388
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  ll n;cin>>n;
  vector<ll> a(n),b(n);
  rep(i,n)cin>>a[i];
  b[0]=0LL;
  rep(i,n-1){
    b[i+1]=a[i]*2-b[i];
  }
  b[0]=(a[n-1]*2-(b[0]+b[n-1]))/2;
  cout<<b[0];
  rep(i,n-1){
    b[i+1]=a[i]*2-b[i];
    cout<<" "<<b[i+1];
  }
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[100005],i,s=0,c=0,p=1;
	n=3;
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	sort(a,a+3);
	if(a[0]==a[1])
	printf("%d",a[2]);
	else
	printf("%d",a[0]);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int count[4][3][10]={{{0}}};
    int i,j,k,n;
    int b,f,r,v;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d\n",&b,&f,&r,&v);
        count[b-1][f-1][r-1]+=v;
    }
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",count[i][j][k]);
            }
        printf("\n");
        }
    if(i!=3)printf("####################\n");
    }

return 0;
}


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

deque <int> d;

int main ()
{
	int n;
	cin >> n;
	int front = 1;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (front) d.push_front (x);
		else d.push_back (x);
		front = !front;
	}
	vector <int> v;
	while (!d.empty ()) {
		int x = d.front ();
		d.pop_front ();
		v.push_back (x);
	}
	if (n % 2 == 0) reverse (v.begin (), v.end ());
	for (int x : v) cout << x << " ";
	return 0;
}

Measured memory_bytes: 3960
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <map>
#include <sstream>
using namespace std;

using Weight = int;
using Capacity = int;
struct Edge {
	int src, dst; Weight weight; Capacity cap;
	Edge(int s, int d, Weight w, Capacity c) : src(s), dst(d), weight(w), cap(c) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

struct FordFulkerson {
	typedef vector<vector<Capacity>> Matrix;
	int n, t;
	vector<bool> vis;
	vector<vector<Capacity>> cap, flow;
	vector<vector<int>> g;
	Capacity inf;
	FordFulkerson(int n)
		: n(n), cap(n, vector<Capacity>(n)), flow(n, vector<Capacity>(n)),
		g(n, vector<int>()), inf(numeric_limits<Capacity>::max() / 8) {
	}
	FordFulkerson(const Graph &graph) {
		*this = FordFulkerson(graph.size());
		for(int i = 0; i < n; i++) {
			for(auto &e : graph[i]) addEdge(e.src, e.dst, e.cap);
		}
	}
	void addEdge(int u, int v, Capacity c) {
		cap[u][v] += c; cap[v][u] += c; flow[v][u] += c;
		g[u].push_back(v); g[v].push_back(u);
	}
	Capacity solve(int s, int t) {
		this->t = t;
		Capacity res = 0, aug = 1;
		while(aug > 0) {
			vis.assign(n, false);
			res += (aug = augment(s, inf));
		}
		return res;
	}
	Capacity augment(const int &v, const Capacity &lim) {
		vis[v] = true;
		if(v == t) return lim;
		for(const int &d : g[v]) {
			if(vis[d] || flow[v][d] == cap[v][d]) continue;
			Capacity aug = augment(d, min(lim, cap[v][d] - flow[v][d]));
			flow[v][d] += aug;
			flow[d][v] -= aug;
			if(aug > 0) return aug;
		}
		return 0;
	}
};

typedef pair<int, int> Pii;

vector<int> f(string s) {
	replace(s.begin(), s.end(), '+', ' ');
	//cout << s << endl;
	vector<int> ret(51);

	stringstream ss(s);
	while(ss >> s) {
		stringstream ss2(s);
		if(s.find('x') == string::npos) {
			ss2 >> ret[0];
		}
		else {
			char c;
			int a = 1, L = 1;
			if(s[0] != 'x') ss2 >> a;
			if(s.find('^') != string::npos) {
				ss2 >> c >> c >> L; // x^L
			}
			ret[L] = a;
		}
	}
	return ret;
}

int u[500];
int v[500];

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

	int N, M;
	while(cin >> N >> M, N) {
		map<Pii, vector<int> > poly;
		for(int i = 0; i < M; i++) {
			string p;
			cin >> u[i] >> v[i] >> p;
			u[i]--, v[i]--;
			poly[Pii(u[i], v[i])] = f(p);
		}

		vector<int> ans(51);
		for(int i = 50; i >= 0; i--) {
			Graph G(N);

			for(auto&& p : poly) {
				int a = p.first.first, b = p.first.second, c = p.second[i];
				G[a].emplace_back(a, b, 0, c);
				G[b].emplace_back(b, a, 0, c);
			}

			FordFulkerson ff(G);
			int f = ff.solve(0, N - 1);
			ans[i] = f;

			for(int j = 0; j < M; j++) {
				int a = u[j], b = v[j];
				if(ff.flow[a][b] != 0 && ff.flow[a][b] != ff.cap[a][b]) {
					for(int l = 0; l <= i; l++) {
						poly[Pii(a, b)][l] = 1e8;
					}
				}
			}
		}

		bool flag = false;
		for(int i = 50; i >= 0; i--) {
			if(ans[i] == 0) continue;
			if(flag) cout << "+";
			flag = true;
			if(i == 0 || ans[i] != 1) cout << ans[i];
			if(i != 0) cout << "x";
			if(i >= 2) cout << "^" << i;
		}
		if(!flag) cout << 0;
		cout << "\n";
	}
}

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
int main() {
	int x;
	cin >> x;
	if (x == 0) {
		cout << "1\n";
	}
	else cout << "0\n";
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll n,m;cin>>n>>m;
  ll s[m],c[m];rep(i,0,m)cin>>s[i]>>c[i];

  ll mi=0;
  if(n==1)mi=-1;
  rep(i,1*pow(10,n-1)+mi,pow(10,n)){
    string t=to_string(i);
    bool e=true;
    rep(j,0,m){
      if(t[s[j]-1]!=(char)(c[j]+'0'))e=false;
    }
    if(e){
      out(i);
      return 0;
    }
  }
  out(-1);

  return 0;
}


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

namespace ABC0613
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int ans = n + n * n + n * n * n;
            Console.WriteLine(ans);
            
        }
    }
}


Measured memory_bytes: 27528
import math
while True:
  n = int(input())
  if n == 0:
    break
  lst = list(map(int, input().split()))
  sum = 0
  for i in range(n):
    sum += lst[i]
  m = sum/n
  sum = 0
  for i in range(n):
    sum += (lst[i] - m)**2
  var = sum/n
  print(math.sqrt(var))


Measured memory_bytes: 5696
n,m=map(int,input().split())
h=list(map(int,input().split()))

ans=list(range(n))

for j in range(m):
    a,b=map(int,input().split())
    if(h[a-1]<h[b-1]):
        ans[a-1]=-1
    elif(h[a-1]>h[b-1]):
        ans[b-1]=-1
    else:
        ans[a-1]=-1
        ans[b-1]=-1

print(sum([j>=0 for j in ans]))

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

void swap(int* x, int* y) {
	int tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
}

void isort(int b[]) {
	int c[10],max = 0, k = 0;
	for (int i = 0; i < 10; i++) {
		max = b[i];
		for (int j = i; j < 10; j++) {
			if (max < b[j]) {
				swap(&max, &b[j]);
			}
		}
		c[i] = max;
	}
	k = 0;
	while (k < 3) {
		cout << c[k] << endl;
		k++;
	}
}

int main()
{
	int a[10], i = 0;
	while (i < 10) {
		cin >> a[i];
		i++;
	}
	isort(a);
	
    return 0;
}

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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#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 log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int k; gi(k);
	k %= 10;
	if(k == 2 || k == 4 || k == 5 ||k == 7 || k == 9)pc('h');
	else if(k == 0 || k == 1 || k == 6 || k == 8) pc('p');
	else pc('b');
	pstr("on");
}


Measured memory_bytes: 3664
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repfl(i, f,l) for(int i = (f); i < (int)(l); i++)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    bool f= false;
    bool a[10][10][10]= {0};
    string s;
    int n;
    cin >> n;
    cin >> s;
    int p[3];
    int count = 0;
    rep(i,10){
        repfl(ii,0,n){
            if(s[ii]== 48+i ){
                p[0] = ii;
                f = true;
                break;
            }
        }
        if(f == true){
        rep(j,10){
            f = false;
            repfl(jj,(p[0]+1),n){
                if(s[jj]==48+j ){
                    p[1] = jj;
                    f = true;
                    break;
                }
            }
            if(f == true){
            f= false;
            rep(k,10){
                repfl(kk,(p[1]+1),n){
                    if(s[kk]==48+k){
                        count ++;
                        break;
                    }
                }
            }
            }
        }
        }    
    }
    cout << count << endl;
}

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

int n;
vector<int> g[8];

int dfs(int v,int x) {
    if (x==(1<<n)-1)
        return 1;
    int c=0;
    for (int u:g[v]) {
        if (~x&1<<u)
            c+=dfs(u,x|1<<u);
    }
    return c;
}

int main() {
    ll n,m;
    cin>>n>>m;
    if (n>=m/2)
        cout<<m/2<<endl;
    else {
        m-=n*2;
        cout<<n+m/4<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
N=int(stdin.readline().rstrip())
data=[]
dic=dict()
word=set()
for i in range(N):
    A,B=[x for x in stdin.readline().rstrip().split()]
    word.add(A)
    data.append((A,int(B),i+1))
for j in data:
    dic[j[0]] = []
for k in data:
    dic[k[0]].append((k[1],k[2]))
for l in sorted(list(word)):
    for m in sorted(dic[l],reverse=True):
        print(m[1])

Measured memory_bytes: 3064
// Problem : A - Coffee
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

int main(){
	string s;
	
	cin >> s;
	
	if (s[2] == s[3] && s[4] == s[5]){
		cout << "Yes";
	}else {
		cout << "No" << endl;
	}
	return 0;	
}


Measured memory_bytes: 256