akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(){
	int N;
	int i;
	int count=0;
	scanf("%d",&N);
	int p;
	for(i=0;i<N;i++){
		scanf("%d",&p);
		if(p!=i+1)
			count++;
	}
	if(count<=2){
		printf("YES");
	}else{
		printf("NO");
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int main()
{
  lint l, r;
  cin >> l >> r;

  lint min = INT_MAX;
  if(r-l>=2019){
    min = 0;
  }else{
    FOR(i,l,r){
      FOR(j,i+1,r+1){
        lint tmp = ((i%2019)*(j%2019))%2019;
        if(tmp < min) min = tmp;
      }
    }
  }

  cout << min << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

from itertools import permutations

for i,p in enumerate(list(permutations(range(1,N+1)))):
    flag = True
    for j in range(N):
        if p[j]!=P[j]:
            flag=False
            break
    if flag:
        break
a = i+1

for i,p in enumerate(list(permutations(range(1,N+1)))):
    flag = True
    for j in range(N):
        if p[j]!=Q[j]:
            flag=False
            break
    if flag:
        break

b=i+1

print(abs(a-b))

Measured memory_bytes: 51952
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	int n, k;
	ll s = 0;
	cin >> n >> k;
	vector<int> p(n);
	rep(i, 0, n)cin >> p[i];
	sort(all(p));
	rep(i, 0, k)s += p[i];
	printf("%lld\n", s);
	return 0;
}


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

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

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (count(all(s), '7') > 0) {
        cout << "Yes";
    } else {
        cout << "No";
    }

}


Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
    int i, j;
    char s[4];
    char tmp1, tmp2;
    int c1, c2;
    c1 = c2 = 0;

    scanf("%s", s);

    tmp1 = s[0];
    tmp2 = '\0';

    for(i = 0 ; i < 4 ; i++){
        if(tmp1 == s[i]) c1++;
        else{ 
            tmp2 = s[i];
        for(j = i ; j < 4 ; j++){
            if(tmp2 == s[j])c2++;
            }
        }
    }
    //printf("%d %d", c1, c2);
    if(c1 == 2 && c2 == 3) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) rep2(i,0,n)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
ll n,ans=1,m=1000000007,ans2=2,ans3=1;
int main()
{
	cin>>n;
	rep(i,n) ans*=10,ans%=m,ans2*=9,ans2%=m,ans3*=8,ans3%=m;
	ans-=ans2-ans3;
	re((m+ans)%m)
	return 0;}

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

using namespace std;

typedef long long ll;

int main(){
	long double a, b, h, m;
	cin >> a >> b >> h >> m;
	long double deg_m = m * 6;
	long double deg_h = h * 30 + m/2;
	long double deg = min(360 - abs(deg_m - deg_h),abs(deg_m - deg_h));
	deg = deg/180 * M_PI;
	long double rsq= a * a + b * b - 2 * a * b * cos(deg);
	cout<<fixed<<setprecision(9)<<sqrt(rsq)<<endl;
}


Measured memory_bytes: 4124
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
enum Status {
    Before,
    Active,
    Finished,
}

fn solve(graph: Vec<Vec<usize>>) {
    let size = graph.len();
    let mut status = vec![Status::Before; size];
    for i in 0..size {
        if Status::Finished == status[i] {
            continue;
        }
        let mut stack = vec![];
        stack.push(i);
        'outer: while !stack.is_empty() {
            let from = *stack.last().unwrap();
            if status[from] == Status::Before {
                // Preorder
                status[from] = Status::Active;
            }
            // For each child
            for &to in &graph[from] {
                match status[to] {
                    Status::Before => {
                        stack.push(to);
                        continue 'outer;
                    }
                    Status::Finished => {}
                    Status::Active => {
                        // A cycle detected.
                        println!("1");
                        return;
                    }
                }
            }
            // Postorder.
            let from = stack.pop().unwrap();
            status[from] = Status::Finished;
        }
    }
    println!("0");
}
use std::io::{BufRead, BufReader};
fn main() {
    let mut read = BufReader::new(std::io::stdin())
        .lines()
        .filter_map(|e| e.ok());
    let (v, e) = {
        let line = read.next().unwrap();
        let line: Vec<&str> = line.split(' ').collect();
        let v: usize = line[0].parse().unwrap();
        let e: usize = line[1].parse().unwrap();
        (v, e)
    };
    let graph = {
        let mut graph: Vec<Vec<_>> = vec![vec![]; v]; // Adj list
        for _ in 0..e {
            let edge = read.next().unwrap();
            let mut edge = edge.split(' ');
            let start: usize = edge.next().unwrap().parse().unwrap();
            let end: usize = edge.next().unwrap().parse().unwrap();
            graph[start].push(end);
        }
        graph
    };
    solve(graph);
}



Measured memory_bytes: 5040
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD=1000000007;
signed main(){
  string a,b,c;
  cin>>a>>b>>c;
  if(a=="0"){
    a="$";
  }else{
    for(Int i=(Int)a.size();i>0;i--){
      if(a[i-1]!='0'){
	a[i-1]--;
	break;
      }
    }
  }
  vector<vector<Int> > dp2(c.size()+1,vector<Int>(10,0));
  if(c.size()>1){
    Int n=c.size();
    vector<Int> dp(n+1,0);
    dp[0]=-1;dp[1]=0;
    Int i=2,j=0;
    while(i<=n){
      if(c[i-1]==c[j]) dp[i++]=++j;
      else if(j>0) j=dp[j];
      else dp[i++]=0;
    }
    for(Int i=0;i<=n;i++){
      for(Int j=0;j<10;j++){
	Int k=i;
	while(k>=0&&c[k]-'0'!=j) k=dp[k];
	if(k<0) k++;
	if(c[k]-'0'==j) k++;
	dp2[i][j]=k;
      }
    }
  }else{
    dp2[0][c[0]-'0']=dp2[1][c[0]-'0']=1;
  }
  
  auto calc=[](string s,string t,vector<vector<Int> > &dp2){
    if(s=="$") return 0LL;
    Int res=0;
    Int n=s.size(),m=t.size();
    vector<vector<Int> > po(2,vector<Int>(n+1,0));
    po[0][n]=po[1][n]=1;
    for(Int i=n;i>0;i--){
      po[1][i-1]=po[1][i]*10%MOD;
      po[0][i-1]=((s[i-1]-'0')*po[1][i]%MOD+po[0][i])%MOD;
    }
    vector<vector<vector<Int> > > dp(2,vector<vector<Int> >(n+1,vector<Int>(m+1,0)));
    if(t!="0"){
      dp[0][0][0]=1;
      for(Int k=0;k<2;k++){
	for(Int i=0;i<n;i++){
	  for(Int j=0;j<=m;j++){
	    if(i==0&&j==0&&t=="0") continue;
	    for(Int a=0;a<10;a++){
	      if(!k&&a>(s[i]-'0')) continue;
	      dp[k||(a<(s[i]-'0'))][i+1][dp2[j][a]]+=dp[k][i][j];
	      dp[k||(a<(s[i]-'0'))][i+1][dp2[j][a]]%=MOD;
	    }
	  }
	  res+=dp[k][i][m]*po[k][i];
	  res%=MOD;
	}
      }
      res+=dp[0][n][m]+dp[1][n][m];
      res%=MOD;
    }else{
      res=1;
      dp[0][0][0]=1;
      for(Int k=0;k<2;k++){
	for(Int i=0;i<n;i++){
	  for(Int j=0;j<2;j++){
	    for(Int a=0;a<10;a++){
	      if(!k&&a>(s[i]-'0')) continue;
	      dp[k||(a<(s[i]-'0'))][i+1][j||a]+=dp[k][i][j];
	      dp[k||(a<(s[i]-'0'))][i+1][j||a]%=MOD;
	    }
	  }
	  res+=dp[k][i][1]*po[!(!k&&s[i]=='0')][i+1];
	  res%=MOD;
	}
      }
    }
    return res;
  };
  Int ans=0;
  ans+=calc(b,c,dp2);
  ans%=MOD;
  ans+=MOD-calc(a,c,dp2);
  ans%=MOD;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 116116
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s ;
  int sum = 700;
  for(int i = 0; i < s.size() + 1; i++){
    if(s[i] == 'o')
      sum+= 100;
  }
  cout << sum <<endl;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	map<string, int> smap;
	cin >> N;
	string s;
	int m = 0;
	rep(i, 0, N)
	{
		cin >> s;
		smap[s]++;
		chmax(m, smap[s]);
	}

	set<string> sset;
	for (auto& p : smap)
	{
		if (p.second == m)
		{
			sset.insert(p.first);
		}
	}

	for (auto& ps : sset)
	{
		cout << ps << endl;
	}

	return 0;
}

Measured memory_bytes: 33280
fun main(args: Array<String>) {
    val row1 = mutableListOf<Int>()
    val row2 = mutableListOf<Int>()
    val row3 = mutableListOf<Int>()
    val bingo1 = mutableListOf(0,0,0)
    val bingo2 = mutableListOf(0,0,0)
    val bingo3 = mutableListOf(0,0,0)

    readLine()!!.split(" ").forEach { row1.add(it.toInt()) }
    readLine()!!.split(" ").forEach { row2.add(it.toInt()) }
    readLine()!!.split(" ").forEach { row3.add(it.toInt()) }

    val n = readLine()!!.toInt()
    for (i in 0 until n) {
        val b = readLine()!!.toInt()
        if (row1.contains(b)) bingo1[row1.indexOf(b)] = 1
        if (row2.contains(b)) bingo2[row2.indexOf(b)] = 1
        if (row3.contains(b)) bingo3[row3.indexOf(b)] = 1
    }

    if (!bingo1.contains(0) || !bingo2.contains(0) || !bingo3.contains(0)
            || (bingo1[0] == 1 && bingo2[0] == 1 && bingo3[0] == 1)
            || (bingo1[1] == 1 && bingo2[1] == 1 && bingo3[1] == 1)
            || (bingo1[2] == 1 && bingo2[2] == 1 && bingo3[2] == 1)
            || (bingo1[0] == 1 && bingo2[1] == 1 && bingo3[2] == 1)
            || (bingo1[2] == 1 && bingo2[1] == 1 && bingo3[0] == 1)) println("Yes")
    else println("No")
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int D;
    cin >> D;
    vector<int> c(26);
    vector<vector<int>> s(D, vector<int>(26));
    REP(i, 26)
        cin >> c[i];
    REP(i, D)
        REP(j, 26) cin >> s[i][j];
    lint sat = 0;

    vector<int> las(26, -1), con(D);

    vector<int> t(D);
    REP(i, D)
    cin >> t[i];

    REP(i, D)
    {
        int tt = t[i] - 1;
        con[i] = tt;
        las[tt] = i;
        sat += s[i][tt];
        REP(j, 26)
        sat -= c[j] * (i - las[j]);
        //cout << sat << "\n";
    }

    int m;
    cin >> m;
    REP(i,m){
        int d, q;
        cin >> d >> q;
        t[d - 1] = q;
        lint sat2 = 0;
        vector<int> las2(26, -1);
        REP(i, D)
        {
            int tt = t[i] - 1;
            con[i] = tt;
            las2[tt] = i;
            sat2 += s[i][tt];
            REP(j, 26)
            sat2 -= c[j] * (i - las2[j]);
        }
        cout << sat2 << "\n";
    }
    return 0;
}

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

const int max_n=2e5+10;
int a[max_n];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;++i) cin>>a[i];
    int max_h=a[1];
    long long sum=0;
    for(int i=2;i<=n;++i){
        if(a[i]<max_h) sum+=max_h-a[i];
        else max_h=a[i];
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 4304
#include<iostream>
#include<string>
using namespace std;
int main(){
	for(;;){
		long long H,W;
		cin>>H>>W;
		if(H==0&&W==0)break;
		else{
			for(long long a=0;a<H;a++){
				for(long long b=0;b<W;b++){
					cout<<"#";
					}
					cout<<endl;
				}
			}
			cout<<endl;
		}
	}



Measured memory_bytes: 3092
#include<iostream>
#include<deque>



inline std::deque<int> create_integer_list(size_t count) {
	std::deque<int> lst(count);
	for (size_t i = 0; i < count; ++i) {
		std::cin >> lst.at(i);
	}
	return lst;
}

int main() {
	size_t N, M, C;
	size_t result{};
	std::cin >> N >> M >> C;
	std::deque<int> B = create_integer_list(M);
	std::deque<std::deque<int>> A(N);
	for (int i = 0; i < N; ++i)
		A.at(i) = create_integer_list(M);
	for (int i = 0; i < N; ++i) {
		int sum{};
		for (int j = 0; j < M; ++j)
			sum += A.at(i).at(j) * B.at(j);
		sum += C;
		if (sum > 0)
			++result;
	}
	std::cout << result << std::endl;
	return 0;
}


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

int main(void)
{
	int i,j,c;
	int a[50];
	int n,p;
	
	while(1)
	{
		scanf("%d %d",&n,&p);
		if(n == 0 && p == 0)break;
	
		for(i=0;i<n;i++){
		  a[i] = 0;
		}
	
		i = 0;
		while(1){
			while(1){
				a[i++] += 1;
				if(i==n)i -= n;
				p--;
				if(p==0){break;}
			}
			
			c = 0;
			for(j=0;j<n;j++)
			{
				if(a[j] != 0){
	  			c++;
	  			if(c==2)break;
	  		}
			}
			if(c == 1){
				if(i==0)i=n;
				printf("%d\n",i-1);
				break;
			}
		
			while(a[i]==0){
				i++;
				if(i==n){
			  i = 0;}
			}

			p = a[i];
			a[i++] = 0;
			if(i==n)i = 0;

		}
	
	}
  return 0;
}

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

using namespace std;
using ll = long long;
using pl = pair<ll,ll>;

struct UnionFind {
  vector<int> par;
  
  UnionFind(int n) : par(n, -1) { }
  void init(int n) { par.assign(n, -1); }
  
  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }
  
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
  
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y); // merge technique
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  
  int size(int x) {
    return -par[root(x)];
  }
};

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
  UnionFind uf(N);
  ll com = N*(N-1) / 2;
  vector<ll> v;
  for(ll i = M-1; i>=0; i--) {
    ll x = A[i]-1;
    ll y = B[i]-1;
    if(uf.issame(x, y))
      v.push_back(0);
    else {
      v.push_back(uf.size(x)*uf.size(y));      
      uf.merge(x, y);
    }
  }
  std::cout << v[M-1] << std::endl;
  for(ll i=M-1; i>0; i--) {
    v[i-1] += v[i];
    std::cout << v[i-1] << std::endl;
  }
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> A(M);
  std::vector<long long> B(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&A[i]);
    scanf("%lld",&B[i]);
  }
  solve(N, M, std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 4212
#include <bits/stdc++.h>
#ifdef TEST
#include <mytest.h>
#else
#define open(...) 0
#define print(...) 42
#endif
using namespace std;

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b, ans = 0;
  cin >> a >> b;
  while (ans * a - ans + 1 < b) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
int a,b;
int main()
{
	cin>>a>>b;
	cout<<ceil((double)a/(double)b)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {
    string s;
    cin >> s;
    ll ans = 0;
    FOR(i, (1 << (s.length() - 1))) {
        VI a(1, 0);
        FOR(j, s.length() - 1)if (i & 1 << j)a.push_back(j + 1);
        a.push_back(s.length());
        FOR1(j, a.size())ans += stoll(s.substr(a[j - 1], a[j] - a[j - 1]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1e9+1;


void solve(){
    int n;
    cin >> n;
    rep(i,111){
        if((n+i)%111==0){
            cout << n+i << endl;
            break;
        }
    }
}

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


Measured memory_bytes: 256
def pow(x, n , mod):
    res = 1
    while n > 0:
        if  bin(n & 1) == bin(1) :
            res = res * x % mod
        x = x*x % mod
        n = n >>1
    return res   

def combination(n,a):
    x = 1
    for i in range(a):
        x = x * (n-i) % mod
    y = 1
    for i in range(a):
        y = y * (a-i) % mod
    y = pow(y, mod-2, mod)
    return (x*y % mod)

n = int(input())
a = list(map(int, input().split()))
mod =1

m = max(a)
a = sorted(a)

ans = 0

for i in a:
    if abs(m/2-i) < abs(m/2-ans):
        ans = i

print(m, ans)

Measured memory_bytes: 14432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    string s;
    cin>>s;
    string ans="NA";
    string ss=s.substr(0,2);
    string sss=s.substr(2,2);
    int i=stoi(ss);
    int j=stoi(sss);
    if(0<i && i <13){
        if(0<j &&j<13){
            ans="AMBIGUOUS";
        }else{
            ans="MMYY";
        }


    }else{
        if(0<j &&j<13){
            ans="YYMM";
        }
    }

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

Measured memory_bytes: 256
# dp practice
n,k=input().strip().split(" ")
n,k=[int(n),int(k)]
h=list(map(int,input().strip().split(" ")))
dp=[1293932222 for _ in range(n)]
dp[0]=0
for i in range(n):
    for j in range(1,k+1):
        if (i+j<=n-1):
            dp[i+j]=min(dp[i+j],abs(h[i]-h[i+j])+dp[i])
print(dp[n-1])
        

Measured memory_bytes: 55904
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
#define vpp vector<pair<ll,ll>>
#define ff first
#define ss second
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
int main()
{
    rkc;
    ll x,a;
    cin>>x>>a;
    if(x<a)cout<<0;
    else cout<<10;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

char a[100][100];
int h,w;

int check( int x , int y ){

  if( a[x][y] == 'x' ){ // すでに訪れてるので終了
    cout << "LOOP" << endl;
    return 0;
  }
  else if( a[x][y] == '.' ){ // .だとループするこはないので終了
    cout << y << " " << x<< endl;
    return 0;
  } 

  else if( a[x][y] == '>' ){
    a[x][y] = 'x'; // 訪れたところにはxを入れる
    check( x , y + 1);
  }
  else if( a[x][y] == '<' ){
    a[x][y] = 'x'; // 訪れたところにはxを入れる
    check( x , y - 1 );
  }
  else if( a[x][y] == '^' ){
    a[x][y] = 'x'; // 訪れたところにはxを入れる
    check( x - 1, y );
  }
  else if( a[x][y] == 'v' ){
    a[x][y] = 'x'; // 訪れたところにはxを入れる
    check( x + 1 , y );
  }

}


int main(void){

  while( cin >> h >> w , h || w ){

    for( int i = 0 ; i < h ; i++ ){
      for( int j = 0 ; j < w ; j++ ){
	cin >> a[i][j]; // 読み込み
      }
    }

    check( 0 , 0 );

    // for( int i = 0 ; i < h ; i++ ){
    // for( int j = 0 ; j < w ; j++ ){
    //	cout << a[i][j];
    // }
    // cout << endl;
    //}

  }
  return 0;
}

Measured memory_bytes: 1168
import math
K=int(input())
out=int(0)
if K<3:
    for i in range (1,K+1):
        for j in range (1,K+1):
            for k in range (1,K+1):
                out=out+math.gcd(math.gcd(i,j),k)
else:
    out = out + K*(K+1)/2
    for i in range (1,K):
        for j in range (i+1,K+1):
            out = out+6*math.gcd(i,j)

    for i in range (1,K-1):
        for j in range (i+1,K):
            for k in range (j+1,K+1):
                out=out+6*math.gcd(math.gcd(i,j),k)
print(int(out))

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

int main(){
  int N, M, X, to0 = 0, toN = 0;
  cin >> N >> M >> X;
  vector<int> v(M);
  for (int i = 0; i < M; i++){
    cin >>v.at(i);
    if (v.at(i) < X) to0++;
    else toN++;
  }
  cout << min(to0, toN);
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<int,string> P;

int main(){
    // dictionary
    int n;
    cin >> n;
    vector<int> p(n),q(n),a(n);
    rep(i,n)cin >> p[i];
    rep(i,n)cin >> q[i];
    rep(i,n)a[i] = i+1;
    map<vector<int>, int> mp;
    do{
        mp[a] = mp.size();
    }while(next_permutation(a.begin(),a.end()));
    cout << abs(mp[p]-mp[q]) << endl;
    return 0;
}

Measured memory_bytes: 5248
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	ans := map[int]int{}
	for x := 1; x < 110; x++ {
		for y := 1; y < 110; y++ {
			for z := 1; z < 110; z++ {
				b := x*x + y*y + z*z + x*y + y*z + z*x
				ans[b]++
			}
		}
	}
	for i := 1; i < n+1; i++ {
		fmt.Fprintln(wr, ans[i])
	}
}


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

int i,j,k,l,m;
ll mod=1000000007;

int main(){    
    ll n,k,ans=0;cin>>n>>k;
    
    for(i=k;i<=n+1;i++){
        ans+=((n-i+2)+(i-1)*(n-i+1));
        ans%=mod;
    }

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

Measured memory_bytes: 3644
N, T  = [int(i) for i in input().split()]
C_T_list = [[int(x) for x in input().split()] for _ in range(N)]
C_T_list.sort()
ans = 0
for C_T in C_T_list:
    if C_T[1] <= T:
        ans = C_T[0]
        break

if ans:     
    print(ans)
else:
    print('TLE')

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

class UnionFind {
    vector<int> parent;

    public:
        UnionFind(int size) {
            parent = vector<int>(size, -1);
        }

        int find(int x) {
            if (parent[x] < 0) {
                // parent itself
                return x;
            } else {
                return parent[x] = find(parent[x]);
            }
        }

        bool unite(int x, int y) {
            int rX, rY;
            if ((rX = find(x)) == (rY = find(y))) {
                // already united
                return false;
            }
            if (size(rX) < size(rY)) {
                int tmp = rX;
                rX = rY;
                rY = tmp;
            }
            parent[rX] += parent[rY];
            parent[rY] = rX;
            return true;
        }

        int size(int x) {
            return -parent[find(x)];
        }

        bool is_same(int x, int y) {
            return find(x) == find (y);
        }

        int component_count() {
            int c = 0;
            for (const int x : parent) {
                if (x < 0) {
                    c++;
                }
            }
            return c;
        }
};

int main() {
    int n, m;
    cin >> n >> m;

    UnionFind uf = UnionFind(n + m);
    int k, l;
    REP(i, n) {
        cin >> k;
        REP(j, k) {
            cin >> l;
            uf.unite(i, n + l - 1);
        }
    }

    REP(i, n - 1) {
        if (!uf.is_same(i, i + 1)) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

ll A, B;

int dy[] = {1, 1, 1, 0, 0, -1, -1, -1};
int dx[] = {0, -1, 1, -1, 1, 0, -1, 1};

void solve() {
    cin >> A >> B;
    char big, small;
    if (A > B) big = '.', small = '#';
    else big = '#', small = '.';
    if (B > A) swap(A, B);
    vector<string> ans(100);
    rep(i,100) {
        ans[i].resize(100);
        rep(j,100) ans[i][j] = small;
    }
    int cnt = 0;
    rep(i,100) {
        rep(j,100) {
            if ((i-1) % 4 == 0 && (j-1) % 4 == 0) {
                ans[i][j] = big;
                cnt++;
            }
            if (cnt == A) break;
        }
        if (cnt == A) break;
    }
    cnt = 0;
    rep(i,100) {
        rep(j,100) {
            if ((i-1) % 4 == 0 && (j-1) % 4 == 0) {
                rep(k,8) {
                    ans[i+dy[k]][j+dx[k]] = big;
                }
                ans[i][j] = small;
                cnt++;
            }
            if (cnt == B-1) break;
        }
        if (cnt == B-1) break;
    }
    cout << "100 100" << endl;
    rep(i,100) cout << ans[i] << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pii pair<ll,ll> 
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() 
{
    FAST;
    ll n;
    cin>>n;
    ll a[n+7][7];
    ll i,j,k;
    for(i=1;i<=n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    ll d[n+7][7];
    memset(d,0,sizeof(d));
    for(i=1;i<=n;i++)
    {
        for(j=0;j<3;j++)
        {
            for(k=0;k<3;k++)
            {
                if(j!=k)
                {
                    d[i][j]=max(d[i][j],a[i][j]+d[i-1][k]);
                }
            }
        }
    }
    // for(i=1;i<=n;i++)
    // {
    //     for(j=0;j<3;j++)
    //     {
    //         cout<<d[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    cout<<max(d[n][0],max(d[n][1],d[n][2]));
}

Measured memory_bytes: 11136
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
const int N = 6005;

int n, t, dp[N];
pair<int, int> a[N];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> t;
    for (int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second;
    sort(a, a + n);
    for (int i = 0; i < n; ++i)
    for (int j = t + a[i].first - 1; j >= a[i].first; --j)
        dp[j] = max(dp[j], dp[j - a[i].first] + a[i].second);

    cout << *max_element(dp, dp + N) << '\n';
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
ab = []
cd = []

n.times do
  ab << gets.split.map(&:to_i)
end

m.times do
  cd << gets.split.map(&:to_i)
end

ab.each do |st|
  min = 1 << 31
  index = 0
  cd.each_with_index do |ch, i|
    dist = (st[0] - ch[0]).abs + (st[1] - ch[1]).abs
    if dist < min
      min = dist
      index = (i + 1)
    end
  end
  puts index
end

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  bool F=false;
  long long M=0;
  long long L=100;
  cin>>N;
  vector<int>vec(N);
  for(int X=0;X<N;X++){
    cin>>vec.at(X);
    M+=vec.at(X);
    if(vec.at(X)%10!=0 && L>vec.at(X)){
      L=vec.at(X);
      F=true;
    }
  }
  if(M%10!=0){
    cout<<M<<endl;
  }
  else if(F==false){
    cout<<0<<endl;
  }
  else{
    cout<<M-L<<endl;
  }
}

Measured memory_bytes: 3612
from typing import List


def get_value(card: str) -> int:
    return card[1]


def bublle_sort(C: List[str]) -> None:
    for i in range(len(C)):
        for j in reversed(range(i + 1, len(C))):
            if get_value(C[j]) < get_value(C[j - 1]):
                C[j], C[j - 1] = C[j - 1], C[j]


def selection_sort(C: List[str]) -> None:
    for i in range(len(C)):
        min_j = i
        for j in range(i, len(C)):
            if get_value(C[j]) < get_value(C[min_j]):
                min_j = j
        C[i], C[min_j] = C[min_j], C[i]


def is_stable(A_in, A_out) -> bool:
    for i in range(len(A_in)):
        for j in range(i + 1, len(A_in)):
            for a in range(len(A_out)):
                for b in range(a + 1, len(A_out)):
                    if get_value(A_in[i]) == get_value(A_in[j]) and A_in[i] == A_out[b] and A_in[j] == A_out[a]:
                        return False
    return True


N = int(input())
C = [str(i) for i in input().split()]
C1 = [i for i in C]
C2 = [i for i in C]

bublle_sort(C1)
print(' '.join(C1))
if is_stable(C, C1):
    print('Stable')
else:
    print('Not stable')

selection_sort(C2)
print(' '.join(C2))
if is_stable(C, C2):
    print('Stable')
else:
    print('Not stable')



Measured memory_bytes: 7172
// ConsoleApplication15.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<algorithm>
using namespace std;
int main()
{
	long long int n;
	double l;
	while (cin>>n)
	{
		l = 1;
		while (n>1)
		{
			n /= 2;
			l *= 2;
			l++;
		}
		cout <<fixed<<setprecision(0)<<l<< "\n";
	}
}

Measured memory_bytes: 256
(defun solve (n b)
  (declare (ignore n))
  (+ (first b)
     (loop for (x . xs) on b
           if (and xs
                   (< (first xs) x))
           sum (first xs)
           else
           sum x)))

#-swank
(let* ((n (read))
       (b (loop repeat (1- n) collect (read))))
  (format t "~A~%" (solve n b)))


Measured memory_bytes: 18788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int ans[][] = new int[N][N];

		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
			ans[i][j] = 0;
			}
		}

		for(int i = 0; i < N; i++) {
			int num = sc.nextInt();
			int k = sc.nextInt();

			for(int j = 0; j < k; j++) {
				int switch_num = sc.nextInt();
				ans[i][switch_num-1] = 1;
			}
		}
		//答えの出力
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
			System.out.print(ans[i][j]);
				if (j != N-1) {
					System.out.print(" ");
				}
			}
			System.out.println();
		}
	}
}


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

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n;
pair<pair<int,int>,int> p[114514];
vector<pair<int,int> > e[114514];

int prim() {
	priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> q;
	bool used[n];
	memset(used, 0, sizeof(used));
	q.push({0,0});
	int res = 0;
	while (!q.empty()) {
		int cost = q.top().first, v = q.top().second; q.pop();
		if (used[v]) continue;
		used[v] = true;
		res += cost;
		for (auto &i:e[v]) q.push({i.second, i.first});
	}
	return res;
}

signed main() {
	cin >> n;
	rep(i,n) {
		cin >> p[i].fi.fi >> p[i].fi.se;
		p[i].se = i;
	}
	sort(p,p+n);
	rep(i,n-1) e[p[i].se].push_back({p[i+1].se, p[i+1].fi.fi-p[i].fi.fi}), e[p[i+1].se].push_back({p[i].se, p[i+1].fi.fi-p[i].fi.fi});
	rep(i,n) swap(p[i].fi.fi, p[i].fi.se);
	sort(p,p+n);
	rep(i,n-1) e[p[i].se].push_back({p[i+1].se, p[i+1].fi.fi-p[i].fi.fi}), e[p[i+1].se].push_back({p[i].se, p[i+1].fi.fi-p[i].fi.fi});
	cout << prim();
}

Measured memory_bytes: 20464
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define INF 10000000
typedef pair<int, int>P;
int h, w;
int f[1005][1005] = { 0 };
int dx[] = { 1,0,-1,0 }, dy[] = { 0,-1,0,1 };
int stop[1005][1005] = { 0 };
int cnt[1005][1005] = { 0 };
int visited[1005][1005] = { 0 };
void bfs(int x, int y) {
	for (int i = 0; i < 1005; i++)
		for (int j = 0; j < 1005; j++) visited[i][j] = 0;
	queue<P>que;
	que.push(P(x, y));
	visited[x][y] = 1;
	while (!que.empty()) {
		P p = que.front();
		que.pop();
		for (int k = 0; k < 4; k++) {
			int nx = p.first + dx[k];
			int ny = p.second + dy[k];
			if (1 <= nx && nx <= h && 1 <= ny && ny <= w&&!visited[nx][ny]) {
				if (f[p.first][p.second] < f[nx][ny]) {
					que.push(P(nx, ny));
					cnt[nx][ny]++;
					visited[nx][ny] = 1;
				}
			}
		}
	}
	return;
}
int main() {
	int res = 0;
	cin >> h >> w;
	for (int i = 0; i <= h + 1; i++)
		for (int j = 0; j <= w + 1; j++) f[i][j] = INF;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) cin >> f[i][j];
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			bool flag = true;
			for (int k = 0; k < 4; k++) {
				int nx = i + dx[k];
				int ny = j + dy[k];
				if (f[i][j] > f[nx][ny]) flag = false;
			}
			if (flag) {
				stop[i][j] = 1;
			}
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (stop[i][j]) {
				//cout << i << " " << j << endl;
				bfs(i, j);
			}
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			//cout << cnt[i][j] << " ";
			if (cnt[i][j] >= 2) res++;
		}
		//cout << "\n";
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 14960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, M;
int a, b;
int ans[51];
int main(){
  cin.sync_with_stdio(false);
  cin >> N >> M;
  for(int i = 0; i <= N; i++){
    ans[i] = 0;
  }
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    ans[a]++;
    ans[b]++;
  }


  for(int i = 1; i <= N; i++){
    cout << ans[i] << endl;
  }


}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<deque>

using namespace std;

class UnionFind{//UnionFind木
 private:
    vector<int> Parent;
 public:
    UnionFind(int N){
        vector<int> Parent(N,-1);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A]=root(Parent[A]);
    }

    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A,int B){
        A=root(A);
        B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) swap(A,B);
        Parent[A]-=Parent[B];
        Parent[B]=A;
    }
};

typedef pair<int, int> P;
typedef long long ll;
const int division = 1000000007;


ll mpow(ll x, ll n){ //x^n(mod division) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % division;
        x = x*x % division;
        n = n >> 1;
    }
    return ans;
}

ll cmb(ll a, ll b){ //aCbをmod計算
    vector<ll> fac; //n!(mod division)
    vector<ll> ifac; //k!^{M-2} (mod division)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    fac.push_back(1);
    ifac.push_back(1);
    for(ll i = 0; i<a; i++){
        fac.push_back(fac[i]*(i+1) % division); // n!(mod division)
        ifac.push_back(ifac[i]*mpow(i+1, division-2) % division); // k!^{M-2} (mod division) ←累乗にmpowを採用
    }
    ll tmp = ifac[a-b]* ifac[b] % division;
    return tmp * fac[a] % division;
}
int gcd(int x,int y){return y ? gcd(y,x%y) : x;};//xとyの最大公約数

int main(){
    int A,P;
    cin >> A >> P;
    P+=3*A;
    cout << P/2 << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int d, score;
vector<int> c(26);
vector<vector<int>> s(400, vector<int>(26)), pos(26);

int get_score(vector<int> t){
    vector<int> pos(26, 0);
    int ans = 0;
    rep(i, t.size()){
        int l = i + 1 - pos[t[i]];
        ans -= (l * (l-1) / 2) * c[t[i]];
        ans += s[i][t[i]];
        pos[t[i]] = i+1;
    }
    rep(i, 26){
        int l = t.size() + 1 - pos[i];
        ans -= (l * (l-1) / 2)* c[i];
    }
    return ans;
}

int main() {
    cin >> d;
    rep(i, 26)cin >> c[i];
    rep(i, d)rep(j, 26)cin >> s[i][j];
    //-----code------// 
    vector<int> t, pos(26, 0);
    rep(i, d){
        int max_score = -mod;
        int best_j = -1;
        rep(j, 26){
            t.push_back(j);
            int score = get_score(t);
            if(max_score < score){
                best_j = j;
                max_score = score;
            }
            t.pop_back();
        }
        t.push_back(best_j);
    }
    vector<int> ans = t;
    while(clock() < 1.95 * CLOCKS_PER_SEC){
        if(rand() % 2 == 0){
            int D = rand() % d, q = rand() % 26;
            int old = t[D];
            int olds = get_score(t);
            t[D] = q;
            int score = get_score(t);
            if(score < olds){
                t[D] = old;
            }
        }else{
            int a = 5 + rand() % (d-10), b = 1 + rand() % 4;
            int olds = get_score(t);
            swap(t[a], t[b]);
            int score = get_score(t);
            if(score < olds){
                swap(t[a], t[b]);
            }
        }
    }
    rep(i, d)cout << ans[i]+1 << endl;
}


Measured memory_bytes: 3728
#include <string>
#include <iostream>
using namespace std;
int H, W, d; string col = "RGBY";
int main() {
	cin >> H >> W >> d;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << col[(i + j) / d % 2 * 2 + (i - j + 4 * W) / d % 2];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	string a;
	cin >> a;
	int n = a.size();
	if (n == 2) {
		if (a[0] == a[1]) {
			printf("%d %d\n", 1, 2);
		} else {
			puts("-1 -1");
		}
		return 0;
	}
	for (int i = 1; i < n; i++) {
		if (a[i] == a[i - 1]) {
			printf("%d %d\n", i, i + 1);
			return 0;
		}
	}
	for (int i = 2; i < n; i++) {
		if ((a[i] == a[i - 1]) || (a[i] == a[i - 2]) || (a[i - 1] == a[i - 2])) {
			printf("%d %d\n", i - 1, i + 1);
			return 0;
		}
	}
	puts("-1 -1");
	return 0;
}

Measured memory_bytes: 512
from collections import Counter
S = input()[::-1]
MOD = 2019
X = [0]
for i, s in enumerate(S):
  X.append((X[-1] + int(s)*pow(10,i,MOD)) % MOD)

C = Counter(X)
res = 0
for v in C.values():
  res += v*(v-1) // 2

print(res)

Measured memory_bytes: 76264
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)(j);i <= (int)(k);i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define fix cout<<fixed<<setprecision(20);
const int maxn=(int)1e6+5;
vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int l;string s;
    cin>>l>>s;
    int ans=0;
    rep(i,0,l-1){
        //debug(s.substr(i));
        vector<int> z=z_function(s.substr(i));
        for(int j=0;j<z.size();j++){
            ans=max(ans,min(j,z[j]));
        }
    }
    cout<<ans<<endl;
}

/* 
s的最长重复子串
二分+ hash or 后缀数组
Zfunction
 */

Measured memory_bytes: 256
def main():
    M = 10 ** 5
    N, K = list(map(int, input().split(' ')))
    count = [0 for _ in range(M + 1)]
    for _ in range(N):
        a, b = list(map(int, input().split(' ')))
        count[a] += b
    ans = 0
    while K > 0:
        ans += 1
        K -= count[ans]
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 5936
use std::io;
use std::cmp;
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let N: i32 = iter.next().unwrap().parse().unwrap();
    println!("ABC{}", N);
}


Measured memory_bytes: 4352