akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define fi first
#define se second
const int MAX = 200000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;

int32_t main()
{
	int n, k;
	cin >> n >> k;
	vector<int> arr(n);
	for(int &w : arr)
		cin >> w;
	sort(arr.begin(), arr.end());
	int ans = 0;
	for(int i = 0; i < k; i++)
		ans += arr[i];
	cout << ans << '\n';

	return 0;
}


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

int main(){ 
  
  ll N,M,V,P; cin >> N >> M >> V >> P;
  
  
  vector<ll> A(N);
  
  for(ll i = 0; i < N; i++){ cin >> A[i];}
  
  sort(A.rbegin(),A.rend());
  
  ll left = -1; ll right = N;
  
  while( right-left > 1 ){ 
    
    
    ll mid = (left+right)/2;
    
    if( mid < P ){ left = mid; continue;} 
    if( A[mid]+M < A[P-1] ){ right = mid; continue;}
    
    // 以下、それ以外の時
    
    ll posts = M*(P+(N-1-mid) );
    
    for(ll i = P-1; i < mid; i++){ 
      
      posts += max(0LL, A[mid]+M-A[i]);
      
    }
    
    if( posts < M*V){ right = mid;}
    else{ left = mid;}
    
  }
  
  // A[0],,,A[left]までが条件を満たす
  
  cout <<  left + 1 << endl;
  
  return 0;
} 
   

Measured memory_bytes: 1024
a, b, c, x, y = map(int, input().split())

ans = 5000*(10**5)*2
for i in range(max(x, y)+1):
    tmp_ans = i*2*c
    if x > i:
        tmp_ans += (x-i)*a
    if y > i:
        tmp_ans += (y-i)*b
    ans = min(ans, tmp_ans)

print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n;
  string t, h;
  int tc = 0, hc = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t >> h;
    if (t > h) {
      tc += 3;
    } else if (t < h) {
      hc += 3;
    } else {
      tc++;
      hc++;
    }
  }
  cout << tc << " " << hc << endl;
}


Measured memory_bytes: 3168
import collections

N = int(input())
A = list(map(int, input().split()))
ans = 0
p_list = []
m_list = []
for i in range(N):
    p_list.append(i + A[i])
    m_list.append(i - A[i])
p_c = collections.Counter(p_list)
m_c = collections.Counter(m_list)

for i in range(N):
    ans += p_c[i - A[i]]
    ans += m_c[i + A[i]]
print(ans//2)

Measured memory_bytes: 168384
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N = in;
    vector<int> D(N);
    rep( i, N ) D[i] = in;

    sort( all(D) );

    cout << (D[N/2] - D[N/2-1]) << "\n";
}


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

int main()
{
    int r[200000];
    int i,n;
    int minv,maxv=-2000000000;

    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>r[i];
    }
    minv=r[0];
    for(i=1;i<n;i++){
        maxv=max(maxv,r[i]-minv);
        minv=min(minv,r[i]);
    }
    cout<<maxv<<endl;
    return 0;
}

Measured memory_bytes: 3856
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
aa=sorted(a)
bb=sorted(b)
ans=aa[0]+bb[0]
for i in range(M):
  x,y,c=map(int,input().split())
  ans=min(ans,a[x-1]+b[y-1]-c)
print(ans)

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

int main() {
    string s, t;
    cin >> s >> t;
    vector<vector<int> > dp(s.size() + 1, vector<int>(t.size() + 1, 100000));
    dp[0][0] = 0;
    for (int i = 0; i <= s.size(); i++) dp[i][0] = i;
    for (int j = 0; j <= t.size(); j++) dp[0][j] = j;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < t.size(); j++) {
            int cnt = 1;
            if (s[i] == t[j]) cnt = 0;
            dp[i + 1][j + 1] =
                min({dp[i][j + 1] + 1, dp[i + 1][j] + 1, dp[i][j] + cnt});
        }
    }
    cout << dp[s.size()][t.size()] << endl;
}


Measured memory_bytes: 6836
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i, n, flag=0;
    scanf("%d",&n);
    //printf("%d",)
    for(i=1; i<=9; i++)
    {
        if(n%i == 0 && n/i <= 9)
        {
            flag=1;
            break;
        }
    }
    if(flag == 1) printf("Yes\n");

    else printf("No\n");
    return 0;
}

//UG02-49-18-012


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

using namespace std;

int main(){

	int n;
	long long int ans = 0;
	string s;
	vector<int> r, g, b;

	cin>> n;
	cin>> s;

	r.resize(n, 0);
	g.resize(n, 0);
	b.resize(n, 0);

	if (s[0] == 'R') r[0] = 1;
	if (s[0] == 'G') g[0] = 1;
	if (s[0] == 'B') b[0] = 1;

	for (int i = 1;i < n;i++) {
		if (s[i] == 'R') r[i] = r[i - 1] + 1;
		else r[i] = r[i - 1];
	}
	for (int i = 1;i < n;i++) {
		if (s[i] == 'G') g[i] = g[i - 1] + 1;
		else g[i] = g[i - 1];
	}
	for (int i = 1;i < n;i++) {
		if (s[i] == 'B') b[i] = b[i - 1] + 1;
		else b[i] = b[i - 1];
	}

	//cout << r[n - 1] << endl;
	//cout << g[n - 1] << endl;
	//cout << b[n - 1] << endl;
	for (int i = 0;i < n-2;i++) {
		for (int j = i + 1;j < n-1;j++) {
			if (s[i] == s[j]) continue;
			//cout << i << " " << j << endl;
			if (s[i] != 'R' && s[j] != 'R') {
				ans += r[n - 1] - r[j];
				if (j + j - i < n && s[2 * j - i] == 'R') ans--;
			}
			if (s[i] != 'G' && s[j] != 'G') {
				ans += g[n - 1] - g[j];
				if (j + j - i < n && s[2 * j - i] == 'G') ans--;
			}
			if (s[i] != 'B' && s[j] != 'B') {
				ans += b[n - 1] - b[j];
				if (j + j - i < n && s[2 * j - i] == 'B') ans--;
			}
			//cout << ans << endl;
		}
	}

	cout<< ans << endl;

	return 0;
}


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

using namespace std;

int main()
{
  int n;
  cin>>n;
  vector<int>a(n+1),b(n+1);
  map<int,int>m;
  for(int i=1;i<=n;i++){
     int x;
     cin>>x;
     a[i]=i+x,b[i]=i-x;
     ++m[b[i]];
  }
  long long cnt=0;
  for(int i=1;i<=n;i++){
    cnt+=m[a[i]];
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 21832
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

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

int main(){
	string hoshino = "Hoshino";
	string hoshina = "Hoshina";
	int tSup;
	cin >> tSup;
	cin.ignore();
	REP(t,tSup){
		string x;
		getline(cin,x);
		while(true){
			int i = x.find(hoshino,0);
			if(i==string::npos){break;}
			x.replace(i,hoshino.length(),hoshina);
		}
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
using namespace std;
typedef long long ll;
const int MAX_N = 10;
const int MAX_S = 1001;

ll dp[MAX_N][MAX_S];

void init(){
  for(int i = 0 ; i <= MAX_N*MAX_N ; i++){
     dp[1][i] = 1;
  }

  for(int i = 2; i < MAX_N ; i++){
    for(int j = 1 ; j < MAX_S ; j++){
      if(j >= i) dp[i][j] += dp[i][j-i];
      if(j >= (i-1)) dp[i][j] += dp[i-1][j-(i-1)];
      if(j >= 101) dp[i][j] -= dp[i-1][j-101];
    }
  }
}

int main(){
  int n,s;
  init();
  while(cin >> n >> s ,n + s){
    cout << dp[n][s] << endl;
  }

  return 0;
}

Measured memory_bytes: 1224
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    int[] as;

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

    void run() {
        FastReader sc = new FastReader();
        as = new int[3];
        for (int i = 0; i < 3; i++) {
            as[i] = sc.nextInt();
        }
        solve();
    }

    void solve() {
        Arrays.sort(as);
        if (as[0] + as[1] == as[2]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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


Measured memory_bytes: 21204
n = gets.to_i
p = gets.chomp
q = gets.chomp
#puts p
#puts q
a = 0
b = 0

#def fact(n)
#  1.upto(n).inject(1) {|sum, n| sum * n}
#end

#f = fact(n)


patterns = 1.upto(n).map {|v| v }.permutation(n).map {|v| v.join(' ') }
#p patterns
patterns.each_with_index do |v, i|
  #puts "v = #{v}, i = #{i}, p = #{p}, q = #{q}\n"
  if v == p
    a = i + 1
  end

  if v == q
    b = i + 1
  end
end

#puts "a = #{a}, b = #{b}\n"

print (a - b).abs


Measured memory_bytes: 11772
#include<iostream>
#include<vector>
#include<stack>

int main(){
	int k;
	std::cin>>k;
	while(k>0){
		std::vector<int>v(10,0);
		std::stack<int>s;
		std::stack<int>s2;
		int a;
		for(int i=0;i<10;i++){
			std::cin>>v[i];
		}
		s.push(v[0]);
		s2.push(0);
		for(int i=1;i<10;i++){
			int x=s.top(),y=s2.top();
			if(v[i]>x&&v[i]>y){
				if(x>=y)s.push(v[i]);
				else s2.push(v[i]);
			}else if(v[i]>x&&v[i]<=y)s.push(v[i]);
			else if(v[i]<=x&&v[i]>y)s2.push(v[i]);
			else{
				std::cout<<"NO"<<std::endl;
				break;
			}if(i==9)std::cout<<"YES"<<std::endl;
		}
		k--;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    string s; cin>>s;
    ll nin=1e10, nax=-1;
    rep(i,s.size()){
        if(s[i]=='A') chmin(nin, i);
        if(s[i]=='Z') chmax(nax, i);
    }
    cout<<nax-nin+1<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
	int a, b;

	while (cin >> a >> b) {
		int sum = a + b;
		int n;
#if 0
		for (n = 0; sum > 0; n++) {
			sum /= 10;
		}
		cout << n << endl;
#else
		if        (sum >= 10000000) {	n = 8;	 
		} else if (sum >= 1000000) {	n = 7;	
		} else if (sum >= 100000) {		n = 6;	
		} else if (sum >= 10000) {		n = 5;	
		} else if (sum >= 1000) {		n = 4;	
		} else if (sum >= 100) {		n = 3;	
		} else if (sum >= 10) {			n = 2;	
		} else if (sum >= 1) {			n = 1;	
		} else {						n = 0;
		}
		cout << n << endl;
	
#endif
	}
	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define OKawaiiKoto ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    //freopen("running_on_fumes_chapter_1_input.txt","r",stdin);
    //freopen("sol.txt","w",stdout);
    OKawaiiKoto
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    vector<string> ans;
    rep(i,n)
    {
        cin>>a[i];
        if(i>=k)
        {
            if(a[i]>a[i-k]) ans.pb("Yes");
            else ans.pb("No");
        }
    }
    rep(i,ans.size()) cout<<ans[i]<<"\n";
}


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

int main() {
	int a,b;
  	double x;
  	int y;
  
  	cin >> a >> b;
  
  	x = (a + b) / 2;
  	y = x;
  
  	if( (a+b) % 2 == 0) {
  		cout << y << endl;
    } else {
    	cout << y + 1 << endl;
    }
  
}


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

int main()
{
	string st;
	string an="No";
	bool f=0;
	cin>>st;
	for(register int i=0;i<st.size();i++)
	{
		if(st[i]=='C') f=1;
		if(f && st[i]=='F')
		{
			an="Yes";
			break;
		}
	}
	cout<<an<<endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int extgcd(int a, int b, int& x, int&y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}

int inv(int a) {
    int x, y;
    extgcd(a, MOD, x, y);
    return (x + MOD) % MOD;
}

ll wx[100], wy[100], r[100];

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, 3) {
        if(s[i] == t[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 764
import sys
import numpy as np
import heapq


def input():
    return sys.stdin.readline()[:-1]


def solve():
    a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K = int(input())
    print(a[K-1])


if __name__ == "__main__":
    solve()


Measured memory_bytes: 12504
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N, M = map(int, input().split())
if N>M:
    N, M = M, N

if N==1 and M==1:
    print(1)
elif N==1 and M!=1:
    print(M-2)
elif N==2:
    print(0)
else:
    v = N*M - 2*M - 2*(N-2)
    print(v)




Measured memory_bytes: 65516
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int n;
  cin >> n;
  vector<int> cnt(3, 0);
  rep(i, n) {
    int a;
    cin >> a;
    if (a%2 != 0) cnt[0]++;
    if (a%4 == 0) cnt[1]++;
    if (a%4 != 0 && a%2 == 0) cnt[2]++;
  }
  if (cnt[2] == 0) cnt[1]++;
  if (cnt[0] <= cnt[1]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;

class Program {
    static void Main (string[] args) {
        int x = int.Parse (Console.ReadLine ());
        if (x >= 30) {
            Console.WriteLine ("Yes");
        } else {
            Console.WriteLine ("No");
        }
    }

}

//dotnet run --project test

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

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

  vector<int> a(n), b(n);
  rep(i, n){
    cin >> a[i];
    b[i] = a[i];
  }

  sort(b.begin(), b.end());
  rep(i, n){
    if(a[i] == b[n-1]) cout << b[n-2] << endl;
    else cout << b[n-1] << endl;
  }

  return 0;

}


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

int main()
{
  int n, m;
  cin >> n >> m;
  int maxL = 0, minR = n;
  for(int i = 0; i < m; ++i)
  {
    int l, r;
    cin >> l >> r;
    if(maxL < l) maxL = l;
    if(minR > r) minR = r;
  }
  
  int ans = max(minR - maxL + 1, 0);
  cout << ans << endl;
}

Measured memory_bytes: 3632
unittest
{
	assert( [ "4 3" ].parse.expand.solve == "3333" );
	assert( [ "7 7" ].parse.expand.solve == "7777777" );
}



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 ) )
{
	auto ab = input.front.split.to!( long[] );
	return tuple( ab[ 0 ], ab[ 1 ] );
}

auto solve( long a, long b )
{
	return ( ( a < b ) ? a.to!( string ).repeat( b ) : b.to!( string ).repeat( a ) ).join;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
#define int long long
#define sc(x) scanf("%lld",&x);
int A[105];
const int mod = 1e9+7;

/*二進数でbitが立つ時にかけるmod*/
int qp(int n)
{
    int ans = 1;
    int x = 2;
    while(n){
        if(n&1)ans=(ans*x)%mod;
        x = (x*x)%mod;
        n>>=1;
    }
    return ans;
}
 
int mulit(int a,int b,int m){
    int ans=0;
    while(b){
        if(b&1) ans=(ans+a)%m;
        a=(a<<1)%m;
        b>>=1;
    }
    return ans;
}
int modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int quick_mod(int a,int b,int m){
    int ans=1;
    while(b){
        if(b&1){
            ans=mulit(ans,a,m);
        }
        a=mulit(a,a,m);
        b>>=1;
    }
    return ans;
}
 
int comp(int a,int b,int m){
    if(a<b) return 0;
    if(a==b) return 1;
    if(b>a-b) b=a-b;
    int ans=1,ca=1,cb=1;
    for(int i=0;i<b;i++){
        ca=ca*(a-i)%m;
        cb=cb*(b-i)%m;
    }
    /*modを一度でも使ってしまうと普通の割り算では結果が変わってしまう*/
    /*そのため, modの逆数を算出し, それをかける必要がある*/
    /*ans=ca*quick_mod(cb,m-2,m)%m;*/
    ans = ca * modpow(cb, m - 2, m)%m;
    return ans;
}
signed main()
{
    int ans,n,a,b;
    sc(n)sc(a)sc(b)
    ans = qp(n);
    ans = (ans-1+mod)%mod;
    int x = comp(n,a,mod);
    ans = (ans-x+mod)%mod;
    int y = comp(n,b,mod);
    ans =(ans-y+mod)%mod;
 
    cout<<ans<<'\n';
}

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

int main(){
int n;
int a[1000000];
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=n-1;i>=0;i--){
cout<<a[i];
if(i>0){
cout<<" ";
}
}
cout<<endl;
return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int dp[100005];

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int N, Q;
    string s;
    cin >> N >> Q >> s;
    dp[0] = 0;
    for (int i = 1; i < N; i++) {
        if (s[i-1] == 'A' && s[i] == 'C') dp[i] = dp[i-1] + 1;
        else                              dp[i] = dp[i-1];
    }
    rep(i, Q){
        int l, r;
        cin >> l >> r;
        cout << dp[r-1] - dp[l-1] << "\n";
    }
}


Measured memory_bytes: 1488
import sys
import math

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()

A, B = map(int, input().split())

i = 1
while True:
    if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B:
        print(i)
        exit(0)
    if math.floor(i * 0.1) > B:
        break
    i += 1

print(-1)


Measured memory_bytes: 38512
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> p;
 
#define MOD 1000000007
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int l, r, d;
    cin >> l >> r >> d;

    int ans = 0;

    for(int i = 1; i <= 100; i++) {
        if(l <= i && i <= r) {
            if(i % d == 0) ans++;
        }
    }

    cout << ans << endl;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    cout << abs(a[0] - a[a.size() - 1]) << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.math.BigInteger;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigInteger A = new BigInteger(sc.next()), B = new BigInteger(sc.next());
		sc.close();
		System.out.println(A.subtract(B));
	}
}


Measured memory_bytes: 75028
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int mod = 1000000007;

int main() {
  ll n, d, a;
  cin >> n >> d >> a;
  vector<P> p;
  rep(i, n) {
    ll x, h;
    cin >> x >> h;
    p.push_back(P(x, h));
  }
  sort(p.begin(), p.end());

  ll ans = 0;
  ll total = 0;
  queue<P> q;

  rep(i, n) {
    ll x = p[i].first;
    ll h = p[i].second;
    while (!q.empty() && q.front().first < x) {
      total -= q.front().second;
      q.pop();
    }
    h -= total;
    if (h > 0) {
      int num = (h + a - 1) / a;
      ans += num;
      ll limit = x + 2 * d;
      total += num * a;
      q.emplace(limit, num * a);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 6000
#include <iostream>

using namespace std;

long long N, M;

int main(){
	cin >> N >> M;
	
	long long	ans = 0;
	
	if(2 * N >= M){
		ans = M / 2;
		cout << ans << endl;
	}else{
		M -= 2 * N;
		ans += N;
		ans += M / 4;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) //[l, r)
#define rep(i,n) REP(i,0,n)           //[0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showslr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i];}cerr<<endl //[l, r))

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

void _DEBUG(){cerr<<endl;}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<",";_DEBUG(b...);}

template<typename T> inline void in(T &e){cin>>e;}
template<typename H,typename... T>void in(H &a, T&... b){in(a);in(b...);}
template<typename T> inline void out(T e){cout<<e<<endl;}
template<typename H,typename... T> void out(H a, T... b){out(a);out(b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n;
int ans=1;

signed main(){
    io();

    in(n);

    REP(i,1,sqrt(n)+1){
        REP(j,2,10){
            int res=pow(i,j);
            if(res>n) break;
            ans=max(ans,res);
        }
    }
    out(ans);

    return 0;
}


Measured memory_bytes: 384
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N,M = map(int, input().split())

e = 0
o = 0

if N>=2:
    e = comb(N,2)
if M>=2:
    o = comb(M,2)
print(e+o)

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i <= k; i++)
#define SZ 100010
#define PB push_back
#define MEM(n, val) memset((n), val, sizeof(n))
#define INF 1000000000
#define F first
#define S second
#define MP make_pair
#define LL long long

int a, b, q;
LL ara_a[SZ], ara_b[SZ];

int main()  {
//    freopen("in.txt", "r", stdin);
    cin >> a >> b >> q;
    FOR(i, 0, a - 1)   {
        cin >> ara_a[i];
    }
    FOR(i, 0, b - 1)   {
        cin >> ara_b[i];
    }
    FOR(i, 0, q - 1)   {
        LL val;cin >> val;
        int le_a = lower_bound(ara_a, ara_a + a, val) - ara_a;
        le_a--;
        int le_b = lower_bound(ara_b, ara_b + b, val) - ara_b;
        le_b--;

        int ri_a = lower_bound(ara_a, ara_a + a, val) - ara_a;
        int ri_b = lower_bound(ara_b, ara_b + b, val) - ara_b;

        LL ans = 100000000000000000LL;

        if(le_a >= 0 && le_b >= 0)    {
            ans = min(ans, val - min(ara_a[le_a], ara_b[le_b]));
//            cout << "hi1\n";
        }
        if(ri_a < a && ri_b < b)    {
            ans = min(ans, max(ara_a[ri_a], ara_b[ri_b]) - val);
//            cout << max(ara_a[le_a], ara_b[le_b]) - val << " " << "hi2\n";
        }
        if(le_a >= 0 && ri_b < b)    {
            ans = min(ans, ara_b[ri_b] - ara_a[le_a] + min(ara_b[ri_b] - val, val - ara_a[le_a]));
//            cout << ara_b[ri_b] - ara_a[le_a] + min(ara_b[ri_b], ara_a[le_a]) << " " << "hi3\n";
        }
        if(le_b >= 0 && ri_a < a)    {
            ans = min(ans, ara_a[ri_a] - ara_b[le_b] + min(ara_a[ri_a] - val, val - ara_b[le_b]));
//            cout << "hi4\n";
        }
        cout << ans << "\n";
    }
    return 0;
}
/**
*/


Measured memory_bytes: 2816
#include <iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int map[2][n];
	for(int j=0; j<2; j++){
		for(int i=0; i<n; i++){
			cin >> map[j][i];
		}
	}
	int ans = 0;
	for(int i=0; i<n; i++){
		int tmp = 0;		
		for(int j=0; j<i; j++){
			tmp += map[0][j];
		}
		tmp += map[0][i];
		for(int j=i; j<n; j++){
			tmp += map[1][j];
		}
		if(ans < tmp) ans = tmp;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
using namespace std;

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

  int cnt = 0;
  int maxi = 0;
  for (int i = 1; i < n; i++) {

    cnt = 0;
    for(int a = 'a'; a <= 'z'; a++) {
      bool l = false;
      bool r = false;

      for(int j = 0; j < i; j++) {
        if(s[j] == a) l = true;
      }

      for(int k = i; k < n; k++) {
        if(s[k] == a) r = true;
      }

      if(l && r) {
        cnt++;
      }
    }
    maxi = max(cnt, maxi);
  }

  cout << maxi << '\n';

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
char a[MAXN];
int main(){
	SF("%s",a);
	int len=strlen(a);
	if(len%2==0){
		int mid=len/2-1;
		int y=0;
		if(a[mid]==a[mid+1]){
			y=1;
			while(mid-y>=0&&a[mid-y]==a[mid]&&a[mid-y]==a[mid+1+y])
				y++;
		}
		y--;
		PF("%d",mid+y+2);
	}
	else{
		int mid=len/2;
		int y=1;
		while(mid-y>=0&&a[mid-y]==a[mid]&&a[mid+y]==a[mid])
			y++;
		y--;
		PF("%d",mid+y+1);
	}
} 

Measured memory_bytes: 384
# encoding: utf-8
N = int(input())
T = [int(input()) for i in range(N)]

T.sort()

def gcd(a, b):
    if a < b: return gcd(b, a)
    elif b == 0: return a
    else: return gcd(b, a % b)

a = T[0]
for Ti in T[1:]: a = a * Ti // gcd(Ti, a)

print(a)

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

bool solve(int x)   
{  
    if(x<0)  
    {  
        return false;  
    }  
      
    int temp = x, res = 0;  
    while(temp)  
    {  
        res = res * 10 + temp % 10;  
        temp = temp / 10;  
    }  
    return x == res;  
}  


int main()
{
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for(int i = a; i <= b; i++){
		if(solve(i)) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n,a,b = [int(x) for x in input().split()]

t = 1
while True:
    if t==1:#Alice
        if a+1==b:
            if a==1:
                print("Borys")
                break
            else:
                a -= 1
        else:
            a += 1
    else:
        if b-1==a:
            if b==n:
                print("Alice")
                break
            else:
                b += 1
        else:
            b -= 1
    t += 1
    t %= 2

Measured memory_bytes: 38256
import itertools
N=int(input())
XY=[]
for i in range(N):
  x,y=map(int,input().split())
  XY+=[[x,y]]
ALL=list(itertools.permutations(XY))
ans=10**9
d=0
for i in ALL:
  for k in range(N-1):
    d2=((i[k][0]-i[k+1][0])**2+(i[k][1]-i[k+1][1])**2)**(1/2)
    d+=d2
ans=d/len(ALL)
print(ans)  

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

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

using ll = long long;
using pll = pair<ll, ll>;

int main()
{
    ll D, T, S;
    cin >> D >> T >> S;

    const auto x = (D / S) + ((D % S) == 0 ? 0 : 1);
    cout << (x <= T ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
#include <map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>
#include <bitset>
#include <string>

int H, W;
std::string S[20];

std::vector<std::vector<int>> all_pairs(std::vector<int> org) {
    std::vector<std::vector<int>> ret;
    if (org.size() == 0) {
        return ret;
    }

    int is_even = org.size() % 2 == 0 ? 1 : 0;

    do {
        bool use = true;
        for (int i = 0; i < org.size() - 1; i += 2) {
            if (org[i] > org[i+1]) {
                use = false;
                break;
            }
        }
        if (use) {
            for (int i = 0; i < org.size() - 3; i += 2) {
                if (org[i] > org[i+2]) {
                    use = false;
                    break;
                }
            }
        }
        if (use) {
            ret.push_back(org);
        }
    } while (std::next_permutation(org.begin() + is_even, org.end()));

    return ret;
}

bool check(std::vector<int> pair) {
    bool used[20] = {};
    std::string T[20];

    for (int i = 0; i < H; i++) {
        T[i].resize(W);
        for (int j = 0; j < W/2; j++) {
            T[i][j] = S[i][pair[j*2]];
            T[i][W-1-j] = S[i][pair[j*2+1]];
        }
        if (W % 2 == 1) {
            T[i][W/2] = S[i][pair.back()];
        }
    }

    bool center_used = false;
    for (int i = 0; i < H; i++) {
        if (!used[i]) {
            std::string tmp = T[i];
            std::reverse(tmp.begin(), tmp.end());
            bool found = false;
            for (int j = i + 1; j < H; j++) {
                if (tmp == T[j]) {
                    found = true;
                    used[j] = true;
                    break;
                }
            }
            if (!found && H % 2 == 1 && !center_used && tmp == T[i]) {
                found = true;
                center_used = true;
            }
            if (!found) {
                return false;
            }
        }
    }

    return true;
}

int main(int argc, char **argv) {
    std::cin >> H >> W;

    for (int i = 0; i < H; i++) {
        std::cin >> S[i];
    }

    std::vector<int> org;
    for (int i = 0; i < W; i++) {
        org.push_back(i);
    }
    std::vector<std::vector<int>> pairs = all_pairs(org);
    //std::cout << "check:" << pairs.size() << std::endl;

    for (auto p : pairs) {
        //for (int i : p) {
        //    std::cout << i << " ";
        //}
        //std::cout << std::endl;
        if (check(p)) {
            std::cout << "YES" << std::endl;
            return 0;
        }
    }

    std::cout << "NO" << std::endl;
    return 0;

}

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

int N, M, P;

struct edge {int s; int t; int d;};
vector <edge> edges;

long long dist[2505];
const long long inf = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> N >> M >> P;
    for(int i = 0; i < M; i++) {
        int u, v, c;
        cin >> u >> v >> c;
        edges.push_back({u, v, -(c - P)});
    }

    dist[1] = 0;
    for(int i = 2; i <= N; i++)
        dist[i] = inf;

    for(int i = 1; i < N; i++) {
        for(auto edge: edges) {
            if(dist[edge.s] != inf)
                dist[edge.t] = min(dist[edge.t], dist[edge.s] + edge.d);
        }
    }
    for(int i = 1; i < N; i++) {
        for(auto edge: edges) {
            if(dist[edge.s] != inf && dist[edge.t] > dist[edge.s] + edge.d) {
                dist[edge.t] = -inf;
            }
        }
    }
    if(dist[N] == -inf) cout << -1 << endl;
    else cout << max(0LL, -dist[N]) << endl;
}

Measured memory_bytes: 384
char s[102];
A(){
	char a[101],b[101],t,t2;
	return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);
}
B(){
	short*q=s;
	char*p,l=0;
	if(*q=='^>'){
		for(;*++q=='=Q';)l++;
		if(l&&*q++=='~~'&&*(p=q)==0)
			return 1;
	}
	return 0;
}
main(){
	scanf("%*d\n");
	for(;~scanf("%[^\n]\n",s);){
		if(A())
			puts("A");
		else if(B())
			puts("B");
		else
			puts("NA");
	}
}

Measured memory_bytes: 0
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        long[] nx = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var n = nx[0];
        var x = nx[1];
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

        long[] tmp = new long[n];
        Array.Copy(a, tmp, a.Length);

        long ans = 0;
        for (int i = 0; i < n - 1; i++)
        {
            if (tmp[i] + tmp[i + 1] > x)
            {

                tmp[i + 1] = Math.Max(0, tmp[i + 1] - (tmp[i] + tmp[i + 1] - x));
                ans += a[i + 1] - tmp[i + 1];
                if (tmp[i] + tmp[i + 1] > x)
                {
                    tmp[i] = Math.Max(0, tmp[i] - (tmp[i] + tmp[i + 1] - x));
                    ans += a[i] - tmp[i];
                }
            }
        }

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 32092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int x,y,ans=0;
inline int abs(int x){return x<0?-x:x;}
int main(){
//	freopen("a.in","r",stdin);
	x=read();y=read();
	if(x==-y) ans=1;
	else if(abs(x)<abs(y)) ans=abs(y)-abs(x)+(x<0)+(y<0);
	else ans=abs(x)-abs(y)+(x>0)+(y>0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
    int N;
    cin>>N;
    vector<string>A(N);
    bool a=false;
    rep(i,N){
        cin>>A[i];
        if(A[i]=="Y"){
            a=true;
        }
    }
    if(a==true){
        cout<<"Four"<<endl;
    }
    else{
        cout<<"Three"<<endl;
    }
}

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


ll num[sz];


int main()
{

  ll n,i,j,c,a,b,p,d;

  cin>>n;

  for(i=1;i<=n;i++)
  {
      cin>>num[i];
  }

  ll mx=0;


  for(i=1;i<n;i++)
  {
      c=0;
      //cout<<i<<" "<<c<<endl;
      while(num[i]>=num[i+1])
      {

          c++;
          i++;
          if(i>=n)break;
      }
     /// cout<<i<<endl;
      mx=max(mx,c);
      //cout<<mx<<endl;


  }

  cout<<mx<<endl;


  return 0;
}



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

int main(){
  int in[1000000],n;
  bool tf=false;
  int cou=0;
  cin >> n;
  for(int i=0;i<n;i++)cin >> in[i];

  for(int i=0;i<n;i++){
    if(in[i] == 1)continue;
    for(int j=2;j<=sqrt((double)in[i]);j++)
      {
	if(in[i]%j == 0)tf=true;
      }
    if(tf)
      {
	tf=false;
      }
    else cou++;
  }
  cout << cou << endl;

  return 0;
}

Measured memory_bytes: 872
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,A,B;
  cin>>N>>A>>B;
  if(A+B>0){
    cout<<(N/(A+B))*A+min(A,N%(A+B))<<endl;
  }
  else{
    cout<<0<<endl;
  }
}

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

using namespace std;

int main(){
  int T1, T2;
  short int R1, R2;

  cin>>T1>>T2>>R1>>R2;

  if(R1 == -1 || R2 == -1){
    if(T1 > T2)
      cout<<"Bob"<<endl;
    else if(T1 < T2)
      cout<<"Alice"<<endl;
    else
      cout<<"Draw"<<endl;
  }
  else{
    if(R1 > R2)
      cout<<"Alice"<<endl;
    else if(R1 < R2)
      cout<<"Bob"<<endl;
    else
      cout<<"Draw"<<endl;
  }

  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
//#define sort(x) sort(x.begin(), x.end())
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,v,p,i,ans=0,sum=0,x,c = 0;
    cin>>n>>m>>v>>p;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    reverse(a,a+n);
    v = max(0ll,v-p);
    ans = p-1;
    i = p-1;
    while(i<n and a[i] == a[p-1])
    {
        ans++;
        sum += a[i];
        i++;
        c++;
    }
    for(;i<n and a[i] >= a[p-1]-m;i++)
    {
        //cout<<sum<<" ";
        x = max(0ll,v-(n-i-1));
        if(c*(a[i]+m) - sum >= x*m)
        {
            ans++;
            sum += a[i];
            c++;
        }
        else
            break;
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 1024
from collections import deque
H, W = map(int, input().split())
area = [['#']*(W+2)]
space = 0
for i in range(H):
    temp = ['#']+list(input())+['#']
    for t in temp:
        if t=='.': space+=1 
    area.append(temp)
area.append(['#']*(W+2))
move = ((1, 0), (-1, 0), (0, 1), (0, -1))

dq = deque([(1,1)])
dist = [[-1]*(W+2) for _ in range(H+2)]
dist[1][1] = 1

while dq:
    nowx, nowy = dq.popleft()
    # if (nowx, nowy) == (W, H): break
    for dx, dy in move:
        nxtx, nxty = nowx+dx, nowy+dy
        if not 0<=nxtx<W+2 and 0<=nxty<H+2: continue
        if dist[nxty][nxtx]>=0 or area[nxty][nxtx]=='#': continue
        dist[nxty][nxtx] = dist[nowy][nowx]+1
        dq.append((nxtx, nxty))
if dist[H][W]==-1: print(-1)
else: print(space-dist[H][W])

Measured memory_bytes: 3316
N,M = map(int,input().split())
K = [0 for m in range(M)]
count = 0

for m in range(M):
  K[m] = list(map(int,input().split()))
P = list(map(int,input().split()))

for i in range(2**N):
  op = [0]*N
  for j in range(N):
    if ((i>>j) & 1):
      op[N-1-j] = 1
      
  flag = True
  
  for k in range(M):
    S = 0
    for l in range(K[k][0]):
      S += op[K[k][l+1]-1]
    if S % 2 != P[k]:
      flag = False
  if flag:
    count += 1
    
print(count)

Measured memory_bytes: 9232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    string S; cin >> S;
    REP(i,S.length())
    {
        if(S[i] == 'A') cout << "T";

        if(S[i] == 'C') cout << "G";

        if(S[i] == 'G') cout << "C";

        if(S[i] == 'T') cout << "A";
    }
    cout << endl;


}


Measured memory_bytes: 256
#include <iostream>
int main() {
	int H[100], W[100];
	int i= 0, j, k, l;
	
	while (1) {
		std::cin >> H[i] >> W[i];
		if (H[i] == 0 && W[i] == 0) break;
		i++;
	}

	for (l = 0; l < i; l++) {
		for (k = 0; k < H[l]; k++) {
			for (j = 0; j < W[l]; j++) {
				if (k % 2 == 0) {
					if (j % 2 == 0) std::cout << "#";
					else std::cout << ".";
				}
				else if (k % 2 == 1) {
					if (j % 2 == 0) std::cout << ".";
					else std::cout << "#";
				}
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3088
import math
import numpy as np
N = int(input())
tb = [[0]*10]*10
tb = np.array(tb)
for i in range(1,N+1):
    s = str(i)
    tb[int(s[0])][int(s[-1])] =tb[int(s[0])][int(s[-1])] +1
 
point =0
 
for i in range(0,10):
    for j in range(0,10):
        point += tb[i][j] * tb[j][i]
 
print(point)

Measured memory_bytes: 14440
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), F(N);
    ll max_A = 0;
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        max_A = max(max_A, A[i]);
    }
    for (ll i = 0; i < N; i++) {
        cin >> F[i];
    }

    sort(F.begin(), F.end(), greater<>());

    multiset<ll> st_A_origin;
    for (ll i = 0; i < N; i++) {
        st_A_origin.insert(A[i]);
    }

    ll ok = max_A * F.front(), ng = -1;
    while (ok - ng != 1) {
        ll mid = (ok + ng) / 2;

        multiset<ll> st_A = st_A_origin;

        //すべてmid以下にできるか
        ll cost = 0;
        for (ll i = 0; i < N; i++) {
            auto itr = st_A.upper_bound(mid / F[i]);
            if (itr == st_A.begin()) {
                cost += *st_A.begin() - mid / F[i];
                st_A.erase(st_A.begin());
            } else {
                st_A.erase(--itr);
            }
        }
        (cost <= K ? ok = mid : ng = mid);
    }

    cout << ok << endl;
}

Measured memory_bytes: 24192
package main

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

func getNextWord(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextWord(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	ww := make([]int, n+1)
	for i := 1; i <= n; i++ {
		ww[i] = ww[i-1] + getNextInt(scanner)
	}
	min := ww[n]
	for i := 1; i < n; i++ {
		min = minint(absint(ww[n]-ww[i]*2), min)
	}

	fmt.Fprintln(writer, min)

	writer.Flush()
}
func absint(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func minint(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

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

using namespace std;
using p=pair<int,int>;
typedef long long ll;

int main() {
  ll k,n;
  cin >> k >> n;
  vector<ll>a(n);
  rep(i,n){
    cin >> a[i];
  }
  ll m=0;
  rep(i,n-1){
    m=max(m,a[i+1]-a[i]);
  }
  m=max(m,k-a[n-1]+a[0]);
  cout << k-m << endl;
  return 0;

}


Measured memory_bytes: 4836
INF = float('inf')
d, g = map(int, input().split())
data = []
calced = set()
for i in range(d):
  p, c = map(int, input().split())
  data.append([p, c, (i + 1) * 100, (i + 1) * 100 * p + c])
def f(data, total, targets):
  if total <= 0:
    return 0
  result = INF
  for i in range(len(targets)):
    p, c, score, subtotal = data[targets[i]]
    t = (total + score - 1) // score
    if t < p and t < result:
      result = t
    nt = tuple(targets[0:i] + targets[i + 1:])
    if nt not in calced:
      calced.add(nt)
      t = p + f(data, total - subtotal, nt)
      if t < result:
        result = t
  calced.add(targets)
  return result
print(f(data, g, tuple(range(len(data)))))


Measured memory_bytes: 3064
n, a = map(int, input().split())
x = [int(i)-a for i in input().split()]

dp = {0: 1}

for i in x:
    tmp = list(dp.items())
    for key, value in tmp:
        dp[key+i] = dp.get(key+i, 0) + value
print(dp[0] - 1)




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

using namespace std;

using ll = long long;

ll solve(vector<ll>& x, int n, ll L) {
    vector<ll> sumx(x);
    for (int i = 1; i < n; i++) {
        sumx[i] += sumx[i - 1];
    }

    ll res = 0;
    for (int i = 0; i < n; i++) {
        int hoge = i + (n - i) / 2;
        if ((n - i) % 2 == 0) {
            ll val = 2 * (sumx[hoge] - sumx[i] - x[hoge] + x[i]) - x[hoge] - 2 * (sumx[n - 1] - sumx[hoge]) + (n - 1 - i) * L;
            res = max(res, val);
        } else {
            ll val = 2 * (sumx[hoge] - sumx[i] - x[hoge] + x[i]) + x[hoge] - 2 * (sumx[n - 1] - sumx[hoge]) + (n - 1 - i) * L;
            res = max(res, val);
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll L;
    int n;
    cin >> L >> n;
    vector<ll> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];

    ll ans = solve(x, n, L);
    
    reverse(x.begin(), x.end());
    for (int i = 0; i < n; i++) {
        x[i] = L - x[i];
    }

    ans = max(ans, solve(x, n, L));
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3428
#include<bits/stdc++.h>
// iteration and input/output stream
#define rep(i,a,b) for(int i = int(a);i<=int(b);i++)
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()-1) cout<<x[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
 
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)
 
#define endl "\n"
#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair
 
// Error detection
#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
 
using namespace std;
 
typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
 
inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
 
#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
    #endif
    SYNC
    string s,t;
    cin>>s>>t;
    int n = s.size();
    int cnt =0 ;
    for (int i = 0; i < n; i++)
    {
        if(s[i]!=t[i])
        {
            cnt++;
        }
    }
    cout<<cnt<<"\n";
    return 0;
}

Measured memory_bytes: 3724