akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> ret(n);
    for (int i = 1; i < n; i++) {
        int a;
        cin >> a;
        ret[--a]++;
    }
    for (auto x:ret)cout << x << endl;
    return 0;
}

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

int main()
{
  
  string s;
  cin>>s;
  int counter=0;
  int maxi=0;
  
  for(char c :s)
  {
    if(c=='S')
      counter=0;
    else
      counter++;
    maxi=max(maxi,counter);
  }
  cout<<maxi<<endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, M;
    cin >> N >> M;
    bool cone[N][N];
    rep(i, N) rep(j, N) cone[i][j] = false;
    rep(i, M){
        int u, v;
        cin >> u >> v;
        u--, v--;
        cone[u][v] = true;
        cone[v][u] = true;
    }
    int ans = 0;
    vector<int> nums;
    rep(i, N) nums.pb(i);
    do{
        bool able = true;
        rep(i, N-1){
            if(!cone[nums[i]][nums[i+1]]) able = false;
        }
        if(nums[0] == 0 && able) ans++;
    } while(next_permutation(nums.begin(), nums.end()));
    cout << ans << endl;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


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

int main(){
  string str;
  int y,m,d;
  while(cin >> str,str[0]!='#'){
    cin >> y >> m >> d;
    if(y > 31){
      cout << "?" << " " << y-30 << " " << m << " " << d << endl;
    }else if(y==31 && m >4){
      cout << "?" << " " << y-30 << " " << m << " " << d << endl;
    }else{
      cout << str << " " <<  y << " " << m << " " << d << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int s[50]={0};
	int h[50]={0};
	int c[50]={0};
	int d[50]={0};
	for(int i=0;i<n;i++){
		string str;
		int tmp;
		cin>>str>>tmp;
		if(str=="S") s[tmp]=1;
		if(str=="H") h[tmp]=1;
		if(str=="C") c[tmp]=1;
		if(str=="D") d[tmp]=1;
	}
	for(int i=1;i<=13;i++){
		if(s[i]==0) cout<<"S "<<i<<endl;
	}
	for(int i=1;i<=13;i++){
		if(h[i]==0) cout<<"H "<<i<<endl;
	}
	for(int i=1;i<=13;i++){
		if(c[i]==0) cout<<"C "<<i<<endl;
	}
	for(int i=1;i<=13;i++){
		if(d[i]==0) cout<<"D "<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 3160
"""
https://abc070.contest.atcoder.jp/tasks/abc070_b
"""
[a,b,c,d]=[int(i) for i in input().split()]
#abcd,cdab,
if b<c or d<a:
    print(0)
#acbd
elif a<=c and c<=b and b<=d:
    print(b-c)
#cabd
elif c<=a and b<=d:
    print(b-a)
#cadb
elif c<=a and d<=b:
    print(d-a)
#acdb
elif a<=c and d<=b:
    print(d-c)


Measured memory_bytes: 3060
#include <stdio.h>
int schedule[101];

int main(void){
    int N,Q,i,j,M,date,max;
    while(scanf("%d %d",&N,&Q),N||Q){
        for(i=0;i<101;i++)schedule[i]=0;
        for(i=0;i<N;i++){
            scanf("%d",&M);
            for(j=0;j<M;j++){
                scanf("%d", &date);
                schedule[date]++;
                //printf("date:%d %d\n",date,schedule[date]);
            }
        }
        max=0;
        for(i=100;i>0;i--){
            if(max<=schedule[i]){
                max=schedule[i];
                date=i;
            }
        }
        if(max>=Q){
            printf("%d\n",date);
        }else{
            printf("%d\n",0);
        }
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

#define FOR(i,n) for(ll i=0;i<n;i++)

struct edge{ll to,cost;};

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0); 
   int a,b,c,d;
   cin >> a >> b >> c >> d;
   if(abs(a-c) <= d){
      cout << "Yes" << endl;
   }
   else if(abs(a-b) <= d && abs(b-c) <= d){
      cout << "Yes" << endl;
   }
   else{
      cout << "No" << endl;
   }
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, y,yukiti=0,higuti=0,noguchi=0,check=0;
	cin >> n >> y;
	y = y / 1000;
	for (int i = 0; i <= n; i ++) {
		for (int j = 0; j <= n-i; j++) {
			if (i * 10 + j + 5 * (n - i - j) == y) {
				yukiti = i;
				higuti = n - i - j;
				noguchi = j;
				check = 1;
				break;
			}
		}
		if (check != 0)break;
	}
	if (check != 0)cout << yukiti << ' ' << higuti << ' ' << noguchi << endl;
	else cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut s: Vec<usize> = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
    let mut h: Vec<usize> = s.clone();
    let mut c: Vec<usize> = s.clone();
    let mut d: Vec<usize> = s.clone();
    let mut ans: Vec<String> = Vec::new();
    for _ in 0..n {
        let t: String = read();
        let i: usize = read();
        if t == "S" {
            s.retain(|&x| x != i);
        } else if t == "H" {
            h.retain(|&x| x != i);
        } else if t == "C" {
            c.retain(|&x| x != i);
        } else if t == "D" {
            d.retain(|&x| x != i);
        }
    }
    ans.extend_from_slice(
        &s.into_iter()
            .map(|x| "S ".to_string() + &x.to_string())
            .collect::<Vec<String>>()[..],
    );
    ans.extend_from_slice(
        &h.into_iter()
            .map(|x| "H ".to_string() + &x.to_string())
            .collect::<Vec<String>>()[..],
    );
    ans.extend_from_slice(
        &c.into_iter()
            .map(|x| "C ".to_string() + &x.to_string())
            .collect::<Vec<String>>()[..],
    );
    ans.extend_from_slice(
        &d.into_iter()
            .map(|x| "D ".to_string() + &x.to_string())
            .collect::<Vec<String>>()[..],
    );
    if ans.len() == 0 {
        print!("");
    } else {
        println!("{}", ans.join("\n"));
    }
}


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

// a quote from http://www.igaris.com/math/c.pdf

#define MOD (1000000000+7)

long long C[1001][1001];

long long power( long long x, int n )
{
	if( n == 0 ) {
		return 1;
	}
	if( n % 2 ) {
		return x * power( x, n - 1 ) % MOD;
	}
	else {
		return power( x * x % MOD, n / 2 );
	}
}

long long ifac( long long x )
{
	long long f = 1;
	while( x > 1 ) {
		f *= power( x, MOD - 2 );
		f %= MOD;
		x--;
	}
	return f;
}

long long part_num( long long n, int k )
{
	if( n == 1 || k == 1) {
		return 1;
	}
	if( n < 0 || k < 1 ) {
		return 0;
	}
	if( C[n][k] ) {
		return C[n][k];
	}
	long long res = ( part_num( n - k, k ) + part_num( n, k - 1 ) ) % MOD;
	C[n][k] = res;
	return res;
}

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

/*
	// Pascal's triangle for combination
	C[0][0] = 1;
	for( int i = 1; i < 1001; i++ ) {
		for( int j = 0; j <= i; j++ ) {
			if( j == 0 || j == i ) {
				C[i][j] = C[i - 1][0];
			}
			else {
				C[i][j] = ( C[i - 1][j - 1] + C[i - 1][j] ) % MOD;
			}
		}
	}
*/

	long long ans = 0;
	if( n >= k ) {
		ans = part_num( n - k, k );
	}

	cout << ans << endl;

	return 0;
}



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


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

Measured memory_bytes: 3644
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int n = 1;
        while (n < 2000) {
            if (n / 10 == b && (int)(n * 0.08) == a) {
                System.out.println(n);
                return;
            }
            n++;
        }
        System.out.println(-1);
    }
}


Measured memory_bytes: 21972
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 2e5 + 7;
const int Inf = 1e9 + 7;
typedef long long ll;
typedef pair <int, int> pr;
map <int, int> mp;
set <int> sst;
vector <int> vect;
priority_queue <pr> qua;
int n;
int a[maxn];
 
int main() {
	cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] -= i;
	}
	sort(a + 1, a + n + 1);
	int mid = 0; //中位数
	if(n & 1) mid = a[(n + 1) / 2];
	else mid = (a[n / 2] + a[n / 2] + 1) / 2;
	for(int i = 1; i <= n; i++) sum += abs(a[i] - mid);
	cout << sum << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int M = Integer.parseInt(sc.next());
    boolean[] f1 = new boolean[N+1];
    boolean[] f2 = new boolean[N+1];
    
    for(int i = 0; i < M; i++){
      int a = Integer.parseInt(sc.next());
      int b = Integer.parseInt(sc.next());
      if(a == 1){
        f1[b] = true;
      }
      if(b == 1){
        f1[a] = true;
      }
      if(a == N){
        f2[b] = true;
      }
      if(b == N){
        f2[a] = true;
      }
    }
    
    String ans = "IMPOSSIBLE";
    for(int i = 1; i <= N; i++){
      if(f1[i] && f2[i]){
        ans = "POSSIBLE";
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 65324
#include <iostream>
#include <cmath>

using namespace std;

int main ()
{
    long X;
    long A, B;

    cin >> X;
    
    for (A = 0; A < 128; A++) {
        for (B = -128; B < 128; B++) {
            if ((pow(A, 5) - pow(B, 5)) == X) {
                goto end;
            }
        }
    }

end:
    cout << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
 
int h1, m1, h2, m2, k;
 
int main(){
	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	h1 = h1 * 60 + m1;
	h2 = h2 * 60 + m2 - k;
	printf("%d\n", max(0, h2 - h1));
	return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<b;i++)
#define f(i,n) for(int i=0;i<n;i++)
typedef unsigned long long ull;
typedef long long ll;
#define pb(a) push_back(a);

int main(){
	int n;
	cin>>n;
	// int dp[]
	int choice[n];
	int a[n][3],dp[n][3];
	// int maxA,maxB,maxC,total=0,na,nb,nc;
	f(i,n){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		if(i==0) {
			dp[i][0]=a[i][0];
			dp[i][1]=a[i][1];
			dp[i][2]=a[i][2];
			// total = max(maxA,max(maxB,maxC));
		}
		else{
			dp[i][0] = a[i][0] + max(dp[i-1][1],dp[i-1][2]);
			dp[i][1] = a[i][1] + max(dp[i-1][0],dp[i-1][2]);
			dp[i][2] = a[i][2] + max(dp[i-1][1],dp[i-1][0]);
			
		}
		
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	return 0;
}

Measured memory_bytes: 2560
using System;

class A{
  static void Main(){
    int[] Ar = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    int ans = 0, soc = 1;
    while (soc < Ar[1]){
      ans++;
      soc += Ar[0]- 1;
    }
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 27524
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n,m,c,ans=0;
    cin >> n >> m >> c;
    int a[n][m];
    vector<int> v;
    vector<int> b(m);
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    for(int i=0;i<n;i++){
        int sum=0;
        for(int j=0;j<m;j++){
            cin >> a[i][j];
            sum += a[i][j]*b[j]; 
        }
        if(sum + c > 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
int  min(int  a,int  b)
{
	return a<b?a:b;
}
int main()
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if (a<=c&&b>=c)printf("%d",min(b,d)-c);else if (c<=a&&a<=d)printf("%d",min(b,d)-a);else printf("0");
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

set<ll> s;
vll t(17, 1);
void calc(ll num, ll keta){
  if(num>3234566667||keta>10) return;
  s.insert(num);
  if(num==0){
    if(keta==0) {
      for(int i=0;i<=9;i++) calc(i*t[keta], keta+1);
    }
    else{
      calc(0, keta+1);
      calc(1*t[keta], keta+1);
    }
  }else{
    ll prev = num/t[keta-1];
    calc(num+prev*t[keta], keta+1);
    if(prev!=0) calc(num+(prev-1)*t[keta], keta+1);
    if(prev!=9) calc(num+(prev+1)*t[keta], keta+1);
  }
}
int main(int argc, char const *argv[]) {
  ll k;std::cin >> k;
  for(int i=1;i<17;i++) t[i] = t[i-1]*10;
  calc(0, 0);
  ll c = 0;
  for(auto itr=s.begin();itr!=s.end();itr++, c++){
    //std::cout << *itr << '\n';
    if(c==k){
      std::cout << (*itr) << '\n';
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 5496
#dp[i][j] denotes answer for subarray from i to j
n=int(input())
l=input().split()
li=[int(i) for i in l]
dp=[[0 for i in range(n)]for i in range(n)]
pref=[0 for i in range(n)]
sumi=0
for i in range(n):
    sumi+=li[i]
    pref[i]=sumi
for i in range(n):
    dp[i][i]=0
for gap in range(1,n):
    for i in range(n-gap):
        left=i
        right=i+gap
        mina=[]
        if(left==0):
            curr=pref[right]
        else:
            curr=pref[right]-pref[left-1]
        for j in range(left,right):
            mina.append(dp[left][j]+dp[j+1][right]+curr)
        dp[left][right]=min(mina)
print(dp[0][n-1])


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for (int i = m; i < n; i++)
using str = string;
using vi = vector<int>;

int d[2019];
int d2[2019];
int main() {

  vi a(200010);
  str s;
  cin >> s;
  int n = s.length();
  int ans = 0;
  rep(i, n) a[i] = s[i] - '0';
  d2[a[0]]++;
  REP(i, 1, n) {
    d[a[i]]++;
    rep(j, 2019) { d[(10 * j + a[i]) % 2019] += d2[j]; }
    ans += d[0];
    rep(j, 2019) {
      d2[j] = d[j];
      d[j] = 0;
    }
  }
  cout << ans << endl;
}


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

int K, X;
int MAX = 1.0e6;

int main() {
    cin >> K >> X;
    
    vector<int> ans;
    for (int i = X - (K-1); i <= X + (K-1); i++) {
        ans.push_back(i);
    }

    for (int i = 0; i < ans.size(); i++) {
        if (ans[i] >= (-1) * MAX && MAX >= ans[i]) {
            cout << ans[i] << " ";
        }
    }
    cout << endl;    

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007

#define ARRAY_MAX 200005

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    int maxi = -1;
    REP(i,n){
        cin >> a[i];
        maxi = max(maxi,a[i]);
    }
    bool used = false;
    int ans = 0;
    REP(i,n){
        if(maxi == a[i] && used == false){
            ans += a[i]/2;
            used = true;
        }else{
            ans += a[i];
        }
    }
    cout << ans << endl;




    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    int N;
    cin>>N;
    vector<int> X(N);
    rep(i,0,N)cin>>X[i];
    auto sorted_X=X;
    sort(sorted_X.begin(),sorted_X.end());
    //1 2 3 4 5 6
    int c[2]={sorted_X[N/2-1],sorted_X[N/2]};

    rep(i,0,N){
        if(X[i]<c[1])cout<<c[1]<<endl;
        else cout<<c[0]<<endl;
    }

    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi = 3.141592654;
void solve()
{
    ld a,b,t;
    cin>>a>>b>>t;
    ld ans=0;
    t=t+.5;
    for(ld i=a; i<t; i+=a)
    {
         ans+=b;
         //cout<<b<<" "<<i<<endl;
    }
    cout<<ans<<endl;
}

int main()
{

    //freopen("Input.txt","r",stdin);
    ios_base :: sync_with_stdio(false);
    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 256
s_num=int(input())
s_list=list(map(int,input().split()))
q_num=int(input())
q_list=list(map(int,input().split()))
count = 0
a_list = []
for q in q_list:
    for s in s_list:
        if s == q:
            count += 1
            break

            
print(count)


Measured memory_bytes: 6504
n,k = map(int,input().split())
x_ls = list(map(int, input().split()))
ans = float('inf')
for i in range(n-k+1):
    if x_ls[i+k-1] < 0:
        ans = min(ans, abs(x_ls[i]))
    elif x_ls[i] < 0 and x_ls[i+k-1] >= 0:
        near = min(abs(x_ls[i]),abs(x_ls[i+k-1]))
        far = max(abs(x_ls[i]),abs(x_ls[i+k-1]))
        ans = min(ans, 2 * near + far)
    elif x_ls[i] >= 0:
        ans = min(ans, x_ls[i+k-1])
print(ans)

Measured memory_bytes: 14480
#include <bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<n;++i)
#define repe(i,k,n) for(int i=k;i<=n;++i)
typedef long long in;

using namespace std;

int main()
{
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
    in h,w;
    cin >> h >> w;
    in blo = h*w;
    if (h == 1 || w == 1) {
        cout << 1;
        return 0;
    }

    if (blo % 2 ==0){
        cout << blo/2;
    }else cout << (blo+1)/2 ;
    return 0;
}


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

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

  int X = atoi(S.c_str());
  int ans = 100000;
  for(int i = 0; i < S.size()-2; i++){
    X = 100 * (int)(S[i] - '0') + 10 * (int)(S[i+1] - '0') + (int)(S[i+2] - '0');
    ans = min(ans, abs(753-X));
  }
  
  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main() {
	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()) {
		ans += s.at(i) - '0';
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string S;
  cin >> S;
  char last = S[S.size()-1];
  set<char> se = {'2', '4', '5', '7', '9'};
  if(se.count(last)) cout << "hon" << endl;
  else if(last == '3') cout << "bon" << endl;
  else cout << "pon" << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int N;
	while(cin >> N){
		vector<long long> A(N);
		for(auto& t : A) cin >> t;
		long long maxVal = A[0];
		for(auto t : A) maxVal = max(maxVal, t);
		vector<int> op;
		if(maxVal >= 0){
			long long sum[2] = {0, 0};
			for(int i=0;i<N;i++) sum[i%2] += max(0LL, A[i]);
			int use = (sum[0] > sum[1] ? 0 : 1);
			cout << sum[use] << endl;
			int rest = N;
			for(int i=N-1;i>=0;i--){
				if(i%2 == use && A[i] < 0){
					op.push_back(i+1);
					rest -= (i%(N-1) ? 2 : 1);
					if(i == 0) use = 1;
				}
			}
			for(int i=rest-1;i>=0;i--){
				if(i%2 == 1 - use) op.push_back(i+1);
			}
		} else {
			cout << maxVal << endl;
			for(int i=N-1;i>=0;i--){
				if(maxVal == A[i]){
					break;
				} else {
					op.push_back(i+1);
				}
			}
			while(op.size() < N - 1) op.push_back(1);
		}
		cout << op.size() << endl;
		for(auto t : op) cout << t << endl;
	}
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int x,y,z;
inline int read()
{
	int n_read=0,o_read=1;
	char c_read=getchar();
	while(c_read<'0'||c_read>'9')
	{
		if(c_read=='-')
			o_read=-1;
		c_read=getchar();
	}
	while(c_read>='0'&&c_read<='9')
	{
		n_read=n_read*10+c_read-'0';
		c_read=getchar();
	}
	return n_read*o_read;
}
int main()
{
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	x=read(),y=read(),z=read();
	printf("%d\n",(x-z)/(y+z));
	putchar('\n');
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){

  long long A, B, K;

  cin >> A >> B >> K;

  if(K<A) A-=K;
  else{
    K-=A;
    A = 0;
    if(K<B) B-=K;
    else B = 0;
  }

  cout << A << " " << B << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] vArr = new int[n];
        int[] cArr = new int[n];

        for (int i = 0; i < n; i++) {
            vArr[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            cArr[i] = sc.nextInt();
        }

        int sum = 0;
        for (int i = 0; i < n; i++) {
            int x = vArr[i] - cArr[i];
            sum += x > 0 ? x : 0;
        }

        System.out.println(sum);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 22996
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.math.*;

import static java.util.Comparator.*;


public class Main {
    public static void main(String[] args) throws IOException {
        FastReader s = new FastReader();
        long n=s.nextLong();
        long k=s.nextLong();
        long val=n%k;
        System.out.println(Math.min(val,k-val));

    }

}


class FastReader
{
    BufferedReader br;
    StringTokenizer st;

    public FastReader()
    {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException  e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

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

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}

Measured memory_bytes: 22996
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        char op = sc.next().charAt(0);
        int b = sc.nextInt();
        while (op!='?'){
            if (op=='+'){
                System.out.println(a+b);
            } else if (op=='-'){
                System.out.println(a-b);
            } else if (op=='*'){
                System.out.println(a*b);
            } else if (op=='/'){
                System.out.println(a/b);
            }
            a = sc.nextInt();
            op = sc.next().charAt(0);
            b = sc.nextInt();
        }
    }
}



Measured memory_bytes: 26232
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,p=1;
    cin>>n;
    vl a(n);
    cin>>a;
    ll ans=0;
    rep(i,n){
        if(a[i]!=p)ans++;
        else p++;
    }
    if(ans==n)puta(-1);
    else puta(ans);

    return 0;
}

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

#define int long long

int32_t main(){
	map<string , int> mp ;
	int n ;
	cin >> n;
	for(int i = 0 ; i < n ; i++){
		string s ;
		cin >> s ;
		mp[s] = 1 ;
	}
	cout << mp.size() ;
	return 0 ;
}


Measured memory_bytes: 19116
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll vis[100100];
vector<ll>adj[100100];
ll dp[100100];
ll dfs(ll x)
{
  dp[x]=0;
  vis[x]=1;
  for(ll i:adj[x])
    {
      if(vis[i]==0)
    	{
    	  dp[x]=max(dp[x],1+dfs(i));
    	}
      else
    	{
    	  dp[x]=max(dp[x],1+dp[i]);
    	}
    }
  //dp[x]+=1;
  return dp[x];
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,m;

  cin>>n>>m;
  ll x,y;
  for(ll i=1;i<=m;i++)
    {
      cin>>x>>y;
      adj[x].push_back(y);
    }
  for(ll i=1;i<=n;i++)
    {
      if(vis[i]==0)
	{
	  dfs(i);
	}
    }
  ll maxi=0;
  for(ll i=1;i<=n;i++)
  {
      //cout<<dp[i]<<" ";
    maxi=max(maxi,dp[i]);
  }
//  cout<<endl;
  cout<<maxi;
}

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

int main(){
	int n;
	cin >> n;
	int data;
	int MAX = INT_MIN;
	int MIN = INT_MAX;
	for(int i = 0; i < n; i++){
		cin >> data;
		MAX = max(MAX,data-MIN);
		MIN = min(MIN,data);
	}
	cout << MAX << endl;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, m, a, M = 1e9+7;
    cin >> n >> m;
    vector<bool> brok(n, false);
    fore(i,0,m) {
        cin >> a;
        brok[a] = true;
    }
    int dp[n+1] = {1};
    fore(i,1,n+1) {
        if (brok[i]) continue;
        fore(j,1,3) {
            if (i-j >= 0 && !brok[i-j]) {
                dp[i] = (dp[i]+dp[i-j]) % M;
            }
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void)
{
	int a,b,d,r;
	double f;
	scanf("%d",&a);
	scanf("%d",&b);
	d=a/b;
	r=a%b;
	f=(double) a/b;
	printf("%d %d %f\n",d,r,f);
	return 0;
}

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

int N[100000];

int search(const void* a, const void* b)
{ 
    return *(int*)a - *(int*)b;
}

int main(void)
{
  int n,n2;
  int i, j;
  int count;

    scanf("%d",&n);
    for (i=0;i<n;++i){
        scanf("%d",N+i);
    }

    scanf("%d", &n2);
    count = 0;
    for (i=0;i<n2;++i){
        int t;

        scanf("%d", &t);
        if (bsearch(&t,N,n,sizeof(int),search) != NULL){
            count=count+1;
        }
    }

    printf("%d\n",count);

    return (0);
}



Measured memory_bytes: 2072
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll a, b;
    cin >> a >> b;

    cout << ((a + b) % 2 == 0 ? (a + b) / 2 : (a + b + 1) / 2) << endl;
    
    return 0;
}

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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

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

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  sort(all(s));
  if (s[0] == s[1] and s[2] == s[3] and s[1] != s[2]) cout << "Yes\n";
  else cout << "No\n";
  return (0);
}


Measured memory_bytes: 256
x=int(input())
y=list(map(int, input().split()))
ans=10**10
chk=10**10
for i in range(min(y),max(y)+1):
	chk=0
	for j in range(x):
		chk=chk+((y[j]-i)**2)
	if ans>chk:
		ans=chk
print(ans)

Measured memory_bytes: 3064
import math
n,k = map(int,input().split())
l = sorted(list(map(int,input().split())))
if l[-1] < k:
    print("IMPOSSIBLE")
    exit()
if k in l:
    print("POSSIBLE")
    exit()


x = l[0]
for i in l[1:]:
    x = math.gcd(x,i)

if x == 1:
    print("POSSIBLE")
else:
    for i in l:
        if (k-i)%x == 0:
            print("POSSIBLE")
            exit()
    print("IMPOSSIBLE")



Measured memory_bytes: 20276
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from bisect import bisect_left

n,k=nii()

l=[]
for i in range(n):
  a,b=nii()
  l.append([a,b])

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

a_l=[]
b_l=[]
for a,b in l:
  a_l.append(a)
  b_l.append(b)

b_rui=[0]
for i in range(1,n+1):
  b_rui.append(b_rui[i-1]+b_l[i-1])
b_rui=b_rui[1:]

inx=bisect_left(b_rui,k)
print(a_l[inx])

Measured memory_bytes: 32152
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

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

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

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll Q;
    cin>>Q;
    vll r(Q),l(Q);
    for(ll i=0;i<Q;i++)cin>>l[i]>>r[i];
    
    vector<bool> prime(100001,true);
    
    ll i_max=sqrt(100000);
    for(ll i=2;i<=i_max;i++){
        if(prime[i]){
            for(ll j=i*2;j<=100000;j+=i){
                prime[j]=false;
            }
        }
    }
    
    vll count(100001,0);
    for(ll i=2;i<=100000;i++){
        count[i]=count[i-1];
        if(prime[i] && i%2==1 && prime[(i+1)/2])count[i]++;
    }
    
    for(ll i=0;i<Q;i++){
        cout<<count[r[i]]-count[l[i]-1]<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
char a,b;
int32_t main(){
CODE_START;
cin>>a;
cin>>b;
if(a>b){
    cout<<'>';
    return 0;
}
if(a==b){
    cout<<'=';
    return 0;
}
if(b>a){
    cout<<'<';
    return 0;
}
}


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

int main(){
  int n,l;
  cin>>n>>l;
  vector<string>s(n);
  rep(i,n)cin>>s[i];
  sort(s.begin(),s.end());
  string min;
  rep(i,n)
    min+=s[i];
    cout<<min<<endl;
  return 0;
}

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

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int r = int.Parse(input[0]);int g = int.Parse(input[1]);int b = int.Parse(input[2]);
            int s = r*100 +g*10 + b;
            Console.WriteLine(s%4==0?"YES":"NO");
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main() {
  int sx, sy, tx, ty, dx, dy;
  cin >> sx >> sy >> tx >> ty;
  dx = tx - sx;
  dy = ty - sy;
  cout << string(dx,'R') + string(dy,'U')
      + string(dx,'L') + string(dy,'D')
      + "D" + string(dx+1,'R') + string(dy+1,'U') + "L"
      + "U" + string(dx+1,'L') + string(dy+1,'D') + "R\n";
}


Measured memory_bytes: 3592
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
const int N = 200005;
int p[N],q[N],e[N];
int n,x,y,a,b,c,idx;
int d[N], r[N];
bool cmp(const int& a, const int& b){
    return a>b;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>x>>y>>a>>b>>c;
    for(int i=0;i<a;++i)cin>>p[i];
    for(int i=0;i<b;++i)cin>>q[i];
    for(int i=0;i<c;++i)cin>>e[i];
    sort(p,p+a,cmp);
    sort(q,q+b,cmp);
    sort(e,e+c);
    idx = 0;
    priority_queue<int>que1,que2,que3;
    for(int i=0;i<min(x,a); ++i) que1.push(-p[i]);
    for(int j=0;j<min(y,b);++j) que2.push(-q[j]);
    for(int i=0;i<c;++i) que3.push(e[i]);
    while(que1.size()<x && que3.size()){
        que1.push(-que3.top());
        que3.pop();
    }
    while(que2.size()<y && que3.size()){
        que2.push(-que3.top());
        que3.pop();
    }
    while(que3.size()){
        int x = -que1.top();
        int y= -que2.top();
        int z = que3.top(); que3.pop();
        if(x > y){
            if(z > y) {
                que2.pop();
                que2.push(-z);
            }
        }else{
            if(z > x) {
                que1.pop();
                que1.push(-z);
            }
        }
    }
    LL ans = 0;
    while(que1.size()){
        ans += -que1.top();
        que1.pop();
    }
    while(que2.size()){
        ans += -que2.top();
        que2.pop();
    }
    /*
    for(int i=0;i<min(x,a);++i) d[idx++]=p[i];
    for(int i=0;i<min(b,y);++i) d[idx++]=q[i];
    sort(d,d+idx);
    priority_queue<int>que;
    for(int i=0, j=0; i<=min(c-1,idx-1), j<c;++i,++j){
        que.push(d[i]);
        que.push(e[j]);
    }
    LL ans=0;
    for(int i=c;i<=idx-1;++i) ans+=d[i];
    int t = (x + y) - (idx - c);
    while(t--){
        ans += que.top();
        que.pop();
    }
    */
    cout<<ans<<"\n"; 
    return 0;
}



Measured memory_bytes: 2936
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll_t;

int H, W, N;

struct cell {
    int i, j;

    bool operator < (const cell& c) const {
        if (i != c.i) return i < c.i;
        return j < c.j;
    }

} P[100000];

int V[100000][3][3];

ll_t R[10];

int main() {
    scanf("%d%d%d", &H, &W, &N);
    for (int i = 0; i < N; i++) {
        scanf("%d%d", &P[i].i, &P[i].j);
        P[i].i--, P[i].j--;
    }
    sort(P, P + N);
    
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++) {
            if (V[k][i][j]) continue;
            int si = P[k].i - i, sj = P[k].j - j;
            if (si < 0 || si + 2 >= H || sj < 0 || sj + 2 >= W)
                continue;
            int count = 0;
            for (int x = 0; x < 3; x++)
            for (int y = 0; y < 3; y++) {
                cell c;
                c.i = si + x, c.j = sj + y;
                int p = lower_bound(P, P + N, c) - P;
                if (p < N && P[p].i == c.i && P[p].j == c.j) {
                    //printf("%d: %d %d %d %d\n", k, si, sj, x, y);
                    V[p][x][y] = 1;
                    count++;
                }
            }
            R[count]++;
        }
    }

    R[0] = (ll_t) (H - 2) * (W - 2);
    for (int i = 1; i <= 9; i++)
        R[0] -= R[i];
    for (int i = 0; i <= 9; i++)
        printf("%lld\n", R[i]);
    return 0;
}

Measured memory_bytes: 4480
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<a+b/2;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string c;
    cin >> c;
    if(c =="a"){
      cout << "vowel" << endl;
    }else if(c=="e"){
         cout << "vowel" << endl;
    }else if(c=="i"){
      cout << "vowel" << endl;
    }else if(c=="o"){
         cout << "vowel" << endl;
    }else if(c=="u"){
         cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }  
}


Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);
  writeln(s[0..5], " ", s[6..13], " ", s[14..19]);
}


Measured memory_bytes: 256
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int,input().split()))

if  x not in p:
    print(x)
    exit()

mae = x-1
ushiro = x+1
for i in range(n):
    if mae not in p:
        print(mae)
        exit()
    elif ushiro not in p:
        print(ushiro)
        exit()
    mae = mae -1
    ushiro = ushiro +1

Measured memory_bytes: 9204
from collections import deque

H, W, *S = open(0).read().split()
H, W, S = int(H), int(W), [list(s) for s in S]

white = sum(s.count(".") for s in S)

Q = deque([(0, 0, 1)])
while Q:
    h, w, count = Q.popleft()
    if (h, w) == (H - 1, W - 1):
        print(white - count)
        quit()

    for nh, nw in [(h, w + 1), (h, w - 1), (h + 1, w), (h - 1, w)]:
        if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == ".":
            S[nh][nw] = "" # visited
            Q.append((nh, nw, count + 1))
print(-1)

Measured memory_bytes: 3316
/**Bismillahir Rahmanir Raheem
    Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e5 + 5;
const int M = 1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}
int main() {
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    ///scanf("%d",&test);
    for(int cs=1; cs<=test; cs++) {
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        if(a==b&&a!=c) {
            cout<<"Yes"<<endl;
        } else if(b==c&&a!=b) {
            cout<<"Yes"<<endl;
        } else if(a==c&&a!=b) {
            cout<<"Yes"<<endl;
        } else {
            cout<<"No"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
// Example solution
#include <iostream>
#include <algorithm>
using namespace std;

using ll = long long ;
using R = double; 


// Combination Table

ll C[51][51];
// C[n][k] -> nCk


void comb_table (int N){

for( int i =0;i<=N;++i){
        for(int j=0;j<=i;++j){
                if(j==0 or j==i){
                        C[i][j] = 1LL;
                }else{
                        C[i][j] =(C[i-1][j-1]+C[i-1][j]);
                }
        }
}
}


int main (void){

int N,A,B;

cin >> N >> A >> B;


const int NMAX = 50;

ll v[NMAX];

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


comb_table(N);
sort(v,v+N);
reverse(v,v+N);


R max_average =0.0;

for ( int i =0;i<A;++i){
        max_average+=v[i];
}

max_average/=A;

int a_th_val_num = 0 ,a_th_val_pos =0;

for( int i =0; i <N;++i){

if (v[i]==v[A-1]){
        a_th_val_num++;
        if(i<A){
                a_th_val_pos++;
        }
}
}


ll cnt=0LL;

if(a_th_val_pos==A){
        for(a_th_val_pos=A;a_th_val_pos<=B;++a_th_val_pos){
                cnt+=C[a_th_val_num][a_th_val_pos];
        }
}else{
        cnt+=C[a_th_val_num][a_th_val_pos];
}


cout.precision(20);
cout<<fixed<<max_average<<endl;
cout<<cnt<<endl;

return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

int main() {
  int N, pi;
  vector<int> P;
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &pi);
    P.push_back(pi);
  }
  int counter = 0;
  for (int i = 0; i < N; ++i) {
    if (P[i] == i + 1) {
      swap(P[i], P[i + 1]);
      ++counter;
    }
  }
  printf("%d", counter);
}


Measured memory_bytes: 892
def rating(m, f, r):
    if m==-1 and f==-1 and r==-1:
        return ""
    elif m==-1 or f==-1:
        return "F"
    elif m + f >= 80:
        return "A"
    elif m + f >= 65:
        return "B"
    elif m + f >= 50:
        return "C"
    elif m + f >= 30:
        if r >= 50:
            return "C"
        else:
            return "D"
    else:
        return "F"

while True:
    buff = input()
    m, f, r = map(int, buff.split())
    rate = rating(m, f, r)
    if rate == "":
        break
    else:
        print(rate)


Measured memory_bytes: 5596
#include <cstdio>
#include <string>
#include <vector>

int solve_testcase() {
    size_t n;
    scanf("%zu", &n);
    if (n == 0)
        return 1;

    std::vector<std::string> w(n);
    for (size_t i=0; i<n; ++i) {
        char buf[16];
        scanf("%s", buf);
        w[i] = buf;
    }

    const size_t sph[]={5, 7, 5, 7, 7};
    for (size_t res=0; res<n; ++res) {
        size_t counter=0, index=0;
        for (size_t i=0; res+i<n; ++i) {
            if (counter + w[res+i].length() > sph[index])
                break;  // match failed

            counter += w[res+i].length();
            if (counter == sph[index]) {
                ++index;
                counter = 0;
            }

            if (index == 5)
                return !printf("%zu\n", res+1);
        }
    }

    // maybe not reached
    return 0;
}

int main() {
    while (!solve_testcase()) {}

    return 0;
}

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

using namespace std;
long long mypow(long long x, long long y)
{
	long long result = 1;
	while (y != 0) {
		if (y%2 != 0) {
			result *= x;
			y -= 1;
		}	
		x *= x;
		y /= 2;
	}
	return result;
}

int main(void)
{
	int n;
	cin >> n;
	vector<vector<pair<int, int>>> G;
	G.resize(n);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		for (int j = 0; j < a; j++) {
			int x, y;
			cin >> x >> y;
			G[i].push_back(make_pair(x-1, y));
		}
	}
	
	int max_ans = 0;
	for (uint32_t i = 0; i < mypow(2, n); i++) {
		bool trusted[n];
		int count = 0;
		for (int j = 0; j < n; j++) {
			if (((i >> j)&1) == 1) {
				trusted[j] = true;
				count++;
			} else
				trusted[j] = false;
		}
		bool contradiction = false;
		for (int j = 0; j < n; j++) {
			if (!trusted[j])
				continue;
			for (auto e : G[j]) {
				if ((trusted[e.first] && e.second == 0)||
						(!trusted[e.first] && e.second == 1)) {
					contradiction = true;
					goto fin;
				}
			}
		}
fin:
		;
		if (!contradiction) {
			if (max_ans < count)
				max_ans = count;
		}

	}
	cout << max_ans << endl;
	return 0;
}

Measured memory_bytes: 3552