akhauriyash/Code-Regression huggingface dataset:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  l1=[]
  l2=[]

  f=True
  for x in l:
    if f:
      f=False
      l1.append(x)
    else:
      f=True
      l2.append(x)

  l1.sort()
  l2.sort()

  l3=[]
  l4=[]

  a=l1[0]
  c=1
  for x in l1[1:]:
    if a==x:
      c+=1
    else:
      l3.append([a,c])
      a=x
      c=1
  l3.append([a,c])

  a=l2[0]
  c=1
  for x in l2[1:]:
    if a==x:
      c+=1
    else:
      l4.append([a,c])
      a=x
      c=1
  l4.append([a,c])

  l3=sorted(l3,key=lambda x:x[1],reverse=True)
  l4=sorted(l4,key=lambda x:x[1],reverse=True)

  if l3[0][0]==l4[0][0]:
    if len(l3)==1 and len(l4)==1:
      return n//2
    elif len(l3)==1:
      return n-l3[0][1]-l4[1][1]
    elif len(l4)==1:
      return n-l3[1][1]-l4[0][1]
    else:
      return min(n-l3[0][1]-l4[1][1],n-l3[1][1]-l4[0][1])
  else:
    return n-l3[0][1]-l4[0][1]

print(main())


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

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

  int ans = 0;
  int pos = s.find("ABC");
  while ( pos != string::npos ) {
    ans++;
    pos = s.find("ABC", pos+1);
  }

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


Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    ArrayList<Integer> d = new ArrayList<>();

    Scanner sc = new Scanner(System.in);
    int size = sc.nextInt();
    for (int i = 0; i < size; i++) {
      d.add(sc.nextInt());
    }

    d.sort(Integer::compareTo);

    int half = d.size()/2;
    int count = d.get(half)-d.get(half-1);
    System.out.println(count);

  }
}


Measured memory_bytes: 60424
#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<cmath>
#include<limits>

using namespace std;

bool check(const vector<int>& v, int K,int Max) {
    int cnt = 1;
    int temp = 0;
    for (int i = 0; i < v.size(); i++) {
        if (v[i] > K) return false;

        if (temp + v[i] > K) {
            cnt++;
            temp = v[i];
        }
        else {
            temp += v[i];
        }

    }

    return cnt <= Max;
}
int main() {
    int N, K; cin >> N >> K;
    vector<int> w(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i];
    }

    int high = 1e9 + 1;
    int low = 0;

    while (high - low > 1) {
        int mid = (high + low) / 2;

        if (check(w, mid,K)) {
            high = mid;
        }
        else {
            low = mid;
        }
    }

    int ans = high;
    cout << ans << endl;
}


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

int main(int, char**) {
        int64_t N;
        std::cin >> N;
        int64_t sum = 0;
        for (int i=1; i<N+1; i++) {
                if ( i%3!=0 && i%5!=0) {
                        sum += i;
                }
        }
        std::cout << sum << std::endl;
        return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MX 1000000000000
void fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}
int main() {
	fastio();
	ll n,k,mn=MX;
	cin>>n>>k;
	ll ar[n],dp[n];
	for(int i=1;i<=n;i++)
	cin>>ar[i];
	dp[1]=0;
	dp[2]=abs(ar[1]-ar[2]);
	for(int i=3;i<=n;i++)
	{
	     for(int j=i-1;j>=(i-k);j--)
	     {
	     	if(j<1)
	     	break;
	     	mn=min(mn,abs(ar[i]-ar[j])+dp[j]);
	     }
	     dp[i]=mn;
	     mn=MX;
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)

int N;
int V[21],C[21];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>V[i];
	}
	REP(i,N){
		cin>>C[i];
	}
	int ans=0;
	REP(Bit,1<<N){
		int sum=0,sum2=0;
		REP(i,N){
			if(Bit&(1<<i)){
				sum+=V[i];
				sum2+=C[i];
			}
		}
		ans=max(ans,sum-sum2);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#define ll long long
using namespace std;

int main(void){
    string s;
    cin >> s;
    bool ans = true;
    ll count = (s.length()-1)/2-1;
    for(ll i = 0; i < (s.length()-1)/2; i++){
        if(s[i]!=s[count])
            ans = false;
        //cout << i << " " << count << endl;
        count--;
    }
    count = s.length()-1;
    for(ll i = (s.length()+3)/2-1; i < s.length(); i++){
        if(s[i]!=s[count])
            ans = false;
        //cout << i << " " << count << endl;
        count--;
    }
    count = s.length()-1;
    for(ll i = 0; i < s.length(); i++){
        if(s[i]!=s[count])
            ans = false;
        count--;
    }

    if(ans==true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

int main() {
  int N, a, b;
  cin >> N >> a >> b;
  int diff = b - a;
  if(diff == 1){
    cout << "Borys" << endl;
  }else if(diff % 2 == 0){
    cout << "Alice" << endl;
  }else if(diff % 2 == 1){
    cout << "Borys" << endl;
  }else{
    cout << "Draw" << endl;
  }
}


Measured memory_bytes: 3628
#include <stdio.h>

int main( )
{
  int n,m;

  while(1)
    {
      scanf("%d%d",&n,&m);
      if(n == 0 && m == 0)break;
      else if(n < m)printf("%d %d\n",n,m);
      else if(m < n)printf("%d %d\n",m,n);
      else printf("%d %d\n",n,m);
    }

  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
int main(){
	double a,b;
	cin>>a>>b;
	if(a>=13) cout<<b<<'\n';
	else if(a<=5) cout<<0<<'\n';
	else cout<<b/2<<'\n';
}

Measured memory_bytes: 764
let n, m = Scanf.scanf "%d %d\n" (fun n m -> n, m) in
let rec f i s =
  if i = m then s
  else
    let a = Scanf.scanf " %d" (fun a -> a) in
    f (i + 1) (s + a) in
let ans = max (n - f 0 0) ~-1 in
Printf.printf "%d\n" ans


Measured memory_bytes: 5844
k, n = gets.split(" ").map(&:to_i)
houses = gets.split(" ").map(&:to_i)
period = []
for i in 0..houses.length-2
  period << (houses[i] - houses[i+1]).abs
end
period << (houses[0] - houses[-1] + k)
new_presiod = period.sort
new_presiod.delete_at(-1)
p new_presiod.inject(:+)

Measured memory_bytes: 20096
import itertools

n, m = map(int, input().split())
lst = []
for _ in range(m):
    item = list(map(int, input().split()))
    item = item[1:]
    lst.append(item)
p = list(map(int, input().split()))

ans = 0
for it in itertools.product([0,1], repeat = n):
    for i, item in enumerate(lst):
        count = 0
        for switch in item:
            if it[switch - 1] == 1:
                count += 1
        if count % 2 != p[i]:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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






int main() {
    ll n, m;
    cin >> n >> m;
    queue<pair<ll, ll>> que;
    ll mn;
    REP(i, m){
        ll t;
        cin >> t;
        que.push({t, 0});
        if(i == 0) mn = t;
    }
    vector<bool> used(n + 1);
    vector<ll> res(n + 1, n);
    ll cnt = 0, len = 1;
    while(!que.empty()){
        auto tmp = que.front(); que.pop();
        ll x = tmp.first, loop = tmp.second;
        if(loop >= len){
            res[len] = n - cnt;
            len++;
        }
        if(x > n || used[x]) continue;
        used[x] = true;
        cnt++;
        que.push({x + 1, loop + 1});
    }
    ll mn2 = n;
    for(ll i = 1; i <= n; i++){
        mn2 = min(mn2, res[i]);
        res[i] = mn2;
    }
    ll q;
    cin >> q;
    REP(i, q){
        ll l;
        cin >> l;
        if(l < mn - 1){
            cout << -1 << endl;
            continue;
        }
        ll ng = 0, ok = n;
        while(ok - ng > 1){
            ll m = (ok + ng) / 2;
            if(res[m] <= l){
                ok = m;
            }
            else{
                ng = m;
            }
        }
        cout << ok << endl;
    }
}



Measured memory_bytes: 5232
from itertools import product
N, M = map(int, input().split())
Cakes = [list(map(int, input().split())) for i in range(N)]

ans = 0
for a, b, c in product([1, -1], repeat=3):
    tmp = []
    for x, y, z in Cakes:
        tmp.append(x * a + y * b + z * c)
    tmp.sort(reverse=True)
    ans = max(ans, sum(tmp[:M]))

print(ans)


Measured memory_bytes: 3384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod; return *this;}
  mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod; return *this;}
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int s;
  cin >> s;
  int n = s/3;

  vector<mint> dp(s+1);
  dp[0] = 1;
  rep(i,s){
    vector<mint> ndp = dp;
    rep(j,s+1){
      if(j-i<3) continue;
      ndp[j] += dp[i];
    }
    swap(dp,ndp);
  }
  cout << dp[s] << endl;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code
int main(int argc, char const* argv[])
{
	LL n,W;
	cin >> n >> W;
	VL w(n), v(n);
	VVL ww(4), wr(4,VL(1,0));
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
		ww[w[i] - w[0]].push_back(v[i]);
	}
	for (int i = 0; i < 4; i++) {
		sort(RALL(ww[i]));
	}

	// 累積和
	for (int i = 0; i < 4; i++) {
		for (int j = 1; j <= ww[i].size(); j++) {
			wr[i].push_back(wr[i][j-1] + ww[i][j-1]);
		}
	}

	LL ans = 0;
	for (int i = 0; i <= ww[0].size(); i++) {
		for (int j = 0; j <= ww[1].size(); j++) {
			for (int k = 0; k <= ww[2].size(); k++) {
				for (int l = 0; l <= ww[3].size(); l++) {
					LL sum_w = w[0] * i + (w[0] + 1) * j + (w[0] + 2) * k + (w[0] + 3) * l;
					LL sum_v = wr[0][i] + wr[1][j] + wr[2][k] + wr[3][l];
					if (sum_w <= W) {
						ans = max(ans, sum_v);
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;

}



Measured memory_bytes: 256
import java.util.Scanner;

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

        while((N = scan.nextInt()) != 0){
            int count = 0;
            int sum = 0;
            for(int i=1; i*2<N; i++){
                for(int j=i; sum<N; j++){
                    sum += j;

                    if(sum == N){
                        count++;
                    }
                }
                sum = 0;
            }

            System.out.println(count);
        }
    }
}

Measured memory_bytes: 19804
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>x(n);
    rep(i,n-1){
        int a; cin>>a;
        x[a-1]++;
    }
    rep(i,n){
        cout<<x[i]<<endl;
    }
}

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

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

   if(k<=a)cout<<k<<endl;
   else if((a+b)>=k)cout<<a<<endl;
   else cout<<a-(k-a-b)<<endl;
}


Measured memory_bytes: 3632
url = "https://atcoder.jp//contests/abc111/tasks/abc111_b"

def main():
    s = input()
    for n in range(int(s), 1000):
        str_n = str(n)
        if len(str_n) == str_n.count(str_n[0]):
            print(n)
            exit()



if __name__ == '__main__':
    main()


Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
long long n;
int main() {
    cin >> n;
    long long limit = sqrt(n) + 1;
    long long x, y;
    for(int i = limit; i >= 1; --i) {
        if(n % i == 0) {
            x = i;
            y = n/i;
            break;
        }
    }

    cout << (x-1) + (y-1) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if(a.equals(b)){
			System.out.print("H");
		}else{
			System.out.print("D");
		}
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MAXN=15;
const int MAXP=(1<<MAXN);
int N,M;
int edge[MAXN][MAXN];
int cscore[MAXP];
int dp[MAXN][MAXP];
int main(){
    ios_base::sync_with_stdio(0);
    cin>>N>>M;
    for (int i=0;i<M;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        edge[a][b]=edge[b][a]=c;
    }
    for (int i=0;i<(1<<N);i++){
        cscore[i]=0;
        for (int j=0;j<N;j++){
            for (int k=j+1;k<N;k++){
                if (i&(1<<j) && i & (1<<k))
                    cscore[i]+=edge[j][k];
            }
        }
    }
    for (int i=0;i<MAXN;i++)
        for (int j=0;j<MAXP;j++)
            dp[i][j]=-1e9;
    for (int i=1;i<(1<<N);i+=2)
        dp[0][i]=cscore[i];
    for (int i=0;i<(1<<N);i++){
        for (int j=0;j<N;j++){
            if (dp[j][i]<0) continue;
            int mask=(1<<N)-1-i;
            for (int sub=mask;sub>0;sub=(sub-1)&mask){
                for (int k=0;k<N;k++){
                    if (edge[j][k] && (sub&(1<<k)))
                        dp[k][i+sub]=max(dp[k][i+sub],dp[j][i]+cscore[sub]+edge[j][k]);
                }
            }
        }
    }
    ll ctot=0;
    for (int i=0;i<N;i++)
        for (int j=i+1;j<N;j++)
            ctot+=edge[i][j];
    cout<<ctot-dp[N-1][(1<<N)-1]<<"\n";
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	
	vector <int> ar(n);
	for(int &x: ar) cin >> x;
	int ctr = 0;
	for(int i=0; i<n; i++){
		if(ar[i] != i+1) ctr++;
	}

	cout << (ctr == 0 or ctr == 2 ? "YES" : "NO");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;

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

  int N; cin >> N;
  ll K; cin >> K;
  vector<int> A(N), F(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> F[i];
  sort(A.begin(), A.end());
  sort(F.begin(), F.end(), greater<int>());

  ll l = -1, r = 1e12;
  while(l + 1 < r) {
    ll c = (l+r)/2;

    ll needk = 0;
    rep(i, N) {
      needk += max(0ll, A[i] - (c/F[i]));
    }

    if(needk <= K) {
      r = c;
    } else {
      l = c;
    }
  }

  cout << r << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = 1;
        while (n-- > 0) {
            int x = sc.nextInt();
            System.out.println("Case " + c++ + ":");
            for (int i = 0; i < 10; i++) {
                x = x * x / 100 % 10000;
                System.out.println(x);
            }
        }
    }
}


Measured memory_bytes: 25956
#include<stdio.h>
int main(void)
{
	int n,m,a[1000],b,box,sum,i,j;
	sum=0;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d %d",&a[i],&b);
	}
	for(i=0;i<m-1;i++){
		for(j=i+1;j<m;j++){
			if(a[i]<a[j]){
				box=a[i];
				a[i]=a[j];
				a[j]=box;
			}
		}
	}
	for(i=0;i<m-1;i++){
		if(a[i]<n){
			sum=sum+(n-a[i]);
		}
	}
	printf("%d\n",sum);
	return 0;
}


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

int main() {
  int n,t;
  cin >> n >> t;
  vector<int>a(n);
  rep(i,0,n) cin >> a[i];
  int cnt = 1,sa = 0,m = a[0];
  rep(i,1,n){
    if(a[i] < m) m = a[i];
    if(a[i]-m > sa){
      sa = a[i]-m;
      cnt = 1;
    }
    else if(a[i]-m == sa) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3796
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
#define ll long long
#define _cle(m, a) memset(m, a, sizeof(m))
#define repu(i, a, b) for(int i = a; i < b; i++)
#define repd(i, a, b) for(int i = b; i >= a; i--)
#define sfi(n) scanf("%d", &n)
#define pfi(n) printf("%d\n", n)
#define eps 1e-12
const int N = 100005;
struct P
{
    double vw, pf, vf, th;
} p[N];
int n;
double pw;
double get(double w)
{
    double mon = 0.0;
    repu(i, 0, n)
    {
        double t = p[i].th - w * p[i].vw;
        if(t >= eps)
            mon += t * p[i].pf / p[i].vf;
    }
    return mon + w * pw;
}

double Three_search(double left, double right)
{
    double mid, midmid;
    double mid_value, midmid_value;
    while(left + eps < right)
    {
        mid = (left + right) / 2.0;
        mid_value = get(mid);
        midmid = (mid + right) / 2.0;
        midmid_value = get(midmid);
        if(mid_value >= midmid_value)
            left = mid;
        else
            right = midmid;
    }
    double ans = get((left + right) / 2.0 );
    return ans;
}

int main()
{
    while(~sfi(n) && n)
    {
        scanf("%lf", &pw);
        double w = 0.0;
        repu(i, 0, n)
        {
            scanf("%lf", &p[i].vw);
            scanf("%lf", &p[i].pf);
            scanf("%lf", &p[i].vf);
            scanf("%lf", &p[i].th);
            w = max((p[i].th / fabs(p[i].vw)), w);
        }
        printf("%.10f\n", Three_search(0.0, 200.0));
    }
    return 0;
}

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

#define ll long long int
#define ff(i,a,b) for(ll i = a; i < b; i++)
#define bf(i,b,a) for(ll i = b-1; i >= a; i--)
#define itf(i,a) for(auto i = a.begin(); i != a.end(); i++)
#define itfr(i,a) for(auto i = a.rbegin(); i != a.rend(); i++)
#define MII map<ll,ll> 
#define MCI map<char,ll>
#define MSI map<string,ll>
#define VI vector<ll> 
#define VC vector<char> 
#define VS vector<string> 
#define MP make_pair
#define tc ll t; cin>>t; while(t--)
#define DISPV(v) itf(i,v) cout << *i << ' ';
#define DISPM(m) itf(i,m) cout << i->first << ' ' << i->second << endl;

const int MOD = int(1e9) + 7;

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll n;
    cin >> n;
    MII m;
    ll totalsum = 0;
    ff(i,0,n){
        ll a;
        cin >> a;
        m[a]++;
        totalsum += a;
    }
    ll q;
    cin >> q;
    while(q--){
        ll a,b;
        cin >> a >> b;
        ll x = m[a];
        totalsum = totalsum - (x*a) + (x*b);
        m[a] = 0;
        m[b] += x;
        cout << totalsum << '\n';
    }
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    string s;
    cin >> s;
    ll n = s.size();
    ll ans = 0;
    for(i = 0;i < n;++i){
        if(s.at(i) != s.at(n-1-i)) ++ans;
    }
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 256
# かつっぱさん見て
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
babies=[(q,i) for i,q in enumerate(a)]
babies.sort(reverse=True)

dp=defaultdict(int)
ans=0
for l in range(n):
  for r in range(n):
    if l+r==n:
      ans=max(ans,dp[(l,r)])
      break
    act,ind=babies[l+r]
    dp[(l+1,r)]=max(dp[(l+1,r)],dp[(l,r)]+act*abs(ind-l))
    dp[(l,r+1)]=max(dp[(l,r+1)],dp[(l,r)]+act*abs(ind-(n-1-r)))

print(ans)
                   

Measured memory_bytes: 335380
#include <stdio.h>
#include <algorithm>

int sx, sy, tx, ty;

int main(void)
{
	scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
	
	// １回目
	for (int i = 0; i < abs(sy - ty); ++i)
	{
		printf("U");
	}
	for (int j = 0; j < abs(sx - tx); ++j)
	{
		printf("R");
	}
	for (int i = 0; i < abs(sy - ty); ++i)
	{
		printf("D");
	}
	for (int j = 0; j < abs(sx - tx); ++j)
	{
		printf("L");
	}

	// ２回目
	printf("L");
	for (int i = 0; i < abs(sy - ty)+1; ++i)
	{
		printf("U");
	}
	for (int j = 0; j < abs(sx - tx)+1; ++j)
	{
		printf("R");
	}
	printf("D");
	printf("R");
	for (int i = 0; i < abs(sy - ty)+1; ++i)
	{
		printf("D");
	}
	for (int j = 0; j < abs(sx - tx)+1; ++j)
	{
		printf("L");
	}
	printf("U");
	return 0;
}

Measured memory_bytes: 128
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort()
f.reverse()

l,r=-1,10**12
while r-l!=1:
  t=(l+r)//2
  c=0
  for i in range(n):
    c+=max(a[i]-t//f[i],0)
  if c<=k:
    r=t
  else:
    l=t
print(r)

Measured memory_bytes: 113564
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

int main(){

  long long int H, A;
  scanf("%lld%lld", &H, &A);

  std::cerr << "Answer: " << std::endl;
  if(H%A == 0){
    std::cout << H/A << std::endl;
  }
  else{
    std::cout << (H/A)+1 << std::endl;
  }

  return 0;
  
}


Measured memory_bytes: 256
#include<iostream>

namespace Ri_ma {
	void output(int a, int b) {  //暇
		std::cout << 2 * b - a << std::endl;
	}
}

int main() {
	int r, g;
	
	std::cin >> r >> g;
	Ri_ma::output(r, g);

	return 0;
}

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

using namespace std;

class Team{
public:
	int tid,correct,penalty;
	int wrong[11];
	bool operator< (const Team &opp) const{
		if(correct!=opp.correct) return correct>opp.correct;
		if(penalty!=opp.penalty) return penalty<opp.penalty;
		return tid<opp.tid;
	}
	Team();
	Team(int id);
};

Team::Team(){
	correct=0;penalty=0;
}
Team::Team(int id){
	tid=id;correct=0;penalty=0;
	for(int i=1;i<=10;i++)wrong[i]=0;
}

Team T[50];

int main(){
	int i,t,p,r;
	while(cin>>t>>p>>r, t){
		int tid, pid, time;
		string mes;
		for(i=1;i<=t;i++) T[i]=Team(i);
		while(r--){
			cin>>tid>>pid>>time>>mes;
			if(mes=="CORRECT"){
				T[tid].correct ++;
				T[tid].penalty += T[tid].wrong[pid]*1200+time;
			}else{
				T[tid].wrong[pid] ++;
			}
		}
		sort(T+1, T+1+t);
		for(i=1;i<=t;i++) cout<<T[i].tid<<" "<<T[i].correct<<" "<<T[i].penalty<<endl;
	}
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int H,W;
  cin >> H >> W;
  int N;
  cin >> N;
  vector<int> v(N);
  queue<int> q;
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    for(int j = 0; j < tmp; j++){
      q.push(i);
    }
  }



  int color[H][W];

  for(int i = 0; i < H; i++){
    if(i%2 == 0){
      for(int j = 0; j < W; j++){
        int col = q.front();
        q.pop();
        color[i][j] = col;
      }
    } else { 
      for(int j = W-1; j >= 0; j--){
        int col = q.front();
        q.pop();
        color[i][j] = col;
      }
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(j == W-1){
        cout << color[i][j]+1 << endl;
      } else { 
        cout << color[i][j]+1 << " ";
      }
    }
  }

}



Measured memory_bytes: 384
X,K,D = map(int,input().split( ))
 
X = abs(X)
 
q, mod = divmod(X, D)

if q >= K:
  print(X-D*K)

else:
  cnt = K-q
  if cnt%2 == 0:
    print(mod)
  if cnt%2 == 1:
    print(D-mod)

Measured memory_bytes: 9100
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int n;
    for (int i=1; ; ++i) {
        cin >> n;
        if (n == 0) {
            break;
        }
        cout << "Case " << i << ": " << n << "\n";
    }
 
    return 0;
}

Measured memory_bytes: 3124
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define PI			2*acos(0.0)
int main()
{
    int n;
    cin >>n;
    int a[n],i,even=0,odd=0;
    for(i=0;i<n;i++)
    {
        cin >>a[i];
        if(a[i]%2)
            odd++;
        else
            even++;
    }
    if(odd%2)
        cout <<"NO";
    else
        cout <<"YES";
    return 0;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define SZ(a) ((int)(a.size()))

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

typedef complex<double> P;
typedef pair<P, double> C;
typedef vector<P> poly;
const double EPS = 1e-9;

#define EQ(a, b) (abs((a)-(b)) < EPS)

double dot(P a, P b){
  return real(conj(a) * b);
};

double cross(P a, P b){
  return imag(conj(a) * b);
};


vector<double> roots(double a, double b, double c){
  double scale = abs(a) + abs(b) + abs(c);
  auto D = b * b - 4 * a *c;
  vector<double> x;
  if(D < -EPS*scale) return x;
  if(D<EPS*scale) return vector<double>(1,-b/2/a);
  if(b<0){
    x.pb((-b+sqrt(D))/2/a);
  }else{
    x.pb((-b-sqrt(D))/2/a);
  }
  
  x.pb(c/a/x.front());
  return x;
}



double area_of_intersection(const C c , const poly v){
  double r = c.second;
  P z = c.first;
  double res = 0;
  rep(i, SZ(v)){
    P p = v[i] - z, q = v[(i +1)%SZ(v)] - z;
    P v = q - p;
    auto t = roots(norm(v), 2*dot(p, v), norm(p)-r*r);
    sort(ALL(t));
    if(!t.empty() && (t.back()<0||t.front()>1)) t.clear();
    t.insert(t.begin(),0);
    t.pb(1);
    rep(i,SZ(t)-1){
      P a = p + t[i] * v, b = p + t[i+1]*v;
      if(EQ(a, 0.) || EQ(b, 0.)) continue;
      P m = (a + b) * .5;
      res += abs(m) <= r + EPS ? cross(a, b) : r * r * arg(b/ a);
    }
  }
  return abs(res) * .5;
}

int n, r;
double x[100], y[100];

void solve(){
  rep(i, n) cin >> x[i] >> y[i];

  poly po;
  rep(i, n) po.pb(P(x[i], y[i]));
  double ans = 0;
  for(int i = 0; i < r; ++i){
    double small = area_of_intersection(C(P(0, 0), i), po);
    double big = area_of_intersection(C(P(0, 0), (i + 1)), po);
    if(i & 1){
      const double pi = acos(-1);
      ans += pi * (2 * i + 1);
      ans -= big - small;
    }else{
      ans += big - small;
    }
  }

  printf("%.18f\n", ans);
}

int main(int argc, char *argv[])
{
  while(cin >> n >> r && n) solve();
  return 0;
}

Measured memory_bytes: 1364
import math
n,d=map(int,input().split())
l=[]
x=0
count=0
for i in range(n):
  l.append(list(map(int,input().split())))
for i in range(n):
  for j in range(n):
    if i!=j:
      x=0
      for k in range(d):
        x+=abs(l[i][k]-l[j][k])**2
      if math.sqrt(x) == int(math.sqrt(x)):
        count+=1
print(int(count/2))

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def dijkstra(s,n,cost,l):
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        for i in range(n):
            if (not used[i]) and (v == -1):
                v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
            break
        used[v] = True
        dist_v = d[v]
        for j,weight in enumerate(cost[v]):
            alt = dist_v + weight
            r = (dist_v - 1) // l
            if (r != (alt - 1) // l) and dist_v != 0:
                alt = (r + 1) * l + weight         
            d[j] = min(d[j],alt)
    return d
 
n,m,l = map(int, input().split())
abc = [list(map(int, input().split())) for i in range(m)]
q = int(input())
st = [list(map(int, input().split())) for i in range(q)]
path = [[float("inf") for i in range(n)] for i in range(n)]
ans_list = []
for i in abc:
  a,b,cost = i[0]-1, i[1]-1, i[2]
  if cost <= l:
    path[a][b] = cost
    path[b][a] = cost
for s in range(n):
  ans_list.append(dijkstra(s,n,path,l))
for i in st:
  s, t = i[0] - 1, i[1] - 1
  ans = ans_list[s][t]
  if ans == float("inf"):
    ans = -1
  else:
    ans = (ans - 1) // l
  print(ans)


Measured memory_bytes: 88284
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> vec(m+1);
  rep(i, n){
    int a, b;
    cin >> a >> b;
    if(a > m) continue;
    vec[m-a].push_back(b);
  }
  priority_queue<int> pq;
  int ans = 0;
  for(int i = m-1; i >= 0; i--){
    for(int b : vec[i]){
      pq.push(b);
    }
    if(!pq.empty()){
      ans += pq.top();
      pq.pop();
    }
  }
  cout << ans << endl;

}



Measured memory_bytes: 5504
/* ITP1_9_A */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String w = br.readLine();
      String t;
      int count = 0;

      while((t = br.readLine()).equals("END_OF_TEXT") == false){

        String[] word = t.split(" ");
        for(String str : word){
          if(str.equalsIgnoreCase(w)) count++;
        }
      }
      System.out.println(count);

    }catch(Exception e){
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 24300
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var max = Math.Sqrt(n);
            var resultDic = new Dictionary<int, int>();

            for (var i = 1; i <= max; i++)
            {
                for (var j = 1; j <= max; j++)
                {
                    for (var k = 1; k <= max; k++)
                    {
                        var num = i * i + j * j + k * k + i * j + i * k + j * k;
                        if (resultDic.TryGetValue(num, out _))
                        {
                            resultDic[num]++;
                        }
                        else
                        {
                            resultDic[num] = 1;
                        }
                    }
                }
            }

            for (var i = 1; i <= n; i++)
            {
                Console.WriteLine(resultDic.TryGetValue(i, out var val) ? val : 0);
            }
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = min({
      abs(a - b) + abs(b - c),
      abs(a - c) + abs(c - b),
      abs(b - a) + abs(a - c),
      abs(b - c) + abs(c - a),
      abs(c - a) + abs(a - b),
      abs(c - b) + abs(b - a),
  });

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[105],ans=0;
int main()
{
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		cin>>a[i];
	}
	ans+=a[0];
	for(int i=0;i<n-2;i++)
	{
		if(a[i]<a[i+1])
			ans+=a[i];
		else
			ans+=a[i+1];
	}
	ans+=a[n-2];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

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

	vi A(N+2);
	vi dist(N+2);
	int all_dist = 0;
	rp(i,1,N+1){
		cin>>A[i];
		dist[i] = abs(A[i-1]-A[i]);
		all_dist += abs(A[i-1]-A[i]);
	}
	dist[N+1] = abs(A[N]-A[0]);
	all_dist += abs(A[N]-A[0]);

	// for(auto a:A) cout<<a<<" ";puts("\n---");///
	// for(auto a:dist) cout<<a<<" ";puts("\n---");///
	// ote(all_dist);//

	vi ans(N+2);
	rp(i,1,N+1){
		// printf("%d %d\n",  (dist[i]+dist[i+1]) , abs(A[i+1]-A[i-1]));//
		ans[i] = all_dist - (dist[i]+dist[i+1]) + abs(A[i+1]-A[i-1]);
	}

	rp(i,1,N+1){
		cout<< ans[i] <<endl;
	}
}


Measured memory_bytes: 2432
#include<stdio.h>
int main()
{
	int n,m,i,j;
	char a[100],c[100][100];
	while(~scanf("%d%d",&n,&m))
	{
		for (i=0;i<n;i++)
		{
			scanf("%s",&a);
			for (j=0;j<m;j++)
			{
				c[i][j]=a[j];
			}
		}
		for (i=0;i<m+2;i++)
		{printf("#");}
		printf("\n");
		for (i=0;i<n;i++)
		{
			printf("#");
			for (j=0;j<m;j++)
			{
				printf("%c",c[i][j]);
			}
			printf("#\n");
		}
		for (i=0;i<m+2;i++)
		{printf("#");}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const ll MOD = 1e9 + 7;

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int N, X;
  while (cin >> N >> X) {
    vector<int> S(N);
    for (int i = 0; i < N; i++) cin >> S[i];
    sort(S.begin(), S.end());
    vector<ll> dp(X + 1, 0);
    for (ll x = 0; x <= X; x++) dp[x] = x;
    for (int i = 0; i < N; i++) {
      int m = S[i];
      vector<ll> ndp(X + 1, 0);
      for (ll x = 0; x <= X; x++) {
        ndp[x] = (dp[x] * i % MOD + dp[x % m]) % MOD;
      }
      dp.swap(ndp);
    }
    cout << dp[X] << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll max3(ll a,ll b,ll c){ return max( max(a,b),c ); }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n,w; cin>>n>>w;
	ll a[n+1],b[n+1];
	forn1(i,n) cin>>a[i]>>b[i];
	ll dp[n+1][w+1];
	forn(i,w+1) dp[0][i] = 0;
	forn(i,n+1) dp[i][0] = 0;
	forn1(i,w)
	{
	    forn1(j,n)
	    {
	        dp[j][i] = dp[j-1][i];
	        if(a[j]<=i) dp[j][i] = max( dp[j][i] , dp[j-1][i-a[j]] + b[j] );
	    }
	}
	ll ans = -1e18;
	forn1(i,n) ans = max(ans,dp[i][w]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 79232
unittest
{
	assert( [ "4", "RRBR" ].parse.expand.solve == "Yes" );
	assert( [ "4", "BRBR" ].parse.expand.solve == "No" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	auto r = s.count( 'R' );
	auto b = s.length.signed - r;
	return ( b < r ) ? "Yes" : "No";
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int A,B,K,i,j=0,a,b[100];	
	cin>>A>>B>>K;
	if(A>B) {
		a=A;
		A=B;
		B=a;
	}
	for(i=1;i<=A;i++) {
		if(A%i==0&&B%i==0) {
			b[j]=i;
			j++;
		}
	}
	cout<<b[j-K];
	
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <functional>
#define rep(i, a, b) for(int i=a;i<b;++i)
#define MOD 1000000007
#define RAND 1000
using namespace std;

int main(void)
{
	int T, N, t[200000], i;
	long long int Tsum = 0;
	cin >> N >> T;
	cin >> t[0];
	if (N == 1) {
		cout << T << endl;
		system("pause");
		return 0;
	}
	rep(i, 1, N) {
		cin >> t[i];
		if (t[i] - t[i - 1] > T)
			Tsum += T;
		else
			Tsum += t[i] - t[i - 1];
		if (i == N - 1) Tsum += T;
	}

	cout << Tsum << endl;

	return 0;
}


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

int main(){
//srandom((unsigned long)time(NULL));

long long N,T;
cin>>N>>T;
vector<long long> t;
long long sum;
for(long long i=0;i<N;i++){
    long long x;
    cin>>x;
    t.emplace_back(x);
}
//t1 t2  (t2-t1)+T
//t1 t2 t3  (t2-t1)+(t3-t2)+T

for(long long i=0;i<N-1;i++){
    if(t[i+1]-t[i]>=T){
        sum+=T;
    }else{
        sum+=t[i+1]-t[i];
    }

}
cout<<sum+T<<endl;


return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define sqr(x) (x)*(x)
typedef long long ll;

int main() {
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RInt;
            var a = IO.RSInt;
            WriteLine(a.Sum() - n);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String T = sc.next();
		sc.close();
		// D および PD
		// DD と PD 重み一緒
		System.out.println(T.replace("?", "D"));
	}
}

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

ll n, k;
ll w[102], v[102];
ll dp[101][100010];
bool vis[101][100010];

ll func( int pos, int weightLeft ) {
  if (weightLeft == 0) return 0;
  if (pos > n) return 0;
  if (vis[pos][weightLeft]) return dp[pos][weightLeft];
  vis[pos][weightLeft] = 1;

  ll x = 0, y = 0;
  if ( weightLeft - w[pos] >= 0 )
    x = func( pos + 1, weightLeft - w[pos] ) + v[pos];
  y = func( pos + 1, weightLeft );

  return dp[pos][weightLeft] = max(x, y);
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> w[i] >> v[i];
  cout << func(1, k) << endl;
  return 0;
}


Measured memory_bytes: 88448
def 解():
    iH,iW = [int(_) for _ in input().split()]

    if iH % 3 == 0 or iW % 3 == 0:
        print(0)
    else:
        w3 = iW // 3
        w2 = iW // 2
        h3 = iH // 3
        h2 = iH // 2
        aY1 = [iH*w3,(iH-h2)*(iW-w3),h2*(iW-w3)]
        aY2 = [iH*(w3+1),(iH-h2)*(iW-w3-1),h2*(iW-w3-1)]
        aT1 = [iW*h3,(iW-w2)*(iH-h3),w2*(iH-h3)]
        aT2 = [iW*(h3+1),(iW-w2)*(iH-h3-1),w2*(iH-h3-1)]
        aH31 = [iW*h3,iW*(iH-2*h3)]
        aH32 = [iW*(h3+1),iW*(iH-2*(h3+1))]
        aW31 = [iH*w3,iH*(iW-2*w3)]
        aW32 = [iH*(w3+1),iH*(iW-2*(w3+1))]

        iMin = iH*iW
        for ea in [aY1,aY2,aT1,aT2,aH31,aH32,aW31,aW32]:
            iMin = min(iMin, max(ea) - min(ea))
        print(iMin)
解()


Measured memory_bytes: 3064
// Problem : C - Ubiquity
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int n;
	cin >> n;

	if(n <= 1)
	{
		cout << 0;
		return;
	}
	int tot=1,et=1;
	int pow[n+1]={0};
	pow[0]=1;
	for(int i=1;i<=n;i++)
	{
		tot*=10;
		et*=8;
		tot%=mod;
		et%=mod;
		pow[i]=et;
	}
	int cnt=0,num=1,den=1,pre=1;
	for(int i=0;i<=n;i++)
	{
		if(i >= 1){
			int tmp = pre*(n-i+1);
			tmp %=mod;
			int den = inv(i,mod);
			tmp *= den;
			tmp %=mod;
			pre = tmp;
			tmp *= pow[n-i];
			tmp %= mod;
			tmp*=2;
			tmp%=mod;
			cnt += tmp;
		}
		else {
			cnt = pow[n];
		}
		cnt %=mod;
	}
	int ans = (tot+mod-cnt)%mod;
	cout << ans;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


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

using ll=long long;
#define int ll

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	// your code goes here
	int A=read(),B=read(),C=read();
	
	FOR(i,0,100000000){
		if(A*i%B==C){
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
using namespace std;
int main(){
	int buf[3];
	for (int &a : buf)cin >> a;
	sort(buf, buf + 3);
	cout << buf[0] << " " << buf[1] << " " << buf[2]<<endl;
	return 0;
}

Measured memory_bytes: 3132