akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
#define mp make_pair
#define pb push_back
#define debug(x) cerr << #x << " = " << x << " "

const int N = 2e5+1;
struct DSU
{
  int p[N];
  void init(int n)
  {
    for (int i = 1; i <= n; ++i) p[i] = i;
  }
  int pa(int x)
  {
    return x==p[x]?x:p[x]=pa(p[x]);
  }
} dsu[2];

namespace DSU0
{
  void init(int n)
  {
    dsu[0].init(n);
  }
  void merge(int x, int y)
  {
    x = dsu[0].pa(x), y = dsu[0].pa(y);
    if (x != y)
      {
	dsu[0].p[x] = y;
      }
  }
}

namespace DSU1
{
  vector<int> v[N];
  map<int, int> ma[N];
  void init(int n)
  {
    dsu[1].init(n);
    for (int i = 1; i <= n; ++i) v[i] = vector<int>(1, i);
  }
  void merge(int x, int y)
  {
    x = dsu[1].pa(x), y = dsu[1].pa(y);
    if (x != y)
      {
	if (v[x].size() > v[y].size()) swap(x, y);
	v[y].insert(v[y].end(), v[x].begin(), v[x].end());
	// do we need to delete v[x]?
	dsu[1].p[x] = y;
      }
  }
  void sort(int n)
  {
    for (int i = 1; i <= n; ++i)
      if (dsu[1].p[i] == i)
	{
	  for (auto e : v[i])
	    ++ma[i][dsu[0].pa(e)];
	}
  }
}

void merge(int id, int x, int y)
{
  if (id == 0) DSU0::merge(x, y);
  else if (id == 1) DSU1::merge(x, y);
  else assert(false);
}
int main()
{
  int n;
  int sz[2];
  scanf("%d %d %d", &n, sz+0, sz+1);
  DSU0::init(n);
  DSU1::init(n);
  for (int id = 0; id < 2; ++id)
    for (int i = 0; i < sz[id]; ++i)
      {
	int u, v; scanf("%d %d", &u, &v);
	merge(id, u, v);
      }
  DSU1::sort(n);
  for (int i = 1; i <= n; ++i)
    {
      int pa0 = dsu[0].pa(i);
      int pa1 = dsu[1].pa(i);
      printf("%d%c", DSU1::ma[pa1][pa0]," \n"[i==n]);
    }
}


Measured memory_bytes: 30848
#include<stdio.h>
void trace(int A[],int N){
  int i;
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}
void insertionSort(int A[],int N){
  int j,i,v;
  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    trace(A,N);
  }
}
int main(){
  int N,i,j;
  int A[100];
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);
  trace(A,N);
  insertionSort(A,N);
  return 0;
}



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

int dp[10000][10000];
int hole[10000][10000]; // (from) 0:none, 1: x, 2 : y, 3 : x, y
int calced[10000][10000];

int solve(int x, int y){
	if (x < 0 || y < 0)return 0;
	if (x == 0 && y == 0)return 1;
	if (calced[x][y] == 1)return dp[x][y];

	switch (hole[x][y]) {
	case 0:
		calced[x][y] = 1;
		return dp[x][y] = solve(x - 1, y) + solve(x, y - 1);
		break;
	case 1:
		calced[x][y] = 1;
		return dp[x][y] = solve(x, y - 1);
		break;
	case 2:
		calced[x][y] = 1;
		return dp[x][y] = solve(x - 1, y);
		break;
	case 3:
		calced[x][y] = 1;
		return dp[x][y] = 0;
		break;
	}
}


int main() {
	int i, j, k, n, p, gx, gy, x1, x2, y1, y2, ans;

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> gx >> gy;
		for (j = 0; j <= gx; j++) {
			for (k = 0; k <= gy; k++) {
				dp[j][k] = 0;
				hole[j][k] = 0;
				calced[j][k] = 0;
			}
		}
		cin >> p;
		for (j = 0; j < p; j++) {
			cin >> x1 >> y1 >> x2 >> y2;
			if (x1 > x2) {
				swap(x1, x2);
				swap(y1, y2);
			} else if (y1 > y2) {
				swap(x1, x2);
				swap(y1, y2);
			}
			if (x2 != x1) {
				hole[x2][y2] += 1;
			} else {
				hole[x2][y2] += 2;
			}
		}
	
		ans = solve(gx, gy);

		if (ans == 0) {
			cout << "Miserable Hokusai!" << endl;
		} else {
			cout << ans << endl;
		}
		
		


	}




	return 0;
}

Measured memory_bytes: 3156
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n, h, w;
	cin >> n >> h >> w;
	vector<int> a(n);
	vector<int> b(n);
	int cnt = 0;
	for ( int i = 0; i < n; i++ ) {
		cin >> a[i] >> b[i];
	}
	for ( int i = 0; i < n; i++ ) {
		if ( a[i] >= h && b[i] >= w ) cnt++;
	}		

	cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    boolean result=false;
   for(int i=0;i<10;i++){
   	for(int j=0;j<10;j++){
      if(A==i*j){
      result=true;
  	 }
    }
   }
    if(result==true){
    System.out.println("Yes");
    }else{
     System.out.println("No");
    }
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void){
  string s[3];
  for(int i = 0; i < 3; i++)
    cin >> s[i];
  
  int count = 0;
  int next = 0;
  int nnext;
  while(count < 100000){
    if(s[next][0]=='a') nnext = 0;
    else if(s[next][0]=='b') nnext = 1;
    else if(s[next][0]=='c') nnext = 2;
    s[next].erase(s[next].begin());
    next=nnext;
    if(s[next].length()==0)
      break;
    count++;
  }
  if(next==0)
    cout << 'A' << endl;
  else if(next==1)
    cout << 'B' << endl;
  else if(next==2)
    cout << 'C' << endl;
    return 0;
}

Measured memory_bytes: 256
N = input()
AB = []
NGflag = 0
for i in range(N):
	a,b = map(int, raw_input().split())
	AB.append((a,b))
ABsort =sorted(AB,key = lambda x:x[1])
now = 0
for item in ABsort:
	now += item[0]
	if now > item[1]:
		NGflag = 1
		break
if NGflag == 0:
	print("Yes")
else:
	print("No")

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

class Program
{
    static void Main()
    {
        while (true)
        {
            sbyte[] l = Console.ReadLine().Split(' ').Select(x => sbyte.Parse(x)).ToArray();
            if (l[0] + l[1] + l[2] == -3) break;

            if (l[0] == -1 || l[1] == -1 || l[0] + l[1] < 30)
            {
                Console.WriteLine("F");
            }
            else if (l[0] + l[1] < 50 && l[2] < 50)
            {
                Console.WriteLine("D");
            }
            else if (l[0] + l[1] < 65)
            {
                Console.WriteLine("C");
            }
            else if (l[0] + l[1] < 80)
            {
                Console.WriteLine("B");
            }
            else
            {
                Console.WriteLine("A");
            }
        }
    }
}

Measured memory_bytes: 9272
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a, b; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> a >> b;
		if (a % b == 0) {
			cout << b << endl;
		}
		else {
			cout << a % b << endl;
		}
	}
	cin >> n;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, A, B;
    ll temp, temp2;
    cin >> N >> A >> B;
    temp = N / (A + B) * A;
    temp2 = min(A, N % (A + B));
    cout << temp + temp2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const int INF = INT_MAX;

struct Edge {
  int to;
  int cap;
  int rev;

  Edge(int to = -1, int cap = -1, int rev = -1) {
    this->to = to;
    this->cap = cap;
    this->rev = rev;
  }
};

const int MAX_N = 100;
const int MAX_V = MAX_N * MAX_N + 10;
bool used[MAX_V];
vector <Edge> G[MAX_V];

void add_edge(int from, int to, int cap) {
  G[from].push_back(Edge(to, cap, G[to].size()));
  G[to].push_back(Edge(from, 0, G[from].size() - 1));
}

int dfs(int v, int t, int f) {
  if (v == t) return f;

  used[v] = true;

  for (int i = 0; i < (int) G[v].size(); ++i) {
    Edge *e = &G[v][i];

    if (!used[e->to] && e->cap > 0) {
      int d = dfs(e->to, t, min(f, e->cap));
      if (d > 0) {
        e->cap -= d;
        G[e->to][e->rev].cap += d;
        return d;
      }
    }
  }

  return 0;
}

int max_flow(int s, int t) {
  int flow = 0;

  for (;;) {
    memset(used, 0, sizeof(used));
    int f = dfs(s, t, INF);
    if (f == 0) return flow;
    flow += f;
  }
}

int DY[4] = {-1, 0, 1, 0};
int DX[4] = {0, 1, 0, -1};

int main() {
  int N, M;
  memset(used, false, sizeof(used));
  cin >> N >> M;

  string grid[N];
  string row;

  for (int i = 0; i < N; ++i) {
    cin >> row;
    grid[i] = row;
  }

  int s = 0;
  int t = MAX_V - 1;

  for (int y = 0; y < N; ++y) {
    for (int x = 0; x < M; ++x) {
      int u = y * M + x + 1;

      if (grid[y][x] == '#') continue;
      if ((y + x) % 2 != 0) {
        add_edge(u, t, 1);
        continue;
      }

      add_edge(s, u, 1);

      for (int i = 0; i < 4; ++i) {
        int ny = y + DY[i];
        int nx = x + DX[i];

        if (ny < 0 || nx < 0 || N <= ny || M <= nx) continue;
        if (grid[ny][nx] == '#') continue;

        int v = ny * M + nx + 1;

        add_edge(u, v, 1);
      }
    }
  }

  cout << max_flow(s, t) << endl;

  for (int y = 0; y < N; ++y) {
    for (int x = 0; x < M; ++x) {
      if ((y + x) % 2 != 0) continue;
      int u = y * M + x + 1;

      for (Edge edge : G[u]) {
        if (edge.to == 0 || edge.cap != 0) continue;

        int ny = (edge.to - 1) / M;
        int nx = (edge.to - 1) % M;

        if (abs(u - edge.to) < M) {
          if (x < nx) {
            grid[y][x] = '>';
            grid[ny][nx] = '<';
          } else {
            grid[y][x] = '<';
            grid[ny][nx] = '>';
          }
        } else {
          if (y < ny) {
            grid[y][x] = 'v';
            grid[ny][nx] = '^';
          } else {
            grid[y][x] = '^';
            grid[ny][nx] = 'v';
          }
        }
      }
    }
  }

  for (int y = 0; y < N; ++y) {
    cout << grid[y] << endl;
  }

  return 0;
}


Measured memory_bytes: 5380
#include <iostream>

// 桁数を求める
int findDigits(int n, int k)
{
    int rtn = 0;
    while (n > 0) {
        rtn++;
        n /= k;
    }
    return rtn;
}

int main()
{
    int n = 0;
    int k = 0;
    std::cin >> n >> k;

    int result = findDigits(n, k);
    std::cout << result << std::endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	N := sc.NextInt()
	v := make([]int, N)
	for i := 0; i < N; i++ {
		v[i] = sc.NextInt()
	}
	ans := 0
	plus := false
	next := true
	for next {
		next = false
		plus = false
		for i := 0; i < len(v); i++ {
			if v[i] > 0 {
				next = true
				if !plus {
					plus = true
					ans++
				}
			}
			if v[i] == 0 {
				plus = false
			}
			v[i] = max(0, v[i]-1)
		}
	}
	fmt.Println(ans)
}

func vmin(v []int) int {
	mn := math.MaxInt32
	for i := 0; i < len(v); i++ {
		mn = min(mn, v[i])
	}
	return mn
}

func lcm(x, y int) int {
	x, y = max(x, y), min(x, y)
	if y == 0 {
		return x
	}
	return lcm(y, x%y)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<pair<int, int>>;
using VTIII = vector<tuple<int, int, int>>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N;
map<string, int> m;


signed main(){
    cin >> N;
    rep(i, 0, N){
        string S;
        cin >> S;
        m[S] = 1;
    }

    cout << SZ(m) << endl;

    return 0;
}

Measured memory_bytes: 19188
n=int(input())
ans=len(str(n))
from math import floor,sqrt
s=floor(sqrt(n))
f=[]
ans=len(str(n))
for i in range(2,s+1):
    if n%i==0:
        t=max(len(str(i)),len(str(n//i)))
        if t<ans:
            ans=t
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    string s;
    cin >> s;
    reverse(all(s));

    vector<string> v = {"dream", "dreamer", "erase", "eraser"};
    for(auto& i : v) reverse(all(i));

    string ans = "YES";
    int i = 0;
    while(i < s.length()){
        if(s.substr(i, 7) == v[1]) i += 7;
        else if(s.substr(i, 6) == v[3]) i += 6;
        else if(s.substr(i, 5) == v[0] || s.substr(i, 5) == v[2]) i += 5;
        else{
            ans = "NO";
            break;
        }
    }

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

Measured memory_bytes: 512
#include <stdio.h>

using namespace std;
typedef long long llong;

#define MAX
const llong mod = 1000000000 + 7;

int main()
{
  int tmp;
  int X, Y, Z;
  scanf("%d", &X);
  scanf("%d", &Y);
  scanf("%d", &Z);

  tmp = X;
  X = Y;
  Y = tmp;

  tmp = X;
  X = Z;
  Z = tmp;

  printf("%d %d %d\n", X, Y, Z);

  return 0;
}

Measured memory_bytes: 1700
A, B, C, X, Y = map(int, raw_input().split())

if A+B<2*C:
    sum=A*X+B*Y
else:
    sum=2*C*min(X,Y) + A*(X-(min(X,Y))) + B*(Y-(min(X,Y)))
    if sum > C*max(X,Y)*2:
        sum=C*max(X,Y)*2

print sum

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var Mod = 1000000007;
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int H = l[0], W = l[1];
            bool rowSharp = false, colSharp = false;
            var dp = new long[H, W];
            for (var i = 0; i < H; i++) {
               var s = Console.ReadLine();
               for (var j = 0; j < W; j++) {
                   if (i == 0) {
                      if (s[j]=='#') break;
                       dp[i, j] = 1;
                   } else {
                      if (j == 0) {
                          if (s[j]=='#') rowSharp = true;
                          else if (!rowSharp) dp[i, j] = 1;
                          continue;
                      }
                      if (s[j]=='.') {
                          dp[i, j] += dp[i-1, j];
                          dp[i, j] %= Mod;
                          dp[i, j] += dp[i, j-1];
                          dp[i, j] %= Mod;
                      }
                   }
               }
               //for (var v = 0; v < W; v++)
               //    Console.Write(dp[i,v]);
               //Console.WriteLine();
            }
            
            Console.WriteLine(dp[H-1, W-1]);
        }
    }
}


Measured memory_bytes: 23004
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{

			//最初の行の数値を読み取る。
			String[] strLine = insBR.readLine().split(" ");
			int[] intLine = new int[strLine.length];
			for(int i = 0; i < strLine.length; i++){
				intLine[i] = Integer.parseInt(strLine[i]);
			}
			int intN = intLine[0];
			int intM = intLine[1];
			int intL = intLine[2];

			//n×m の行列 A
			int[][] intA = new int[intN][intM];
			for(int i = 0; i < intN; i++){
				strLine = insBR.readLine().split(" ");
				for(int j = 0; j < intM; j++){
					intA[i][j] = Integer.parseInt(strLine[j]);
				}
			}

			//m×l の行列 B
			int[][] intB = new int[intM][intL];
			for(int i = 0; i < intM; i++){
				strLine = insBR.readLine().split(" ");
				for(int j = 0; j < intL; j++){
					intB[i][j] = Integer.parseInt(strLine[j]);
				}
			}

			//n×l の行列 C
			long[][] longC = new long[intN][intL];
			for(int i = 0; i < intN; i++){
				for(int j = 0; j < intL; j++){
					for(int k = 0; k < intM; k++){
						longC[i][j] += intA[i][k] * intB[k][j];
					}
				}
			}

			for(int i = 0; i < intN; i++){
				for(int j = 0; j < intL; j++){
					if(j != intL - 1){
						System.out.print(longC[i][j] + " ");
					}else{
						System.out.println(longC[i][j]);
					}
				}
			}




		}catch(IOException e){
			e.printStackTrace();
		}catch(NumberFormatException e){
			e.printStackTrace();
		}
	}

}



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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) string((s).rbegin(), (s).rend())
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;


int main(){
	while(1){
		int sx, sy;
		cin >> sx >> sy;

		if(!sx && !sy) return 0;

		int n;
		cin >> n;

		int field[12][10][10] = {};
		FOR(i, 1, n+1){
			int x, y;
			cin >> x >> y;
			for(int j = x-1; j <= x+1; j++){
				for(int k = y-1; k <= y+1; k++){
					if(j < 0 || j > 9 || k < 0 || k > 9)continue;
					field[i][k][j] = 1;
				}
			}
		}
		rep(i, 10){
			rep(j, 10){
				field[n+1][i][j] = 1;
			}
		}


		//rep(i, n+2){
		//	rep(j, 10){
		//		rep(k, 10){
		//			cout << field[i][j][k];
		//		}
		//		cout << endl;
		//	}
		//	cout << endl;
		//}

		typedef pair<int, P> POS;

		queue<POS> q;
		q.push(MP(0, MP(sx, sy)));

		int dx[] = {-2, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 2};
		int dy[] = {-1, 0, 1, 2, -2, 2, -2, 2, -2, -1, 0, 1};
		bool ok = false;

		while(!q.empty()){
			int next = q.front().first+1;
			if(next == n+1){
				ok = true;
				break;
			}
			P p = q.front().second;
			q.pop();
			rep(i, 12){
				int x = p.X + dx[i];
				int y = p.Y + dy[i];
				
				if(x < 0 || x > 9 || y < 0 || y > 9) continue;
				if(field[next][y][x] == 0) continue;
				q.push(MP(next, MP(x, y)));
			}			
		}
		cout << (ok?"OK":"NA") << endl;

	}
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second
#define MP make_pair
#define PB push_back

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;


int main()
{
  int n, m ;
  cin >> n >> m ;
  vector<int> l(m) ;
  vector<int> r(m) ;
  
  REP(i,m){
    cin >> l.at(i) >> r.at(i) ;
  }
  
  sort(ALL(l)) ;
  sort(ALL(r)) ;
  
  cout << max(r.at(0)-l.at(m-1)+1,0) <<endl ;

  return 0 ;
}

Measured memory_bytes: 1024
n,k=map(int,input().split())
ls=list(map(int,input().split()))
check_ls=[0 for i in range(n)]
ps=[1]
nxt=1
while True:
    idx=nxt-1
    if check_ls[idx]==-1:
        break
    ps.append(ls[idx])
    nxt=ls[idx]
    check_ls[idx]=-1

loop_start_idx = ps.index(ps[-1])
loop_length=len(ps)-loop_start_idx-1
loop_ls=ps[loop_start_idx:-1]
if k<len(ps):
    print(ps[k])
else:
    idx=(k-loop_start_idx)%loop_length
    print(loop_ls[idx])

Measured memory_bytes: 107216
#include<bits/stdc++.h>
#define ll long long
#define  vi vector<int>
#define pb push_back
//#define int long long
#define boost ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0)
#define pi pair<int,int>
#define F first
#define S second
using namespace std;

//int mod=(int)(1e9+7);

void solve()
{
 string s;
 cin>>s;
 map<int,int>m;
 
 ll mod=2019;
 m[0]++;
 ll ans=0;
 reverse(s.begin(),s.end());
 ll t=1;
 ll rem=0;
 for(int i=0;i<s.length();i++)
 {  
   ll x=((s[i]-'0')*t)%2019;
   rem=(rem+x)%2019;
   ans+=m[rem];
   m[rem]++;
   t=(t*10)%2019;
 }
 cout<<ans;
}

signed main()
{ boost;
 //cout<<fixed<<setprecision(14 );
 // int t;cin>>t;
  //for(int i=1;i<=t;i++)
  solve();
 // cout<<"Case #"<<i<<": "<<solve()<<endl;

return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,j,n=0,t,a,b,c=0;
	string s,s1,s2;
	cin>>t;
	while(t--)
    {
        cin>>a>>b;
        if(a==b)
            c++;
        else
            c=0;
        if(c>=3)
            n=1;
    }
    if(n==1)
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    string s;
    cin >> s;

    int len = s.size();
    int64_t sum = 0;
    for (int i = 0; i < (1<<(len-1)); i++) {
        bitset<9> ope(i);
        char c = (char)s.at(0);
        string num = "";
        num += c;
        for (int j = len-2; j >= 0; j--) {
            if (ope[j] == 0) {
                c = (char)s.at(len-1-j);
                num += c;
            } else {
                sum += stoll(num);
                num = (char)s.at(len-1-j);
            }
        }
        sum += stoll(num);
    }

    cout << sum << endl;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){

	int n;cin >> n;
	vector<int> v(n);
	REP(i,n)cin >> v[i];
	int ans = 0;

	REP(i,n-1){
		if(v[i] == i+1 && v[i+1] == i+2){
			swap(v[i],v[i+1]);
			ans++;
		}
	}

	REP(i,n-1){
		if(v[i] == i+1 || v[i+1] == i+2){
			swap(v[i],v[i+1]);
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
// https://atcoder.jp/contests/abc052/tasks/arc067_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
const int MOD = 1e9 + 7;
const int SZ = 1e3;

// constexprな素数列挙(エラトステネスの篩)
// https://259-momone.hatenablog.com/entry/2018/05/06/015026
template <int N> struct Prime {
    bool b[N + 1]; // trueなら素数
    constexpr Prime() : b() {
        fill_n(b, N + 1, true);
        b[0] = b[1] = false;
        for (int_fast64_t i = 2; i <= N; ++i) {
            if (b[i]) {
                for (int_fast64_t j = i * i; j <= N; j += i) {
                    b[j] = false;
                }
            }
        }
    }
};
Prime<SZ> prime;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll ans = 1;
    FOR(i, 2, n + 1) {
        // 素数の場合
        if (prime.b[i]) {
            // n!の中で素因数iは何乗か？
            ll tot = 0;
            for (int j = i; j <= n; j *= i) { // 2,4,8...
                tot += n / j;                 // 12/2 + 12/4 + 12/8
            }
            //約数の個数*(tot+1)%modで更新
            ans = (ans * (tot + 1)) % MOD;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
using System;

class B
{
	static void Main()
	{
		var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int ans = 0;
		for (int i = 0; i < a[0]; i++)
		{
			var b = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
			if (Math.Sqrt(b[0] * b[0] + b[1] * b[1]) <= a[1]) ans++;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 46248
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    sort(vec.begin(), vec.end());
 
    int ans = 0;
 
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (vec[k] != vec[j] and vec[i] != vec[j] and
                    vec[k] + vec[j] > vec[i]) {
                    ans++;
                }
            }
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

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

int main(){
    int n, a, b;
    cin >> n;
    vector<pair<int, int>> task(n);
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        task[i] = make_pair(b, a);
    }
    sort(task.begin(), task.end());
    int time = 0;
    bool flag = 1;
    for(int i = 0; i < n; i++){
        time += task[i].second;
        if(time > task[i].first) flag = 0;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

//??¨????????????????????????????????¨
const int MAX_PRIME = 100100;

vector<int> is_prime(MAX_PRIME,1);
vi primes;

void calcPrime(){
	is_prime[0]=is_prime[1]=0;
	for(int i=2; i<MAX_PRIME; i++){
		if(is_prime[i]==1){
			for(int j=i+i; j<MAX_PRIME; j+=i){
				is_prime[j]=0;
			}
			primes.push_back(i);
		}
	}
}


int main(){
	calcPrime();
	//cout<<primes.size()<<endl;
	int m, a, b;
	while(cin>>m>>a>>b && m + a + b){
		int p = 2, q = 2;
		for(int i = 0; i < primes.size(); i++){
			for(int j = i; j < primes.size(); j++){
				if((ll)primes[i] * primes[j] > (ll)m) break;
				if((double)a / b > (double) primes[i] / primes[j] + EPS) break;
				if((ll) primes[i] * primes[j] > (ll)p * q) p = primes[i], q = primes[j];
			}
		}
		cout<<p<<" "<<q<<endl;
	}
}

Measured memory_bytes: 3144
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	var AC, WA, TLE, RE int

	var result string

	for i := 0; i < N; i++ {
		fmt.Scan(&result)

		switch result {
		case "AC":
			AC++
		case "WA":
			WA++
		case "TLE":
			TLE++
		case "RE":
			RE++
		default:
		}
	}
	line := `AC x %d
WA x %d
TLE x %d
RE x %d
`
	fmt.Printf(line, AC, WA, TLE, RE)
}


Measured memory_bytes: 6332
#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>
#include <numeric>
#include <cmath>
#include <set>
#include <functional>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl;

#define INF 2000000000

int A[200020];
int bc[200020];

int main() {
    int N, K;
    cin >> N >> K;
    set<int>st;
    rep(i, N) {
        cin >> A[i];
        bc[A[i]]++;
    }
    sort(bc+1,bc+N+1);
    int sum = 0;
    for (int i = 1; i <= N - K; i++) {
        sum += bc[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1792
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        X: u64,
    }

    let mut now = 100;
    let mut ans = 0;
    while now < X {
        ans += 1;
        now += now / 100;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <vector>
 
typedef long long ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;

using namespace std;

int main() {

	int n;

	cin >> n;

	ll ans = 0;

	for (int i = 1; i <= n; i++) {

		if (i % 15 == 0 || i % 3 == 0 || i % 5 == 0) {
			
		} else {
			ans += i;
		}
	}

	cout << ans << endl;
}

//printf("%ld\n", ans);

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 5;

inline void sosad() {
	puts( "-1" );
	exit( 0 );
}

int x[ N ], y[ N ];

void getresult( int64_t xx, int64_t yy ) {
	for ( int i = 34 ; i >= 0 ; i -- ) {
		int64_t cur = static_cast< int64_t >( 1 ) << i;
		if ( abs( xx ) > abs( yy ) ) {
			if ( xx < 0 ) {
				xx += cur;
				putchar( 'L' );
			} else {
				xx -= cur;
				putchar( 'R' );
			}
		} else {
			if ( yy < 0 ) {
				yy += cur;
				putchar( 'D' );
			} else {
				yy -= cur;
				putchar( 'U' );
			}
		}
	}
	assert( xx == 0 and yy == 0 );
	putchar( '\n' );
}

void solve_odd( int n ) {
	puts( "35" );
	for ( int i = 34 ; i >= 0 ; -- i )
		printf( "%" PRId64 "%c", static_cast< int64_t >( 1 ) << i, " \n"[ i == 0 ] );
	for ( int i = 0 ; i < n ; ++ i ) 
		getresult( x[ i ], y[ i ] );
}

void solve_eve( int n ) {
	puts( "36" );
	printf( "1 " );
	for ( int i = 34 ; i >= 0 ; -- i )
		printf( "%" PRId64 "%c", static_cast< int64_t >( 1 ) << i, " \n"[ i == 0 ] );
	for ( int i = 0 ; i < n ; ++ i ) {
		putchar( 'R' );
		getresult( x[ i ] - 1, y[ i ] );
	}
}

int main() {
	int n; scanf( "%d", &n );
	for ( int i = 0 ; i < n ; ++ i )
		scanf( "%d %d", x + i, y + i );
	for ( int i = 1 ; i < n ; ++ i )
		if ( abs( x[ i ] + y[ i ] - x[ 0 ] - y[ 0 ] ) & 1 )
			sosad();
	if ( ( x[ 0 ] + y[ 0 ] ) & 1 ) solve_odd( n );
	else solve_eve( n );
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
  string S;
  cin >> S;
  int N = S.size();
  string ans = "yes";
   for(int i = 0; i < N; ++i){
   for(int j = i + 1; j < N; ++j){
   if(S[i] == S[j])
   {ans = "no";}
   }
  }
   cout << ans << endl;
 }


Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i=0; i<n; i++){
  cin >> a[i];
  }
  
  set<int> s;
  
  for(int j=0; j<n; j++){
    s.insert(a[j]);
  }
  
  if(s.size() == n){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 10368
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


k = int(input())
a = list(map(int, input().split()))
v1 = 2
v2 = 2
ans = None
for num in a[::-1]:
#     print(v1,v2)
    # num人組を作って生き残れた人がv1~v2人
    if (v1-1)//num == (v2)//num:
        ans = -1
        break
    v1 = ((v1-1)//num+1) * num
    v2 = (v2)//num * num + (num-1)
if ans == -1:
    print(ans)
else:
    print(v1,v2)

Measured memory_bytes: 86704
def l(): return list(map(int, input().split()))
def m(): return map(int, input().split())

def sieve(n): # エラトステネスの篩ですよ
  num = [True]*n
  num[0] = num[1] = False
  for i in range(2,int(n**0.5)+1):
    if num[i]:
      for j in range(i**2, n, i):
        num[j] = False
  return [i for i in range(2,n) if num[i]]

def main():
  q = int(input())
  l , r = [0]*q, [0]*q
  for i in range(q):
    l[i], r[i] = m()
  rr = max(r) 
  prime = sieve(rr+1)
  # print(prime)
  likp = [0]*rr
  for i in prime:
    if (i+1) // 2 in prime:
      likp[i-1] = 1
  # print(likp)
  sm = [0]*(rr+1)
  for i in range(rr):
    sm[i+1] = sm[i] + likp[i]
  # print(sm)
  for i in range(q):
    print(sm[r[i]] - sm[l[i]-1])
   


if __name__ == '__main__':
  main()

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

namespace KCLC
{
    class Program
    {
        static void Main()
        {
            string Input = Console.ReadLine();
            int Length = Input.Length;
          
            int Wa = 0;
            for(int i = 0; i < Length; i++) Wa += Input[i] - '0';
          
            if(Wa % 9 == 0) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin>>n;
    
    int arr[n];
    
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    
    int sum=0;
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            sum+=arr[i]*arr[j];
        }
    }
    
    cout<<sum<<endl;
   return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readlines
infty = 2 ** 20

lines = input()

n, m = list(map(int, lines[0].split()))

coin = list(map(int, lines[1].split()))

T = [[0] * (n+1) for i in range(m+1)]

#0行目の初期化
for i in range(1, n+1):
    T[0][i] = infty
#0列目の初期化
for i in range(m+1):
    T[i][0] = 0
#1行目の初期化
for i in range(1, n+1):
    T[1][i] = i

cnt = 0
for i in range(1, m+1):
    if coin[i-1] > n:
        continue
    else:
        cnt += 1
        for j in range(1, n+1):
            if j < coin[i-1]:
                T[i][j] = T[i-1][j]
            else:
                a = T[i-1][j] ; b = T[i][j-coin[i-1]]+1
                if a < b:
                    T[i][j] = a
                else:
                    T[i][j] = b

print(T[cnt][n])


Measured memory_bytes: 43744
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String line = in.next();
        final Map<Character, Integer> map = new HashMap<>();

        for (char c : line.toCharArray()) {
            map.compute(c, (character, integer) -> {
                final int result;
                if (integer == null) {
                    result = 1;
                } else {
                    result = integer + 1;
                }
                return result;
            });
        }

        if (map.keySet().size() != 2) {
            System.out.println("No");
            return;
        }

        if (map.values().stream().anyMatch(i -> i != 2)) {
            System.out.println("No");
            return;
        }

        System.out.println("Yes");
    }
}


Measured memory_bytes: 27092
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
    string S;
    map<char, int> map{};

    cin >> S;

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

    for(auto i = map.begin(); i != map.end() ; ++i ) {
        if(i->second %2 == 1){
            cout << "No" << endl;
            exit(0);
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    int p = a.size(),term=0;
    for(int i = 0; a[i]!='\0'; i++)
    {
        if(a[i] != b[i])
        {
            term++;
        }
    }
    cout << term << endl;
}



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

const int N = 1e5 + 90;

int n, a[3][N], c[N], p[N], m, S, t[N * 3], bl[N * 3];
bool r[N];

void Ji (bool x) { if (!x) puts("No"), exit(0); }

bool Pd () {
	bool ret = 0;
	for (int i = 1; i <= S; ++i) t[i] = 0;
	for (int i = 1; i <= m; ++i) ++t[p[i]];
	for (int i = 1, j = 0; i <= S; ++i) if (t[i]) bl[i] = ++j;
	for (int i = 1; i <= m; ++i) while (i != bl[p[i]]) std :: swap(p[i], p[bl[p[i]]]), ret ^= 1;
	return ret;
}

int main () {
	scanf("%d", &n); S = 3 * n;
	for (int i = 0; i < 3; ++i) for (int j = 1; j <= n; ++j) scanf("%d", &a[i][j]);
	for (int i = 1; i <= n; ++i) {
		if (a[0][i] > a[1][i]) {
			Ji(a[0][i] == a[1][i] + 1);
			Ji(a[1][i] == a[2][i] + 1);
			Ji(a[1][i] % 3 == 2);
			c[i] = a[1][i] / 3;
			Ji((c[i] ^ i) & 1);
			++c[i];
			r[i & 1] ^= 1;
		} else {
			Ji(a[0][i] + 1 == a[1][i]);
			Ji(a[1][i] + 1 == a[2][i]);
			Ji(a[1][i] % 3 == 2);
			c[i] = a[1][i] / 3;
			Ji((c[i] ^ i) & 1);
			++c[i];
		}
	}
	for (int i = 1; i <= n; ++i, ++i) p[++m] = c[i];
	Ji(Pd() == r[0]); m = 0;
	for (int i = 2; i <= n; ++i, ++i) p[++m] = c[i];
	Ji(Pd() == r[1]);
	puts("Yes");
	return 0;
}

Measured memory_bytes: 3840
s_a = input()
s_b = input()
s_c = input()
next_ = s_a[0]
s_a = s_a[1:]
for i in range(len(s_a)*len(s_b)*len(s_c)+1):
  if next_ == 'a':
    if s_a == '':
      print('A')
      break
    next_ = s_a[0]
    s_a = s_a[1:]
  elif next_ == 'b':
    if s_b == '':
      print('B')
      break
    next_ = s_b[0]
    s_b = s_b[1:]
  else:
    if s_c == '':
      print('C')
      break
    next_ = s_c[0]
    s_c = s_c[1:]

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
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);
        BUnevenNumbers solver = new BUnevenNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class BUnevenNumbers {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextInt();

            long answer = 0;
            for (int tens = 10; tens / 10 <= n; tens *= 100) {
                long max = tens - 1;
                long min = tens / 10;
                max = Math.min(max, n);

                answer += max - min + 1;
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 22996
# ABC073D - joisino's travel
from itertools import permutations
from scipy.sparse.csgraph import floyd_warshall


def main():
    N, M, R, *RABC = map(int, open(0).read().split())
    visit, ABC = [i - 1 for i in RABC[:R]], RABC[R:]
    G = [[float("inf")] * N for _ in range(N)]
    for v, u, c in zip(*[iter(ABC)] * 3):
        v, u = v - 1, u - 1
        G[v][u] = G[u][v] = c
    dist = floyd_warshall(G, directed=0)
    ans = float("inf")
    for perm in permutations(visit):
        cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
        ans = min(ans, cur)
    print(int(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 18832
de = false
require 'prime'
n,k = gets.chomp.split().map(&:to_i)
a = gets.chomp.split().map(&:to_i)
a.sort!
a.reverse!

def divisors(n)
  n.prime_division.inject([1]) do |ary, (p, e)|
    (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
  end.sort
end

divs = divisors(a.inject(:+)).reverse
p divs if de
divs.each do |divisor|
  divided = a.map{|e| e%divisor}.sort.select{|e| e>0}
  if divided.empty?
    puts divisor
    exit
  end

  p [divisor, 'divided', divided] if de
  rui = []
  divided.each do |e|
    rui.push (rui.last || 0) + e
  end
  rui2 = []
  divided.reverse_each do |e|
    rui2.push (rui2.last || 0) + divisor - e
  end
  rui2.reverse!

  minimum = Float::INFINITY
  size = divided.size
  p ['rui', rui] if de
  p ['rui2', rui2] if de
  (size-1).times do |i|
    diff = [rui[i], rui2[i+1]].max
    minimum = diff if minimum > diff
  end

  p ['minim', minimum] if de
  if minimum <= k
    puts divisor
    break
  end
end


Measured memory_bytes: 4472
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n,t;
    cin >> n >> t;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    map<int,int>mp;
    int ma = -1;
    for(int i = n-1; i >= 0; i--){
        ma = max(ma, a[i]);
        mp[ma-a[i]]++;
    }
    int ans = 0;
    for(auto x:mp)ans = x.second;
    cout << ans << endl;
}

Measured memory_bytes: 5376
#include<stdio.h>
int main(){
	int x,y,z,ans;
	scanf("%d%d%d",&x,&y,&z);
	ans=x/(z+y);
	if(x-ans*(z+y)>=z)
		printf("%d\n",ans);
	else
		printf("%d\n",ans-1);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    ll x, y;
    while (cin >> x >> y)
    {
        if (x == 0 && y == 0)
        {
            break;
        }
        else
        {
            cout << min(x, y) << " " << max(x, y) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3000
import System.Environment
import Data.Maybe
import Data.List
import Control.Exception

main :: IO ()
main = do
  isTest <- getEnv "TEST" `catch` (\(SomeException _) -> return "")
  if isTest == "1"
    then do
      testFile <- readFile "tests"
      putStrLn $ tests testFile
    else do
      input <- getContents
      putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve s = show $ (min a b) + (min c d)
  where [a, b, c, d] = fmap read (lines s) :: [Int]

tests :: String -> String
tests text = case testParse text of
  Right bodys -> unlines (fmap (\(i, body) -> test i body) (zip [1 ..] bodys))
  Left  msg   -> "Test file parse error:" ++ msg

test :: Int -> (String, String) -> String
test n (input, outputRight)
  | output == outputRight
  = header ++ "Passed"
  | otherwise
  = header
    ++ "Faild\n"
    ++ "Right:"
    ++ show outputRight
    ++ "\nOutput:"
    ++ show output
 where
  header = "test" ++ show n ++ ":"
  output = trim $ solve input

testParse :: String -> Either String [(String, String)]
testParse s = case lines s of
  (sp1:sp2:bodys) -> testBodysParse sp1 sp2 bodys
  _               -> Left "testParse"

testBodysParse
  :: String -> String -> [String] -> Either String [(String, String)]
testBodysParse sp1 sp2 = (traverse . testBodyParse) sp2 . (split sp1)

testBodyParse :: String -> [String] -> Either String (String, String)
testBodyParse sp body = case fmap (trim . unlines) (split sp body) of
  [input, output] -> Right (input, output)
  _               -> Left "testBodyParse"

split :: Eq a => a -> [a] -> [[a]]
split spratar = foldr f [[]]
 where
  f x (p:ps) | x == spratar = [] : p : ps
             | otherwise    = (x : p) : ps
  f _ _ = undefined

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 508