akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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;}



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin >> n;
    vector<string> s(n);
    REP(i,n)cin >> s[i];

    int j[4] = {0,0,0,0};
    REP(i,n){
        if(s[i] == "AC"){
            j[0]++;
        }else if(s[i] == "WA"){
            j[1]++;
        }else if(s[i] == "TLE"){
            j[2]++;
        }else if(s[i] == "RE"){
            j[3]++;
        }
    }

    cout << "AC x " << j[0] << "\nWA x " << j[1] << "\nTLE x " << j[2] << "\nRE x " << j[3] << endl;
    
    return 0;
}

Measured memory_bytes: 6364
import java.util.Scanner;

public class Main {

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        String c = "";
        String d = "";

        for (int i = 0; i < a; i++) {
            c += b;
        }

        for (int i = 0; i < b; i++) {
            d += a;
        }

        System.out.println(c.compareTo(d) > 0 ? d : c);
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  if (N == 2) {
    cout << A[1] << " " << A[0] << endl;
    return 0;
  }

  vector<int> x(N);
  int tmp = 0;
  for (int i = 1; i < N - 1; i += 2) {
    tmp = (tmp ^ (A[i] ^ A[i + 1]));
  }
  x[0] = tmp ^ A[N - 1];
  cout << x[0] << " ";
  for (int i = 1; i < N; i++) {
    x[i] = (A[0] ^ A[i]) ^ x[0];
    cout << x[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 4708
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int n,k;cin>>n>>k;
	int a[n];
	fo0(i,n){
		cin>>a[i];
	}
	ld avg[1001];
	for(int i=1;i<=1000;i++){
		int temp=i*(i+1)/2;
		avg[i]=(temp*1.0)/i;
	}
	ld res=0.0;
	ld prefix[n+2];
	for(int i=0;i<n+2;i++){
		prefix[i]=0.0;
	}
	for(int i=0;i<n;i++){
		prefix[i+1]=prefix[i]+avg[a[i]];
	}
	for(int i=0;i<n-k+1;i++){
		ld ans=0.0;
		ans=prefix[i+k]-prefix[i];
		res=max(res,ans);
	}
	cout<<prec(res);

}

int32_t main()
{
	
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 4992
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int fib[45] = {};
    fib[0] = fib[1] = 1;

    int n;
    cin >> n;
    if (n < 2) {
        cout << fib[n] << endl;
    } else {
        for (int i = 2; i <= n; i++) {
            fib[i] = fib[i - 1] + fib[i - 2];
        }
        cout << fib[n] << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#define MAX 1000000

int main(int argc, const char * argv[]) {
    int t[MAX],n,i,j;
    for(i=0;i<MAX;i++){
        t[i]=1;
    }
    t[0]=t[1]=0;
    for(i=2;i*i<MAX;i++){
        if(t[i]==1){
            for(j=i*i;j<MAX;j+=i){
                t[j]=0;
            }
        }
    }
    
    for(i=1;i<MAX-1;i++)
        t[i+1]+=t[i];
    while(scanf("%d",&n)!=EOF)
        printf("%d\n",t[n]);
    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    long long k;
    cin >> n >> k;
    vector<long long> as(n), bs(n+1, 0);
    for (auto& a : as) {
        cin >> a;
        --a;
    }
    for (int i = 0; i < n; ++i) {
        bs[i+1] = (bs[i] + as[i]) % k;
    }
    map<long long, vector<int>> m;
    for (int i = 0; i <= n; ++i) {
        m[bs[i]].push_back(i);
    }
    long long total_count = 0;
    for (auto& x : m) {
        auto& v = x.second;
        int m = (int) v.size();
        int j = 0;
        for (int i = 0; i < m; ++i) {
            while (j < i && v[i] - v[j] >= k) ++j;
            total_count += i - j;
        }
    }
    cout << total_count << endl;
    return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
 
int ppl[55]={0};
int n,p,now,num;
 
int main(){
  int i,j,k;
  while(1){
    cin >> n >> p;
    if(n+p==0)break;
    now = p;
    num = 0;
    while(1){
      if(now>0){
    ppl[num]++;
    now--;
      }
      else if(ppl[num]==p)break;
      else{
    now = ppl[num];
    ppl[num]=0;
      }
      num++;
      num%=n;
    }
    printf("%d\n",num);
    for(i=0;i<n;i++)ppl[i]=0;
  }
  return 0;
}





Measured memory_bytes: 3136
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int n, l, r;
	while (cin >> n >> l >> r, n) {
		int ans = 0, a[60];
		for (int i = 0; i < n; i++)cin >> a[i];
		for (int y = l; y <= r; y++) {
			int i;
			for (i = 0; i < n; i++) {
				if (y%a[i] == 0)goto a;
			}
			ans += (n % 2 + 1) % 2; goto b;
		a:ans += (i % 2 + 1) % 2;
		b:;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3108
N,M=[int(x) for x in input().split()]

#N  -> num of S piece
#M  -> num of c piece

num=0

if(2*N < M):
    #print("a")
    dif = M - 2 * N #何個cが余ってるか
    num = N + (dif // 4)
else:
    num = M // 2

print(num)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ll k, n, i, dis, maxa = 0;

    cin >> k >> n;

    ll house[n];

    for(i = 0; i < n; i++)
    {
        cin >> house[i];
        if(i > 0) {
            dis = house[i] - house[i - 1];
            maxa = dis > maxa ? dis : maxa;
        }
    }

    dis = house[0] + k - house[n - 1];

    cout << k - max(dis, maxa) << endl;

    return 0;
}


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

#define int long long
#define endl "\n"
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);

const int N = 2e5 + 5;

void solve();
int32_t main()
{
    IOS;
    int x,y;
    cin >> x >> y;
    if(x*2<=y && x*4>=y && y%2==0)
        cout << "Yes\n";
    else
        cout << "No\n";
}



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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

int main(){
  int n;
  scanf("%d",&n);

  cout<<"ABC"<< n<<"\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <map>

using namespace std;

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

typedef vector<int> vi;

int main()
{
	int a, b, c;
	int rect=0, hishi=0;
	while(scanf("%d,%d,%d", &a, &b, &c) != EOF){
		hishi += a==b;
		rect += a*a+b*b==c*c;
	}
	printf("%d\n%d\n", rect, hishi);

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <utility>

using llint = long long int;
using namespace std;

namespace CsF {
	string ConvertBit(int N, int e) {
		string s = "";
		int r = 0;
		while (N != 0) {
			r = N % e;
			s = to_string(r) + s;
			N -= r;
			N /= e;
		}
		return s;
	}

	int GCD(int a, int b) {
		if (a < b)swap(a, b);
		int r = a % b;
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		return b;
	}

	int LCM(int a, int b) {
		int n = a * b;
		return (n / GCD(a, b));
	}

#define MIN_INT -2147483648
#define MAX_INT 2147483647
}

using namespace CsF;


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



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

using namespace std;

typedef long long ll;

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

const int N = 1e5 + 9, M = 1e5 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

ll sum(ll b, ll n){
    if(n < b)   return n;
    return sum(b, n / b) + (n % b);
}

int main(){
    init();

    ll n, s;    cin >> n >> s;
    if(n == s)  return cout << s + 1, 0;
//    if(n < s)   return cout << -1, 0;

    for(int i = 2;i <= 1e5;i++){
        ll sDigits = sum(i, n);
        if(sDigits == s)    return cout << i, 0;
    }


    /*
        q + pb = n
        q + p = s

        pb - p = n - s
        p(b - 1) = n - s
    */


    ll d = n - s, ans = llOO;
    for(ll i = 1;i * i <= d;i++){
        if(d % i == 0){
            if(sum(i + 1, n) == s)  ans = min(ans, i + 1);
            if(sum(d/i + 1, n) == s)  ans = min(ans, d/i + 1);
        }
    }

    cout << (ans == llOO ? -1 : ans);

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int N, ans = 0;
  
  cin >> N;
  
  for(int i = 1;i <= N;i += 2){
    int c = 0;
    for(int j = 1;j <= i;j++){
      if(i % j == 0) c++;
    }
    
    if(c == 8) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

const ll INF = 1e18;

int main(){
	int a,b,q;
	cin >> a >> b >> q;
	vector<P> locate(a+b);
	rep(i,a){
		ll x;
		cin >> x;
		locate[i] = make_pair(x,0);
	}
	rep(i,b){
		ll x;
		cin >> x;
		locate[a+i] = make_pair(x,1);
	}
	sort(locate.begin(), locate.end());
	
	// make list
	vector<ll> dist(a+b,INF), leftdist(a+b,INF), rightdist(a+b,INF);
	int p = 0;
	int type = locate[0].second;
	
	for(int i = 1; i < a+b; i++){
		if(type == locate[i].second){
			leftdist[i] = leftdist[i-1] + (locate[i].first - locate[i-1].first);
		}
		else{
			while(p < i){
				rightdist[p] = locate[i].first - locate[p].first;
				p++;
			}
			leftdist[i] = locate[i].first - locate[i-1].first;
			type = locate[i].second;
		}
	}
	
	rep(i,a+b) dist[i] = min(leftdist[i], rightdist[i]);
	
	// answer query
	vector<ll> aa(a+b);
	rep(i,a+b) aa[i] = locate[i].first;
	rep(i,q){
		ll x;
		cin >> x;
		if(x <= aa[0]){
			cout << aa[0] - x + dist[0] << endl;
			continue;
		}
		if(x >= aa[a+b-1]){
			cout << x - aa[a+b-1] + dist[a+b-1] << endl;
			continue;
		}
		
		auto p = lower_bound(aa.begin(), aa.end(), x);
		auto backp = p - 1;
		ll right = *p - x + dist[p-aa.begin()];
		ll left = x - *backp + dist[backp-aa.begin()];
		cout << min(left,right) << endl;
	}

	return 0;
}

Measured memory_bytes: 10752
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    string s;
    while (cin >> s) {
        if (s == "-") {
            break;
        }
        int m; cin >> m;
        while (m--) {
            int h; cin >> h;
            rotate(s.begin(), s.begin()+h, s.end());
        }
        cout << s << "\n";
    }

    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long ll;
const int maxx=1e5+100;
const int MOD=1e9;
struct node
{
    int to,nextt;
}e[maxx];
int n;
int p[maxx];
int x[maxx];
int head[maxx];
int dp[maxx];
int f[maxx];
int cnt=0;
void add(int u,int v)
{
    e[cnt].to=v;
    e[cnt].nextt=head[u];
    head[u]=cnt++;
}
void dfs(int u)
{
    for(int i=head[u]; ~i; i=e[i].nextt){
        dfs(e[i].to);
    }
    dp[0]=0;
    for(int i=head[u]; ~i; i=e[i].nextt){
        int v=e[i].to;
        for(int j=x[u]; j>=0; j--){
            int temp=INF;
            if(j>=x[v])
                temp=min(temp,dp[j-x[v]]+f[v]);
            if(j>=f[v])
                temp=min(temp,dp[j-f[v]]+x[v]);
            dp[j]=temp;
        }
    }
    for(int i=0; i<=x[u]; i++){
        f[u]=min(f[u],dp[i]);
    }
}
int main()
{
    scanf("%d",&n);
    memset(head,-1,sizeof(head));
    for(int i=2; i<=n; i++){
        scanf("%d",&p[i]);
        add(p[i],i);
    }
    for(int i=1; i<=n; i++){
        scanf("%d",&x[i]);
    }
    memset(f,INF,sizeof(f));
    dfs(1);
    if(f[1]<INF)
        cout<<"POSSIBLE"<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll N, K;
  cin >> N >> K;
  set<int> s;
  int d;
  for (int i = 0; i < K; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      s.insert(a);
    }
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (s.find(i) == s.end()) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

S = input()
count = [0] * 26
for c in S:
    count[ord(c) - ord('a')] += 1

n = len(S)
ans = n * (n - 1) // 2 + 1
for c in count:
    ans -= c * (c - 1) // 2
print(ans)



Measured memory_bytes: 9464
def resolve():
    s = input()
    win, lose = 0, 0
    hands = {0: "g", 1: "p"}
    for i in range(len(s)):
        h = hands[i % 2]
        if s[i] == "g" and h == "p":
            win += 1
        elif s[i] == "p" and h == "g":
            lose += 1
    print(win - lose)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3316
#include<stdio.h>
int main()
{
int a,i=0,m=0,n=0,d=1,c=0,S=0;
scanf("%d",&a);
if(a<105)
{printf("0\n");
return 0;}


for(m=105;m<=a;)
{d=1;
c=0;
for(d;d<=m;d++)
{
if(m%d==0)
{
c++;
}

}

if(c==8)
{
S++;
}
m=m+2;
}
printf("%d\n",S);
return 0;
}


Measured memory_bytes: 128
M=3
n,c=gets.split.map(&:to_i)
d=c.times.map{gets.split.map(&:to_i)}
color=n.times.map{gets.split.map{|l|l.to_i-1}}
k=[*0...M].map{Array.new(c,0)}
n.times{|i|n.times{|j|k[(i+j)%3][color[i][j]]+=1}}
s=[*0...M].map{Array.new(c,0)}
M.times{|m|c.times{|pre_color|
  c.times{|post_color|
    next if pre_color==post_color
    s[m][post_color]+=k[m][pre_color]*d[pre_color][post_color]
  }
}}

puts [*0...c].permutation(M).map{|perm|
  perm.each_with_index.map{|x,idx|s[idx][x]}.inject(:+)
}.min

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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int32_t main()
{
    int n,k;
    cin>>n>>k;
    map< int,int > mp;
    for(int i=0;i<k;i++)
    {
        int d;
        cin>>d;
        for(int j=0;j<d;j++)
        {
            int x;
            cin>>x;
            mp[x]++;
        }
    }
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(mp[i]==0)
         cnt++;
    }
    cout<<cnt<<"\n";
      return 0;
}

Measured memory_bytes: 3620
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library

#pragma endregion library

int main(){
    int n; cin >> n;
    vi p(n*n); rep(i,n*n) cin >> p[i];
    vv<int> cost(n,vi(n));
    rep(i,n)rep(j,n) cost[i][j]=min(min(i,n-i-1),min(j,n-j-1));
    vi dx={1,0,-1,0},dy={0,1,0,-1};
    ll ans=0; int reach = 42;
    rep(i,n*n){
        int pi=(p[i]-1)%n,pj=(p[i]-1)/n;
        int cnt = cost[pi][pj];
        ans+=cost[pi][pj];
        cost[pi][pj]=-cnt-reach;
        deque<tuple<int,int,int>> d;
        d.emplace_back(pi,pj,cnt);
        while(!d.empty()){
            int ni,nj,ncnt;
            tie(ni,nj,ncnt)=d.front(); d.pop_front();
            rep(j,4){
                int nwi=ni+dx[j],nwj=nj+dy[j];
                if(0>nwi || nwi>=n) continue;
                if(0>nwj || nwj>=n) continue;
                if(cost[nwi][nwj]>ncnt){
                    cost[nwi][nwj]=ncnt;
                    d.emplace_back(nwi,nwj,ncnt+1);
                } else if (-cost[nwi][nwj]-reach>ncnt){
                    cost[nwi][nwj]=-ncnt-reach;
                    d.emplace_back(nwi,nwj,ncnt);
                }
            }
        }

    }
    cout << ans << '\n';
    
}

Measured memory_bytes: 5300
using System;
using System.Collections.Generic;
using System.Linq;
namespace KCLC
{
    class Program
    {
        static void Main()
        {
            string Input = Console.ReadLine();
            int Length = Input.Length;
            int[] Hairetu = new int[Length];
            for(int i = 0; i < Length; i++)
            {
                Hairetu[i] = (int)Input[i] - 48;
            }
            int Wa = 0;
            for(int j = 0; j < Length; j++)
            {
                Wa += Hairetu[j];
            }
            if(Wa % 9 == 0) { Console.WriteLine("Yes"); }
            else { Console.WriteLine("No"); }
        }
    }
}

Measured memory_bytes: 27176
N=int(input())
S=list(map(str,input()))
L=[0,0,0]
for i in range(N):
  if S[i]=="R":
    L[0]+=1
  elif S[i]=="G":
    L[1]+=1
  elif S[i]=="B":
    L[2]+=1
ans=L[0]*L[1]*L[2]

for i in range(N-2):
  for j in range(int((N-i-1)/2)):
    if S[i]!=S[i+j+1] and S[i]!=S[i+2*j+2] and S[i+j+1]!=S[i+2*j+2]:
      ans-=1

print(str(ans))

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

class D
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var k = h[1];

		var bw = new int[k, k, 2];
		foreach (var x in new int[h[0]].Select(_ => Console.ReadLine().Split()))
		{
			var p = x.Take(2).Select(int.Parse).ToArray();
			bw[p[0] % k, p[1] % k, (p[0] / k + p[1] / k + (x[2] == "B" ? 0 : 1)) % 2]++;
		}

		var t = new int[k, 2];
		for (int c = 0; c < 2; c++)
			for (int i = 0; i < k; i++)
				for (int j = 0; j < k; j++)
					t[i, c] += bw[i, j, c];

		var M = 0;
		for (int j = 0; j < k; j++)
		{
			var s = Enumerable.Range(0, 2).Select(c => Enumerable.Range(0, k).Sum(i => t[i, c])).ToArray();
			for (int i = 0; i < k; i++)
			{
				M = Math.Max(M, s.Max());
				s[0] += t[i, 1] - t[i, 0];
				s[1] += t[i, 0] - t[i, 1];
			}

			for (int i = 0; i < k; i++)
			{
				t[i, 0] += bw[i, j, 1] - bw[i, j, 0];
				t[i, 1] += bw[i, j, 0] - bw[i, j, 1];
			}
		}
		Console.WriteLine(M);
	}
}


Measured memory_bytes: 25608
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>K;
    cout<<50<<endl;
    rep(i,50){
        if(i + (K%50) < 50){
            cout<<max(0LL, i + (K/50) - K%50);
        }else{
            cout<<i + (K/50) + 51 - K%50;
        }
        if(i != 49) cout<<' ';
        else cout<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<cmath>
using namespace std;
int n,tmp[1<<18],A[1<<18],MA[1<<18];
map<int,int>M;
int cnt[1<<18];
stack<int>S,P;
long long make[1<<18];
bool check(int k)
{
	for(int i=0;i<=n;i++)
	{
		while(S.top()>A[i])
		{
			int p=S.top();S.pop();
			int Mp=P.top();P.pop();
			int next,Mnext;
			if(S.top()<A[i])
			{
				next=A[i];
				Mnext=MA[i];
			}
			else
			{
				next=S.top();
				Mnext=P.top();
			}
			int d=p-next;
			if(d>=(1<<18))d=(1<<18)-1;
			long long take=make[d];
			if(cnt[Mp]>take)cnt[Mp]-=take;
			else cnt[Mp]=0;
			cnt[Mnext]+=(cnt[Mp]+take-1)/take+(S.top()<A[i]);
			cnt[Mp]=0;
		}
		if(S.top()<A[i])S.push(A[i]),P.push(MA[i]);
		cnt[MA[i]]++;
	}
	return cnt[0]==1;
}
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>tmp[i];
		A[i]=tmp[i];
	}
	sort(tmp,tmp+n);
	int sz=0;
	for(int i=0;i<n;i++)
	{
		if(M[tmp[i]]==0)
		{
			M[tmp[i]]=++sz;
		}
	}
	A[n]=0;
	M[0]=0;
	for(int i=0;i<=n;i++)MA[i]=M[A[i]];
	int L=0,R=2e5;
	S.push(0);
	P.push(0);
	while(R-L>1)
	{
		int M=(L+R)/2;
		make[0]=1;
		for(int i=1;i<1<<18;i++)
		{
			if(make[i-1]<1<<18)make[i]=make[i-1]*M;
			else make[i]=1<<18;
		}
		if(check(M))R=M;
		else L=M;
		cnt[0]=0;
	}
	cout<<R<<endl;
}

Measured memory_bytes: 17456
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


int main(void) {
  ll i, j, k;
  string L;
  cin >> L;
  ll N=L.size();
  ll dp[22][2]={};
  
  memset(dp, -1, sizeof(dp));
  
  dp[0][1]=0;
  for(i=0; i<N; i++) {
    if(dp[i][0]!=-1)
      chmax(dp[i+1][0], dp[i][0]+9);
    
    if(dp[i][1]!=-1) {
      if(L[i]=='0') {
        chmax(dp[i+1][1], dp[i][1]+L[i]-'0');
      }else {
        chmax(dp[i+1][1], dp[i][1]+L[i]-'0');
        chmax(dp[i+1][0], dp[i][1]+L[i]-'0'-1);
      }
    }
    
    
  }
  
  pt(max(dp[N][0], dp[N][1]));
}



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

using namespace std;

typedef long long ll;
typedef long double ld;

const int Inf = 2e9;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    vector <int> dp(n, Inf);
    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
        dp[i] = min(dp[i], dp[i - 1] + abs(a[i - 1] - a[i]));
        if (i >= 2) dp[i] = min(dp[i], dp[i - 2] + abs(a[i - 2] - a[i]));
    }
    cout << dp[n - 1] << '\n';
}

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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}

const ll M=1e9+7;

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    ll n;
    cin>>n;
    bool mat[n][n];
    for(ll i=0;i<n;i++)
    	for(ll j=0;j<n;j++)
    		cin>>mat[i][j];
    
    vector<ll> dp((1LL<<n),0);
    dp[0]=1;
    
    for(ll mask=1;mask < (1<<n);mask++)
    {
        ll id=__builtin_popcountll(mask);

        for(ll i=0;i<n;i++)
        {
        	if(((mask>>i) & 1) && mat[id-1][i])
        		dp[mask]=(dp[mask] + dp[mask^(1LL<<i)])%M;
        }
    }

    ll ans=dp[(1LL<<n)-1];
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 19568
import java.util.Scanner;

public class Main {
    final static int max = 100001;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] card = new int[max];

        for (int i = 1; i < max; i++) {
            card[i] = -1;
        }

        int num = 0;
        for (int i = 1; i <= n; i++) {
            int tmp = sc.nextInt();
            if (card[tmp] == -1) {
                card[tmp] = 0;
                num++;
            }
            card[tmp] = (card[tmp] + 1) % 2;
        }

        int zero = 0;
        for (int i = 1; i < max; i++) {
            if (card[i] == 0) zero++;
        }

        System.out.println((num - (zero % 2)));
    }
}


Measured memory_bytes: 33336
#include <bits/stdc++.h>
#define FORR(i, a, b)  for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b)  for (int i = (b); i >= (a); --i)
#define REPP(i, a, b)  for (int i = (a); i < (b); ++i)
#define REPD(i, a, b)  for (int i = (b); i > (a); --i)
#define fi             first
#define se             second
#define mp             make_pair
#define pb             push_back
#define pf             push_front
#define cmin(a, b)     if ((a) > (b)) (a) = (b)
#define cmax(a, b)     if ((a) < (b)) (a) = (b)
#define BIT(x, i)      (((x) >> (i)) & 1)
#define MASK(i)        (1LL << (i))
#define debug(x)       cout << (x) << "\n"
#define endl           "\n"
#define ii             pair <int, int>
#define ll             long long
#define reset(x)       memset(x, 0, sizeof(x))
#define mem(a, x)      memset(x, (a), sizeof(x))
#define task           ""
#define IO             freopen (task".inp","r",stdin),freopen (task".out","w",stdout);

using namespace std;

const int mod = 1007050321;
const int base = 521;
const int MOD = 1e9 + 7;
const int inf = 2e9;
const int N = 1e5 + 5;

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

    int x, y;
    cin >> x >> y;
    bool ok = true;
    if (y % 2 == 1) ok = false;
    else {
        ok = false;
        for (int i = 0; i <= x; ++i) {
            int leg4 = y - i*2;
            if (leg4 >= 0 && leg4 % 4 == 0 && leg4/4 == x - i)
                ok = true;
        }
    }
    cout << ((ok) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#define N 100

int main(){
  int n, r[N], p[N], i, l, j, q, k, num;
  int m[N][N];

  scanf("%d", &num);

  for(i = 1; i <= num; i++){
    scanf("%d%d", &r[i], &p[i]);
  }
  p[0] = r[1];
  n = num;
  for(i = 1; i <= n; i++){
    m[i][i] = 0;
  }
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n-l+1; i++){
      j = i+l-1;
      m[i][j]= 2147483647;
      for(k = i; k <= j-1; k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	if(m[i][j] > q){
	  m[i][j] = q;
	}
      }
    }
  }

  printf("%d\n", m[1][j]);

  return 0;
}
  
  



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

class Program
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var N = nm[0];
        var M = nm[1];
        var list = new List<int[]>();
        var listCount = 0;
        for (int i = 0; i < N; ++i)
        {
            var ab = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
            if (M < ab[0]) continue;
            list.Add(new int[] { ab[0], ab[1] });
            listCount++;
        }
        list = list.OrderBy(x => x[0]).ToList();
        var tempList = new List<int>();
        var index = 0;
        var ans = 0;
        if(1 <= listCount)
        {
            for (int i = 1; i <= M; ++i)
            {
                while (index < listCount && list[index][0] <= i)
                {
                    var ins = LowerBound(list[index][1], tempList);
                    tempList.Insert(ins, list[index][1]);
                    index++;
                }
                if (tempList.Any())
                {
                    var n = tempList.Last();
                    ans += n;
                    tempList.RemoveAt(tempList.Count()-1);
                }
            }
        }
        Console.WriteLine(ans);
    }

    static int LowerBound(long value, List<int> array)
    {
        var low = 0;
        var high = array.Count();
        
        while (low < high)
        {
            var middle = (high + low) / 2;
            if (value <= array[middle]) high = middle;
            else low = middle + 1;
        }
        return low;
    }
}


Measured memory_bytes: 29752
// 有没有思路都先分析完样例！！！说不定会有启发！！！
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

typedef long long ll;
const int N = 1e5 + 10;
ll n, Q, m, q[N], x, f[N], ans[N];

void solve(ll x, ll v) {
    int k = upper_bound(q + 1, q + m + 1, x) - q - 1;
    if (!k) {
        ans[1] += v, ans[x + 1] -= v;
        return;
    }
    f[k] += v * (x / q[k]), solve(x % q[k], v);
}

int main() {
    cin >> n >> Q;
    q[++m] = n;
    rep(i, 1, Q) {
        scanf("%lld", &x);
        while (m && q[m] >= x) --m;
        q[++m] = x;
    }

    f[m] = 1;
    for (int i = m; i >= 2; i--)
        f[i - 1] += f[i] * (q[i] / q[i - 1]), solve(q[i] % q[i - 1], f[i]);

    ans[1] += f[1], ans[q[1] + 1] -= f[1];
    rep(i, 1, n) ans[i] += ans[i - 1], printf("%lld\n", ans[i]);
    return 0;
}


Measured memory_bytes: 4096
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    vector<int> v[100001];

    ll ans[100001],n;

    void bfs(int s)
    {
        queue<pii> q;
        int visited[100001];
        int i,j;
        for(i=1;i<=n;++i)
            visited[i]=0;
        visited[s]=1;
        q.push({s,0});
        while(!q.empty())
        {
            pii x=q.front();
            q.pop();
            i=x.f;
            ans[x.s]++;
            for(j=0;j<v[i].size();++j)
            {
                if(visited[v[i][j]]==0)
                {
                    visited[v[i][j]]=1;
                    q.push({v[i][j],x.s+1});
                }
            }
        }
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int x,y,i,j,a,b;
            cin>>n>>x>>y;
            for(i=2;i<=n;++i)
            {
                v[i].pb(i-1);
                v[i-1].pb(i);
            }
            v[x].pb(y);
            v[y].pb(x);
            for(i=1;i<=n;++i)
            {
                bfs(i);
            }
            for(i=1;i<=n-1;++i)
                cout<<ans[i]/2<<endl;
        }
        return 0;
    }


Measured memory_bytes: 2688
//
// Created on 2020/05/20.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


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

    int ans = (t/a)*b;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, n; cin >> h >> n;
    vll a(n);
    REP(i, n) cin >> a[i];
    if (h <= accumulate(ALL(a), 0LL)) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

char a[100010],b[100010];
int cc,flag=1;

void jud()
{
	for(int i=0;i<cc-1;i++)
	{
		if(a[i]!=b[cc-i-2])
		{
			flag=0;
			return ;
		}
	}
}

int main( )
{
	while(~scanf("%c",&a[cc]))
	{
		cc++;
	}
	for(int i=0;i<cc;i++)
	{
		if(a[i]=='p')b[i]='q';
		if(a[i]=='q')b[i]='p';
		if(a[i]=='b')b[i]='d';
		if(a[i]=='d')b[i]='b';
	}
	jud();
	if(flag==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
   int N;
   cin >> N;
   int sum = 0;
   int top = 0;
   int p;
   for (int i = 0; i < N; i++) {
      cin >> p;
      if (p > top) {
         top = p;
      }
      sum += p;
   }
   sum -= top / 2;
   cout << sum <<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String ans = "No";
    BREAK:for (int i=0;i<=9;i++){
      for (int j=0;j<=9;j++){
        if ((i*j)==N){
          ans = "Yes";
          break BREAK;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23508
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#include <stack>
#include <math.h>
#include <cstdio>
#include <string.h>

using namespace std;
int main(void) {
	long long int x, i, j, ans = 0;
	cin >> x;

	for (i = 1; i <= x; i++) {
		for (j = 2; j <= 10; j++) {
			if (pow(i, j)>x)break;
			if (pow(i, j) <= x) {
				long long int t = pow(i, j);
				ans = max(ans, t);

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int x;
	cin >> x;
	if (x == 0) cout << 1 << endl;
	else cout << 0 << endl;
}



Measured memory_bytes: 3608
fn main() {
    use std::io;
    let mut input = String::new();
    let _ = io::stdin().read_line(&mut input);
    let input_nums =
        input.trim().split_whitespace().map(|x| x.parse::<usize>().unwrap()).collect::<Vec<_>>();
    let a = input_nums[0];
    let b = input_nums[1];
    let c = input_nums[2];

    let mut i = 0;

    loop {
        if (a * i) % b == c {
            println!("YES");
            break;
        }
        if i > 1000 {
            println!("NO");
            break;
        }
        i += 1;
    }

}

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

#define ll long long
#define ar array
#define PI (3.14159265358979323846264338327950L)
#define ld long double

void solve() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  
  // long double yhComp = A*(cos(((long double)H/12)*2*PI));
  // long double xhComp = A*(cos((((double)H/12)*2*PI)-(PI/2)));
  
  // long double ymComp = B*(cos(((long double)M/60)*2*PI));
  // long double xmComp = B*(cos((((long double)M/60)*2*PI)-(PI/2)));

  // long double yDiff = abs(yhComp - ymComp);
  // long double xDiff = abs(xhComp - xmComp);

  // long double answer = sqrt(pow(xDiff, 2) + pow(yDiff, 2));

  // printf("%20.20Lf\n", answer);

  ld angle1 = ((ld)H/12.0)*2.0*PI + (((ld)M/60.0)*2.0*PI)/12.0;
  ld angle2 = ((ld)M/60.0)*2.0*PI;
  ld angle = abs(angle1-angle2);

  ld x = powl((ld) A, 2) + powl((ld) B, 2) - (2 * (ld) A * (ld) B * cosl(angle));
  printf("%20.20Lf\n", sqrt(x));
  return 0;
}


Measured memory_bytes: 4164
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

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

	if (s.back() == 's') {
		s += "es";
	} else {
		s += "s";
	}

	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3136
// 提出時に消す
// package app;

import java.util.Scanner;

// 提出時にMainに変更する
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int x = sc.nextInt();
        int t = sc.nextInt();

        int kaisu = n / x;
        if (n % x > 0) {
            kaisu++;
        }

        System.out.println(t * kaisu);

        sc.close();
    }
}

Measured memory_bytes: 35800
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  VI A(N);
  rep(i,N) cin>>A[i];
  int ans=0;
  rep(i,N) if(i==A[A[i]-1]-1) ans++;
  cout<<ans/2<<endl;
}

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

int main() {
	int N;
	cin >> N;

	vector<int> A(N);
	for (int i = 0; i < N;i++) cin >> A.at(i);

	sort(A.begin(), A.end());

	int Q = A[0];
	int W = A[N - 1];
	cout << W - Q << endl;
}

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

int main(){
  int num;
  double weight, height;
  char ch;
  while (cin >> num >> ch >> weight >> ch >> height) {
    double bmi = weight / (height * height);
    if (bmi >= 25.0)
    cout << num << endl;
  }
}



Measured memory_bytes: 3184
from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return (over // under)%(10**9+7)
N,k=map(int,input().split())
l=N-k
for i in range(1,k+1):
    if l<i-1:
        print(0)
    else:
        num1=l-(i-1)
        print((cmb(k-1,i-1)*cmb(num1+i,i))%(10**9+7))


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  int kuro = 0;
  vector<string> s(H);
  REP(i, H) cin >> s[i];
  REP(i, H) REP(j, W) {
    if(s[i][j] == '#') { kuro++; }
  }
  queue<P> Q;
  vector<vector<int>> d(H, vector<int>(W, -1));
  d[0][0] = 0;
  Q.push(P(0, 0));
  int dx[4] = {0, 1, 0, -1};
  int dy[4] = {1, 0, -1, 0};
  while(!Q.empty()) {
    P p = Q.front();
    Q.pop();
    if(p.first == H - 1 && p.second == W - 1) { break; }
    for(int i = 0; i < 4; i++) {
      int x = p.first + dx[i];
      int y = p.second + dy[i];
      if(x < 0 || H <= x || y < 0 || W <= y || s[x][y] == '#') { continue; }
      if(d[x][y] != -1) { continue; }
      d[x][y] = d[p.first][p.second] + 1;
      Q.push(P(x, y));
    }
  }
  if(d[H - 1][W - 1] == -1) {
    cout << -1 << endl;
    return 0;
  }
  int ans = H * W - d[H - 1][W - 1] - kuro - 1;
  cout << ans << endl;
  return 0;
}

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

int main() {
    int n; cin >> n;
    int h[100001];
    rep(i,n) cin >> h[i];
    h[n] = 1000000001;
    int ans,cnt; ans = cnt = 0;
    rep(i,n) {
        if (h[i] >= h[i+1]) cnt ++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;;
}

Measured memory_bytes: 4012
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int M=(int)1e5+5;
void Rd(int &res){
	res=0;static char p;
	while(p=getchar(),p<'0');
	do{
		res=(res*10)+(p^48);
	}while(p=getchar(),p>='0');
}
int n,a[M];
int ans1[M],ans2[M];
int main(){
	Rd(n);
	for(int i=0;i<n;i++)Rd(a[i]);
	sort(a,a+n);
	for(int l=0,r=n-1;l<r;l++,r--)swap(a[l],a[r]);
	int x=0,y=0,nx,ny;
	for(;;){
		nx=x+1,ny=y+1;
		if(nx>=n||ny>=a[nx])break;
		x=nx,y=ny;
	}
	int cnt1=a[x]-y-1,cnt2=0;
	for(int j=x+1;j<n;j++)if(y<a[j])cnt2++;
	if((cnt1&1)||(cnt2&1))puts("First");
	else puts("Second");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
template<class L>
void ci(vector<vector<L>> a,int b,int c){
	fo(i,b){
		fo(j,b)
		cin>>a[i][j];
	}
}
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
	int a,c=0,d,e;
	cin>>a;
	vector<int> b(a);
	fo(i,a)
	cin>>b[i];
	Sort(b);
	for(int i=0;i<a;i=i){
		e=0;
		d=b[i];
		while(d==b[i]){
			e++;
			i++;
		}
		c+=e-1;
	}
	uni(b);
	if(c%2==0)
	    cout<<b.size()<<endl;
    else
    	cout<<b.size()-1<<endl;
}			

Measured memory_bytes: 1024