akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    int H, W, D; cin >>H>>W>>D;
    vvi A(H, vi(W));
    unordered_map<int, pii> m;
    rep(i, H) {
        rep(j, W) {
            cin >> A[i][j];
            m[A[i][j]] = make_pair(i, j);
        }
    }
    vi cost(H*W+1, 0); // 前のマス(x-D)からあるマス(x)に移動するのに必要な累積コスト(魔力)
    rep1(x, H*W+1) {
        if (x-D >= 1) {
            int i, j, prev_i, prev_j;
            i = m[x].first;
            j = m[x].second;
            prev_i = m[x-D].first;
            prev_j = m[x-D].second;
            cost[x] = cost[x-D] + abs(i - prev_i) + abs(j - prev_j);
        }
    }

    int Q; cin >> Q;
    rep(i, Q) {
        int L, R; cin >> L >> R;
        int ans = cost[R] - cost[L];
        cout << ans << endl;
    }
}


Measured memory_bytes: 5668
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;
use std::cmp::Ordering;

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    let S = buf_it.next().unwrap().chars().collect::<Vec<_>>();
    let Q = buf_it.next().unwrap().parse::<usize>().unwrap();

    let Query = (0..Q).map(|_|
        (buf_it.next().unwrap().parse::<usize>().unwrap(),
        buf_it.next().unwrap(),
        buf_it.next().unwrap())
    ).collect::<Vec<_>>();

    let mut T = (0..26).map(|_| SegmentTree::new(N,max,0)).collect::<Vec<_>>();

    for (i,&c) in S.iter().enumerate(){
        let c = (c as usize) - ('a' as usize);
        T[c].set(i,1);
    }

    for j in 0..Q{
        if Query[j].0 == 1{
            let i = Query[j].1.parse::<usize>().unwrap() -1;
            let c = Query[j].2.chars().collect::<Vec<_>>()[0];
            let c = (c as usize) - ('a' as usize);
            for k in 0..26{
                T[k].set(i,0);
            }
            T[c].set(i,1);
        } else {
            let l = Query[j].1.parse::<usize>().unwrap() -1;
            let r = Query[j].2.parse::<usize>().unwrap();
            let mut ans = 0;
            for k in 0..26{
                ans += T[k].get(l,r);
            }
            println!("{}",ans);
        }
    }
}

struct SegmentTree<N,F>
where F:Fn(N,N) ->N{
    n: usize,
    T: Vec<N>,
    func: F,
    identity: N,
}

impl<N:Copy,F> SegmentTree<N,F>
where F:Fn(N,N) ->N {
    fn new(n:usize,func:F,identity:N) -> SegmentTree<N,F>{
        let mut T = SegmentTree { n:n,T:Vec::new(),func:func,identity:identity};
        T.init();
        T
    }
    fn init(&mut self){
        self.n = 1<<format!("{:b}",self.n-1).len();
        self.T = (0..(2*self.n-1)).map(|_| self.identity).collect();
    }
    fn set(&mut self,index:usize,value:N){
        let i = index + self.n - 1;
        self.T[i] = value;
        self._update_parent((i-1)/2);
    }
    fn _update_parent(&mut self,i:usize){
        self.T[i] = (self.func)(self.T[i*2+1],self.T[i*2+2]);
        if i>0 { self._update_parent((i-1)/2)}
    }
    fn get(&self,l:usize,r:usize) -> N{
    self._get(l,r,0,0,self.n)
    }
    fn _get(&self,l:usize,r:usize,i:usize,a:usize,b:usize) -> N{
        if l<=a && b<=r {
            self.T[i]
        } else if b<=l || r<=a {
            self.identity
        } else{
            (self.func)(self._get(l,r,2*i+1,a,(a+b)/2),
                        self._get(l,r,2*i+2,(a+b)/2,b))
        }
    }
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  ll H = nextInt();
  ll W = nextInt();
  int N = nextInt();

  map<pair<int,int>, ll> c;
  REP(i, N) 
  {
    int x = nextInt();
    int y = nextInt();
    for (int dx = -2; dx <= 0; dx++)
    for (int dy = -2; dy <= 0; dy++)
    {
      int nx = x + dx;
      int ny = y + dy;
      if (1 <= nx && nx <= H && 1 <= ny && ny <= W)
        c[{nx, ny}]++;
    }
  }
  vector<ll> ans(10);
  ans[0] = (H-2) * (W-2);
  for (auto it = c.begin(); it != c.end(); ++it) {
    // cout << it->first << " " << it->second << endl;
    int x = it->first.first;
    int y = it->first.second;
    if (1 <= x && x <= H-2 && 1 <= y && y <= W-2) {
      ans[ it->second ]++;
      ans[0]--;
    }
  }
  REP(i, 10) cout << ans[i] << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 56448
#include<stdio.h>

int main(){
 int p, q , r ;

 scanf("%d%d%d", &p , &q , &r) ;
 if(p>=q && p >=r){
    printf("%d", q+r);
 }else if(q>=p && q >=r){
    printf("%d", p+r);
 }else if(r>=p && r>=q){
    printf("%d",p+q);
 }

}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n, a, b;


int main() {
    cin >> n >> a >> b;
    repp(i, a, b + 1) {
        if (i % n == 0) {
            puts("OK");
            return 0;
        }
    }
    puts("NG");

    return 0;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }


using namespace std;

signed main() {
    int N;
    cin >> N;
    vector<int> A(N+1);
    vector<map<int, pair<int, int>>> dp(N+1);
    REPS(i, N) { 
        cin >> A[i];
    }

    dp[0][0] = mp(0, 0);

    function<int(int, int, bool)> rec = [&](int i, int j, bool used) -> int {
        if (!((i - 1) / 2 <= j && j <= (i + 1) / 2)) {
            return -LL_HALFMAX;
        }
        
        // 停止条件
        if (i == 0 && j != 0) {
            return -LL_HALFMAX;
        }

        
        // 既に評価済みのノード
        if (dp[i].count(j) == 1) {
            if (used) {
                return dp[i][j].second;
            }
            else {
                return dp[i][j].first;
            }
        }

        int f = max(rec(i - 1, j, false), rec(i - 1, j, true));
        int s = rec(i - 1, j - 1, false) + A[i];

        dp[i][j] = mp(f, s);

        return used ? s : f;
    };

    int ans = max(rec(N, (N) / 2, true), rec(N, (N) / 2, false));

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 70544
import java.util.*;

public class Main {

    public static void dfs(int color, int index, List<Edge> es, ArrayList<Integer> colors,ArrayList<ArrayList<Edge>> nodes){
       if(colors.get(index) != 100)
           return;
       colors.set(index,color);
       ArrayList<Edge> edges = nodes.get(index);
       for(int i = 0;i < edges.size();i++){
           Edge e = edges.get(i);
           if(e == null)
               break;
           if(e.from == index) {
               if (e.weight % 2 == 0){
                   dfs(color, e.to, es, colors,nodes);
               }
               else{
                   dfs(1 - color, e.to,es, colors,nodes);
               }
           }
           else if(e.to == index){
               if(e.weight % 2 == 0){
                   dfs(color,e.from,es,colors,nodes);
               }
               else{
                   dfs(1 - color,e.from,es,colors,nodes);
               }
           }
       }
    }

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Edge> edges = new ArrayList<>();
        ArrayList<ArrayList<Edge>> nodes = new ArrayList<>();

        for(int j = 0;j < N;j++)
            nodes.add(new ArrayList<>());

        for(int i = 0;i < N - 1; i++) {
            int u, v;
            long w;
            u = sc.nextInt() - 1;
            v = sc.nextInt() - 1;
            w = sc.nextLong();

            Edge e = new Edge(u,v,w);
            nodes.get(u).add(e);
            nodes.get(v).add(e);

            edges.add(e);
        }
        ArrayList<Integer> colors = new ArrayList<>(Collections.nCopies(N + 1,100));
        dfs(0,edges.get(0).from,edges,colors,nodes);


        for(int i = 0; i < N;i++)
            System.out.println(colors.get(i));
    }



  public static class Edge{
        int from;
        int to;
        long weight;

        Edge(int f,int t,long w){
            from = f;
            to = t;
            weight = w;
        }
    }






    public static Integer min(List<Integer> ar){
        int min = 10000;
        int index = 0;
        for(int i = 0; i< ar.size();i++){
            if(min > ar.get(i)){
                min = ar.get(i);
                index = i;
            }
        }
        return min;
    }
}





Measured memory_bytes: 130760
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;
int main(){
  long long kazu = 0;
  cin >> kazu;
  vector<long long> h(kazu);
  for(long long i = 0;i <= kazu - 1;i++){
    cin >> h[i];
  }
  vector<long long> dp(kazu);
  for(long long i = 0;i <= kazu - 1;i++){
    dp[i] = 1000000000000000000;
  }
  dp[0] = 0;
  for(long long i = 1;i <= kazu - 1;i++){
    dp[i] = min(dp[i],dp[i - 1] + abs(h[i] - h[i - 1]));
    if(i > 1){
     dp[i] = min(dp[i],dp[i - 2] + abs(h[i] - h[i - 2]));
    }
  }
  cout << dp[kazu - 1] << endl;
}

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

namespace ABC057A___Remaining_Time
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] time = input.Split(' ');
            //string presentTime = time[0];
            //string contestTime = time[1];
            double presentTime = double.Parse(time[0]);
            double contestTimeHourLater = double.Parse(time[1]);


            DateTime presentTimeHour = DateTime.Today.AddHours(presentTime);
            DateTime contestTimeHour = presentTimeHour.AddHours(contestTimeHourLater);

            Console.WriteLine(contestTimeHour.Hour);


        }
    }
}


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

int deck[64], buf[64];

int main(){
    int n, r, p, c;
    while (1){
	cin >> n >> r;
	if (n == 0 && r == 0) break;

	for (int i = 0; i < n; i++){
	    deck[i] = n - i; buf[i] = n - i;
	}

	for (int i = 0; i < r; i++){
	    cin >> p >> c;

	    // for blue
	    for (int j = 0; j < p-1; j++){
		buf[c+j] = deck[j];
	    }
	    // for orange
	    for (int j = 0; j < c; j++){
		buf[j] = deck[p-1+j];
	    }
	    for (int j = p + c - 1; j < n; j++){
		buf[j] = deck[j];
	    }

	    for (int m = 0; m < n; m++) deck[m] = buf[m];
	}
	cout << deck[0] << endl;

    }
}

Measured memory_bytes: 1160
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

struct Combination{
private:
    int N;
    long long M;
    vector<long long> f, i;
public:
    void init(int n, long long m){
        N = n; M = m;
        f.resize(N+1); f[0] = 0;
        i.resize(N+1); i[0] = 0;
        for(long long j=1; j<=N; j++){
            f[j] = f[j-1];
            long long tmp = j;
            while(tmp % 2 == 0){
                f[j]++;
                tmp /= 2;
            }
            i[j] = -f[j];
        }
    }
    long long C(int n, int r){
        //cout << n << " " << r << " " << f[n] << " " << i[r] << " " << i[n-r] << endl;
        if(f[n] + i[r] + i[n-r] > 0) return 0;
        else return 1;
    }
};

int N;
string S;

bool one = false;
int A[1000000];
Combination comb;

signed main(){
    cin >> N >> S;
    string T = "";
    rep(j, S.size()-1){
        T += (char)(abs(S[j]-S[j+1])+'0');
    }
    S = T;
    N--;\
    
    comb.init(N, 2);
    rep(i, N) one |= (S[i]=='1');
    if(one){
        // 答えは 0 か 1
        rep(i, N) A[i] = (S[i]-'0') % 2;
        int ans = 0;
        rep(i, N){
            if(comb.C(N-1, i) == 1) ans ^= A[i];
        }
        cout << ans << endl;
    }
    else{
        // 答えは 0 か 2
        rep(i, N) A[i] = (S[i]-'0') / 2;
        int ans = 0;
        rep(i, N){
            if(comb.C(N-1, i) == 1) ans ^= A[i];
        }
        cout << ans*2 << endl;
    }
}

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

int main (){
  string S;
  cin>>S;
  if(S[0]==S[1]||S[1]==S[2]||S[2]==S[3]){
    cout<<"Bad"<<endl;
  }
  else{
    cout<<"Good"<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll f(ll x){
    if(x==0)return 1;
    return x*f(x-1);
}
int main(void){
    // Your code here!
    ll n,a,b;
    cin>>n>>a>>b;
    if(a>b || n<1){
        cout<<0<<endl;
    }
    else {
        cout<<max((ll)0,(b-a)*(n-2)+1)<<endl;
    }
    
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Pair[] pairs = new Pair[n];
            for (int i = 0; i < n; i++) {
                long h = in.nextLong();
                long p = in.nextLong();
                pairs[i] = new Pair(h, p);
            }
            Arrays.sort(pairs);

            long[] dp = new long[n + 1];
            Arrays.fill(dp, Long.MAX_VALUE);
            dp[0] = 0;
            for (int i = 0; i < n; i++) {
                for (int j = i; j >= 0; j--) {
                    if (dp[j] <= pairs[i].x) {
                        dp[j + 1] = Math.min(dp[j + 1], dp[j] + pairs[i].y);
                    }
                }
            }

            for (int i = n; i >= 0; i--) {
                if (dp[i] != Long.MAX_VALUE) {
                    out.println(i);
                    return;
                }
            }
        }

        public class Pair implements Comparable<Pair> {
            long x;
            long y;

            Pair(long x, long y) {
                this.x = x;
                this.y = y;
            }

            public int compareTo(Pair p) {
                return Long.compare(x + y, p.x + p.y);
            }

        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 26708
#include<stdio.h>
#include<string.h>
int main(){
  char s[100];
  char t[100];
  char check[200];
  scanf("%s",s);
  scanf("%s",t);
  strcpy(check,s);
  strcat(check,s);
  if(strstr(check,t) != NULL){
    printf("Yes\n");
  }
    else{
      printf("No\n");
    }

    return 0;
  }


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

int tanishi(int n);

int main(void)
{
	int i;
	int n;
	char num[256];

	while (1){
		scanf("%d", &n);
		if (n == 0) {
			break;
		}

		sprintf(num, "%o", n);

		for (i = 0; num[i] != '\0'; i++) {
			if (num[i] >= '4'){
				num[i]++;
			}
			if (num[i] >= '6'){
				num[i]++;
			}
		}

		printf("%s\n", num);
	}

	return (0);
}

Measured memory_bytes: 620
s = input()
T = input()

slen = len(s)
Tlen = len(T)
ans = "UNRESTORABLE"
if slen >= Tlen:
    for i in range(slen - Tlen + 1)[::-1]:
        for j in range(Tlen):
            if not s[i+j] in ("?", T[j]):
                break
        else:
            ans = s
            ans = ans[:i] + T + ans[i+Tlen:]
            ans = ans.replace("?", "a")
            break

print(ans)

Measured memory_bytes: 3064
# ABC071 C - Sentou
N,TT = map(int,input().split())
T = list(map(int,input().split()))

ans = 0
start = 0

if len(T) == 1:
    ans = TT + T[0]
    print(ans)
    exit()

for i in range(N-1):
    if i == N-2:
        if T[i+1]-T[i] >= TT:
            ans += TT
        else:
            ans += TT+T[i+1]-start
    if T[i+1]-T[i] >= TT:
        ans += TT+T[i]-start
        start = T[i+1]
    elif T[i+1]-T[i] < TT:
        pass
print(ans)

Measured memory_bytes: 25708
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  if(A>=13){
    cout << B;
  }
  else if(A<=12&&A>=6){
    cout << B/2;
  }
  else{
    cout << 0;
  }
}

Measured memory_bytes: 256
n = int(input())
taro_sum = 0
hanako_sum = 0
for i in range(n):
    a, b = input().split()
    if a > b:
        taro_sum += 3
    elif a < b:
        hanako_sum += 3
    else:
        taro_sum += 1
        hanako_sum += 1
print(taro_sum, hanako_sum)



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

map<unsigned int, int> match;
set<unsigned int> road;

//flag : whether road between left and right is available
int countMatching(unsigned int left, unsigned int right, bool flag = true){
  //cout << "call "<< (flag ? "t " : "f ") << left << " " << right << endl;
  if(right - left == 1 || right - left == -1){
    return 1;
  }
  //memo check
  if(match.find((left << 16) + right) != match.end()){
    return match[(left << 16) + right];
  }
  
  long long result = -1;
  //Get leftest road
  set<unsigned int>::iterator froad = road.lower_bound((left + 1 << 16) - right + !flag);
  //There is no inner road in the segment.
  if(froad == road.end() || *froad >> 16 >= right ){
    result = 1;
  }else{
    unsigned int nleft = *froad >> 16, nright = 0x10000 - *froad & 0xFFFF;
    if((left & 1) == (nleft & 1)){
      if(match.find((nleft << 16) + nright) != match.end()){
        result = match[(nleft << 16) + nright];
      }else{
        result = countMatching(nleft + 1, nright - 1) + countMatching(nleft, nright, false);
      }
      result *= countMatching(nright + 1, right);
    } else {
      result = countMatching(nleft + 1, nright - 1);
      result *= countMatching(nright, right);
    }
    result %= 1000003;
  }
  if(flag){
    match[(left << 16) + right] = result;
  }
  //cout << (flag ? "t " : "f ") << left << " " << right << " : " << result << endl; 
  return result;
}

int main(){
  int N, M;
  while(true){
    cin >> N >> M;
    //end of cases
    if(N == 0 && M == 0){
      break;
    }
    match.clear();
    road.clear();
    for(int i = 0; i < M; i++){
      int start, end;
      cin >> start >> end;
      //Start and End should be between 0 and N-1
      start--; end--;
      //Skip roads which has odd number of nodes between its Start and End.
      if((start - end) % 2 == 0){
        continue;
      }
      if(start < end){
        road.insert(((start + 1) << 16) - end);
      }else{
        road.insert(((end + 1) << 16) - start);
      }
    }
    if(N & 1){
      cout << 0 << endl;
      continue;
    }
    if(road.size() == 0){
      cout << 2 << endl;
      continue;
    }
    int result = countMatching(0, N-1) + countMatching(1, N-2);
    cout << result % 1000003 << endl;
  }
  return 0;
}

Measured memory_bytes: 6076
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>
#include <set>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    ll N, K;
    cin >> N >> K;
    map<ll, ll> countMap;
    set<ll> elementSet;
    REP(i, N)
    {
    	ll a, b;
    	cin >> a >> b;
    	elementSet.insert(a);
    	auto itr = countMap.find(a);
    	if (itr != countMap.end())
    	{
    		countMap[a] += b;
    	}
    	else {
    		countMap[a] = b;
    	}
    }

    // set から vector に変換し昇順にソートする
    vector<ll> elementVec(elementSet.begin(), elementSet.end());
    sort(elementVec.begin(), elementVec.end());

    ll count = 0;
    int ans;
    for (int i = 0; i < elementVec.size(); ++i)
    {
    	if (count <= K && count + countMap[elementVec[i]] >= K)
    	{
    		ans = elementVec[i];
    		break;
    	}
    	else{
    		count += countMap[elementVec[i]];
    	}
    }

    cout << ans << endl;
}


Measured memory_bytes: 7680
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit
from collections import Counter


def main(readline=stdin.readline):
    count = Counter()
    member = []

    while 1:
        n = int(readline())
        if not n:
            exit()

        count.clear()
        del member[:]

        for _ in range(n):
            i, price, num = (int(s) for s in readline().split())
            count[i] += price * num
            if i not in member:
                member.append(i)

        member = [i for i in member if count[i] >= 1000000]

        if member:
            print(*member, sep='\n')
        else:
            print('NA')


if __name__ == '__main__':
    main()

Measured memory_bytes: 4736
lines = []

while line = gets
  lines << line.chomp.split(' ')
end

lines_i = lines.map { |l| l.map(&:to_i) }
target = lines_i[1]

# 4〜lastまでの数値入れ替え+合計値算出
lines_i.each_with_index do |_line, i|
  next if i < 3

  p target.sum - (target[_line[0] - 1] - _line[1])
end


Measured memory_bytes: 14044
N = int(input())
lia=[int(it) for it in input().split()]
lib=[int(it) for it in input().split()]
lip=[lia[i]-lib[i] for i in range(N)]
sb = 0
for i in range(N):
  if (lip[i]>0):
    sb+=lip[i]
sa2 = 0
for i in range(N):
  if (lip[i]<0):
    sa2+=(-lip[i])//2
x = sum(lib)-sum(lia)
if (x<0):
  print ("No")
else:
  if (sa2>=sb):
    print ("Yes")
  else:
    print ("No")


Measured memory_bytes: 4600
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
    int h,w;
    cin>>h>>w;
    vvi f(h+2,vi(w+2,1));
    vvi walk(h+2,vi(w+2,0));
    int gy,gx,y=0,x=0,v=0;
    range(i,1,h+1)range(j,1,w+1){
        char c;
        cin>>c;
        switch(c){
            case 'G': gy=i,gx=j,f[i][j]=0; break;
            case '.': f[i][j]=0;break;
            case '#': break;
            case '^': y=i,x=j,v=0,f[i][j]=0; break;
            case '>': y=i,x=j,v=1,f[i][j]=0; break;
            case 'v': y=i,x=j,v=2,f[i][j]=0; break;
            case '<': y=i,x=j,v=3,f[i][j]=0; break;
        }
    }
    walk[y][x]=1;
    rep(loop,6000000){//2646
        vvi vec={{-1,0},{0,1},{1,0},{0,-1}};
        if(f[y+vec[(v+1)%4][0]][x+vec[(v+1)%4][1]]==0){
            v=(v+1)%4;
            y+=vec[v][0], x+=vec[v][1];
            walk[y][x]=1;
        }else if(f[y+vec[v][0]][x+vec[v][1]]==1){
            v=(v+3)%4;
        }else{
            y+=vec[v][0],x+=vec[v][1];
            walk[y][x]=1;
        }
        if(y==gy&&x==gx){
            break;
        }
    }
    if(y==gy&&x==gx){
        int ans=0;
        rep(i,h+2)rep(j,w+2)ans+=walk[i][j];
        cout<<ans<<endl;
    }else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3192
import math

def NumOfDigit(X):
    i=0
    while X>0:
        X//=10
        i+=1
    return i

def F(A,B):
    return max(NumOfDigit(A),NumOfDigit(B))

if __name__=="__main__":
    N=int(input())

    A,B=1,1
    now_min=NumOfDigit(N)
    while A<=math.sqrt(N):
        if N%A==0:   #Bは整数か？
            B=N/A     #A*B=Nが成立

            result=F(A,B)
            if result<now_min:
                now_min=result

        A+=1

    print(now_min)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <ctime>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

struct Point{
    vector<ll> x;
};

int main()
{
    // 整数の入力
    ll N,total;
    cin >> N;
    if (N < 10){
        cout <<  N << endl;
    }else if(N <100){
        cout << 9 << endl;
    }else if (N < 1000){
        cout <<  N - 99 + 9 << endl;
    }else if (N < 10000){
        cout <<  999 - 99 + 9 << endl;
    }else if (N < 100000){
        cout <<  N - 9999 + 999 - 99 + 9 << endl;
    }else{
        cout <<  99999 - 9999 + 999 - 99 + 9 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    H = il()
    tmp = -1
    for n in range(N):
        if tmp > H[n]:
            if tmp == H[n] + 1:
                tmp = H[n] + 1
            else:
                print('No')
                break
        else:
            tmp = H[n]

    else:
        print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 12992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	int t = v[0];
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		if (v[i-1] <= v[i]) continue;
		int d = v[i-1] - v[i];
		ans += d;
		v[i] = v[i-1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 4044
/*
        Author: Prokash
                CSE48, JU

*/

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

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll n=100005;
int main()
{
    FAST;
    map<ll,ll>mp;
    ll i,t,ans=0,in;
    cin>>t;
    while(t--)
    {
        cin>>in;
        mp[in]++;
    }
    for(i=0;i+2<=n;i++)
    {
        ans=max((mp[i]+mp[i+1]+mp[i+2]),ans);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int a,b,c,d,ans;
    cin >> a>>b>>c>>d;
    int start,end;
    start = ::max(a,c);
    end = ::min(b,d);
    if(end-start < 0){
        ans = 0;
    }else{
        ans = end-start;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3532
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <deque>
#include <queue>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N;
    cin >> N;
    int tmp;
    queue<int> a;
    deque<int> b;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        a.push(tmp);
    }
    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0)
        {
            b.push_back(a.front());
            a.pop();
        }
        else
        {
            b.push_front(a.front());
            a.pop();
        }
    }
    if (N % 2 == 0)
    {
        while (!b.empty())
        {
            cout << b.front() << " ";
            b.pop_front();
        }
    }
    else
    {
        while (!b.empty())
        {
            cout << b.back() << " ";
            b.pop_back();
        }
    }
    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
using namespace std;
int main(void){
    int n,x;
    cin>>n>>x;
    if(x<=1||x>=2*n-1){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
        if(n==2){
            cout<<1<<endl<<2<<endl<<3<<endl;
        }else{
            for(int i=1,c=1;i<=2*n-1;i++){
                if(i==n-2&&x<=2*n-3){
                    cout<<x+2<<endl;
                }else if(i==n-1){
                    cout<<x-1<<endl<<x<<endl<<x+1<<endl;
                    i=n+1;
                }else if(i==n+2&&x>=3){
                    cout<<x-2<<endl;
                }else{
                    if((c==x-2&&x>=3)||c==x-1){
                        c=x+2;
                    }
                    
                    if(c==x+2&&x<=2*n-3){
                        c=x+3;
                    }
                    cout<<c<<endl;
                    c++;
                }
                
            }
        }
    }
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

int main(void)
{
	int n, c, k;
	cin >> n >> c >> k;
	vec<int> t(n);
	rep(i, n) cin >> t[i];
	sort(t.begin(), t.end());

	int num = 0;
	int left = t[0];
	int ans = 0;
	rep(i, n) {
		if (num == c || left + k < t[i]) {
			num = 1;
			left = t[i];
			ans++;
		} else {
			num++;
		}
	}
	ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = [[INT(), i] for i in range(N)]

A.sort(key = lambda x:x[0])

cnt = 0
for i, (x, idx) in enumerate(A):
	if i%2 != idx%2:
		cnt += 1

print(cnt//2)

Measured memory_bytes: 26888
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int T1, T2, R1, R2;
	
	cin>>T1>>T2>>R1>>R2;
	
	if(R1 != -1 && R2 != -1){
		if(R1 > R2) cout<<"Alice"<<endl;
		else if(R1 < R2) cout<<"Bob"<<endl;
		else cout<<"Draw"<<endl;
	} else {
		if(T1 < T2) cout<<"Alice"<<endl;
		else if(T2 < T1) cout<<"Bob"<<endl;
		else cout<<"Draw"<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3216
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define int long long

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    ll a[330], sum = 0;
    rep(i, N) {
        cin >> a[i];
        sum += a[i];
    }
    ll all = 1LL, hoshugo = 0;
    rep(i, N) {
        all *= 3LL;
        all %= mod;
    }
    vector<vector<ll>> dp(N + 1, vector<ll>(sum + 1, 0));
    auto dp2 = dp;
    dp[0][0] = 1LL; dp2[0][0] = 1LL;
    rep(i, N) {
        rep(s, sum + 1) {
            if(s - a[i] >= 0) {
                (dp[i + 1][s] += dp[i][s - a[i]]) %= mod;
                (dp2[i + 1][s] += dp2[i][s - a[i]]) %= mod;
            }
            (dp[i + 1][s] += 2 * dp[i][s]) %= mod;
            (dp2[i + 1][s] += dp2[i][s]) %= mod;
        }
    }
    Rep(s, (ll)(sum + 1) / 2, sum + 1) {
        (hoshugo += dp[N][s] * 3) %= mod;
    }
    if(sum % 2 == 0) {
        hoshugo -= 3 * dp2[N][sum / 2];
        hoshugo = (hoshugo + 4 * mod) % mod;
    }
    ll ans = all - hoshugo;
    cout << (ans + mod) % mod << endl;
	return 0;
}

Measured memory_bytes: 423104
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

int main() {
    int N,M,t;
    ll mod=1e9+7;
    cin >> N >> M;
    Vi vs(N),vt(M);
    vector<Vi> a(N,Vi(M,0));
    REP(i,N) {
        cin >> vs[i];
    }
    REP(i,M) {
        cin >> vt[i];
        }
    
    ll ans;
    vector<Vl> dp(N+1, Vl(M+1,0));
    vector<Vl> sum(N+1, Vl(M+1,0));
    for (int i = 0; i < N; ++i){
        for (int j = 0; j < M; ++j){
            if (vs[i] == vt[j]) dp[i+1][j+1] = (sum[i][j] + 1)%mod;
            sum[i+1][j+1] = (sum[i+1][j] + sum[i][j+1] - sum[i][j] + mod + dp[i+1][j+1])%mod;
            }
    }
    ans = (sum[N][M] + 1)%mod;
    cout << ans << endl;
}

Measured memory_bytes: 78720
fun main(args: Array<String>) {
    abc112d()
}

fun abc112d() {
    val (n, m) = readLine()!!.split(' ').map { it.toLong() }

    for (i in m / n downTo 1) {
        if (m % i == 0L && m / i >= n) return println(i)
    }
}


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

int n,K;
int main () {
    cin>>n;
    K=-1;
    bool ok = false;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (n == i * j) {
                K=1;
            }
        }
    }
    
    if (K == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main (String [] args){
		List <Integer> list = new ArrayList<Integer>();
		HashMap <Integer, Integer>hm = new HashMap<Integer, Integer>();
		int v1 = Integer.parseInt(sc.next());
		int v2 = Integer.parseInt(sc.next());		
		int v3 = Integer.parseInt(sc.next());
		String ans_str = "";
		if((v1+v2)>=v3){
			ans_str = "Yes";
		}else{
			ans_str = "No";
		}
		System.out.println(ans_str);
		System.out.flush();
		sc.close();
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <stdio.h>

using namespace std;
typedef pair<int, int> P;

int n, m;
vector<P> vec[100005];
int pre[100005];
int rnk[100005];

int main(void)
{
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int p, y;
		cin >> p >> y;
		pre[i] = p;
		vec[p].push_back(make_pair(y, i));
	}
	
	for(int i = 1; i<= n; i++) sort(vec[i].begin(), vec[i].end());
	for(int i = 1; i<=n ; i++){
		for(int j = 0; j < vec[i].size(); j++){
			rnk[vec[i][j].second] = j+1;
		}
	}
	
	for(int i = 0; i < m; i++){
		printf("%06d%06d\n", pre[i], rnk[i]);
	}
	return 0;
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a=-1;bool b=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='C'){
			a=i;
		}
	}
	if(a==-1){
		cout<<"No";
		return 0;
	}
	
	for(int i=0;i<s.size();i++){
		if(s[i]=='F'&&i>a){
			b=1;
		}
	}
	if(b==0){
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>

using namespace std;

int main(){
	int W, H, N;
	cin >> W >> H >> N;
	
	int box[101][101] = {};

	while(N-- > 0){
		int x, y, a;
		cin >> x >> y >> a;
		for(int i = 1; i <= 100; ++i){
			for(int j = 1; j <= 100; ++j){
				if((a == 1 && i <= x) || (a == 2 && i > x) || (a == 3 && j <= y) || (a == 4 && j > y)){
					box[i][j] = 1;
				}
			}
		}
	}
	
	int ans = 0;
	for(int i = 1; i <= W; ++i){
		for(int j = 1; j <= H; ++j){
			if(box[i][j] != 1){
				ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
(let ((lst (list (read) (read) (read)))
      (lnth (read))
      (ans "Yes"))
  (cond ((<= (abs (- (first lst) (third lst))) lnth) nil)
        ((and (<= (abs (- (first lst) (second lst))) lnth) (<= (abs (- (second lst) (third lst))) lnth)))
        (t (setq ans "No")))
  (princ ans))

Measured memory_bytes: 3944
def surround(h, w):
    ret = 0
    for i in [-1, 0, 1]:
        ret += int(ans[h-1][w+i]=="#")
        ret += int(ans[h+1][w+i]=="#")
    for i in [-1, 1]:
        ret += int(ans[h][w+i]=="#")
    return str(ret)


Height, Width = map(int, input().split())
ans = [list(input()) for _ in range(Height)]
ans = [["."]*Width] + ans + [["*"]*Width]
# print(ans)
for i in range(Height+2):
    ans[i] = ["."] + ans[i] + ["."]
for h in range(1, Height+1):
    for w in range(1, Width+1):
        if ans[h][w] == "#":
            continue
        ans[h][w] = surround(h, w)

ans = ans[1:-1]
for i in range(Height):
    print("".join(ans[i][1:-1]))

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <bitset>
#include <queue>
#include <utility>
#include <functional>
#include <sstream>
using namespace std;
#define ll long long
 
int main(void){
    ll n;
    cin >> n;
    ll a[n], b[n];
    for(ll i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    ll ans = 0;
    for(ll i = n-1; i >= 0; i--){
        if((a[i]+ans)%b[i]!=0)
            ans += b[i]-(a[i]+ans)%b[i];
    }
    cout <<  ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	long a = Long.parseLong(scan.next());
	long b = Long.parseLong(scan.next());
	long x = Long.parseLong(scan.next());

	long ans = 0;
	long q = a / x;
	long min = (a % x == 0 ? q * x : (q+1) * x);
	if(min <= b) {
	    ans++;
	    ans += (b-min) / x;
	}
	    
	System.out.println(ans);
	scan.close();
    }
}


Measured memory_bytes: 23636
rang = int(input())
words = []
for i in range(rang):
    words.append(input())

d = {w: 0 for w in words}
m = 0
for w in words:
    d[w] += 1
    if (d[w] > m):
         m = d[w]
most = [k for k,v in d.items() if v == m]

most.sort()
for wrd in most:
    print(wrd)


Measured memory_bytes: 35216
package main

import (
	"fmt"
	"bufio"
	"os"
	"strings"
)

func main(){
	var scanner = bufio.NewScanner(os.Stdin)

	var strs []string 
	if scanner.Scan() {
		strs = strings.Split(scanner.Text(), " ")
	}
	a,b,c := strs[0][0], strs[1][0], strs[2][0]
	
	fmt.Printf("%c%c%c", a,b,c)
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static void main(String[] args){
  	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int largest = Integer.MIN_VALUE;
    int second =  Integer.MIN_VALUE;
    int[] arr = new int[n];
    int val;
    for (int i=0; i<n;i++){
      val = sc.nextInt();
      arr[i] = val;
      if (val > largest){
        second = largest;
        largest = val;
        
      } else if (second < val) {
        second = val;
      }
      
    }
    for (int num:arr){
      if (num == largest){
        System.out.println(second);
    } else{ System.out.println(largest);}
                           }
  }
}

Measured memory_bytes: 86780
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	String str = sc.next();
		char c = str.charAt(0);
      	if(Character.isUpperCase(c)){
       		System.out.println("A");
        }else{
        	System.out.println("a");
        }
	}
}

Measured memory_bytes: 35672
package main
import (
	"fmt"
)

type ints []int
func (is ints)insertionSort(){
	for i:=1; i<len(is); i++{
		v := is[i]
		j := i-1
		for j>=0 && is[j]>v{
			is[j+1]=is[j]
			j--
		}
		is[j+1]=v
		is.printme()
	}
}
func (is ints)printme(){
	for i, v := range is{
		fmt.Print(v)
		if i<len(is)-1{
			fmt.Print(" ")
		}
	}
	fmt.Println()
}

func main(){
	var n int
	fmt.Scan(&n)
	var numbers ints
	for i:=0; i<n; i++{
		var x int
		fmt.Scan(&x)
		numbers = append(numbers, x)
	}
	numbers.printme()
	numbers.insertionSort()
}


Measured memory_bytes: 1220