akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

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





	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define vi vector<int>
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long 
using namespace std;
const int mod = 1e9+7;
main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;cin >> n;
	
	
	
	vi v(n+1);
	for(int i = 1; i <= n; i++)
		cin >> v[i];
	ll s = 0, mon = 1000;
	for (int i = 1; i <= n-1; i++) {
		if (v[i] <= v[i+1]) {
			s+=mon/v[i];
			mon%=v[i];
		}
		else {
			mon+=s*v[i];
			s = 0;
		}
	}
	mon += s*v[n];
	cout <<mon;
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int count;
    
    for (int i = 0; ; i++) {
        if (A <= B) {
            int temp = A;
            A = B;
            B = temp;
        }
        if (A <= C) {
            int temp = A;
            A = C;
            C = temp;
        }
        if (B <= C) {
            int temp = B;
            B = C;
            C = temp;
        }
        
        if (A == B && B == C) {
            count = i;
            break;
        }
        else if (A == B) {
            C += 2;
            continue;
        }
        else if (B == C) {
            B += 1;
            C += 1;
            continue;
        }
        else {
            B += 1;
            C += 1;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
m = int(input())
n = list(map(int, input().split()))
sunuke = 0
araiguma = sum(n)

min = 10000000000
for i in range(m - 1):
    araiguma -= n[i]
    sunuke += n[i]
    #print(abs(sunuke - araiguma))
    if min > abs(sunuke - araiguma):
        min = abs(sunuke - araiguma)
print(min)

Measured memory_bytes: 24944
//Keep Working Hard
  // I__Like__Food  
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int mod = 1e9 + 7;
  const int mod2 = 998244353;
  const int N = 20005;
  const int INF = 1e16;
  const double PI = acos(-1);




int32_t main()
{
       

    IOS




    int n,m;
    cin >> n >> m;
    int sum = 0;
    vector<int> v(n);
    for(int i = 0; i < n; i++)
    {
      cin >> v[i];
      sum +=v[i];
    }
    sort(all(v),greater<int>());
    bool ok = true;
    double k =(double) (double)(sum)/(double(4*m));
    for(int i = 0; i < m; i++)
    {
      if(v[i]< k)
      {
        ok = false;
        break;
      }
    }
    if(ok)
    {
      cout <<"Yes";
    }
    else
    {
      cout << "No";
    }
  return 0;
} 

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
cnt=0
A.append(0)
for i in range(N):
    if B[i]<=A[i]:
        cnt+=B[i]
    else:
        cnt+=A[i]
        t=max(0,A[i+1]+A[i]-B[i])
        cnt+=A[i+1]-t
        A[i+1]=t
print(cnt)

Measured memory_bytes: 19116
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long n = long.Parse(input[0]);
		long k = long.Parse(input[1]);
    long memo = 1;
		long answer = 0;

    while(true)
    {
      answer++;
      memo *= k;
      if(memo > n) break;
    }

		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <vector>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

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

ll ans, mx, sum, mn = 1e8, cnt;

int main(){
	ll r;
	cin>>r;
	double ans = 2*3.14159265359*r;
	cout<<fixed<<setprecision(20)<<ans<<endl;
}


Measured memory_bytes: 3256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using ti3 = tuple<int, int, int>;
using vti3 = vector<ti3>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
template<class T> void cmin(T &a, const T&b) { if (a > b)a = b; }
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
int main() {
	int n;
	cin >> n;
	vi a(n);
	rep(i, n)cin >> a[i];
	int mincost=1<<30;
	for (int i = -100; i <= 100; i++) {
		int cost = 0;
		rep(j, n)cost += (a[j] - i)*(a[j] - i);
		cmin(mincost, cost);
	}
	cout << mincost << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long a[n+5];
    long long sum=0;
    map<long long,long long>mp;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
        mp[a[i]]++;
    }
    int q;
    cin>>q;
    while(q--)
    {
        int a,b;
        cin>>a>>b;
        int f=mp[a];
        sum=sum+(b-a)*f;
        mp[b]=mp[b]+mp[a];
        mp[a]=0;
        cout<<sum<<'\n';
    }
    return 0;
}

Measured memory_bytes: 10300
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Read();
            string b = Read();
            if (b == a[2].ToString() + a[1].ToString() + a[0].ToString())
            {
                WriteLine("YES");
            }
            else
            {
                WriteLine("NO");
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.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<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const int mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int n;
  cin>>n;
  int p[n],sum=0;
  rep(i,n){
    cin>>p[i];
    sum+=p[i];
    }
  sum/=n;
  int ans1=0,ans2=0;
  rep(i,n){
    ans1+=(p[i]-sum)*(p[i]-sum);
    ans2+=(p[i]-sum-1)*(p[i]-sum-1);
    }
  cout<<min(ans1,ans2)<<endl;
  return 0;         
  }

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

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

  int c = a * b;

  if (c % 2 == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
import math
n = int(input())
a = [int(x) for x in input().split()]
b = sorted(a)
if n%2:
  k1 = (b[n//2-1]+b[n//2])/2
  k2 = (b[n//2+1]+b[n//2])/2
  k3 = (b[n//2-1]+b[n//2+1])/2
else:
  k1 = b[n//2-1]
  k2 = b[n//2]
  k3 = -1

if k1 == k2:
  for i in range(n):
    print(k1)
else:
  for i in range(n):
    if n%2 and a[i] == b[n//2]:
      print(k3)
    elif a[i] <= k1:
      print(k2)
    else:
      print(k1)
  

Measured memory_bytes: 26212
class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def nhr(self, n, r):
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]

N, K = map(int, input().split())
MOD = 10**9 + 7
comb = Combination(N * 2)

L = max(1, N - K)

ans = 0
for l in range(L, N + 1):
    zero = N - l
    ans += comb.ncr(N, zero) * comb.nhr(N - zero, zero)
    ans %= MOD

print(ans)

Measured memory_bytes: 53616
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 1e3 + 5;
const long long mod = 1e9 + 7;
long long dp[MAX_N][MAX_N];
long long calc[MAX_N][MAX_N];
int n, a, b, c, d;

long long power(long long x, long long y, long long p){
    long long res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
long long fact[MAX_N], inv_fact[MAX_N];
void pre(){
    fact[0] = 1;
    inv_fact[0] = 1;
    int i = 0;
    for(i = 1; i < MAX_N; i++){
        fact[i] = fact[i - 1] * i;
        fact[i] %= mod;
        inv_fact[i] = power(fact[i], mod - 2, mod);
    }
}
long nCr(int n, int r){
    if(n < r)
        return 0;
    long long ans = fact[n];
    ans *= inv_fact[r];
    ans %= mod;
    ans *= inv_fact[n - r];
    ans %= mod;
    return ans;
}

long long go(int size, int till_now){
    if(size == b + 1){
        if(till_now == n) {
            //cout << size << " " << till_now << "\n";
            return 1;
        }
        else
            return 0;
    }
    if(dp[size][till_now] != -1)
        return dp[size][till_now];
    long long ans = go(size + 1, till_now);
    long long ways = 1;
    if(c != 1)
        ways = calc[size][till_now];
    int rem = n - till_now;
    for(int i = c; i <= d; i++){
        if(rem - (i - 1) * size < size)
            break;
        ways *= nCr(rem - (i - 1) * size, size);
        ways %= mod;
        ans += ((ways * inv_fact[i]) % mod * go(size + 1, till_now + size * i)) % mod;
        ans %= mod;
    }
    return dp[size][till_now] = ans;
}
void solve(){
    int i = 0, j = 0;
    for(i = a; i <= b; i++){
        for(j = 0; j <= n; j++){
            int rem = n - j;
            if(rem - (c - 1) * i < 0)
                break;
            calc[i][j] = power(power(fact[i], c - 1, mod), mod - 2, mod);
            calc[i][j] *= fact[rem];
            calc[i][j] %= mod;
            calc[i][j] *= inv_fact[rem - (c - 1) * i];
            calc[i][j] %= mod;
        }
    }
    memset(dp, -1, sizeof(dp));
    cout << go(a, 0) << "\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    int t = 1;
    //cin >> t
    while(t--){
        cin >> n >> a >> b >> c >> d;
        solve();
    }

    return 0;
}


Measured memory_bytes: 16128
import java.util.Scanner;

public class Main {

    private void execute() throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String[] a = sc.nextLine().split(" ");
        double asum = 0d;
        for (int i = 0; i < n; i++) {
            asum += 1.0d / Double.parseDouble(a[i]);
        }
        System.out.println(1.0d / asum);
    }

    public static void main(String[] args) {
        try {
            new Main().execute();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int n,a,cnt=0;
set<int> s;
set<int> :: iterator it;
map<int,int> mp;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		s.insert(a);
		++mp[a];
	}
	for(it=s.begin();it!=s.end();it++)
	{
		if(mp[*it]%2==1)
		{
			cnt+=1;
}
	}
	printf("%d",cnt);
}

Measured memory_bytes: 9600
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        
        long ans=0L;
        
        for(int i=0;i<=N;i++){
            if(i%3==0||i%5==0){
                
            }else{
                ans+=i;
            }
        }
        
        System.out.println(ans);
    }
}


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

using namespace std;

namespace {

#define VEVE(i, a, b) for (ll i = a, __##i = b; i < __##i; ++i)
#define DYDY(i, a, b) for (ll i = a, __##i = b; i > __##i; --i)
#define RARA(x, seq) for (auto &x : seq)
#define SIZE(x) ((ll)(x.size()))
#define ALL(x) x.begin(), x.end()

typedef int64_t ll;
typedef double dd;
typedef pair<ll, ll> Seg;

ll Go(const vector<Seg>& segs) {
  multiset<Seg> by_lef, by_rig;
  RARA(s, segs) {
    by_lef.insert(s);
    by_rig.emplace(s.second, s.first);
  }
  ll at = 0, sum = 0;
  while (true) {
    bool moved = false;
    // find seg with max lef and move right
    if (by_lef.empty())
      break;
    auto it = --by_lef.end();
    if (it->first >= at) {
      sum += abs(it->first - at);
      at = it->first;
      by_rig.erase(by_rig.find(make_pair(it->second, it->first)));
      by_lef.erase(it);
      moved = true;
    }

    // find seg with min rig and move lef
    if (by_rig.empty())
      break;
    it = by_rig.begin();
    if (it->first <= at) {
      sum += abs(it->first - at);
      at = it->first;
      by_lef.erase(by_lef.find(make_pair(it->second, it->first)));
      by_rig.erase(it);
      moved = true;
    }
    if (not moved) {
      // all intervals now intersect current position
      // can visit all remaining intervals for free
      break;
    }
  }
  sum += abs(at);
  return sum;
}

void Solve(ll) {
  ll n;
  if (not(cin >> n))
    return;
  vector<Seg> segs(n);
  RARA(s, segs) {
    cin >> s.first >> s.second;
  }
  const ll rig_first = Go(segs);
  RARA(s, segs) {
    s = {-s.second, -s.first};
  }
  const ll lef_first = Go(segs);
  const ll res = max(lef_first, rig_first);
  cout << res << endl;
}

void Init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
}

int32_t main() {
#ifdef AZN
  freopen("input.txt", "r", stdin);
#endif
  Init();
  ll tests = 11;
  VEVE(test, 1, tests + 1) Solve(test);
  return 0;
}


Measured memory_bytes: 14336
from collections import defaultdict

X, Y = map(str, input().split())

d = defaultdict(int)
i = 0
for s in 'ABCDEF':
    d[s] = i
    i += 1

if d[X] < d[Y]:
    print('<')
elif d[X] > d[Y]:
    print('>')
else:
    print('=')


Measured memory_bytes: 3316
a, b, k = (int(i) for i in input().split())
cdiv = []
ans = []
a,b = min(a,b),max(a,b)
for i in range(1, a + 1):
    if a % i == 0:
        cdiv.append(i)
for i in cdiv:
    if b % i == 0:
        ans.append(i)


print(ans[len(ans) - k])


Measured memory_bytes: 3060
#include <iostream>

#include <map>
#include <string>

#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

using std::map;
using std::string;

using std::max;

int
main()
{
  int N, M;
  string s;
  map<string, int> mm;
  cin >> N;
  for (int n = 0; n < N; n++)
  {
    cin >> s;
    mm[s]++;
  }
  cin >> M;
  for (int m = 0; m < M; m++)
  {
    cin >> s;
    mm[s]--;
  }
  int gain = 0;
  for (auto it = mm.begin(); it != mm.end(); it++)
  {
    gain = max(gain, it->second);
  }
  cout << gain << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

bool Bsearch(int key, int A[], int len) {
	int l = 0, r = len - 1;
	while (l <= r) {
		int mid = l + (r - l) / 2;
		if (A[mid] > key)
			r = mid - 1;
		else if (A[mid] < key)
			l = mid + 1;
		else
			return true;
	}
	return false;
}

int main() {
	int n, *S;
	int q, *T;
	int ans = 0;
	cin >> n;
	S = new int[n];
	for (int i = 0; i < n; i++)
		cin >> S[i];
	cin >> q;
	T = new int[q];
	for (int i = 0; i < q; i++)
		cin >> T[i];

	sort(S, S + n);
	for (int i = 0; i < q; i++)
		for (int j = 0; j < n; j++)
			if (Bsearch(T[i], S, n) == true) {
				ans++;
				break;
			}

	cout << ans << endl;
	delete[] S;
	delete[] T;
	return 0;
}

Measured memory_bytes: 1248
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    if(Math.abs(N-M)>=2){
      System.out.println(0);
    }else{
      long[] fac = new long[Math.max(N,M)+1];
      fac[0] = 1;
      for(int i=1;i<=Math.max(N,M);i++){
        fac[i] = (fac[i-1]*i)%1000000007;
      }
      long ans = (fac[N]*fac[M])%1000000007;
      if(N==M){
        ans = (2L*ans)%1000000007;
      }
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 23124
// https://atcoder.jp/contests/abc168/tasks/abc168_a

#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>

using namespace std;
#define lli long long int

int main()
{
    int n;
    cin>>n;
    n=n%10;
    if(n==2 || n==4 || n==5 || n==7 || n==9)
        cout<<"hon\n";
    else if(n==0 || n==1 || n==6 || n==8)
        cout<<"pon\n";
    else
    {
        cout<<"bon\n";
    }
    return 0;
}

Measured memory_bytes: 3636
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program {
	static void Main() {
		var N = NextLong();
		var T = new long[N];

		for (var i = 0; i < N; i++) {
			T[i] = NextLong();
		}
		var M = NextLong();
		var ans = new long[M];
		for (var i = 0; i < M; i++) {
			var P = NextLong();
			var X = NextLong();
			ans[i] = T.Sum() - T[P - 1] + X;
		}
		WriteLine(string.Join("\n", ans));
	}

	static long NextLong() {
		return long.Parse(NextString());
	}

	static string NextString() {
		var result = new List<char>();
		while (true) {
			int next = Read();
			if (next < 0)
				break;
			var nextChar = (char)next;
			if (!char.IsWhiteSpace(nextChar))
				result.Add(nextChar);
			else if (nextChar != '\r')
				break;
		}
		return string.Join("", result);
	}
}


Measured memory_bytes: 13396
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0
def modinv(a, m):
    g, x, y = xgcd(a, m)
    return x % m
def main():
    s=list(input())
    mod=10**9+7
    K=modinv(10,13)
    U=[[0 for i in range(10) ]for k in range(13)]
    for i in range(13):
        for j in range(10):
            U[i][j]=((i-j)*K)%13

    dp=[[0 for k in range(13)] for i in range(len(s))]
    #dp[i][j]=初めのindex=i番目まで見たときに、あまりがjになるような方法の総数
    num=s[0]
    if s[0]=="?":
        for i in range(10):
            dp[0][i]=1
    else:
        number=int(s[0])
        dp[0][number]=1

    for i in range(1,len(s)):
        for k in range(13):
            if s[i]=="?":
                for j in range(10):
                    dp[i][k]+=dp[i-1][U[k][j]]%mod
            else:
                number=int(s[i])
                dp[i][k]=dp[i-1][U[k][number]]%mod
    print(dp[len(s)-1][5]%mod)
if __name__ == "__main__":
    main()

Measured memory_bytes: 69384
#![allow(unused_imports)]
#![allow(non_snake_case)]
use proconio::{input, fastout};
use proconio::marker::{Chars, Bytes, Usize1};

#[fastout]
fn main() {
    input!{
        n: usize,
        c: Chars
    }
    let v = c.iter().filter(|&&x| x == 'R').count();
    let w = c[..v].iter().filter(|&&x| x == 'R').count();
    println!("{}", v-w);
}


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

int main(){
	long long N,M;
	cin >> N >> M;
	vector<long long> A(N),B(M);
	for(long long i=0;i<N;i++)cin >> A[i];
	for(long long i=0;i<M;i++)cin >> B[i];
	
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	
	for(long long i=1;i<N;i++){
		if(A[i]==A[i-1]){
			printf("0\n");
			return 0;
		}
	}
	for(long long i=1;i<M;i++){
		if(B[i]==B[i-1]){
			printf("0\n");
			return 0;
		}
	}
	
	long long ans=1;
	
	for(long long i=N*M;i>0;i--){
		auto A_upper=upper_bound(A.begin(),A.end(),i);
		auto A_lower=lower_bound(A.begin(),A.end(),i);
		auto B_upper=upper_bound(B.begin(),B.end(),i);
		auto B_lower=lower_bound(B.begin(),B.end(),i);
		
		bool A_exist=(A_upper-A_lower==1);
		bool B_exist=(B_upper-B_lower==1);
		
		if(!A_exist && !B_exist)ans*=(A.end()-A_upper)*(B.end()-B_upper)-(N*M-i);
		if(A_exist && !B_exist)ans*=(B.end()-B_upper);
		if(!A_exist && B_exist)ans*=(A.end()-A_upper);
		ans%=1000000007;
	}
	
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N, A, X;
  cin >> N >> A;
  X = N % 500 - A;
  if (X <= 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ll INF = 1e9 + 10;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1);
const int M = 1e3 + 10;
const int N = 1e6 + 10;

int a[N];

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

    fr(i, n) {
        scanf("%d", &a[i]);
    }

    vector<int> v;
    frab(i, 1, n) {
        if (a[i] <= a[i - 1]) {
            v.pb(a[i]);
        }
    }
    //sort(v.begin(), v.end());
    //reverse(v.begin(), v.end());

    //for (auto x: v) cout << x << " ";cout << endl;

    ll tl = 0, tr = n + 2;

    while (tr - tl > 1) {
        ll tm = (tl + tr) / 2;
        auto u = v;
        map<int, int, std::greater<int> > m;

        fr(i, u.size()) {
            int x = u[i];
            while (m.size() && m.begin()->first > x)
                m.erase(m.begin());
            m[x]++;
            if (tm > 1) {
                while (m.count(x) && m[x] >= tm && x > 1) {
                    m[x - 1] += m[x] / tm;
                    m[x] %= tm;
                    x--;
                }
            }
        }

        if (u.size())
            m[1] = max(1, m[1]);

        if (m[1] >= tm)
            tl = tm;
        else
            tr = tm;
    }
    cout << tr << "\n";

}

int main() {
    //freopen("a.in", "r", stdin);
    //ios_base::sync_with_stdio(false);
    solve();

    return 0;

}


Measured memory_bytes: 2676
import java.util.*

tailrec fun <T> calcPermutationList(
    sortedList: Array<T>,
    queue: ArrayDeque<List<T>>,
    permutationList: MutableList<List<T>> = mutableListOf()
): List<List<T>> {
    if (queue.isEmpty()) {
        return permutationList
    }

    val p = queue.removeFirst()
    if (p.size == sortedList.size) {
        permutationList += p
    } else {
        queue += sortedList.filterNot { p.contains(it) }.map { p + it }
    }

    return calcPermutationList(sortedList, queue, permutationList)
}

fun main(args: Array<String>) {
    val n = readInteger()
    val p = readIntegerList()
    val q = readIntegerList()

    calcPermutationList((1..n).toList().toTypedArray(), ArrayDeque<List<Int>>().apply { addFirst(listOf()) })
        .let { it.indexOf(p) - it.indexOf(q) }
        .let(Math::abs)
        .let(::println)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 48884
/*

*/
#include <bits/stdc++.h>

using namespace std;

#define ll          long long int
#define mp          make_pair
#define pb          push_back
#define fi          first
#define si          second
#define fastIO      ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F(a,n)      for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n)     for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n)      for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n)     for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m)   for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m)  for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m)  for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
const int nax = 1e5 + 5;
const int mod = 1e9+7;
ll n, w;
ll *weight, *cost;
ll dp[101][nax];

ll func(ll i, ll w_curr){
	//base case
	if(w == 0){
		return 0;
	}
	if(i == n){
		return 0;
	}
	//recursive case
	if(dp[i][w_curr] != -1){ return dp[i][w_curr];}

	ll op1 = func(i + 1, w_curr);
	ll op2 = weight[i] > w_curr ? 0 : cost[i] + func(i + 1, w_curr - weight[i]);

	return dp[i][w_curr] = max(op1, op2);
}

int main(){
fastIO
    cin>>n>>w;
    memset(dp, -1, sizeof(dp));
	weight = new ll[n];
	cost = new ll[n];
	for(int i=0; i<n; i++){
		cin>>weight[i];
		cin>>cost[i];
	}
	cout<<func(0, w);
}

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

int MAX_A = 10000;

void countingsort(vector<int> &A, vector<int> &B, int k)
{
    vector<int> C(k,0);

    for(int j=0; j<A.size(); ++j){
        C[A[j]]++;
    }
    for(int i=1; i<k; ++i){
        C[i] = C[i] + C[i-1];
    }
    for(int j=A.size()-1; j>=0; --j){
        B[C[A[j]]-1] = A[j];
        C[A[j]]--;
    }


}

int main()
{
    int n;
    cin >>n;
    vector<int> A(n,0);
    for(int i=0; i<n; ++i){
        cin >> A[i];
    }
    vector<int> B(n,0);
    countingsort(A,B,MAX_A);

    for(int i=0; i<n; ++i){
        if( i > 0)
            cout << ' ';
        cout << B[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 18332
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func allAtoi(num []string) []int {
	conv := make([]int, len(num))
	for i, item := range num {
		conv[i], _ = strconv.Atoi(item)
	}
	return conv
}

func main() {
	nums := allAtoi(strings.Split(nextLine(), " "))
	ans := nums[0] - nums[1]
	if ans < 0 {
		ans = 0
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
n,q=map(int,input().split())
cnt=[0]*(n)
g=[[] for _ in range(n)]
for _ in range(n-1): #木グラフの隣接リストを作成
  a,b=map(int,input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
for _ in range(q):
    a , b = map(int,input().split())
    a = a - 1
    cnt[a] += b
import collections
q=collections.deque()
q.append(0)
check=[0]*n
while q:
  v=q.pop()
  check[v]=1
  for u in g[v]:
    if check[u]==1:
      continue
    cnt[u]+=cnt[v]
    q.append(u)
print(*cnt)

Measured memory_bytes: 56528
n, m = map(int, input().split())
G = [[] for _ in range(n)]
deg = [0] * n # 各頂点の入力次数
for _ in range(m):
    x, y = map(lambda x: int(x)-1, input().split())
    G[x].append(y)
    deg[y] += 1

from collections import deque
# 入力次数が0の頂点をBFSの開始点とする
q = deque([])
for i in range(n):
    if deg[i] == 0:
        q.append(i)
dp = [0] * n

while q:
    v = q.popleft()

    for nv in G[v]:
        # vからnvへの入力を削除
        deg[nv] -= 1
        if deg[nv] == 0:
            q.append(nv)
            dp[nv] = max(dp[nv], dp[v]+1)
    
print(max(dp))


Measured memory_bytes: 23088
//#pragma comment(linker, "/STACK:1024000000,1024000000")
/* vim: set fdm=marker */
//{{{
#define __ return
int ATTENTION() {
	/* pls IGNORE this function and go down and HACK me
	 * read this AFTER contest
	 * this function is empty and it will not be called !
	 */

	http://codeforces.com/group/Pmz2A2x7ES
	/* I created a group there.
	 * I hope with the group, people can finish
	 * past contests, which is important for 
	 * increasing rating.
	 * I am still getting familiar with this function.
	 */
	 __ 0;
}
// deprecated because mac doesn't support this...
/* #include <bits/stdc++.h> */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < 0) return gcd(-a, b);
	if(b < 0) return gcd( a,-b);
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll qpow(ll a, ll n, ll mod) {
	a %= mod;
	ll ans = 1LL;
	while(n) {
		if(n & 1) ans = (ans*a % mod);
		a = (a*a % mod);
		n >>= 1;
	}
	return ans;
}

inline ll rev(ll a, ll p) {
	return qpow(a, p - 2, p);
}

#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define rep(x, st, en) for(int x = st; x < en; x++)
#define rer(x, st, en) for(int x = st; x >= en; x--)
#define pb push_back
#define mp make_pair
#define dbgm(msg, var) cerr<<#msg<<" "<<#var<<" = "<<var<<endl; 
#define dbg(var) cerr<<#var<<" = "<<var<<endl;
#define X first
#define Y second
// build prefix sum
template<typename T>
inline void BPS(T* DST, T* SRC, int N, int s = 0) {
	DST[s] = SRC[s];
	rep(i, 1, N) DST[s + i] = DST[s + i - 1] + SRC[s + i];
}
inline int in() { int x; cin>>x; return x; }
#ifdef ALNDBG
namespace alndbg {
	clock_t s, e;
}
#endif

inline void tic() {
#ifdef ALNDBG
	alndbg::s = clock();
#endif
}

inline void toc() {
#ifdef ALNDBG
	alndbg::e = clock();
	cerr<<1000.0 * (alndbg::e - alndbg::s) / CLOCKS_PER_SEC<<" ms"<<endl;
#endif
}



//}}}

// -------------------- Spliters ------------------------
// BFS求最短路小心vis可能访问过

int main() {
  int N, H, W;
  cin>>N>>H>>W;
  cout<<(N - H + 1) * (N - W + 1)<<endl;
	return 0;
}
// --USE C++11
// *-USE O2



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    long N=gl();
	    long A=gl();
	    long B=gl();
	    
       //System.out.print((int)Math.floor(Math.sqrt(n)));
	    long s=Math.floorDiv(N, A+B);
	    long a=N%(A+B);

        if (a<A) {
    	    System.out.print(s*A+a);
        }else {
        	System.out.print(s*A+A);
        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35740
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s1, s2;
    cin >> s1 >> s2;
    string ans = "";
    for(int i=0; i<min(s1.size(), s2.size()); i++){
        ans.push_back(s1[i]);
        ans.push_back(s2[i]);
    }
    if(s1.size()<s2.size()){
        ans.push_back(s2[s2.size()-1]);
    }else if(s1.size()>s2.size()){
        ans.push_back(s1[s1.size()-1]);
    }
    cout << ans << endl;
    return 0;
}

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




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

	vector<int> a(n);
	vector<pair<int, int>> bc(m);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

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

	int b, c;
	for (int i = 0; i < m; i++) {
		cin >> b >> c;
		bc[i] = make_pair(c, b);
	}

	sort(bc.begin(), bc.end());
	reverse(bc.begin(), bc.end());

	int buf = 0;
	long long  sum = 0;
	auto itr = bc.begin();
	for (int i = 0; i < n; i++) {
		if (itr->first <= a[i]) break;
		a[i] = itr->first;
		if (--itr->second == 0) itr++;
		if(itr == bc.end()) break;
	}
	for (int i = 0; i < n; i++) {
		sum += a[i];
	}

	cout << sum << endl;


	return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 n;
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 200005
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;

ll Tree[MAX], h[MAX];

ll query(int idx)
{
    ll x = 0;
    while(idx>0)
    {
        x = max(x, Tree[idx]);
        idx-=idx&(-idx);
    }
    return x;
}

void update(int idx, ll x, int n) ///n is the size of the array, x is the number to add
{
    while(idx<=n)
    {
        Tree[idx] = max(Tree[idx], x);
        idx+=idx&(-idx);
    }
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    int n;
    cin>>n;
    for(int i = 1; i <= n; i++)
        cin>>h[i];
    ll mx = 0;
    for(int i = 1; i <= n; i++)
    {
        ll a;
        cin>>a;
        ll cur = query(h[i]) + a;
        update(h[i], cur, n);
        mx = max(mx, cur);
    }
    cout<<mx<<endl;

    //End();
    return 0;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2153&lang=jp
typedef long long ll;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef pair<int, int> pii;

int dlx[4] = {1, 0, -1, 0};
int dly[4] = { 0,1,0,-1 };
int drx[4] = { 1,0,-1,0 };
int dry[4] = { 0,-1,0,1 };

bool LRf[55][55][55][55];

int W, H;
bool bfs(pii l,pii r,vvc& L,vvc& R){
	memset(LRf, false, sizeof(LRf));
	queue<pair<pii, pii>> q;
	q.push({ l,r });
	while (!q.empty()) {
		auto pp = q.front(); q.pop();
		l = pp.first; r = pp.second;
		if (LRf[l.first][l.second][r.first][r.second] == true) continue;
		LRf[l.first][l.second][r.first][r.second] = true;

		if (L[l.first][l.second] == '%' && R[r.first][r.second] == '%') return true;
		if (L[l.first][l.second] == '%' || R[r.first][r.second] == '%') continue;

		for (int i = 0; i < 4;i++) {
			int lx = l.first + dlx[i], ly = l.second + dly[i];
			int rx = r.first + drx[i], ry = r.second + dry[i];
			if (L[lx][ly] == '#' && R[rx][ry] == '#')continue;
			if (L[lx][ly] == '#') {
				if (LRf[l.first][l.second][rx][ry]) continue;
				q.push({ {l.first,l.second},{rx,ry} });
			}
			else if(R[rx][ry] == '#'){
				if (LRf[lx][ly][r.first][r.second]) continue;
				q.push({ {lx,ly},{r.first,r.second} });
			}
			else {
				if (LRf[lx][ly][rx][ry]) continue;
				q.push({ {lx,ly},{rx,ry} });
			}
		}
	}
	return false;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	while (cin >> W >> H) {
		if ((W | H) == 0)break;
		vvc L(H + 2, vc(W + 2, '#'));
		vvc R(H + 2, vc(W + 2, '#'));
		pii ls, rs;
		for (int i = 1; i <= H;i++) {
			for (int j = 1;j <= W;j++) {
				cin >> L[i][j];
				if (L[i][j] == 'L') ls = { i,j };
			}
			for (int j = 1;j <= W;j++) {
				cin >> R[i][j];
				if (R[i][j] == 'R') rs = { i,j };
			}
		}

		if (bfs(ls, rs, L, R)) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 13604
import java.util.*;
import java.lang.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double deg = sc.nextDouble();
        double rad = Math.toRadians(deg);
        
        double s = 0;
        double l = 0;
        double hb = 0;
        double ha = 0;
        
        ha = b * Math.sin(rad);
        hb = a * Math.sin(rad);
        s = b * hb / 2;
        l = a + b + Math.hypot(hb, (b - a * Math.cos(rad)));
        
        System.out.println(s);
        System.out.println(l);
        System.out.println(ha);
    }
}


Measured memory_bytes: 27924
def solve():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    INF=float('inf')
    n,m=map(int,input().split())
    l=[list(map(int,input().split())) for _ in range(m)]
    d=[INF]*n
    nbr=[[] for _ in range(n)]
    used=[False]*m
    for x in l:
        x[0]-=1
        x[1]-=1
    #print(l)
    for i in range(m):
        nbr[l[i][0]].append(i)
        nbr[l[i][1]].append(i)
    #print(nbr)
    def sol(i):
        for x in nbr[i]:
            if used[x]:continue
            used[x]=True
            i1=l[x][0]^l[x][1]^i
            dd=d[i]+l[x][2]*(2*(l[x][0]==i)-1)
            if d[i1]!=dd and d[i1]!=INF:
                print('No')
                exit()
            elif d[i1]==INF:
                d[i1]=dd
                sol(i1)
    for i in range(n):
        if d[i]==INF:
            d[i]=0
            sol(i)
    #print(d)
    print('Yes')
solve()

Measured memory_bytes: 154392
#include <bits/stdc++.h>
using namespace std;
#define _int long long
int main() {
	_int N;
	
	scanf("%lld",&N);
	for(_int h=1;h<=3500;h++)
	{
		for(_int n=1;n<=3500;n++)
		{
		   _int x=4*h*n-n*N-N*h;
		   _int y=N*h*n;
		   
		   if(x>0 && (y%x==0))
		   {
		   	cout<<h<<" "<<n<<" "<<y/x<<endl;
		   	return 0;
		   }
		}
			
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{
    int N,C;
    cin>>N>>C;
    ve<ve<int>> D(C,ve<int>(C,0)),c(N,ve<int>(N,0));
    rep(j,C) in(C,D[j]);
    rep(j,N) in(N,c[j]);
    rep(i,N) rep(j,N) c[i][j]--;
    
    ve<ve<int>> A(3,ve<int>(C,0));
    
    rep(i,N) rep(j,N){
        int a = (i+1+j+1)%3;
        A[a][c[i][j]]++;
    }
    
    int ans = 2000000000;
    
    rep(i,C) rep(j,C) rep(k,C){
        
        if(i==j || j==k || i==k) continue;
        int an = 0;
        rep(l,C) an += (D[l][i]*A[0][l]+D[l][j]*A[1][l]+D[l][k]*A[2][l]);
            
        
        
        ans = min(an,ans);
        
    }
    
    out(ans);

    
    return 0;
}


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

using namespace std;

int main()
{
    int n;  cin >> n;
    vector <int> v(n), occ(2e5 + 50); 

    for (int i = 0; i < n - 1; i++)
    {
        scanf ("%d", &v[i]);
        occ[v[i]]++;
    }
    
    for (int i = 1; i <= n; i++)
    {
        cout << occ[i] << "\n";
    }
    
}

Measured memory_bytes: 4848
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <cassert>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
using namespace std;
using i8t = std::int64_t;
using u8t = std::uint64_t;
using vi8t = std::vector<i8t>;
using vvi8t = std::vector<std::vector<i8t>>;
using vu8t = std::vector<u8t>;
#include <limits>
static const i8t i8t_max=numeric_limits<i8t>::max();
static const i8t i8t_min=numeric_limits<i8t>::min();
#include <unordered_map>
#include <unordered_set>
template<typename Key,typename Value> using map_t=std::unordered_map<Key, Value>;
template<typename Key> using set_t=std::unordered_set<Key>;
#define F3(i,i0,iN,step) for(i8t i=i0,i##_N=iN;i<i##_N;i+=step)
#define F2(i,i0,iN) F3(i,i0,iN,1)
#define F(i,N) F3(i,0,N,1)
#define FR(i,N) for(i8t i=N;i--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
template<typename T> T umax(T& ans,T const& value) {if(value>ans)ans=value;return ans;}
template<typename T> T umin(T& ans,T const& value) {if(value<ans)ans=value;return ans;}
template<typename T> struct identity { using type = T; };

void main1(){
  R(N)R(X)R(Y);
  i8t a=X-1;
  i8t b=N-Y;
  i8t l=N-a-b;
  F2(k,1,N){
    i8t count=0;
    auto _cntstr=[&](i8t len){count+=max<i8t>(0,len-k+1);};
    _cntstr(a+b+1);
    if(l>=2){
      _cntstr(min(a,k-1)+min(l/2,k));
      _cntstr(min(b,k-1)+min(l/2,k));
      i8t c=l/2-1;
      if(k>=2&&c>0){
        _cntstr(min(a,k-2)+1+min(c,k-1));
        _cntstr(min(b,k-2)+1+min(c,k-1));
      }
      if(l>=3){
        _cntstr(l-2);
        if(k<l+1-k)count+=max<i8t>(0,k-2);
      }
    }
    P(count);
  }
}

void main2(){
  R(N)R(X)R(Y);X--;Y--;
  if(X>Y)swap(X,Y);
  i8t r=Y-X+1;
  auto _dist=[r,X,Y](i8t x,i8t y){
    if(x<=X){
      if(y<=X){
        return y-x;
      }else if(y<=Y){
        return (X-x)+std::min(y-X,r-(y-X));
      }else{
        return (X-x)+1+(y-Y);
      }
    }else if(x<=Y){
      if(y<=Y){
        return std::min(y-x,r-(y-x));
      }else{
        return std::min(Y-x,r-(Y-x))+y-Y;
      }
    }else{
      return y-x;
    }
  };

  vi8t A(N,0);
  F(x,N)F2(y,x+1,N)A[_dist(x,y)]++;
  F2(k,1,N)P(A[k]);
}
int main() {
  main2();
  return 0;
}


Measured memory_bytes: 256
import sys


def main():
    n = int(sys.stdin.readline().strip())
    A = [int(s) for s in sys.stdin.readline().strip().split()]

    total = 0
    for i in range(n):
        if i % 2:
            total -= A[i]
        else:
            total += A[i]
    ans = [-1] * n
    ans[0] = total

    for i in range(1, n):
        ans[i] = -ans[i-1] + 2 * A[i-1]

    print(' '.join([str(num) for num in ans]))


if __name__ == '__main__':
    main()



Measured memory_bytes: 70936
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;

int main(void){
    vector<int> a(3);
    for(int i = 0; i < 3; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    cout << a.at(0) + a.at(1) + a.at(2) * 10 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
ll gcd(ll a, ll b, ll c)
{
    ll ans1;
    ans1 = __gcd(a, b);
    ans1 = __gcd(ans1, c);

    return ans1;

}
int main()
{
    ll ans = 0, i, j, k, n;
    cin>>n;
    for(i = 1; i<=n; i++)
    {
        for(j = 1; j<=n; j++)
        {
            for(k = 1; k<=n; k++)
            {
              ans+=gcd(i, j, k);
              //printf("%lld %lld %lld and gcd %lld", i, j, k, gcd(i, j, k));
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}


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

int main(){
lint N,s;
cin >>N; pair<lint,lint>d[N] ;
rep(i,N) {
    cin>>s;
   d[i]= make_pair(s,i+1);

}
sort(d,d+N);
rep(i,N){
    lint a,b;
    tie(a,b)=d[i];
    cout<<b<<" ";
}
   
 }



  


Measured memory_bytes: 2432