akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int A=0, T=1, G=2, C=3;
unsigned long MOD=1000000007UL;

int main(){
  int N; cin>>N;
  vector<vector<vector<vector<unsigned long>>>>
    dp(101, vector<vector<vector<unsigned long>>>(4, vector<vector<unsigned long>>(4, vector<unsigned long>(4, 0))));
  
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      for(int k=0;k<4;k++){
        if(i==A&&j==G&&k==C||i==A&&j==C&&k==G||i==G&&j==A&&k==C) continue;
        dp[3][i][j][k] = 1;
      }
    }
  }
  
  for(int n=4; n<=N; n++){
    for(int h=0;h<4;h++){
      for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
          for(int k=0;k<4;k++){
        	if(i==A&&j==G&&k==C||i==A&&j==C&&k==G||i==G&&j==A&&k==C) continue;
            if(h==A&&j==G&&k==C) continue;
            if(h==A&&i==G&&k==C) continue;
            dp[n][i][j][k]+=dp[n-1][h][i][j];
            dp[n][i][j][k]%=MOD;
          }
        }
      }
    }
  }
  
  unsigned long ans = 0;
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      for(int k=0;k<4;k++){
        ans+=dp[N][i][j][k];
        ans%=MOD;
      }
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>
#include<numeric>

using namespace std;

int n,x,y;
string s;
long long k;

int main(){
  cin>>s;
  cin>>k;
  int cnt = 0;
  for(int i=0;i<(int)s.length();i++){
    if(s[i] == '1') cnt++;
    else break;
  }
  if(k > cnt) cout<<s[cnt]<<endl;
  else cout<<"1"<<endl;
  return 0;
}


Measured memory_bytes: 256
s=input()
ss=""
res=0
for c in s:
    ss+=c if c!="x" else ""
if ss!=ss[-1::-1]:
    print(-1)
elif len(ss)%2==0:
    ss=ss[:len(ss)//2]
    for c in ss:
        l=s.find(c)
        r=s.rfind(c)
        res+=max(l,len(s)-1-r)-min(l,len(s)-1-r)
        s=s[l+1:r]
    print(res)
else:
    cent=ss[len(ss)//2]
    ss=ss[:len(ss)//2]
    for c in ss:
        l=s.find(c)
        r=s.rfind(c)
        res+=max(l,len(s)-1-r)-min(l,len(s)-1-r)
        s=s[l+1:r]
    l=s.find(cent)
    r=s.rfind(cent)
    res+=max(l,len(s)-1-r)-min(l,len(s)-1-r)
    print(res)

Measured memory_bytes: 3444
#include <iostream>
using namespace std;
#define F(i) for (int i=0; i<10; i++)
int main()
{
	int n;
	while(cin >> n){
		int count = 0;
		F(a)F(b)F(c)F(d)if(a+b+c+d==n) count++;
		cout << count << endl;
	}
	return(0);
}

Measured memory_bytes: 0
from itertools import combinations
x = int(input())
li = [i**5 for i in range(-200, 200)]
dic = {}
for i in range(-200, 200):
    dic[i**5] = i
for a, b in combinations(li, 2):
    if a - b == x:
        print(dic[a], dic[b])
        break
    elif b - a == x:
        print(dic[b], dic[a])
        break

Measured memory_bytes: 9244
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
    }

    let mut ans = vec![0, 0, 0, 0];
    for _i in 0..n {
        input! {
            s: String,
        }

        if s == "AC" {
            ans[0] += 1;
        } else if s == "WA" {
            ans[1] += 1;
        } else if s == "TLE" {
            ans[2] += 1;
        } else {
            ans[3] += 1;
        }
    }
    println!("AC x {}", ans[0]);
    println!("WA x {}", ans[1]);
    println!("TLE x {}", ans[2]);
    println!("RE x {}", ans[3]);
}


Measured memory_bytes: 2572
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define nn int n=0
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool; 
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
int x = 0, y = 0;
//BEGIN OF CODE.
int main(void){
	int r, d;
	cin >> r >> d;
	vllint x(11,0);
	cin >> x[0];
	rep(i, 10) {
		x[i + 1] = x[i] * r - d;
		cout << x[i+1] << rt;
	}
	please AC;
}
//THE END.

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  map<LL,LL> mp;
  REP(i,N){
	LL x; cin >> x;
	mp[x]++;
  }

  LL a = 0, b = -1;
  for(auto it=mp.rbegin();it!=mp.rend();++it){
	if(it->SS >= 2){
	  a = it->FF;
	  it->SS -= 2;
	  break;
	}
  }
  for(auto it=mp.rbegin();it!=mp.rend();++it){
	if(it->SS >= 2){
	  b = it->FF;
	  it->SS -= 2;
	  break;
	}
  }
  cout << max(0ll, a*b) << endl;

  return 0;
}


Measured memory_bytes: 6528
// Problem : A - Circle Pond
// Contest : AtCoder - AtCoder Beginner Contest 163
// URL : https://atcoder.jp/contests/abc163/tasks/abc163_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9 + 7;
using Int = long long;


const double PI = acos(-1);
int32_t main() {
	int R; cin >> R;
	cout << 2 * PI * R << "\n";
	
}

Measured memory_bytes: 3788
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
#define all(c) ((c).begin()), ((c).end())
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
template<typename T>T gcd(T a, T b) {return b==0?a:gcd(b, a%b);}
#ifndef ONLINE_JUDGE
#define debug(fmt, ...) {printf("debug ");printf(fmt,##__VA_ARGS__);puts("");}
#else
#define debug(fmt, ...)
#endif
const int maxn = 1e5+5;
typedef long long ll;
const ll mod = 1e9+7;
int Case = 1;
int n, m;
struct node{
	int l, r;
}cc[maxn], t[maxn];
bool cmp1(node a, node b) {
	return (a.l < b.l || (a.l == b.l && a.r < b.r));
}
bool cmp2(node a, node b) {
	return (a.l < b.l || (a.l == b.l && a.r > b.r));
}
bool cmp3(node a, node b) {
	return (a.r < b.r || (a.r == b.r && a.l > b.l));
}
bool cmp4(node a, node b) {
	return (a.r < b.r || (a.r == b.r && a.l < b.l));
}
int prel[maxn], prer[maxn];
int sufl[maxn], sufr[maxn];
void solve() {
	cin>>n;
	for(int i = 1; i <= n; i++) {
		cin>>t[i].l>>t[i].r;
	}
	ll res = 0;
	sort(t+1, t+1+n, cmp1);
	cc[1] = t[1];
	int len = 1;
	for(int i = 2; i <= n; i++) {
		if(t[i].l == cc[len].l && t[i].r == cc[len].r) continue;
		cc[++len] = t[i];
	}
	if(len == 1) {
		cout<<2ll*(cc[1].r-cc[1].l+1)<<endl;
		return;
	}
	prer[0] = 2e9;
	for(int i = 1; i <= len; i++) {
		prel[i] = max(prel[i-1], cc[i].l);
		prer[i] = min(prer[i-1], cc[i].r);
	}
	sufr[len+1] = 2e9;
	for(int i = len; i >= 1; i--) {
		sufl[i] = max(sufl[i+1], cc[i].l);
		sufr[i] = min(sufr[i+1], cc[i].r);
	}
	for(int i = 2; i <= len; i++) {
		ll A = max(prer[i-1] - prel[i-1]+1, 0);
		ll B = max(sufr[i] - sufl[i]+1, 0);
		res = max(res, A+B);
		if(i != len) {
			A = cc[i].r-cc[i].l+1;
			B = max(0, min(sufr[i+1], prer[i-1])-max(prel[i-1], sufl[i+1])+1);
			res = max(res, A+B);
		}
	}
	cout<<res<<endl;
	return;
}
int main() {
	while(Case--) {
		solve();
	}
	return 0;
}

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

int main(){
    long long n, a, b;
    cin >> n >> a >> b;
    long long ans = 0;
    ans += (n - (n % (a + b))) / (a + b) * a;
    ans += min(n % (a + b), a);
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
pt, pa = 0, 0
for _ in range(n):
    t, a = tuple(map(int, input().split()))
    l = 0
    r = 10**18+1
    while (r-l) > 1:
        mid = (l+r)//2
        if (t*mid >= pt and a*mid >= pa):
            r = mid
        else:
            l = mid
    pt, pa = t*r, a*r

print(pt+pa)


Measured memory_bytes: 9100
n, a, b = list(map(int, input().split()))
ans = 0


def dsum(n):
    wa = 0
    while n > 0:
        wa += n % 10
        n //= 10
    return wa


for i in range(1, n + 1):
    res = i
    if a <= dsum(i) <= b:
        ans += i

print(ans)


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

class Program
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var X = line[0];
        var Y = line[1];
        var Z = line[2];
        var K = line[3];
        var A= Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var B= Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var C = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        Array.Sort(C);
        Array.Reverse(C);
        var array = new long[X * Y];
        var index = 0;
        for (int i=0;i<X;++i)
        {
            for (int j=0;j<Y;++j)
            {
                array[index] = A[i] + B[j];
                index++;
            }
        }
        Array.Sort(array);
        Array.Reverse(array);
        var arrayLength = Math.Min(K, X * Y);
        var arrayAll = new long[arrayLength * Z];
        index = 0;
        for (int i=0;i<arrayLength;++i)
        {
            for (int j=0;j<Z;++j)
            {
                arrayAll[index] = array[i] + C[j];
                index++;
            }
        }
        Array.Sort(arrayAll);
        Array.Reverse(arrayAll);
        index = 0;
        foreach (var ans in arrayAll)
        {
            Console.WriteLine(ans);
            if (K <= ++index) break;
        }
    }
}

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

int		main(void)
{
	int w, h, n;

	cin >> w >> h >> n;
	vector<int> a1;
	vector<int> a2;
	vector<int> a3;
	vector<int> a4;
	for (int i = 0; i < n; i++)
	{
		int x, y, a;

		cin >> x >> y >> a;
		if (a == 1)
			a1.push_back(x);
		if (a == 2)
			a2.push_back(x);
		if (a == 3)
			a3.push_back(y);
		if (a == 4)
			a4.push_back(y);
	}
	sort(a1.begin(), a1.end());
	sort(a2.begin(), a2.end());
	sort(a3.begin(), a3.end());
	sort(a4.begin(), a4.end());
	if (a2.empty() == false)
		w = a2[0];
	if (a4.empty() == false)
		h = a4[0];
	if (a1.empty() == false)
		w -= a1[a1.size() - 1];
	if (a3.empty() == false)
		h -= a3[a3.size() - 1];
	if (w < 0 || h < 0)
		cout << 0 << endl;
	else
		cout << w * h << endl;
}



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

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<pair<ll,ll> > > vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin() , x.end()
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define left (node << 1)
#define right (node << 1) + 1
#define pii pair<int,int> 
#define mii map<int,int>
#define vi vector<int>
#define umii unordered_map<int,int>
#define mod 998244353
#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 repo(i,o,e) for(int i = o ; i < e ; i++)
#define rep(n) for(int i = 0 ; i < n ; i++)
const ll sz = 2e5+5;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};


bool sbs(const pll &a , const pll &b){
    return a.second > b.second;
}

void solve(){
    int n,k;cin >> n >> k;
    string s;
    cin >> s;
    rep(n){
        if(i == k-1){
            s[i] = s[i] + 32;
        }
    }
    cout << s;  
}

int main(){
    FIO;
    int t = 1;
    while(t--){
        solve();
    }
    return 0;
}

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

typedef pair<int,int> P;

// A[i] := i 番目の問題を解くのにかかる時間
int A[16] = {0};
int ans = 0;

void solve(vector<P> v, int pos, int total, int AC){
	if( pos == v.size() ){
		ans = max( ans , AC );
		return ;
	}
	
	int time = v[pos].first;
	int i = v[pos].second;
	if( total + A[i] <= time ){
		solve( v , pos+1 , total + A[i] , AC+1 );
	}
	solve( v , pos+1 , total , AC );
}

int main(){
	int n;
	vector<P> v;
	
	cin >> n;
	for(int i=0 ; i < n ; i++ ){
		int a, b;
		cin >> a >> b;
		A[i] = a;
		v.push_back( P(b,i) );
	}
	sort( v.begin() , v.end() );
	solve( v , 0 , 0 , 0 );
	cout << ans << endl;
}

Measured memory_bytes: 0
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    R, C, K = MI()
    item = [[0] * (C + 1) for i in range(R + 1)]

    for i in range(K):
        r_, c_, v_, = MI()
        item[r_ - 1][c_ - 1] = v_

    dp = [[[0 for _ in range(C + 2)] for _ in range(R + 2)] for _ in range(4)]

    for i in range(R + 1):
        for j in range(C + 1):
            for k in range(4):
                a = dp[k][i][j]
                v = item[i][j]

                if k == 3:
                    dp[0][i + 1][j] = max(a, dp[0][i + 1][j])
                    continue
                dp[0][i + 1][j] = max(a, a + v, dp[0][i + 1][j])
                dp[k][i][j + 1] = max(a, dp[k][i][j + 1])
                dp[k + 1][i][j + 1] = max(a + v, dp[k + 1][i][j + 1])

    print(max(dp[0][R][C], dp[1][R][C], dp[2][R][C], dp[3][R][C]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 461672
#include <stdio.h>

int main(){

  int i,j,k,n, b, f, r, v,c[5][4][11];

  scanf("%d",&n);

  for(i=0;i<5;i++){
    for(j=0;j<4;j++){
      for(k=0;k<11;k++){
      c[i][j][k]=0;
      }
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
    c[b][f][r]=v+c[b][f][r];
  }
  
  for(i=1;i<=4;i++){
    if(i>1){
      printf("####################\n");
    }
    for(j=1;j<=3;j++){
      for(k=1;k<=10;k++){
	printf(" %d",c[i][j][k]);
      }
      printf("\n");
    }
  }

  
  
  return 0;
}

Measured memory_bytes: 612
a, b = map(int, input().split())

p = a
q = b
r = p % q
while r > 0:
  p = q
  q = r
  r = p % q
sgd = q

d = 2
count = 1
while d * d <= sgd:
  d_flag = False
  while q % d == 0:
    d_flag = True
    q //= d
  if d_flag:
    count += 1
  if d == 2:
    d = 3
  else:
    d += 2
if q > 1:
  count += 1
    
print(count)

Measured memory_bytes: 3064
/* AtCoder Beginner Contest abc137
 * Problem D
 * Au: SJoshua
 */
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

struct info {
	int delay, reward;
	bool operator < (const info &p) const {
		return reward < p.reward;
	}
};

int main(void) {
	int n, m;
	cin >> n >> m;
	vector <info> jobs(n);
	for (int i = 0; i < n; i++) {
		cin >> jobs[i].delay >> jobs[i].reward;
	}
	sort(jobs.begin(), jobs.end(), [](info &a, info &b) -> bool {return a.delay < b.delay; });
	priority_queue <info> pq;
	auto it = jobs.begin();
	long long int ans = 0;
	for (int i = 0; i < m; i++) {
		while (it != jobs.end() && it->delay <= i + 1) {
			pq.push(*it);
			it++;
		}
		if (!pq.empty()) {
			ans += pq.top().reward;
			pq.pop();
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    set<int> s;
    for (int i = a, j = 0; j < k; j++) s.insert(i+j);
    for (int i = b-k+1; i <= b; i++) s.insert(i);
    for (auto&& i : s) if (a <= i && i <= b) cout << i << endl;
    return 0;
}

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

int main(){
  int N,A;
  cin >> N;
  if(N%2==0){
    A=N/2;
  }
  else{
    A=(N+1)/2;
  }
  cout << fixed << setprecision(10) << (double)A/N << endl;
}
  

Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll X, Y;
	cin >> X >> Y;
	if (500 * X >= Y)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  for (int i=0;i<N;i++){
    string S;
    cin >> S;
    if(S =="Y"){
    cout << "Four" << endl;
    break;
    }
    if(i<N-1){
      continue;
    }
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
import sys
n, m = map(int, input().split())
 
g = [[] for _ in range(n)]
for _ in range(m):
    u, v = map(int, input().split())
    g[u-1].append(v-1)
    g[v-1].append(u-1)

N = n-1
for i in g[0]:
    if N in g[i]:
        print('POSSIBLE')
        sys.exit()

print('IMPOSSIBLE')

Measured memory_bytes: 41668
// [[ABC134C] Exception Handling] https://www.luogu.com.cn/problem/AT4843
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int h, w, n;
  cin >> h >> w >> n;

  int ans = n / max(h, w);
  if (n % max(h, w) != 0) ans++;

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


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, char> Pc;
typedef pair<int, string> Ps;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
struct Node { int data; Node *left, *right; Node(int data) : data(data), left(NULL), right(NULL) {} };
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll X;
  cin >> X;
  REP(a, 10e2) {
    for (int b = -10e2; b <= 10e2; b++) {
      if (pow(a, 5) - pow(b, 5) == X) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }

  return 0;
}


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

int main(){
	int n;
	cin>>n;
	
	while(n!=0){
		if(n%10!=7) {
			n=n/10;
		}
		
		else{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	
	cout<<"No"<<endl;
	return 0;
} 

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

int main() {
 int64_t A, B, K; 
 cin >> A >> B >> K;

   if( A > K ){
    cout << A - K << " " << B << endl;  
   }
   else if ( A + B < K ){
   cout << 0 << " " << 0 << endl;
   }
   else{
     cout << 0 << " " << A + B - K << endl;  
   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                      \
  ifstream in("loadtolb/abc128_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

/**
 * bit全探索
 */
int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, M;
  cin >> N >> M;

  vector<vector<int>> c(M, vector<int>());
  rep(i, M) {
    int k;
    cin >> k;
    rep(j, k) {
      int l;
      cin >> l;
      l--;
      c[i].push_back(l);
    }
  }
  vector<int> p(M);
  rep(i, M) { cin >> p[i]; }

  ll ans = 0;
  rep(i, pow(2, N)) {
    // printf("%d--\n", i);
    int totOn = 0;
    rep(j, M) {
      int cntOn = 0;
      for (auto l : c[j]) {
        // printf("  l:%d, %d, %d\n", l, (1 << l), i & (1 << l));
        cntOn += ((i & 1 << l) != 0);
      }
      if (cntOn % 2 == p[j]) totOn++;
    }
    if (totOn == M) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
/*
AOJ - ITP1_7_c
Date: 20181001
Author: Mikoron * ♡mikoiwate♡
 */

#define MAX 100

#include<stdio.h>

int main(void) {
        short i, j, r, c, buf;
        int sum_c, sum_r[MAX];

        scanf("%hd %hd", &r, &c);

        for(i = 0; i < c; i++) {
                sum_r[i] = 0;
        }

        for(i = 0; i <= r; i++) {
                sum_c = 0;
                for(j = 0; j <= c; j++) {
                        if(i != r) {
                                if(j != c) {
                                        scanf("%hd", &buf);
                                        printf("%hd ", buf);
                                        sum_c += buf;
                                        sum_r[j] += buf;
                                }
                                else {
                                        printf("%d", sum_c);
                                }
                        }
                        else {
                                if(j != c) {
                                        printf("%d ", sum_r[j]);
                                        sum_c += sum_r[j];
                                }
                                else {
                                        printf("%d", sum_c);
                                }

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



Measured memory_bytes: 2060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder
{
	class Program
	{
		static void Main(string[] args)
		{
			Console.ReadLine();
			var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var counter = new Dictionary<int, int>();
			foreach (var item in input)
			{
				for (int i = item - 1; i <= item + 1; i++)
				{
					if (counter.ContainsKey(i)) counter[i]++;
					else counter.Add(i, 1);
				}
			}
			Console.WriteLine(counter.Values.Max());
		}
	}
}

Measured memory_bytes: 23264
# cook your dish here
from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left

def L():
    return list(map(int, stdin.readline().split()))

def In():
    return map(int, stdin.readline().split())

def I():
    return int(stdin.readline())

P = 1000000007
s = input()
n = len(s)
if len(s)%2 == 0:
    print("No")
else:
    if s[0:(n-1)//2] == s[(n+1)//2:]:
        st1 = (s[0:(n-1)//2:-1])
        if st1 == st1[::-1]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


Measured memory_bytes: 3568
//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define pb push_back
using namespace std;
ll a[3001],x=0,y=0,su=0;
ll dp[3005][3005];
ll ans(int i,int j){
    if(i==j)return dp[i][j]=a[i];
    else if(i>j)return dp[i][j]=-1;
    if(i+1==j)
    return dp[i][j]=max(a[i],a[j]);
    if(dp[i][j])
    return dp[i][j];
    else
    return dp[i][j] = max(a[i]+min(ans(i+2,j),ans(i+1,j-1)),a[j]+min(ans(i+1,j-1),ans(i,j-2)));
}
void solve(){
    int n;
    cin>>n;
    //int a[n];
    for(int i=0;i<n;i++){cin>>a[i];su+=a[i];}
    x=ans(0,n-1);
    y=su-x;
    cout<<(x-y);
    
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


Measured memory_bytes: 49904
#include<iostream>
#include<sstream>
#include <iomanip>
using namespace std;

int main()
{
	int n, count = 0, i, j, p;
	stringstream ss;
	cin>>n;
	while (cin>>n) {
		cout<<"Case "<<++count<<":"<<endl;
		for (i = 0; i < 10; i++) {
			ss.str("");
			ss<<setw(8)<<setfill('0')<<right<<n*n<<endl;
			n = 0; p = 1;
			for (j = 0; j < 4; j++) {
				n += p*(ss.str()[5-j]-'0');
				p *= 10;
			}
			cout<<n<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h = sc.nextInt();
		Sord[] sords = new Sord[n];
		int max = 0;
		for (int i = 0; i < n; i++) {
		    sords[i] = new Sord(sc.nextInt(), sc.nextInt());
		    max = Math.max(max, sords[i].small);
		}
		Arrays.sort(sords);
		int count = 0;
		for (int i = 0; i < n; i++) {
		    if (sords[i].big <= max) {
		        break;
		    }
		    h -= sords[i].big;
		    count++;
		    if (h <= 0) {
		        break;
		    }
		}
		if (h > 0) {
		    count += (h + max - 1) / max;
		}
        System.out.println(count);
   }
   
   static class Sord implements Comparable<Sord> {
       int small;
       int big;
       
       public Sord(int small, int big) {
           this.small = small;
           this.big = big;
       }
       
       public int compareTo(Sord another) {
           return another.big - big;
       }
   }
}




Measured memory_bytes: 92944
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>  
#include<set>
#include<iterator>
#include<list>
#include<utility>
#include<cstdlib>
#include<queue>
#include<stack>
#include<bitset>
//#include<bits/stdc++.h>
#define PI  2*acos(0.0)
#define pb push_back

       
using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;



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

ll n,d,p,q,cnt=0;
cin>>n>>d;
while(n--)
{
  cin>>p>>q;

ld ans=ceil(sqrt(p*p  +  q*q));

if(ans<=d) cnt++;


}
cout<<cnt<<"\n";



	
	
	return 0;
	
	
	       /***Israil Hosen
	            Computer Science & Engineering
	         University Of Rajshahi.
	         ***/
	
	
	
}

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

int w, h, n, x,ans, y, a, v[111][111];

int main()
{
    cin >> w >> h >> n;
    while(n--)
    {
        cin >> x >> y >> a;
        if(a==1)
        {
            for(int j = 1; j<=x; ++j)
                for(int i = 1; i<=h; ++i)
                    v[i][j]=1;
        }
        else if(a==2)
        {
            for(int j = x+1; j<=w; ++j)
                for(int i = 1; i<=h;++i)
                    v[i][j]=1;
        }
        else if(a==3)
        {
            for(int i=1;i<=y;++i)
                for(int j=1;j<=w;++j)
                    v[i][j]=1;
        }
        else
        {
            for(int i=y+1; i<=h;++i)
                for(int j = 1;j<=w;++j)
                    v[i][j]=1;
        }
    }

    for(int i =1;i<=h;++i)
        for(int j=1;j<=w;++j)
            if(!v[i][j])
                ++ans;
    cout << ans;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 
 
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
 
 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) return b; 
    return gcd(b % a, a); 
} 
 
int main(){
    
    fastio;
 
    ll t; t=1;
    while(t--){
        ld r; cin>>r;
        cout<<fixed<<setprecision(4)<<2*(3.1415)*r;
    }
    return 0;
}

Measured memory_bytes: 3756
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();

		int subX = x1 - x2;
		int subY = y1 - y2;


		System.out.println((x2 + subY) + " " + (y2 - subX) + " " + (x1 + subY) + " " + (y1 - subX));
		sc.close();
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<map>
using namespace std;

#define MAX 100

int main()
{
	int sum, tmpsum;
	int i;
	string letters;
	map<char, int> values;
	values['I'] = 1;
	values['V'] = 5;
	values['X'] = 10;
	values['L'] = 50;
	values['C'] = 100;
	values['D'] = 500;
	values['M'] = 1000;
	while (cin>>letters) {
		sum = 0;
		tmpsum = values[letters[0]];
		for (i = 1; i < letters.size(); i++) {
			if (values[letters[i-1]] == values[letters[i]]) {
				tmpsum += values[letters[i-1]];
			} else if (values[letters[i-1]] > values[letters[i]]) {
				sum += tmpsum;
				tmpsum = values[letters[i]];
			} else {
				sum -= tmpsum;
				tmpsum = values[letters[i]];
			}
		}
		sum += tmpsum;
		cout<<sum<<endl;
	}
	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int a , b , c , k ; 
  cin >> a >> b >> c >> k ;
  
  int ans = min(a,k) ;
  if(a+b < k){ 
    ans -= k-a-b ;
  }
  
  cout << ans ;
  
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H,W;
    cin >> H >> W;
    vector<string> G(H);
    for(int i=0; i<H; i++){
        cin >> G[i];
    }
    int ans = inf;
    for(int i=0; i<H-2; i++){
        int fst = 0;
        for(int h=0; h<=i; h++){
            for(int w=0; w<W; w++){
                if(G[h][w] != 'W') fst++;
            }
        }
        for(int j=i+1; j<H-1; j++){
            int sec = 0;
            for(int h=i+1; h<=j; h++){
                for(int w=0; w<W; w++){
                    if(G[h][w] != 'B') sec++;
                }
            }
            int thd = 0;
            for(int k=j+1; k<H; k++){
                for(int w=0; w<W; w++){
                    if(G[k][w] != 'R') thd++;
                }
            }
            chmin(ans,fst+sec+thd);
        }
    }
    cout << ans << enld;
    return 0;
}


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

int A, B;

int solve();

int main(){
  cin >> A;
  cin >> B;
  int count = 0;
  for(int i = 0; ; i++){
    if(B <= (1 + i  * (A-1))){
      count = i;
      break;
    }
  }
  cout << count << endl;
}


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

int main() {
	
	string code,str;
	int p=0, t[10]={},i,j,k,l;
	int a,b;
	
	code = ">+++++[<++++++>-]>+++++[<++++++++>-]>+++++[<++++++++++>-]>++++++[<++++++++++>-]>+++++++[<++++++++++>-]>++++++++[<++++++++++>-]>+++++++++[<++++++++++>-]>++++++++++[<++++++++++>-]>+++++++++++[<++++++++++>-]>++++++++++++[<++++++++++>-]<<<<<<<<<<";
	
	cin>>str;
	
	for(i=0;i<str.length();++i){
		a = (str[i]/10)-3;
		b = a - p;
		p = a;
		
		if(b>=0)for(j=0;j<b;++j)code+=">";
		else for(j=0;j>b;--j)code+="<";
		
		int c=str[i]-(a+3)*10;
		
		for(k=0;k<c;++k)code+="+";
		code+=".";
		for(k=0;k<c;++k)code+="-";
		
	}

	cout<<code<<endl;
	
	return 0;
}

Measured memory_bytes: 1240
def frog1(N,h):
    dp=[0]*(N+1)
    dp[0]=0
    dp[1]=abs(h[1]-h[0])

    for i in range(2,N):
        dp[i]=min((abs(h[i]-h[i-1])+dp[i-1]),(abs(h[i]-h[i-2])+dp[i-2]))

    return dp[N-1]


N=int(input())
h=list(map(int,input().split()))
print(frog1(N,h))

Measured memory_bytes: 13928
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    int n;
    cin>>n;
    unordered_map<string,long long> d;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        sort(All(s));
        d[s]++;
    }
    long long  res = 0;
    for(auto it:d){
        res+=it.second*(it.second-1)/2;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 10660
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>


int NL_num[100];
int NL[100][100];
int found[100];
int distance[100];



#define MAX_LENGTH  (100)

typedef struct{
    int array[MAX_LENGTH];
    int first;
    int last;
}QUEUE;

QUEUE pq;

void init(QUEUE*);
int enqueu(QUEUE*,int);
int dequeue(QUEUE*,int*);


void init(QUEUE* pQueue)
{
    int i;
    for(i = 0; i < MAX_LENGTH; i++){
        pQueue->array[i] = 0;
    }
    pQueue->first = 0;
    pQueue->last = 0;
}

int enqueue(QUEUE* pQueue,int value)
{
    if((pQueue->last + 1) % MAX_LENGTH == pQueue->first){
        return 0;
    }
    pQueue->array[pQueue->last] = value;
    pQueue->last = (pQueue->last + 1) % MAX_LENGTH;
    return 1;
}


int dequeue(QUEUE* pQueue,int* pValue)
{
    if(pQueue->first == pQueue->last)
    {
        return 0;
    }
    *pValue = pQueue->array[pQueue->first];
    pQueue->first = (pQueue->first+1) % MAX_LENGTH;
    return 1;
    
}

/*
 * NL:??£??\????????????????????????
 * NL_num:??£??\?????????NL???????????????????´??????????????´???°
 * ans:???????´???°?????°????????????????????????????´??????????????????????
 * ans_num:2?????\???
 * found:???????´???°?????????????????§???????????????????????????????????????????????°
 * ?¬??????¢?????????????´??????????
 */
void bfs(int n){
    
    int i, num,index, flag;
    index = n-1;
    
    //???????????????????????´????????????found????????°????????????
    if (!found[index]) {
        found[index] = 1;
    }
    
    enqueue(&pq, index);
    flag = dequeue(&pq, &index);
    
    
    while (flag) {
        num = NL_num[index];
        for (i=0; i < num; i++) {
            
            if ( !found[ NL[index][i] - 1 ] ) {
                enqueue(&pq, NL[index][i] - 1);
                distance[NL[index][i] - 1] = distance[index] + 1;
                found[ NL[index][i] - 1 ]  = 1;
            }
        }
        flag = dequeue(&pq, &index);
    }
    
    return;
    
}

int main(){
    
    int i,j,n, cn, v, u;
    
    //the number
    scanf("%d",&n);
    u = 0;
    
    for (i=0; i < n; i++) {
        scanf("%d %d",&u, &cn);
        NL_num[u-1] = cn;
        for (j=0; j < cn; j++) {
            scanf("%d",&v);
            NL[u-1][j] = v;
        }
    }
    
    for (i=0; i < n; i++) {
        distance[i] = -1;
    }
    
    distance[0] = 0;
    
    bfs(1);
    
    for (i=0; i<n; i++) {
        printf("%d %d\n", i+1, distance[i]);
    }
    
    return 0;
}

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

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

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int i, j, r, c, a, sum;
    cin>>r>>c;
    vector<vector<int>> mat(r, vector<int>(c));
    vector<int> sumr(r);
    vector<int> sumc(c);
    rep(i, r) {
        rep(j, c) {
            cin>>a;
            mat[i][j] = a;
            sumr[i] += mat[i][j];
            sumc[j] += mat[i][j];
        }
    }

    rep(i, r) {
        rep(j, c) {
            cout<<mat[i][j]<<" ";
        }
        cout<<sumr[i]<<endl;
    }
    sum = 0;
    rep(j, c) {
        sum += sumc[j];
        cout<<sumc[j]<<" ";
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3164
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#include <unordered_map>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;

int N, S[100010];
unordered_map<int, int> dp[100010];

void solve(int k, int C) {
    if(dp[k].count(C) and dp[k][C] != -INF) return;
    if(k > 0) {
        solve(k-1, C);
        int A = N - 1 - k*C;
        dp[k][C] = dp[k-1][C] + S[A] + S[k*C]; 
    }
    else dp[k][C] = 0;
}

signed main() {
    cin >> N;
    for(int i=0; i<N; i++) cin >> S[i];

    // ありえる k, C の列挙
    for(int A=1; A<=N-2; A++) {
        int kC = N - 1 - A;

        // 約数列挙
        vector<int> ks;
        for(int k=1; k*k<=kC; k++) {
            if(kC % k == 0) {
                ks.push_back(k);
                if(k*k != kC) ks.push_back(kC/k);
            }
        }

        for(const auto &d : ks) {
            int k = d, C = kC / d;
            dp[k][C] = -INF;
        }
    }

    for(int k=N-1; k>=1; k--) {
        for(auto &e : dp[k]) {
            int C = e.first;
            solve(k, C);
        }
    }

    int ans = 0;
    for(int k=N-1; k>=0; k--) {
        for(auto &e : dp[k]) {
            int C = e.first, val = e.second;
            int A = N - 1 - k*C;

            if(A <= 0 or C <= 0 or A <= C) continue;
            if(A%C == 0 and 0 <= A/C and A/C <= k) continue;
            chmax(ans, val);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 69040
#include<stdio.h>
#include<math.h>
void hidariokiku(int *hidari, int *migi);
//this file is not a C file but a C++ file                                      

int main(void){
    int inpnum;//最初の数字の記憶                                               
    int a,b,c;//辺の長さを記憶                                                  

    for(scanf("%d", &inpnum); inpnum != 0; inpnum -= 1) {
        scanf(" %d %d %d", &a, &b, &c);
        //a > b > cの形に持っていく                                             
        hidariokiku(&a, &b);
        hidariokiku(&b, &c);
        hidariokiku(&a, &b);
        //判定                                                                  
        if(pow(a, 2) == pow(b, 2) + pow(c, 2)) {
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}

void hidariokiku(int *hidari, int *migi) {
  int space;
    if(*hidari < *migi) {
        space = *hidari;
        *hidari = *migi;
        *migi = space;
    }
}

Measured memory_bytes: 1008
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

const i32 mod = 1000000007;

i32 mod_pow (i32 r, i32 n) {
  i32 t = 1;
  i32 s = r;
  while (n > 0) {
    if (n & 1) t = (i64) t * s % mod;
    s = (i64) s * s % mod;
    n >>= 1;
  }
  return t;
}

i32 inv (i32 a) {
  return mod_pow (a, mod - 2);
}

i32 *fact = NULL;
i32 *iFact = NULL;
void init_fact (const i32 n) {
  fact = (i32 *) calloc (n + 1, sizeof (i32));
  fact[0] = 1;
  for (i32 i = 1; i <= n; ++i) {
    fact[i] = (i64) i * fact[i - 1] % mod;
  }
  iFact = (i32 *) calloc (n + 1, sizeof (i32));
  iFact[n] = inv (fact[n]);
  for (i32 i = n - 1; i >= 0; --i) {
    iFact[i] = (i64) (i + 1) * iFact[i + 1] % mod;
  }
}

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void run (void) {
  i32 n, h, d;
  scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &n, &h, &d);
  init_fact (n);
  i64 p = 0;
  for (i32 i = 1; i <= n; ++i) {
    p += fact[i];
  }
  p %= mod;
  i32 *dp = ALLOC (h + d, i32) + d;
  dp[0] = fact[n];
  i64 sum = dp[0];
  for (i32 i = 1; i < h; ++i) {
    dp[i] = sum * p % mod;
    sum = (sum + dp[i] + mod - dp[i - d]) % mod;
  }
  printf ("%" PRIi64 "\n", sum);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 13824
from heapq import heappush, heappop

INF = 10 ** 12

V, E, r = map(int, input().split())
edges_lst = [[] for _ in range(V)]
dist_lst = [INF for _ in range(V)]

for _ in range(E):
    s, t, dist = map(int, input().split())
    edges_lst[s].append((t, dist))

que = []
heappush(que, (0, r))
dist_lst[r] = 0

while que:
    dist, node = heappop(que)
    for to, cost in edges_lst[node]:
        if dist_lst[to] > cost + dist:
            dist_lst[to] = cost + dist
            heappush(que, (cost + dist, to))

for dist in dist_lst:
    if dist == INF:
        print('INF')
    else:
        print(dist)


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

double r[1024];
double d[1024];
int n;

int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) {
    scanf("%lf", &r[i]);
    d[i] = r[i];
    for(int j = 0; j < i; ++j) {
      double dz = (r[i] + r[j]);
      double dy = std::abs(r[i] - r[j]);
      double dx = sqrt(dz * dz - dy * dy);
      d[i] = std::max(d[i], d[j] + dx);
    }
  }

  double res = 0.0;
  for(int i = 0; i < n; ++i) {
    res = std::max(res, d[i] + r[i]);
  }
  printf("%.20lf\n", res);
  
  return 0;
}

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

int main(){
    int n,k,ans=0;
    cin >> n >> k;
    for(int i = 0 ; i < n ; i += 1){
        int a;
        cin >> a;
        if(a >= k){
            ans += 1;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    double a[n+1][n+1];
    double b[n+1];
    for(int i=1;i<=n;i++){ 
        cin>>b[i];
        
    }
    a[0][0]=1;
    for(int i=1;i<=n;i++){
        a[0][i]=a[0][i-1]*b[i];
        a[i][0]=0;
       // cout<<a[0][i]<<" ";
    }
//    cout<<ceil((float)n/2)<<endl;
    for(int i=1;i<ceil((float)n/2);i++){
        for(int j=1;j<=n;j++){
            a[i][j]=a[i][j-1]*b[j]+a[i-1][j-1]*(1-b[j]);
          ///   cout<<a[i][j]<<" "; 
        }
        //cout<<endl;
    }
    double l=0;
    for(int i=0;i<ceil((float)n/2);i++){
        l=l+a[i][n];
        
    }
    printf("%.10lf",l);//dl<<endl;
    
    
}

Measured memory_bytes: 70144
N, W = list(map(int, input().split()))
v = [0 for i in range(N)]
w = [0 for i in range(N)]
for i in range(N):
    v[i], w[i] = list(map(int, input().split()))
dp = [[-1 for j in range(W + 1)] for i in range(N + 1)]

def rec(i, j):
    if dp[i][j] != -1:
        return dp[i][j]
    if i == N:
        res = 0
    elif j < w[i]:
        res = rec(i + 1, j)
    else:
        res = max(rec(i + 1, j),rec(i + 1, j - w[i]) + v[i])
    dp[i][j] = res
    return res

print(str(rec(0, W)))

Measured memory_bytes: 26188