akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

constexpr long long MOD = 1000000007;
constexpr long long MAX = 200000 + 1;
#define FORR(i, a, b) for (int i = (b)-1; i >= (a); --i)
using ll = long long;

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

ll comb(ll n, ll r) {
  return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

int main() {
  long long N, M, K;
  std::cin >> N >> M >> K;
  long long y = (M * M * (M + 1)) / 2 - (M * (M + 1) * (2 * M + 1)) / 6;
  y %= MOD;
  y *= N * N;
  y %= MOD;
  long long x = (N * N * (N + 1)) / 2 - (N * (N + 1) * (2 * N + 1)) / 6;
  x %= MOD;
  x *= M * M;
  x %= MOD;
  long long I = (x + y) % MOD;
  long long n = N * M + 1;

  fact[0] = 1;
  for (int i = 0; i < n; ++i)
    fact[i + 1] = fact[i] * (i + 1) % MOD;
  fact_inv[n] = power(fact[n], MOD - 2);

  for (int i = n - 1; 0 <= i; --i)
    fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;

  std::cout << (I * comb(N * M - 2, K - 2)) % MOD << std::endl;

  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int a, b;
  cin >> a >> b;
  cout << a - (a > b) << endl;
  return 0;
}

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

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


Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;

int main(){
int a,b,c; cin >>a>>b>>c;
 cout<<max(c-(a-b),0)<<endl;
}


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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 30;

char s[MAXN];
char vis[MAXN];
char pre[MAXN];

int main()
{
	scanf("%s", s + 1);

	int L = strlen(s + 1);

	if (L < 26) {
		FOR(i, 1, L) vis[s[i] - 'a' + 1] = true;
		FOR(i, 1, 26) if (!vis[i]) {printf("%s%c\n", s + 1, i + 'a' - 1); return 0;}
	}
	else {
		char flag = false;
		FOR(i, 1, L) if (s[i] - 'a' + 1 != L - i + 1) {flag = true; break;}
		if (!flag) {puts("-1"); return 0;}
		FOR(i, 1, L) s[i] = s[i] - 'a' + 1, pre[i] = s[i];
		std::next_permutation(s + 1, s + L + 1);
		FOR(i, 1, L) {printf("%c", s[i] + 'a' - 1); if (s[i] != pre[i]) break;} putchar(10);
	}
	
	return 0;
}


Measured memory_bytes: 256
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    n, a = ns()
    x = na()
    l = 2500

    dp = [[0 for _ in range(l + 1)] for __ in range(n + 1)]
    dp[0][0] = 1

    for xi in x:
        for i in range(n - 1, -1, -1):
            for li in range(l):
                tmp = li + xi
                if dp[i][li] != 0 and tmp <= l:
                    dp[i + 1][tmp] += dp[i][li]
    ans = 0
    for i, dpi in enumerate(dp):
        if i == 0:
            continue
        ans += dpi[a * i]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10956
#include <stdio.h>
int main()
{
   char s1[100],x[100],s2[100];
   
   scanf("%s",s1);
   scanf(" %s",x);
   scanf(" %s",s2);
    
   printf("%c%c%c",s1[0],x[0],s2[0]);
   
   return 0; 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
string s;
cin >> s;
 
int n = s.size();
 
for(int i = 'a';i <= 'z';i++){
int j;
for(j = 0;j < n;j++){
if(s[j] == i){
break;
}
}
 
if(j == n){
cout << (char)i << endl;
return 0;
}
}
 
cout << "None" << endl;
 
return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <string>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;

int main()
{
  char a[20];
  cin >> a;
  REP(i,19)
  {
    if(i != 5 && i != 13)
    {
      cout << a[i];
    }
    else
    {
      cout << " ";
    }
  }
  cout << endl;

  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >>n;
  double v[n],ans;
  for(int i=0;i<n;i++)cin >>v[i];
  sort(v,v+n);
  ans=(v[0]+v[1])/2;
  for(int i=0;i<n-2;i++)ans=(ans+v[i+2])/2;
  printf("%f",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <bitset>
#include <unordered_map>
#include <queue>

#define mp make_pair
#define pb push_back
#define FI first
#define SI second


#ifdef _MSC_VER
    #define ALIGN(x) __declspec(align(x))
#else
    #define ALIGN(x) __attribute__((aligned(x)))
#endif


using namespace std;

typedef long long ll;

const int maxn = 100007;
const int mod = 1000000007;

int a[maxn];
int f[maxn];
int st[maxn];
int ans[maxn];
int x[maxn];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%d", a + i);
    f[1] = 1; f[0] = 1;
    for (int i = 2; i <= n; ++i) f[i] = (1ll * f[i - 1] * i) % mod;
    st[0] = 0;
    for (int i = 1; i < n; ++i) {
        int pos = a[i - 1];
        int leave = st[i - 1];
        int x = i - leave - 1;
        if (((x + 1) * 2 - 1) <= pos) {
            st[i] = leave;
        } else {
            st[i] = leave + 1;
        }
    }
    for (int i = 0; i < n; ++i) {
        x[st[i] + 1] += 1;
    }
    for (int i = 1; i <= n; ++i) {
        x[i] += x[i - 1];
    }
    int res = 1;
    for (int i = 1; i <= n; ++i)
        res = (1ll * res * (x[i] - i + 1)) % mod;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var cc = cin.next().ToCharArray();

            var sum = 0L;
            foreach (var c in cc)
            {
                sum += c - '0';
            }

            Console.WriteLine(sum % 9 == 0 ? "Yes":"No") ;
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 27068
from collections import defaultdict
import math

def combination(n, r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

N = int(input())
L = defaultdict(int)
ans = 0
for _ in range(N):
    s = sorted(list(input()))
    L[str(s)] += 1

for c in L.values():
    if c > 1:
        ans += combination(c, 2)
print(ans)

Measured memory_bytes: 22364
#include <bits/stdc++.h>
using namespace std; 
typedef long long ll; 
ll N, P, ans = 1;
bool komposit[1000005];
vector<ll>primes; 
int main(){ 	for(ll i=2;i<=1000000;i++){  	if(komposit[i]) continue;  	for(ll j=i*i;j<=1000000;j+=i)   	komposit[j] = 1;  	primes.push_back(i); 	}   	cin >> N >> P; 	for(ll prime:primes){  	ll cnt = 0;  	while(P%prime == 0){   	cnt++;   	P /= prime;  	}     	ans *= pow(prime, floor(cnt/N)); 	}   	ans *= pow(P, floor(1/N));   	cout << ans << endl;   	return 0;
}

Measured memory_bytes: 2424
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private struct Pair { public int x, y; }
    public static void Main()
    {
        //input
        int N = NextInt();
        double[] p = LineDouble();

        //[i枚目][表の枚数]
        double[,] dp = new double[3000, 3000];
        dp[0, 0] = 1.0;
        for (int i = 0; i < N; i++)
            for (int j = i; j != -1; j--)
            {
                //i枚目が表or裏
                dp[i + 1, j] += dp[i, j] * (1.0 - p[i]);
                dp[i + 1, j + 1] += dp[i, j] * p[i];
            }
        double ans = 0.0;
        for (int i = (N / 2) + 1; i <= N; i++)
        {
            ans += dp[N, i];
            //Console.WriteLine(i+" "+dp[N,i]);
        }
        Console.WriteLine(ans);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 83168
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;
const int N = 6e5 + 500;
const int LN = 21;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;

long long n, m, u, v, k, t, q, a, x, d, b;


int main() {
   ios::sync_with_stdio(false);cin.tie(0);
   cin >> u >> v;
   
   if (v - u + 1 > 2019) {
      cout << 0 << endl;
   } else {
      long long best = 2019;
      for (long long i = u; i <= v; ++i) {
         for (long long j = i + 1; j <= v; ++j) {
            best = min(best, (i * j) % 2019);
         }
      }
      cout << best << endl;
   }
}







Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char cal[12];
    int i;
    for(i=0;i<10;i++) {
        scanf("%c",&cal[i]);
    }
    if((cal[3])!='8') cal[3]='8';
    for(i=0;i<10;i++) {
        printf("%c",cal[i]);
    }
    printf("\n");
    return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

int a[N];

long long lcm(long long a, long long b) {
  return a/__gcd(a, b)*b;
}

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  long long l = 1;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
    l = lcm(l, a[i]/2);
  }
  for (int i = 0; i < n; ++i) {
    if (l*2/a[i]%2 == 0) {
      debug(a[i]);
      puts("0");
      return;
    }
  }
  long long ans = (m+l)/(2*l);
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4180
n,q=map(int,input().split())
s=list(input())
l=[0 for i in range(n+1)]
tmp=0
for i in range(1,n):
    if s[i]=="C" and s[i-1]=="A":
        tmp+=1
    l[i]=tmp
for i in range(q):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    print(l[b]-l[a])

Measured memory_bytes: 84064
# -*-coding: utf-8 -*-

import sys

def main():
    input = sys.stdin.readline
    n, m = map(int, input().split())
    y_dict = {}
    ken_dict = {}
    for i in range(m):
        p_i, y_i = map(int, input().split())
        y_dict[y_i] = []
        y_dict[y_i].append(p_i)

        if not p_i in ken_dict:
            ken_dict[p_i] = []
            ken_dict[p_i].append(y_i)
        else:
            ken_dict[p_i].append(y_i)


    for key in ken_dict.keys():
        ken_dict[key].sort()
        for i,value in enumerate(ken_dict[key]):
            i += 1
            y_dict[value].append(i)
    
    for value in y_dict.values():
        print(str(value[0]).zfill(6) + str(value[1]).zfill(6))
    
    return


if __name__ == '__main__':
    main()

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

int a[10];

void prt(int n) {
  static const char * t = "abcdefghijklmnopqrstuvwxyz";
  for(int i = 0 ; i<n;i++){
    cout << t[a[i]];
  }
  cout << endl;
}

int get_mx(int i)
{
  if( i==0 ){ return 0; }
  int m = -1;
  for(int j = 0; j < i; j++){
    if( a[j] > m ) m = a[j];
  }
  return (m+1);
}

int nx(int n){
  int i = n - 1;
  while(i>=0){
    a[i] ++;
    if( i > 0 ){
      if( a[i] <= get_mx(i) ) return 0;
      a[i] = 0;
    }
    i --;
  }
  return 1;
}

int main()
{
  int n;
  for(n=0;n<10;n++){
    a[n] = 0;
  }
  cin >> n;
  
  while(1){
    prt(n);
    if( nx(n) ){
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 1536
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();

    let mut l = vec![0i64; n + 1];
    l[0] = 2;
    l[1] = 1;
    for i in 2..n + 1 {
        l[i] = l[i - 1] + l[i - 2];
    }
    println!("{}", l[n]);
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	for(int i=0,pt=0,px=0,py=0;i<n;++i){
		int t,x,y; cin>>t>>x>>y;
		int st=abs(t-pt),di=abs(x-px)+abs(y-py);
		if(di>st||di%2!=st%2){
			cout<<"No\n"s;
			return 0;
		}
		pt=t,px=x,py=y;
	}
	cout<<"Yes\n"s;
}


Measured memory_bytes: 3640
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000

int solve(int n){
  if(n==1) return 0;
  vector<vector<int> > t(31, vector<int>());

  rep(i,n){ //people number n
    int f; scanf("%d",&f);
    rep(j,f){
      int d;
      scanf("%d",&d);
      t[d].pb(i);
    }
  }

  vector<set<int> > own(n);
  rep(i,n) own[i].insert(i);

  rep(day,31){
    // share all maps
    set<int> newset;
    rep(i, t[day].size()){
      for(auto itr : own[t[day][i]])
	newset.insert(itr);
    }
    rep(i, t[day].size()){
      own[t[day][i]] = newset;
    }

    // check finish
    rep(i, t[day].size()){
      if(own[t[day][i]].size() == n) return day;
    }
  }

  return -1;
}


int main(){
  int n;
  while(cin>>n, n){
    cout<< solve(n) << endl;
  }
  return 0;
}

Measured memory_bytes: 3324
A, B = map(int, input().split())
if A == B == 1:
    print(1)
    exit(0)


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return set([val[0] for val in arr])

print(len(factorization(A) & factorization(B))+1)


Measured memory_bytes: 38520
#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];
  }
  sort(a.rbegin(), a.rend());
  int ans = 0, sign = 1;
  for(int i = 0 ; i < n ; i++){
    ans += sign * a[i];
    sign = -sign;
  }
  cout << ans << endl;
  return 0;
}


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

vector<int> p;

void solve(int m, int a, int b){
	long long ma = -1;
	int x = -1, y = -1;
	for(int i=0; i<p.size()&&p[i]<m; ++i){
		for(int j=i; j<p.size()&&(long long)p[i]*p[j]<=m; ++j){
			if(a*p[j] <= b*p[i] && ma < (long long)p[i]*p[j]){
				ma = (long long)p[i]*p[j];
				x = p[i];
				y = p[j];
			}
		}
	}
	cout << x << " " << y << "\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	for(int i=2; i<100000; ++i){
		bool f = true;
		for(int j=0; j<p.size(); ++j){
			if(i % p[j] == 0){
				f = false;
				break;
			}
		}
		if(f) p.push_back(i);
	}
//	for(int i=0; i<10; ++i)
//		cout << p[i] << "\n";
	while(1){
		int m, a, b;
		cin >> m >> a >> b;
		if(m == 0) return 0;
		solve(m, a, b);
	}
}


Measured memory_bytes: 3140
import java.util.Scanner;

public class Main{

	static int count = 0;

	public static void main(String[] args) throws Exception {

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

		int[] A = new int[n];
        int[] B = new int[n];
        int K = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            A[i] = sc.nextInt();
            K = Math.max(K, A[i]);
        }

        CountingSort(A, B, K);

        StringBuilder builder = new StringBuilder();
        builder.append(B[0]);
        for (int i = 1; i < n; i++) {
            builder.append(' ').append(B[i]);
        }
        System.out.println(builder);

	}

	static void CountingSort(int[] a, int[] b, int k) {
		int[] C = new int[k+1];

		for(int i = 0; i < a.length; i++)
			C[a[i]]++;


		for(int i = 1; i <= k; i++)
			C[i] = C[i-1] + C[i];

		for(int i = a.length - 1; i >= 0; i--) {
			C[a[i]]--;
			b[C[a[i]]] = a[i];
 		}
	}
}


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

int main(void){
   int a,b,k;
   cin >> a >> b >> k;
   vector<int> c(2*k);
   int p = a,q = b;
   for(int i = 0;i < 2*k;i++)c[i] = 0;
   for(int i = 0;i < k;i++,a++,b--){
       if(a <= q)c[i] = a;
       if(b >= p)c[k+i] = b;
   }
   sort(c.begin(),c.end());
   if(c[0] > 0)cout << c[0] << endl;
   for(int i = 1;i < 2*k;i++){
       if(c[i] != c[i-1] && c[i] > 0)cout << c[i] << endl;
   }
}

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

int n, m, q;
vector<ll> a, b, c, d;

ll score(vector<int> &A){
  ll sc = 0;
  rep(i,q){
    if(A[b[i]] - A[a[i]] == c[i]) sc += d[i];
  }
  return sc;
}

ll recur(vector<int> &A) {
  if(A.size() == n) return score(A);
  ll ans = 0;
  int last = (A.empty()? 0:A.back());
  for (int i = last; i < m;i++){
    A.push_back(i);
    ans = max(ans, recur(A));
    A.pop_back();
  }
  return ans;
}

int main() {
  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  rep(i, q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--, b[i]--;
  }
  vector<int> A;
  cout << recur(A) << endl;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

int main() {
    string s;
    ll k;
    cin >> s >> k;
    int cnt = 0;
    int next = -1;
    rep(i, s.size()) {
        if (s[i] - '0' != 1) {
            next = s[i] - '0';
            break;
        } else
            cnt++;
    }
    if (k <= cnt)
        cout << 1 << endl;
    else
        cout << next << endl;
}

Measured memory_bytes: 3632
n, t = map(int, input().split())

li_keiro = list()
for i in range(n):
    li_keiro.append(tuple(map(int, input().split())))

time_list = list(filter(lambda x: x[1] <= t, li_keiro))

if len(time_list) == 0:
    print("TLE")
else:
    print(min(time_list, key=lambda x: x[0])[0])


Measured memory_bytes: 2940
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

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 &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep0(i,n) for(i=0;i<(n);i++)
#define repn(i,m,n) for(int i=(m);i<=(n);i++)

#define all(n) n.begin(),n.end()

#define PUTLINE cout<<__LINE__<<endl;

int main() {
	Int n=in(),i;
	int res=0;
	for(i=1L;i<n;i*=3L){
		++res;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	long n = sc.nextLong();
	long a = sc.nextLong();
	long b = sc.nextLong();
	System.out.print(n / (a+b) * a + Math.min(n%(a+b), a));
    }
}


Measured memory_bytes: 35968
use std::io::Read;

fn main() {
    let mut buf = String::new();
    let _ = std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut it = buf.split_whitespace();
    let a: i32 = it.next().unwrap().parse().unwrap();
    let b: i32 = it.next().unwrap().parse().unwrap();
    let c: i32 = it.next().unwrap().parse().unwrap();
    let k: u32 = it.next().unwrap().parse().unwrap();
    if a>=b && a>=c {
        println!("{}", a*2_i32.pow(k)+b+c);
    } else if b>=a && b>=c {
        println!("{}", b*2_i32.pow(k)+a+c);
    } else {
        println!("{}", c*2_i32.pow(k)+a+b);
    }
}


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

using namespace std;

using ll = long long;
using P = pair<int, ll>;
using T = tuple<int, int, ll>;

void dfs(int cur, vector< vector<P> >& g, vector<P>& memo) {
    for (P& p : g[cur]) {
        int nex = p.first;
        ll s = p.second;
        if (memo[nex].first != 0) continue;
        memo[nex].first = -memo[cur].first;
        memo[nex].second = s - memo[cur].second;
        dfs(nex, g, memo);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector< vector<P> > g(n);
    vector<T> es;
    for (int i = 0; i < m; i++) {
        int u, v;
        ll s;
        cin >> u >> v >> s;
        u--; v--;
        g[u].emplace_back(v, s);
        g[v].emplace_back(u, s);
        es.emplace_back(u, v, s);
    }

    vector<P> memo(n, P(0, 0));
    memo[0].first = 1;
    dfs(0, g, memo);

    ll minv = 1, maxv = 1145141919;
    for (T& t : es) {
        int u, v;
        ll s;
        tie(u, v, s) = t;
        int var = memo[u].first + memo[v].first;
        ll sum = memo[u].second + memo[v].second;
        if (var == 0) {
            if (sum != s) {
                cout << 0 << endl;
                return 0;
            }
        } else if (var > 0) {
            ll tmp = s - sum;
            if (tmp <= 0 || tmp % var != 0) {
                cout << 0 << endl;
                return 0;
            }
            ll x = tmp / var;
            minv = max(minv, x);
            maxv = min(maxv, x);
        } else {
            var = -var;
            ll tmp = sum - s;
            if (tmp <= 0 || tmp % var != 0) {
                cout << 0 << endl;
                return 0;
            }
            ll x = tmp / var;
            minv = max(minv, x);
            maxv = min(maxv, x);
        }
    }

    for (P& p : memo) {
        if (p.first == 1) {
            minv = max(minv, -p.second + 1);
        } else {
            maxv = min(maxv, p.second - 1);
        }
    }

    cout << max(maxv - minv + 1, 0LL) << endl;
    return 0;
}

Measured memory_bytes: 15600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n;
    cin>>n;
    vector<int> ans(3);
    vector<int> x(n), y(n), h(n);
    rep(i,n) cin>>x[i]>>y[i]>>h[i];
    for(int i=0; i<=100; ++i){
        for(int j=0; j<=100; ++j){
            bool ok=true;
            int hi;
            rep(K,n){
                if(h[K]>0){
                    hi=h[K]+abs(i-x[K])+abs(j-y[K]);
                    break;
                }
            }
            rep(K,n){
                if(h[K]!=max(0,(hi-abs(i-x[K])-abs(j-y[K])))) ok=false;
            }
            if(ok && hi>0){
                ans[0]=i; ans[1]=j; ans[2]=hi;
            }
        }
    }
    rep(i,3) cout<<ans[i]<<" ";
    cout<<endl;
    return 0;
}

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

int n,m,k;

main(){
			ios::sync_with_stdio(false); cin.tie(0);
			cin>>n>>m>>k;
			if (k==0){
				cout<< "Yes";
				return 0;
			}
			for(int i=1; i<=n; i++)
				for(int j=1; j<=m; j++){
					int q = i*j +(n-i)*(m-j);
					if (q==k){
						cout<< "Yes";
						return 0;
					}
				}
			cout<< "No";
}


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

int M, N;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int maze[91][91];

bool check(int x, int y){
	return x >= 0 && x < N && y >= 0 && y < M && maze[x][y] == 1;
}

int dfs(int tx, int ty, int c)
{
	int res = c;
		
	for(int i = 0; i < 4; i++){
		int nx = tx + dx[i];
		int ny = ty + dy[i];
			
		if(check(nx, ny)){
			maze[nx][ny] = 0;
			res = max(res, dfs(nx, ny, c + 1));
			maze[nx][ny] = 1;
		}
	}
	
	return res;
}


int main() {
	while(1){
		cin >> M;
		cin >> N;
		if(M == 0 && N == 0)break;
		for(int i = 0; i < N; i++)
			for(int j = 0; j < M; j++)
				cin >> maze[i][j];
			
		int ans = 0;
		for(int i = 0; i < N; i++){
			for(int j = 0; j < M; j++){
				if(maze[i][j] == 1){
					maze[i][j] = 0;
					ans = max(ans, dfs(i, j, 1));
					maze[i][j] = 1;
				}
			}
		}
	
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
string rev(string s){
    reverse(s.begin(),s.end());
    return s;
}
int main()
{
    int m;
    vector<string> x;
    
    //入力
    cin >> m;
    while(m--){
     string st;
     cin >> st; 
     set<string> s;  

    
        for (int j = 1; j < st.length(); j++)
        {
            string a=st.substr(0,j),
            b=st.substr(j),
            c=rev(a),
            d=rev(b);
            s.insert(a+b);
            s.insert(b+a);
            s.insert(a+d);
            s.insert(d+a);
            s.insert(c+b);
            s.insert(b+c);
            s.insert(c+d);
            s.insert(d+c);

            
        }
        cout << s.size()<<endl;
    
    }
    
}




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

using namespace std;

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

int main()
{
  string k;
  cin >> k;
  ll ans = 0;
  
  if(k[0] == '7' || k[1] == '7' || k[2] == '7')
  {
    cout << fixed << "Yes" << endl;
  }
  else
  {
    cout << fixed << "No" << endl;
  }
  
  return 0;
}


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

using namespace std;

using ll = long long;

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

  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();

  vector<vector<int>> dp(n + 1, vector<int>(m + 1));
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (s[i - 1] == t[j - 1]) {
        dp[i][j] = 1 + dp[i - 1][j - 1];
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }

  string lcs;
  int i = n, j = m;
  while (i > 0 && j > 0) {
    if (dp[i - 1][j - 1] + 1 == dp[i][j] && s[i - 1] == t[j - 1]) {
      lcs += s[i - 1];
      --i, --j;
    } else if (dp[i - 1][j] == dp[i][j]) {
      --i;
    } else {
      --j;
    }
  }

  reverse(lcs.begin(), lcs.end());
  cout << lcs << '\n';

  return 0;
}


Measured memory_bytes: 35584
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>
#include<queue>

int main()
{
	int a, b, count{};
	scanf("%d%d", &a, &b);
	for (int i = a; i <= b; i++)
	{
		if (i / 10000 == i % 10 && i / 1000 % 10 == i / 10 % 10)
			count++;
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define oo 1000000000
#define inf 1000000000000000000
#define M 1000000007
#define M2 1000000009
#define pii pair<ll,ll>
using namespace std;
typedef long long ll;
const int N = 2e5+100;
const int SQRTN = 320;
const int LOGN = 20;
const double PI = acos(-1);
const double TAU = 2*PI;

int n , m;
char s[22][22];
int cost[22][22];
int vis[22][22];
vector<pair<int,int> > v;
pair<int,int> cur;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
queue<pair<int,int> > q;
inline void solve(){
    cin >> n >> m ;
    for(int i = 0 ; i < n ; i++){
        scanf("%s",s[i]);
    }
    int ans = 0;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < m ; j++){
            for(int ij = 0 ; ij < n ; ij++){
                for(int jj = 0 ; jj < m ; jj++){
                    
                    if(s[i][j]=='#')continue;
                    if(s[ij][jj]=='#')continue;
                    if(i==ij&&j==jj)continue;
                    cost[ij][jj]=0;
                    cost[i][j]=0;
                    for(int i = 0 ; i < v.size(); i++){
                        vis[v[i].F][v[i].S]=0;
                    }
                    v.clear();
                    q.push(make_pair(i,j));
                    while(!q.empty()){
                        cur=q.front();
                        q.pop();
                        v.push_back(cur);
                        for(int x = 0 ; x < 4 ; x++){
                            if(cur.F+dx[x]>=n)continue;
                            if(cur.S+dy[x]>=m)continue;
                            if(cur.F+dx[x]<0)continue;
                            if(cur.S+dy[x]<0)continue;
                            if(s[cur.F+dx[x]][cur.S+dy[x]]=='#'){
                                    continue;
                            }
                            if(vis[cur.F+dx[x]][cur.S+dy[x]])continue;
                            vis[cur.F+dx[x]][cur.S+dy[x]]=1;
                            q.push(make_pair(cur.F+dx[x],cur.S+dy[x]));
                            cost[cur.F+dx[x]][cur.S+dy[x]]=cost[cur.F][cur.S]+1;

                        }
                    }
                    ans = max(ans,cost[ij][jj]);
                }
            }
        }
    }
    cout << ans << endl;




}

signed main() {
	int t=1;
	while(t--){
		solve();
	}
    return 0;
}


Measured memory_bytes: 256
#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;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


using HashType = tuple<ll,ll>;
struct RollingHash {

  const ll mod1 = 999999893;
  const ll mod2 = 999999929;
  const ll b1 = 3422539;
  const ll b2 = 1245103;
  vector<ll> h1, h2;
  vector<ll> pow1, pow2;

  RollingHash(const string &s) {
    const int n = s.size();
    h1.assign(n+1, 0);
    h2.assign(n+1, 0);
    pow1.assign(n+1, 1);
    pow2.assign(n+1, 1);
    REP(i, n) {
      h1[i+1] = (h1[i] * b1 + s[i]) % mod1;
      h2[i+1] = (h2[i] * b2 + s[i]) % mod2;
      pow1[i+1] = pow1[i] * b1 % mod1;
      pow2[i+1] = pow2[i] * b2 % mod2;
    }
  }

  HashType get(int l, int r) {
    ll v1 = ((h1[r] - h1[l] * pow1[r-l]) % mod1 + mod1) % mod1;
    ll v2 = ((h2[r] - h2[l] * pow2[r-l]) % mod2 + mod2) % mod2;
    return HashType {v1, v2};
  }
};



int main2() {
  int N; cin >> N;
  string s; cin >> s;
  RollingHash h = RollingHash(s);

  int len = N/2;
  for (; len > 0 ; len--) {

    set<HashType> vis;

    bool found = false;
    for (int i = len; i + len <= N; i++) {
      vis.insert(h.get(i-len, i));
      if (vis.count(h.get(i, i + len)) > 0) {
        found = true;
        break;
      }
    }
    if (found) break;
  }
  cout << len << endl;

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val>
Val gcd(Val a, Val b) {
//use ll or int for gcd
    if (b==0) return a;
    else return gcd(b, a%b);
}
template <typename Val>
Val vec_max(vector<Val> v){
  return *max_element(v.begin(),v.end());
}
template <typename Val>
Val vec_min(vector<Val> v){
  return *min_element(v.begin(),v.end());
}


//---------------------------------------------------------------

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  ll ans = 0;
  vector<int>R;
  vector<int>G;
  vector<int>B;
  rep(i,N){
    if(S.at(i)=='R'){
      R.push_back(i);
    }else if(S.at(i)=='G'){
      G.push_back(i);
    }else{
      B.push_back(i);
    }
  }

  rep(i,R.size()){
      rep(k,B.size()){
        int r,g,b;
        r=min(R.at(i),B.at(k));
        b=max(R.at(i),B.at(k));
        g = G.size();
        if((r-(b-r))>=0&&S.at(r-(b-r))=='G'){
          g--;
        }
        if((b+(b-r))<N&&S.at(b+(b-r))=='G'){
          g--;
        }
        if((b-r)%2==0&&S.at(r+(b-r)/2)=='G'){
          g--;
        }

        ans +=g;

      }

  }


  cout<<ans<<endl;
}


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

int mod = 1e9+7;
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n,k,l,r,d;
    cin >> l >> r >> d;
    int res = 0;
    for(int i=l;i<=r;i++)
        if(i%d == 0) res++;
    cout << res;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi d;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    d.resize(n);
    rep(i,n){
        cin>>d[i];
    }
    sort(all(d));
    ll l = d[n/2 -1];
    ll r = d[n/2];
    print(r-l);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int dist[100005][3]; //あまりの状態も持っとく

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int> > to(n);
    rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
    }
    int sv, tv; cin >> sv >> tv;
    sv--; tv--;
    rep(i, n)rep(j, 3) dist[i][j] = INF;
    queue<P> q;
    q.push(P(sv, 0));
    dist[sv][0] = 0;
    //BFS
    while (!q.empty()) {
        int v = q.front().first;
        int l = q.front().second;
        q.pop();
        for (int u : to[v]) {
            int nl = (l+1)%3;
            if (dist[u][nl] != INF) continue; //すでに訪問済みならcontinue
            dist[u][nl] = dist[v][l] + 1;
            q.push(P(u, nl));
        }
    }
    int ans = dist[tv][0];
    if (ans == INF) ans = -1; //tvに余り0で到達できない
    else ans /= 3;
    cout << ans << endl;
}

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

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

    bool flag = 0;
    if(s[0]!=s[1]) {
        if(s[0]!=s[2]) {
            if(s[1]!=s[2]){
                flag = 1;
            }
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

const int MAX_N=190;
const int LOG_N=16;

int dp[LOG_N+5][MAX_N][MAX_N][MAX_N],N,M,t[MAX_N][MAX_N];
string Map[MAX_N];

int main(){
	cin>>N>>M;
	for(int i=0;i<N;i++) cin>>Map[i];
	for(int i=0;i<MAX_N;i++) for(int j=0;j<MAX_N;j++) 
		t[i][j]=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			int add=0;
			if(Map[i][j]=='#') add=1;
			t[i+1][j+1]=t[i+1][j]+t[i][j+1]-t[i][j]+add;
		//	printf("%d ",t[i+1][j+1]);
		}
//		printf("\n");
	}
	for(int x=0;x<=N;x++) for(int l=0;l<=M;l++){
		for(int r=l+1;r<=M;r++){
			int low=x,high=N+1;
			while(low<high-1){
				int mid=(low+high)/2;
				int sum=t[x][l]+t[mid][r]-t[x][r]-t[mid][l];
			//	printf("%d\n",sum);
				if(sum==0||sum==(mid-x)*(r-l))
					low=mid;
				else 
					high=mid;
			}
			dp[0][x][l][r]=low;
		//	cout<<x+1<<" "<<l+1<<" "<<r+1<<" "<<low<<endl; 
		}
	}
	for(int p=1;p<=LOG_N;p++) for(int x=0;x<=N;x++)
		for(int l=0;l<=M;l++) for(int r=0;r<=M;r++){
			dp[p][x][l][r]=max(dp[p][x][l][r],dp[p-1][dp[p-1][x][l][r]][l][r]);
			for(int cut=l+1;cut<r;cut++){
				if(dp[p][x][l][r]>=dp[p-1][x][l][cut]) 
					break;
				dp[p][x][l][r]=max(dp[p][x][l][r],min(dp[p-1][x][l][cut],dp[p-1][x][cut][r]));
			}
		}
	for(int p=0;p<=LOG_N;p++) if(dp[p][0][0][M]>=N){
		printf("%d\n",p);
		return 0;
	}
}

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

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  string t, p;
  cin >> t >> p;
  int curr = 0;
  while (true) {
    int found = t.find(p, curr);
    if (found != string::npos) {
      cout << found << endl;
      curr = found+1;
    } else
      break;
  }
  return 0;
}



Measured memory_bytes: 3256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
#include<fstream>
using namespace std;
typedef long long LL;

int main(void)
{
	LL h;
	cin >>h;
	LL i=0;
	while (h > 0) {
		h/=2;
		i+=i;
		i++;
	}
	cout <<i<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for _ in range(n):
  s = input()
  if s == "AC":
    ac += 1
  elif s == "WA":
    wa += 1
  elif s == "TLE":
    tle += 1
  elif s == "RE":
    re += 1
  
print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

Measured memory_bytes: 9204
int main(){
   int x,y;scanf("%d%d",&x,&y);
   if(x == 2)x=3;
   else if(x==4||x==6||x==9||x==11)x=2;
   else x=1;
   if(y == 2)y=3;
   else if(y==4||y==6||y==9||y==11)y=2;
   else y=1;
   printf(x==y?"Yes":"No");
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>

using namespace std;

inline bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
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(); }
template<class T> inline T sqr(T x) { return x*x; }

typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef long long ll;
typedef unsigned long long ull;

#define For(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };
const int mod = 1000000007;
const int INF = 1e9;

int main()
{
	int n;
	while (cin >> n && n){

		map<P, int> mp;

		//??????
		mp[P(-1, -1)] = -1;
		mp[P(INF + 1, INF + 1)] = -1;

		rep(i, n){
			char c;
			cin >> c;
			if (c == 'W'){
				int l, s;
				cin >> l >> s;

				auto bg = mp.begin();
				while (s){
					auto nx = next(bg);
					int ri = bg->first.second;
					int le = nx->first.first;
					if (ri + 1 < le){
						int ad = min(s, le - ri - 1);
						mp[P(ri + 1, ri + ad)] = l;
						s -= ad;
						bg = next(bg);
					}

					if (s)
						if (next(bg)->second != -1)bg = nx;
						else{
							int st = nx->first.second + 1;
							mp[P(st, st + s - 1)] = l;
							s = 0; break;
						}
				}
			}
			if (c == 'D'){
				int l;
				cin >> l;
				for (auto j = mp.begin(); j != mp.end(); j = next(j)){
					if (j->second == l){
						j = prev(j);
						mp.erase(next(j));
					}
				}
			}
			if (c == 'R'){
				int l;
				cin >> l;
				bool f = false;
				for (auto j : mp){
					if (j.first.first <= l && l <= j.first.second){
						cout << j.second << endl; f = true; break;
					}
				}
				if (!f){
					cout << -1 << endl;
				}
			}

		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main(){
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    for (ll i = 0; i < m;i++){
        ll a;
        cin >> a;
        ans += a;
    }
    if(n>=ans){
        cout << n - ans;
    }
    else{
        cout << "-1";
    }
}

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

int main(){
  int n,a[110][110];
  cin >> n;
  for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin >> a[i][j];

  long long res = 0;
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)res += std::min(a[i][j],a[j][i]);
  cout << res << endl;
}

Measured memory_bytes: 1200