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

int main()
{
	int64_t n, x;

	while (cin >> n >> x && (n || x))
	{
		int64_t ans = 0;

		for (int64_t i = 1; i <= n; i++)
		{
			for (int64_t j = i + 1; j <= n; j++)
			{
				for (int64_t k = j + 1; k <= n; k++)
				{
					if (i + j + k == x)
					{
						ans++;
					}
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3068
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());
        int int3 = Integer.parseInt(scan.next());
        int int4 = Integer.parseInt(scan.next());
//        String temp_str1 = "";
//        String temp_str2 = "";
        int temp_int1 = 0;
//        String str1 = scan.next();
//        String str2 = scan.next();
//        String str3 = scan.next();
        int ans_int = 0;
        String ans = "";
//        double ans_dob = 0;
        if(int2>=int1){
            ans_int = int1*int3;
        }else{
            ans_int = int2*int3 + (int1-int2)*int4;
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(ans_int);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(all(v));
  double ans = v[0];
  for (int i = 1; i < n; i++) {
    ans = (ans + v[i]) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll x, ll y)
{
  return y ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y)
{
  return x * y / gcd(x, y);
}
bool is_prime(int x)
{
  for (int i = 2; i * i <= x; i++)
  {
    if (x % i == 0)
      return 0;
  }
  return true;
}
vector<bool> prime_table(int n)
{
  vector<bool> prime(n + 1, 1);
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 2; i * i <= n; i++)
  {
    if (!prime[i])
      continue;
    for (int j = i * i; j <= n; j++)
      prime[j] = 0;
  }
  return prime;
}
map<int, int> prime_factor(int n)
{
  map<int, int> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1)
    res[n]++;
  return res;
}
ll modpow(ll a, ll n, ll mod)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
ll modinv(ll a, ll mod)
{
  return modpow(a, mod - 2, mod);
}

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

  int l=s.size();
  ll ans=0;
  for(int bit=0;bit<(1<<l-1);bit++){
    ll temp=int(s[0]-'0');
    for(int i=0;i<l-1;i++){
      if(bit&(1<<i)){
        ans+=temp;
        temp=int(s[i+1]-'0');
      }else{
        temp=temp*10+int(s[i+1]-'0');
      }
      // cout<<ans<<endl;
    }
    ans+=temp;
    // cout<<ans<<endl;
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  int a,b,c;
  cin >> a;
  cin >> b;
  cin >> c;
  
  int a01 = abs(a-b);
  int a02 = abs(a-c);
  int a12 = abs(b-c);

  int ans;

  ans = a01 +a12;
  
  if((a02+ a12)<ans){
    ans = a02+ a12;
  }
  else if((a01 + a02)<ans){
    ans =a01 + a02;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
const int N = 1e6;
using namespace std;
int n,d,sr[N + 5],sw[N + 5],ans;
char ch[N + 5];
int main()
{
    scanf("%d",&n);
    scanf("%s",ch + 1);
    for (int i = 1;i <= n;i++)
    {
        sr[i] = sr[i - 1];
        sw[i] = sw[i - 1];
        if (ch[i] == 'R')
            sr[i]++;
        else
            sw[i]++;
    }
    ans = N + 5;
    for (int i = 0;i <= n;i++)
        ans = min(ans,max(sw[i],sr[n] - sr[i]));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5528
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0), PHIDIV = 1 / ((1 + sqrt(5)) / 2);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int N, A, B;
vec< int > h;
bool isOK(int mid) {
  int tmpans = 0;
  REP(i, N) {
    if (h[i] > mid * B) {
      tmpans += (int)ceil(1.0 * (h[i] - mid * B) / A);
    }
  }
  return tmpans <= mid;
}
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin >> N >> A >> B;
  A -= B;
  h.resize(N);
  REP(i, N) { cin >> h[i]; }
  sort(ALL(h));
  int l = 0, r = h[N - 1];
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (isOK(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  print(r);
  // DEBUG(calc())0  print(min({calc(l), calc(r), calc(l + 1)}));
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int a,b;
    cin>>a>>b;
    cout<<a+b/2;
    return 0;
}


Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int n;
		scanf("%d",&n);
		vector<int> a(n);
		for (int i=0 ;  i<n ; i++)
		scanf("%d",&a[i]);
		int ans = INF;
		for (int i=0 ; i<101 ; i++)
		{
			int cost = 0;
			for (int j=0 ; j<n ; j++)
			{
				cost+=(a[j]-i)*(a[j]-i);
			}
			ans = min(ans,cost);
		}
		printf("%d",ans);
		return 0;
}  


Measured memory_bytes: 3744
// C - Welcome to AtCoder
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int ac_exist[100000];//[p-1]: init false
int wa_count[100000];//[p-1]: init 0

int main(){
	int n,m,p,ac=0,wa=0;
	string s;
	cin>>n>>m;
	rp(i, 0, m){
		cin>>p>>s; --p;
		if(ac_exist[p]){// ac
			continue;
		}
		else{//not ac
			if(s[0]=='A'){
				ac_exist[p] = true;
				wa += wa_count[p];
				ac++;
			}
			else{
				wa_count[p]++;
			}
		}
	}

	cout<< ac <<" "<< wa <<endl;
}

Measured memory_bytes: 1024
def main():
    """
    2 <= K < N <= 10^5
    1 <= hi <= 10^9
    """
    N, K = map(int, input().split())
    h = [int(input()) for _ in range(N)]

    ans = f(N, K, h)
    print(ans)


def f(N, K, h):
    h = sorted(h, reverse=True)

    ans = float("inf")
    for i in range(N - K + 1):
        tmp = h[i] - h[i+K-1]
        ans = min(ans, tmp)

    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 8280
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef string str;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef pair<int, int> pii;
typedef vector<pii> vpii ;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  cin >> n ;
  vll num(n) ;
  REP(i,n){
    cin >> num[i] ;
  }
  vll left(n) ;
  left[0] = num[0] ;
  REP(i,n-1){
    left[i+1] = num[i+1] + left[i] ;
  }
  vll right(n) ;
  right[n-1] = num[n-1] ;
  for(int i=n-2;i>=0;i--){
    right[i] = right[i+1] + num[i] ;
  }
  /*
  REP(i,n){
    cout << left[i] <<"::"<<right[i] <<endl ;
  }
  */
  vll ans(n-1) ;
  REP(i,n-1){
    ans[i] = abs(left[i]-right[i+1]) ;
    //cout << ans[i] <<endl ;
  }
  sort(ALL(ans)) ;
  
  cout << ans[0] <<endl ;
  
  
  
  
  return 0 ;
}




Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100],b[100],ra[100];
int kt(int a[],int n){
	int ret=0;
	for(int i=1;i<=n;i++){
		int cnt=0;
		for(int j=i+1;j<=n;j++){
			if(a[j]<a[i]) cnt++;
		}
		ret+=cnt*ra[n-i];
	}
	return ret;
} 
void init(int n){
	ra[0]=1;
	for(int i=1;i<=n;i++) ra[i]=i*ra[i-1];
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	init(30);
	int num1=kt(a,n);
	int num2=kt(b,n);
	cout<<abs(num1-num2)<<'\n';
	return 0;
 } 

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(x) cout<<x<<endl
#define Gput(a,b) G[a].push_back(b)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll fact(ll x){
  ll y=1;
  for(ll i=1;i<=x;i++){
   y*=i;
   y%=1000000007;
  }
  return y;
}
int main() {
  ll n;
  cin>>n;
  vec d(n);
  loop(i,n){
  cin>>d[i];
  }
  bool check=true;
  ll ans=1ll;
  if(d[0]!=0){
    check=false;
  }
  sort(all(d));
  
  if(d[0]!=0||d[1]!=1){
    check=false;
  }
  loop(i,n-1){
    if(d[i+1]>d[i]+1){
      check=false;
    }
  }
  map<ll,ll> s;
  loop(i,n){
    s[d[i]]++;
  }
  Loop(i,1,d[n-1]+1){
    ll t=s[i];
    loop(c,t){
      ans*=(s[i-1]%998244353);
      ans=ans%998244353;
    }
    ans=ans%998244353;
  }
  if(check){
      putout(ans%998244353);
  }
  else putout(0);
    
    
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    int n,t,a;
    double ans = 1e9;
    cin>>n>>t>>a;
        
    int h[n+5];
 
    for(int i=0;i<n;++i){
        
        cin>>h[i];
        
        ans =  min(ans,abs(a-(t-h[i]*0.006)));
    }  
    
    for(int i=0;i<n;i++){
        if(ans ==  abs(a-(t-h[i]*0.006)))
        {    cout<<i+1;
             break; 
        }
    }
    
    
 
 
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(x==0&&y==0) break;
			
			if(x>y){
				System.out.println(y+" "+x);
			} else{
				System.out.println(x+" "+y);
			}
				
		}
	}
}

Measured memory_bytes: 27208
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#include <random>
#include <map>
#include <math.h>
#pragma warning(disable : 4996)

#define MAX_N 1000
#define MAX_PF 32


int PFC[MAX_N+1];

void countPrimeFactor(int n) {
	for (int i = 2; i <= MAX_PF; ++i) {
		while(n%i == 0) {
			PFC[i]++;
			n /= i;
		}
		if (n == 1) break;
	}
	if (n != 1) PFC[n]++;
}

int main(void) {
	int n;
	scanf("%d", &n);
	for (int i = 2; i <= n; ++i) {
		countPrimeFactor(i);
	}
	long long d = 1;
	for (int i = 2; i <= n; ++i) {
		if (PFC[i] == 0) continue;
		d = (d*(PFC[i] + 1)) % 1000000007;
	}
	printf("%lld", d);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b,c,d;
    while(~scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d))
    {
        int t=b-a;
        bool flag=false;
        for(int i=0;i<n;i++)
        if(t>=i*c-(n-1-i)*d&&t<=i*d-(n-1-i)*c) {flag=true; break;}
        if(flag) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
def readinput():
    a,b,c,d=map(int,input().split())
    return a,b,c,d

def main(a,b,c,d):
    xy1=a*c
    xy2=a*d
    xy3=b*c
    xy4=b*d
    return max(xy1,xy2,xy3,xy4)

if __name__=='__main__':
    a,b,c,d=readinput()
    ans=main(a,b,c,d)
    print(ans)


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

#define int            long long int
#define float          long double
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define inf            1e18
#define set_pre(x,y)   fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)

using namespace std;
int dfs(vector<bool>&visited,vector<int>&dp,int i,list<int>*Graph)
{
    if(visited[i])
        return dp[i];
    dp[i]=0;
    visited[i]=true;
    for(auto c:Graph[i])
    {
        dp[i]=max(dp[i],dfs(visited,dp,c,Graph)+1);

    }
    return dp[i];
}
int32_t main()
{
    int n,m;
    cin>>n>>m;
    list<int>Graph[n];
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        Graph[x-1].push_back(y-1);
    }
    vector<bool>visited(n,false);
    vector<int>dp(n,0);
    for(int i=0;i<n;i++)
    {
        if(!visited[i])
        {
            dfs(visited,dp,i,Graph);
        }
    }

    cout<<*max_element(dp.begin(),dp.end())<<endl;
}

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

typedef long long ll;

const int N = 2500;
ll arr[N + 5];
ll sq[N + 5];

ll tipe[3];

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin>>n;
	for(int i = 0;i < n;i++) cin>>arr[i];
	sort(arr, arr + n);
	for(int i = 0;i < n;i++) sq[i] = arr[i] * arr[i];
	for(int i = 0;i < n;i++) {
		for(int j = i + 1;j < n;j++) {
			int lo = j + 1;
			int hi = n - 1;
			int ub = -1;
			while(lo <= hi) {
				int mid = (lo + hi) / 2;
				if(arr[i] + arr[j] > arr[mid]) {
					ub = mid;
					lo = mid + 1;
				} else hi = mid - 1;
			}
			
			if(ub != -1) {
				int lo = j + 1;
				int hi = ub;
				int resL = j;
				while(lo <= hi) {
					int mid = (lo + hi) / 2;
					if(sq[i] + sq[j] > sq[mid]) {
						resL = mid;
						lo = mid + 1;
					} else hi = mid - 1;
				}
				
				lo = j + 1;
				hi = ub;
				int resH = ub + 1;
				while(lo <= hi) {
					int mid = (lo + hi) / 2;
					if(sq[i] + sq[j] < sq[mid]) {
						resH = mid;
						hi = mid - 1;
					} else lo = mid + 1;
				}
				int total = ub - j;
				int t1 = resL - j;
				int t3 = ub + 1 - resH;
				int t2 = total - t1 - t3;
//				cout<<"RESL "<<resL<<" "<<resH<<endl;
//				cout<<"AT "<<i<<" "<<j<<" "<<t1<<" "<<t2<<" "<<t3<<endl;
				tipe[0] += t1, tipe[1] += t2, tipe[2] += t3;
			}			
		}
	}
	cout<<tipe[0] + tipe[1] + tipe[2]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <iterator>
#include <set>

const int MAX = 2001;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
using namespace std;

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    int n, k;
    cin >> n >> k;
    COMinit();
    for (int i = 1; i <= k; ++i) {
        cout << COM(k-1, i-1) * COM(n-k+1, i) % MOD << endl;
    }
}


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

int main() {
    int a,b,c,tmp;
    cin >> a >> b >> c;
    if ( a > b ) {
    	tmp = a;
    	a = b;
    	b = tmp;
    } 
    if ( b > c ) {
    	tmp = b;
    	b = c; 
    	c = tmp;
    }
    if ( a > b ) {
    	tmp = a;
    	a = b;
    	b = tmp;
    }
    cout << a << " " << b << " " << c << endl;
	return 0;
}


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

int main() {
  long long int A, B, C;
  cin >> A >> B >> C;
  long long int ans1 = A * B * abs(C / 2 - (C - C / 2));
  long long int ans2 = A * C * abs(B / 2 - (B - B / 2));
  long long int ans3 = B * C * abs(A / 2 - (A - A / 2));
  cout << min(min(ans1, ans2), ans3) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a,b;
		a = sc.nextInt();
		b = sc.nextInt();
		int k =0;
		for(int i=0;i<3;i++){
			if(b==0){
				k=1;
			}
			if((int)(b/Math.pow(10,i))==0){
				break;	
			}
			k++;
		}

		int h = a * (int)Math.pow(10,k) + b;
		boolean yes = false;
		
		for(int i=0;i<=317;i++){
			if(h == i*i){
				yes = true;
			}
		}

		System.err.println(h);
		if(yes){
			System.out.println("Yes");
		}else{
			System.out.println("No");

		}
	}
}


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

using namespace std;
typedef long long ll;

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

ll a[200020];
ll rs[200020];
ll di;
ll N;

int main(void)
{
    ll su = 0;
    cin >> N;
    REP(i, N) {
        cin >> a[i];
        su += a[i];
    }

    rs[0] = a[0];
    REP(i, N-1) rs[i+1]=rs[i]+a[i+1];

    ll mi = 10e9+7;
    
    REP(i, N - 1) {
        di = abs(rs[i] - (su-rs[i]));
//        cout << i << " " << di << endl;
        mi = min(mi, di);
    }
    cout << mi << endl;
}


Measured memory_bytes: 3328
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

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

        if (n % 500 <= a) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}




Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int a,b;

int main(){
	cin >> a >> b;
	
	int mi=2*INF;
	if(a<=b) mi=min(mi, b-a);
	if(-a<=b) mi=min(mi,b+a+1);
	if(a<=-b) mi=min(mi,-b-a+1);
	if(-a<=-b) mi=min(mi, -b+a+2);
	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int X;

	cin >> X;

	switch (X % 7)
	{
	case 0: cout << "thu" << endl; break;
	case 1: cout << "fri" << endl; break;
	case 2: cout << "sat" << endl; break;
	case 3: cout << "sun" << endl; break;
	case 4: cout << "mon" << endl; break;
	case 5: cout << "tue" << endl; break;
	case 6: cout << "wed" << endl; break;
	default:break;
	}

	return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int n;
long long gcd(long long x,long long y){ return(!y ? x : gcd(y,x%y));}
long long lcm(long long x,long long y){ return(((x/gcd(x, y)) * y)) ;} 
int main() {
	// your code goes here
	cin>>n;
 long long x, g=1;
while(n--) {
cin>>x;g=lcm(x, g);}
cout<<g;
  
	return 0;
}

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

int main() {
	int A,B;
	cin >> A >> B;
	if(A>=10 || B >= 10){
		cout << -1 << endl;
	} else {
		cout << A*B << endl;
	}
}

Measured memory_bytes: 256
main = do
  n: k: _ <- map read . words <$> getLine :: IO [Int]
  ps <- map read . words <$> getLine :: IO [Int]
  putStrLn $ show $ (\x -> fromIntegral (x + k) / 2 :: Double) $ maximum $ assocSum k ps

assocSum k ps = map (\(x, y) -> abs (x - y)) $ zip qs $ foldl (\a x -> tail a) qs [1..k]
    where qs = scanl (+) 0 ps


Measured memory_bytes: 79228
#include <iostream>
using namespace std;
#define rep(i,c,n) for(int i=c;i<n;i++)

  int gcd(int a, int b){
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
  }

int main() {
  int k;
  cin>>k;
  long long int ans=0;
  
  rep(i,1,k+1){
    rep(j,1,k+1){
      rep(l,1,k+1){
        int x=0;
        x=gcd(j,l);
        ans+=gcd(x,i);
        //cout<<i<<j<<l<<endl;
        //cout<<x<<endl;
      }
    }
  }

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

Measured memory_bytes: 3584
from collections import deque

class Node:
    def __init__(self):
        self.val = -1
        self.link = []

def main():
    N = int(input())
    nodes = [Node() for i in range(N)]
    for i in range(N-1):
        a, b = map(int, input().split())
        a -= 1; b -= 1;
        nodes[a].link.append(nodes[b])
        nodes[b].link.append(nodes[a])
    c = list(map(int, input().split()))
    c = sorted(c, reverse=True)
    count = 0
    q = deque()
    q.append(nodes[0])
    while len(q) > 0:
        node = q.popleft()
        node.val = c[count]
        count += 1
        for next in node.link:
            if next.val == -1:
                q.append(next)
    print(sum(c) - c[0])
    for i in range(N):
        print(nodes[i].val, end="")
        if i != N-1:
            print(" ",end="")
        else:
            print()

if __name__ == "__main__":
    main()


Measured memory_bytes: 7608
x,n=map(int,input().split())
I=list(map(int,input().split()))
S=[]
T=[]
ans=[]
for i in range(-200,200):
    S.append(i)
    if i in I:
        S.remove(i)
for j in range(len(S)):
    if j==0:
        T.append(S[0])
    elif abs(x-S[j-1])>abs(x-S[j]):
        T.clear()
        T.append(S[j])
print(min(T))


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

// 0,0 start
int n;
string s;
long long ans=0;

void F(long long x,long long y){
	if(x==n){
		ans+=y;
		return;
	}
	long long cur=0;
	for(long long i=x;i<=n;i++){
		cur=(10*cur)+(s[i]-'0');
		F(i+1, y+cur);
	}
}

int main(){
	//freopen("input.txt","r",stdin);
	cin >> s;
	n=s.size();
	F(0,0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
ListV=[int(_) for _ in input().split()]
ListC=[int(_) for _ in input().split()]
NewList=[x - y for (x, y) in zip(ListV, ListC)]
AnswerList=[]
for i in range(N):
  if NewList[i] >= 0:
    AnswerList.append(NewList[i])
print(sum(AnswerList))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main() {
  int X;
  cin >> X;
  if(X >= 400) {
    if(X < 600) {
      cout << "8" << endl;
    }
    else if(X < 800) {
      cout << "7" << endl;
    }
    else if(X < 1000) {
      cout << "6" << endl;
    }
    else if(X< 1200) {
      cout << "5" << endl;
    }
    else if(X < 1400) {
      cout << "4" << endl;
    }
    else if(X < 1600) {
      cout << "3" << endl;
    }
    else if(X < 1800) {
      cout << "2" << endl;
    }
    else if(X < 2000) {
      cout << "1" << endl;
    }
  }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x){
	register short f=1;x=0;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
	x*=f;
}
template<typename T>inline void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
template<typename T>inline void writeln(T x){
	write(x),putchar('\n');
}
long long a,b;
int main(){
	read(a),read(b);
	write(int(b*pow(b-1,a-1)));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int A,B,T,X = 0;
    cin >> A >> B >> T;
  int Y = A;
for (int i = 0;i< T+0.5; i = i+0.0001){
if ( i = A ){
  X = X + B;
}
  A = A + Y;
  
}
  cout << X - B;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

//snuke
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

long long modpow(long long a, long long n, long long m) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  COMinit();
  ll n,k;
  cin >> n >> k;
  if(k-n>=-1){ cout << COM(n+n-1,n) << endl; return 0; }
  
  mint ans=0;
  rep(i,k+1){
    mint tmp = COM(n,i);
    tmp *= COM(n-1,i);
    ans += tmp;    
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 12160
#!/usr/bin/env python3
import sys


def solve(S: str):
    if S=="RRR":
        ans=3
    elif "RR" in S:
        ans=2
    elif "R" in S:
        ans=1
    else:
        ans=0
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9080
#include <stdio.h>
#include <math.h>

// データの個数と各データが与えられ、データセットの標準偏差を出力
// 与えられるデータの個数が0なら終了
int main()
{
	int iInputN, iInputS;
	int iCnt;
	double dAve;
	int iSum, iNijouSum;

	scanf("%d", &iInputN);

	while (iInputN != 0)
	{
		iSum = 0;
		iNijouSum = 0;
		for (iCnt = 0; iCnt < iInputN; iCnt++)
		{
			scanf("%d", &iInputS);
			iSum += iInputS;
			iNijouSum += pow(iInputS, 2);
		}
		// 二乗の平均‐平均の二乗
		dAve = (double)iSum / iInputN;
		printf("%.8lf\n", sqrt((double)iNijouSum / iInputN - pow(dAve, 2)));

		scanf("%d", &iInputN);
	}

	return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define INF 100000000
#define mod 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

ll modpow(ll x, ll n) {
    ll res=1;
    while(n>0) {
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}


int main() {
    ll n, m, ans;
    cin >> n >> m;
    
    if(n*2>m)
        ans = m/2;
    else
        ans = n + (m-n*2)/4;

    cout << ans << endl;
}


Measured memory_bytes: 256
#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++)

int main() {
    string S; cin >> S;
    if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
import java.util.Scanner;

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

        if (n == 100) {
            n = 101;
        }

        if (d == 0) {
            System.out.println(n);
        } else if (d == 1) {
            System.out.println(100 * n);
        } else {
            System.out.println(10000 * n);
        }
    }
}


Measured memory_bytes: 21716
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc075.contest.atcoder.jp/tasks/arc075_a>
問題文============================================================
 あなたはコンピュータで試験を受けています。試験は N 問の問題からなり、
 i 問目の問題の配点は si です。
 それぞれの問題に対するあなたの解答は「正解」または「不正解」のいずれかとして判定され、
 正解した問題の配点の合計があなたの成績となります。
 あなたが解答を終えると、解答がその場で採点されて成績が表示される…はずでした。
 
 ところが、試験システムに欠陥があり、成績が 10 の倍数の場合は、画面上で成績が 0 と表示されてしまいます。
 それ以外の場合は、画面に正しい成績が表示されます。
 この状況で、成績として画面に表示されうる最大の値はいくつでしょうか？
=================================================================

解説=============================================================

 全体の合計からが１０の倍数でなければそれが答え
 10の倍数であれば、最も小さい10の倍数でない一つの要素を引けば答え
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> s(N);
    for(auto &in:s) cin >> in;
    ll Sum = accumulate(s.begin(), s.end(), 0LL);
    ll ans = Sum%10 == 0 ? 0 : Sum;
    for(int i = 0; i < N;i++){
        if(s[i]%10 == 0) continue;
        ans = max(ans,Sum-s[i]);
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
        int a,b, avg;
        scanf("%d %d", &a, &b);
        avg = (a+b)/2;
        if((avg*2)==(a+b))
        {
               printf("%d", avg);
         }
         else{
          printf("%d", avg+1);
         }
         return 0;
}

Measured memory_bytes: 128
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
#print(L)
ans = 0
def find(x, arr):
  a = len(arr)//2
  cur = a
  while True:
    a //= 2
    if arr[cur] < x:
      if cur == len(arr)-1:
        return cur+1
      elif arr[cur+1] >=x:
        return cur+1
      else:
        cur += max(1,a)
    else:
      if cur == 0:
        return 0
      else:
        cur -= max(1, a)
for i in range(N-2):
  for j in range(i+1, N-1):
    ans += bisect.bisect_left(L, L[i] + L[j])-j-1
print(ans)

Measured memory_bytes: 3188
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << a << " " << b << " " << 3*c-a-b << endl;
    cout << -2*a-b+4*c << " " << c << " " << 2*a+b-2*c << endl;
    cout << a+b-c << " " << 2*c-b << " " << 2*c-a << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
int main(void)
{
  char ch;
  while((ch=getchar())!=EOF){
    if(isalpha(ch)){
      if(isupper(ch))
	putchar(tolower(ch));
      else
	putchar(toupper(ch));
    }
    else
      putchar(ch);
  }
  return 0;
}

Measured memory_bytes: 524
#include <iostream>

using namespace std;

int main ()
{
	int a,b,c;

	for (int s = -2; s < 100; s++)
  {

		cin >> a >> b >> c;
		if (a == -1 && b == -1 && c == -1)
		break;


	if (a == -1)
	{
		cout << 'F';
	}
	else if (b == -1)
	{
		cout << 'F';
	}

	else if (a + b >= 80)
	{
		cout << 'A';
	}

	else if (a + b >= 65)
	{
		cout << 'B';
	}

	else if (a + b >= 50 || c >= 50)
		{
		cout << 'C';
		}

	else if (a + b >= 30 && a > -1 && b > -1)
		{
		cout << 'D';
		}
	else if (a + b < 30 && a > -1 && b > -1)
	{
		cout << 'F';
	}
	cout << endl;
  }
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;

int main(){

    int a,b;
    cin >> a >> b;

    cout << (b - 1 + a - 2) / (a - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int N=sc.nextInt();
        int T=sc.nextInt();
        int[] t=new int[N];
        for (int i = 0; i < N; i++) {
            t[i]=sc.nextInt();
        }
        long ans=T;
        for (int i = 0; i < N-1; i++) {
            if(t[i+1]-t[i]>=T){
                ans+=T;
            }else{
                ans+=t[i+1]-t[i];
            }
        }
        out.println(ans);
    }
}

Measured memory_bytes: 89040
H, W = map(int, input().split())
A = [input() for _ in range(H)]

h_check = [0] * H
w_check = [0] * W

for i in range(H):
  flag = 0
  for j in range(W):
    if A[i][j] != ".":
      flag = 1
      break
  h_check[i] = flag

for j in range(W):
  flag = 0
  for i in range(H):
    if A[i][j] != ".":
      flag = 1
      break
  w_check[j] = flag

for i in range(H):
  if h_check[i]:
    tmp = ""
    for j in range(W):
      if w_check[j]:
        tmp += A[i][j]
    print(tmp)

Measured memory_bytes: 39536
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <math.h>

#if defined SUBLIME
#  define ISTREAM ss
#else
#  define ISTREAM cin
#endif


using namespace std;
int main()
{
	#if defined SUBLIME
		string str = "9999.99";
		stringstream ss;
		ss << str;
	#endif
	double a;
	ISTREAM >> a;
	cout << fixed << setprecision(6) << a * a * M_PI << " " << 2 * a * M_PI << endl;
}

Measured memory_bytes: 3212
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int N;
	cin >> N;
	int two = 0, four = 0, odd = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (a % 4 == 0) four++;
		else if (a % 2 == 0) two++;
		else odd++;
	}
	if (odd > four) {
		if (odd == four + 1 && two == 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
 }

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

int main()
{
    int n, m, a, b;
    std::cin >> n >> m;
    int city[n + 1];
    for (int i = 0; i < n + 1; i++) { city[i] = 0; }
    for (int i = 1; i < m + 1; i++)
    {
        std::cin >> a >> b;
        city[a]++;
        city[b]++;
    }
    for (int i = 1; i < n + 1; i++) { std::cout << city[i] << std::endl; }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	int ans=(n*(n-1)/2)+(m*(m-1)/2);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
import math

ans = 0
for i in range(1,n+1):
    for j in range(i, n+1):
        for k in range(j, n+1):
            if i == j and j == k:
                ans += i
            
            elif len({i,j,k}) == 2:
                ans += math.gcd(math.gcd(i,j),k)*3
            
            elif len({i,j,k}) == 3:
                ans += math.gcd(math.gcd(i,j),k)*6
        
print(ans)

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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    string ans="";
    while(n){
        int x=n%26;
        if(x==0)x=26;
        ans+=char('a'+x-1);
        n-=x;
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans;
}

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

int main(){
  int H,W;
  cin>>H>>W;
  int64_t c[10][10];
  
  for(int i=0;i<10;++i){
    for(int j=0;j<10;++j){
      cin>>c[i][j];
    }
  }
  
  int A[H][W];
  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      cin>>A[i][j];
    }
  }
  
  for(int k=0;k<10;++k){
    for(int i=0;i<10;++i){
      for(int j=0;j<10;++j){
        c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
      }
    }
  }
  
  int64_t ans=0;
  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      if(A[i][j]!=-1) ans += c[A[i][j]][1];
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<cmath>
#include<cstdio>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
typedef pair<ll,ll > P;


int main() {
	ll i, j, k, l, m, n, sum, flag, cc, M, X, H, W, N, K,h,w,C;
	cin >> N >>M;
	vector<P>A(N);
	REP(i, 0, N) {
		cin >> A[i].first >> A[i].second;
	}
	sort(A.begin(), A.end());
	ll ans = 0;
	REP(i, 0, N) {
		ans += fmin(M, A[i].second)*A[i].first;
		if (M > A[i].second) {
			M -= A[i].second;
		}
		else {
			output(ans);
			return 0;
		}
	}
	output(ans);


	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int main() {
	pair<int, int> a, b, c, d;
	cin >> a.first >> a.second >> b.first >> b.second; // a(x1,y1) b(x2,y2)

	c.first = b.first - (b.second - a.second);
	c.second = b.second - (a.first - b.first);
	d.first = a.first - (b.second - a.second);
	d.second = a.second - (a.first - b.first);

	cout << c.first << " " << c.second << " " << d.first << " " << d.second << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		char[][] array = new char[H][W];
		int black = 0;
		int[] lineCount = new int[H];
		int[] tateCount = new int[W];
		for(int i = 0; i < H; i++) {
			String line = sc.next();
			for(int j = 0; j < W; j++) {
				char tmp = line.charAt(j);
				array[i][j] = tmp;
				if(array[i][j] == '#') {
					black++;
					lineCount[i]++;
				}
			}
		}
		sc.close();


		for(int i = 0; i < W; i++) {
			for(int j = 0; j < H; j++) {
				if(array[j][i] == '#') {
					tateCount[i]++;
				}
			}
		}

		int count = 0;

		for (int i = 0; i < Math.pow(2, H); i++) {
			for (int j = 0; j < Math.pow(2, W); j++) {
				int check = 0;
				for(int h = 0; h < H; h++) {
					for(int w = 0; w < W; w++) {
						if(((i >> h) & 1) == 0 && ((j >> w) & 1) == 0 && array[h][w] == '#') {
							check++;
						}
					}
				}
				if(check == K) count++;
			}
		}

		System.out.println(count);
	}
}

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

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

	int h,a;
	int ans=0;
	cin >> h>>a;
	while (h>0){
		h-=a;
		ans++;
	}

	cout << ans<< "\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a[200000],N;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>a[i];
	}
	sort(a,a+N);
	for(int i=0;i<N;i++)
	{
		if(a[i]==a[i+1])
		{
		cout<<"NO"<<'\n';
		return 0;
		}
	}
	cout<<"YES"<<'\n';
	return 0;
} 


Measured memory_bytes: 3836
#include<stdio.h>
int main(void){
  char a;
  scanf("%s",&a);
  if(a=='A'){
    printf("T");
  }
  if(a=='C'){
    printf("G");
  }
  if(a=='T'){
    printf("A");
  }
  if(a=='G'){
    printf("C");
  }  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
using namespace std;

class osa_k{
private:
    vector<int> prime_sieve;
    vector<int> set_prime;
    int N;
    void eratosthenes(){
        for(int i=2;i*i<N;i++) {
            if(prime_sieve[i]<i) continue;
            for(int j=i*i;j<N;j+=i){
                if(prime_sieve[j]==j) prime_sieve[j] = i;
            }
        }                
    }

    void setPrimeSet(){
        for(int i=2;i<N;i++){
            if(prime_sieve[i]==i){
                set_prime.emplace_back(i);
            }
        }        
    }
public:    
    osa_k(const int n){
        N=n;
        prime_sieve.resize(n);
        iota(prime_sieve.begin(),prime_sieve.end(),0);
        eratosthenes();
        //setPrimeSet();
    }

    vector<int> get_factor(int i) {
        vector<int> res;
        while(i>1){
            res.emplace_back(prime_sieve[i]);
            i/=prime_sieve[i];
        }
        //素因数の重複なしが欲しいなら、以下のコメントアウトを解除
        sort(res.begin(),res.end());
        decltype(res)::iterator result = unique(res.begin(), res.end());
        res.erase(result, res.end());
        return res;
    }

};



int main(){
    int n;cin>>n;
    osa_k o(1000005);
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    vector<int> s(1000005);
    int co=a[0];
    for(int i=0;i<n;i++){
        co=gcd(co,a[i]);
    }
    if(co!=1){
        cout<<"not coprime"<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        vector<int> tmp=o.get_factor(a[i]);
        for(int j=0;j<tmp.size();j++){
            if(s[tmp[j]]>0){
                cout<<"setwise coprime"<<endl;
                return 0;
            }
            else{
                s[tmp[j]]+=1;
            }
        }
    }
    cout<<"pairwise coprime"<<endl;    

    return 0;
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

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

const int MOD = 1e9+7;

int fat[2000007];
int inv[2000007];

int binExp(int x, int p){
	int ans = 1;
	while(p){
		if(p&1)
			ans = 1LL * ans * x % MOD;
		x = 1LL * x * x % MOD;
		p >>= 1;
	}
	return ans;
}

int comb(int a, int b){
	int up = 1LL * fat[a] * inv[b] % MOD;
	up = 1LL * up * inv[a-b] % MOD;
	return up;
}

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

	fat[0] = inv[0] = 1;
	for(int i = 1; i < 2000007; i++){
		fat[i] = 1LL * fat[i-1] * i % MOD;
		inv[i] = binExp(fat[i], MOD-2);
	}

	int k; cin >> k;
	string s; cin >> s;
	int n = s.size();

	ll ans = 0;
	for(int i = 0; i <= k; i++){
		int add = 1LL * comb(n+k, i+n) * binExp(25, k-i) % MOD;
		ans = (ans + add) % MOD;
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 19884
#include <stdio.h>

int main(){

  int n, i, j, k, l, u, v[101][101];

  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      v[i][j] = 0;
    }
  }
  for(i=1;i<=n;i++){

    scanf("%d",&k);
    scanf("%d",&u);

    for(j=1;j<=u;j++){
      scanf("%d",&l);
      v[k][l]=1;
   
    }
  }

  for(i=1;i<=n;i++){

    printf("%d",v[i][1]);

    for(j=2;j<=n;j++){

      printf(" %d",v[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

int memo[100010];

signed main() {
	int N, M;
	cin >> N >> M;

	vector<int> A(N);
	rep(i, N) cin >> A[i];

	rep(i, N) memo[i + 1] = memo[i] + A[i];

	unordered_map<int, int> m;
	rep(i, N) {
		memo[i + 1] %= M;
		m[memo[i + 1]]++;
	}

	int ret = 0;
	int sum = 0;
	rep(i, N) {
		ret += m[sum];

		m[memo[i + 1]]--;
		sum = memo[i + 1];
	}

	cout << ret << endl;
}


Measured memory_bytes: 5260