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

// 💖 Hi, thanks for using ICIE! 💖
// 🔧 To use a custom code template, press Ctrl+Shift+P and select "ICIE Template configure" from the list 🔧
// 📝 If you spot any bugs or miss any features, create an issue at https://github.com/pustaczek/icie/issues 📝

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N, K;
    int h[100005], dp[100005];
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> h[i];
        dp[i] = 2e9;
    }
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]); 
    for (int i = 1; i < N; i++) {
        for (int j = 1; j <= K && i >= j; j++) {
            int c2 = dp[i - j] + abs(h[i] - h[i - j]);
            dp[i] = min(dp[i], c2);
        }
    }
    cout << dp[N - 1];
}


Measured memory_bytes: 4400
nums = list(map(int, input()))

ans_map = {}
for i in range(3):
    if i == 0:
        ans_map['+'] = nums[0] + nums[1]
        ans_map['-'] = nums[0] - nums[1]
        continue

    for operators in dict.fromkeys(ans_map):
        tmp_val = ans_map[operators]
        if i == 2:
            if tmp_val + nums[i + 1] == 7:
                print('{}{}{}{}{}{}{}=7'.format(
                    nums[0],
                    operators[0],
                    nums[1],
                    operators[1],
                    nums[2],
                    '+',
                    nums[3]
                ))
                break

            if tmp_val - nums[i + 1] == 7:
                print('{}{}{}{}{}{}{}=7'.format(
                    nums[0],
                    operators[0],
                    nums[1],
                    operators[1],
                    nums[2],
                    '-',
                    nums[3]
                ))
                break
            continue

        ans_map[operators + '+'] = tmp_val + nums[i + 1]
        ans_map[operators + '-'] = tmp_val - nums[i + 1]
        del ans_map[operators]

Measured memory_bytes: 3064
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 = new int[n + 1];
		int[] l = new int[n + 1];
		int[] r = new int[n + 2];
		int[] m = new int[n + 1];
		l[0] = 0;
		r[n + 1] = 0;

		for (int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
		}

		for (int i = 0; i < n; i++) {
			l[i + 1] = gcd(l[i], a[i]);
		}

		for (int i = n; i > 0; i--) {
			r[i] = gcd(r[i + 1], a[i]);
		}

		for (int i = 0; i <= n; i++) {
//			System.out.println("i:" + i + ", " + l[i] + ", " + r[i]);
		}

		for (int i = 1; i <= n; i++) {
			m[i] = gcd(l[i], r[i + 1]);
//			System.out.println("i:" + i + ", m[" + i + "]:" + m[i]);
		}

		int max = 0;
		for (int i = 1; i <= n; i++) {
			if (m[i] > max) {
				max = m[i];
			}
		}

		System.out.println(max);
		sc.close();

	}

	public static int gcd(int m, int n) {
		if (m < n)
			return gcd(n, m);
		if (n == 0)
			return m;
		return gcd(n, m % n);
	}

}

Measured memory_bytes: 61264
#template
def inputlist(): return [int(j) for j in input().split()]
#template
N = int(input())
L = inputlist()
L.sort()
ans = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i]+ L[j] > L[k] and L[i] != L[j] and L[j] != L[k]:
                ans +=1
print(ans)

Measured memory_bytes: 9124
{-# OPTIONS_GHC -O3 #-}
{-# LANGUAGE ViewPatterns, ScopedTypeVariables #-}

import qualified Data.ByteString as B (getLine)
import qualified Data.ByteString.Char8 as C (readInt, words, unpack, reverse, dropWhile)
import qualified Data.Maybe as M (fromJust)
import Data.Char as C (isSpace)

readInt = fst . M.fromJust . C.readInt
rstrip = C.reverse . C.dropWhile C.isSpace . C.reverse

f k x = 2 * min x (k - x)

main = do
    (map readInt . C.words -> [n]) <- B.getLine
    (map readInt . C.words -> [k]) <- B.getLine
    (map readInt . C.words -> xs) <- B.getLine
    putStrLn $ show $ sum $ map (f k) xs


Measured memory_bytes: 508
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1173&lang=jp

#include <iostream>
#include <string>
#include <stack>
using namespace std;

// 方針：'('を見たら')'をStに入れる。'['を見たら']'をSに入れる。
// ']'を見たらStがemptyでなくtopが']'であることを確かめてpopする。
// ')'もおなじ。
// おかしくなったらその瞬間にno。だめでなければyes。
// ……ではなく、ダメでなかった場合は、Stが空ならyesである。

string S;

bool ok() {
  stack<char> St;
  for (unsigned int i=0; i<S.size(); i++) {
    switch(S[i]) {
    case '(':
      // cerr << S[i] << " pushed." << endl;
      St.push(')');
      break;
    case '[':
      // cerr << S[i] << " pushed." << endl;
      St.push(']');
      break;
    case ')':
      if (!St.empty() && St.top() == ')') {
	// cerr << S[i] << " popped." << endl;
	St.pop();
	break;
      } else {
	// cerr << "fails." << endl;
	return false;
      }
    case ']':
      if (!St.empty() && St.top() == ']') {
	// cerr << S[i] << " popped." << endl;
	St.pop();
	break;
      } else {
	// cerr << "fails." << endl;
	return false;
      }
    default: break;
    }
  }
  return St.empty();
}

int main() {
  while (getline(cin, S) && S != ".") {
    if (ok()) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n, k;
    cin >> n >> k;
    int ans = k;

    for(int i = 1; i < n; i++) 
        ans *= (k-1);

    cout << ans << endl;

  
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int MAXN=100000+2;
int a[MAXN],b[MAXN];
int tot=0,k;
void wwq(int n,int m){
	if(a[m]==k){
		tot++;
		return;
	}
	if(a[(n+m)/2]==k){
		tot++;
		return;
	}
	if(a[(n+m)/2]!=k)
		if(a[(n+m)/2]<k){
		   if((n+m)/2!=n) wwq((n+m)/2,m);
		}
		else {
		   if((n+m)/2!=m) wwq(n,(n+m)/2);
        }
	
}
int main(){
	int n,q;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	cin>>q;
	for(int i=1;i<=q;i++) cin>>b[i];
	for(int i=1;i<=q;i++){
		k=b[i];
		wwq(1,n);
	}
	cout<<tot<<endl;
	return 0;	
} 

Measured memory_bytes: 3596
#include<iostream>

using namespace std;

int main()
{
	for(int n;cin>>n,n;){
		int sa=0,sb=0;
		for(int i=0;i<n;i++){
			int a,b;	cin>>a>>b;
			if     (a>b)	sa+=a+b;
			else if(a<b)	sb+=a+b;
			else			sa+=a,sb+=b;
		}
		cout<<sa<<' '<<sb<<endl;
	}
	return 0;
}

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

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const bool DEBUG = 0;
const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	string s; cin>>s;
	int ans=0, cnt=0;
	forn(i,0,3){
		if(s[i]=='R'){
			cnt++;
		}
		else{
			ans=max(ans, cnt);
			cnt=0;
		}
	}
	ans=max(ans, cnt);
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 3620
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b,c = map(int, input().split())
    print(max(0, c-a+b))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3436
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> intint;

int main(void)
{
    
    int a,b,c;
    cin >> a >> b >> c;
    if(a >= b && a >= c){
        pr(a*10+b+c);
    }else if(b >= a && b >= c){
        pr(a+b*10+c);
    }else{
        pr(a+b+c*10);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 1 << 50;

const ll MOD = 1000000007;


ll a[100010];
ll ab[100010];
ll abc[100010];
ll dp[100010][5];
ll weloveabc(){
    char S[100010];
    int slong = 0;
    while((S[slong] = getchar()) != '\n'){
        slong++;
    }
    int m1, m2;
    char ABC[3] = {'A', 'B' ,'C'};
    dp[slong][3] = 1;
    REP(i, slong){
        REP(j, 4){
            if(S[slong - i - 1] == '?'){
                m1 = 3;
            }else{
                m1 = 1;
            }
            if((S[slong - i - 1] == ABC[3 - j] || S[slong - i - 1] == '?') && j != 0){
                m2 = 1;
            }else{
                m2 = 0;
            }
            dp[slong - i - 1][3 - j] = (dp[slong - i][3 - j] * m1 + dp[slong - i][4 - j] * m2) % MOD;
            
        }
    }
    
    return dp[0][0] % MOD;
}
/*
int dp[20][1010];
int p[20];
int c[20];
int allgreen(){
    int D, G;
    cin >> D >> G;
    G /= 100;
    int mondaisuu = 0;
    REP(i, D){
        int cc;
        cin >> p[i] >> cc;
        c[i] = cc / 100;
    }
    
    REP(i, D){
        REP(j, p[i]){
            mondaisuu ++;
            for(int k = mondaisuu; k > j; k --){
                int bonasu = 0;
                if(j + 1 == p[i]){bonasu = c[i];}
                dp[i + 1][k] = max(dp[i][k], dp[i][k - j - 1] + (i + 1) * (j + 1) + bonasu);
            }
        }
    }
    int saishoumondaisuu = 0;
    REP(i, mondaisuu + 1){
        if(dp[D][i] >= G){
            saishoumondaisuu = i;
            break;
        }
    }
    
    return saishoumondaisuu;
}
*/
int main(){
    
    
   /* char S[20];
    int i = 0;
    bool mitasu = true;
    while((S[i] = getchar()) != '\n'){
        i++;
    }
    
    if(S[0] != 'A')mitasu = false;
    bool is_C = false;
    for(int j = 2; j < i - 1; j++){
        if(S[j] == 'C'){
            is_C = true;
            S[j] = 'c';
            break;
        }
    }
    if(!is_C)mitasu = false;
    bool komoji = true;
    for(int j = 1;j < i; j++){
        if(S[j] >= 'a' && S[j] <= 'z'){
        }else{
            komoji = false;
            break;
        }
    }
    if(!komoji)mitasu = false;
    if(mitasu)printf("AC\n");
    else {printf("WA\n");}
    */
    printf("%lld\n",weloveabc());
}


Measured memory_bytes: 4608
#include <iostream>
int main(){
	int a,b;
	std::cin >> a;
	std::cin >> b;
	if(a < b){
		std::cout << "a < b" <<std::endl;
	}
	if(a > b){
		std::cout << "a > b" <<std::endl;
	}
	if(a == b){
		std::cout << "a == b" << std::endl;
	}}

Measured memory_bytes: 3092
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =2e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
char s[MAXN];
int main()
{
	//前R后W 
	//大体思路 从前往后一遍 到第i个前面有几个r几个w 后面有几个r几个w 然后贪心 
	//因为需要前面R 后面W 所以前面w的个数个后面r的个数的max值 
	int n;
	scanf("%d",&n);
	scanf("%s",s+1);
	int ans=inf,r=0,w=0;
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='R') r++;
		else w++;
	}
	int r1=0,w1=0,r2=r,w2=w;
	for(int i=0;i<=n;i++)
	{
		ans=min(ans,max(w1,r2));
		if(i)
		{
			if(s[i]=='R')
			{
				r1++;
				r2--;
			}
			else
			{
				w1++;
				w2--;
			}
		} 
	}
	ans=min(ans,max(w1,r2));
	printf("%d\n",ans);
	return 0;
}

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

int main(void){
  int n, r;
  while(cin >> n >> r){
    vector<int> C(n);
    for(int i=0; i < n; i++){
      C[i] = i;
    }
    for(int i=0; i < r; i++){
      vector<int> A;
      vector<int> B;
      if(n%2 == 0){
        A = vector<int>(n/2); B = vector<int>(n/2);
      }else{
        A = vector<int>((n/2)+1); B = vector<int>(n/2);
      }
      for(int i=0; i < B.size(); i++){
        B[i] = C[i];
      }
      for(int i=0; i < A.size(); i++){
        A[i] = C[i+B.size()];
      }
      int c; cin >> c;
      int ind_A = 0, ind_B = 0, ind_C = 0;
      while(!((int)A.size() == ind_A && (int)B.size() == ind_B)){
        for(int i=0; i < C.size(); i++){
        }
        int rep;
        rep = min((int)A.size()-ind_A, c);
        for(int i=0; i < rep; i++){
          C[i+ind_C] = A[ind_A+i];
        }
        ind_C += rep; ind_A += rep;

        rep = min((int)B.size()-ind_B, c);
        for(int i=0; i < rep; i++){
          C[i+ind_C] = B[ind_B+i];
        }
        ind_C += rep; ind_B += rep;
      }
    }
    cout << C[n-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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 (b<a) { a=b; return 1; } return 0; }

int mod(int x, int d){
    if(x%d==0){
        return x/d;
    }else{
        return x/d + 1;
    }
}

int main()
{
    int n, k; cin >> n >> k;
    int l , r;
    rep(i, n){
        cin >> l;
        if(l==1) {l=i; break;}
    }

    int ans = INF;
    for(int i=l-k+1; i<=l; i++){
        if(i<0) continue;
        if(i+k-1>=n) continue;

        int left, right, t;
        left = i;
        right = n - i - k;
        chmin(ans, 1+mod(left, k-1) + mod(right, k-1));
    }   
    pr(ans);
    return 0;}

Measured memory_bytes: 3580
#coding:utf-8
n = int(input())
List = list(map(int,input().split()))
sort = sorted(List)

l = sort[n // 2 - 1]
r = sort[n // 2]
for i in range(n):
    num = List[i]
    if num <= l:
        print(r)
    else:
        print(l)
    


Measured memory_bytes: 26772
#include <iostream>  
#include <cstdio>  
#include <cstring>  
#include <algorithm>  
  
using namespace std;  
const int maxn=2e5+100;  
int par[maxn],sum[maxn];  
int N,K,p,tot;  
  
void init(int n)  
{  
    for(int i=0;i<=n;i++)  
        par[i]=i;  
}  
  
int find(int x)  
{  
    if(par[x]==x)  
        return x;  
    return par[x]=find(par[x]);  
}  
void unit(int x,int y)  
{  
    int fx=find(x),fy=find(y);  
    if(fx!=fy)  
        par[fx]=fy;  
}  
bool same(int x,int y)  
{  
    return find(x)==find(y);  
}  
int main()  
{  
    while(~scanf("%d%d",&N,&K))  
    {  
        int ans=0;  
        memset(sum,0,sizeof(sum));  
        memset(par,0,sizeof(par));  
        tot=0;  
        init(N);  
        int t;  
        scanf("%d",&t);  
        sum[t]++;  
        p=t;  
        tot++;  
        for(int i=2;i<=N;i++)  
        {  
            scanf("%d",&t);  
            sum[t]++;  
            if(!same(t,p))  
            {  
                tot++;  
                unit(t,p);  
            }  
        }  
        sort(sum,sum+N+1);  
        if(tot<=K)  
            ans=0;  
        else  
        {  
            int cnt=tot-K;  
            int pos=lower_bound(sum,sum+N+1,1)-sum;  
            while(cnt--)  
                ans+=sum[pos++];         
        }  
        printf("%d\n",ans);  
    }  
    return 0;  
}

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

int main(){
    int m,f,r;
    while (1){
        cin >> m >> f >> r;
        if (m==-1 && f==-1 && r==-1) break;
        
        if (m==-1 || f ==-1) cout << "F" << "\n";
        else if (m+f>=80) cout << "A" << "\n";
        else if (m+f>=65 && m+f<80) cout << "B" << "\n";
        else if (m+f>=50 && m+f<65) cout << "C" << "\n";
        else if (m+f>=30 && m+f<50){
            if (r>=50) cout << "C" << "\n";
            else cout << "D" << "\n";
        }
        else if (m+f<30) cout << "F" << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 3016
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

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


int main() {
    int h,w;
    cin >> h >> w;
    char c[60][60];
    int wsum = 0;
    rep(i,h) rep(j,w) {
        cin >> c[i][j];
        if(c[i][j] == '.') wsum++;
    }
    int dist[60][60];
    rep(i,h) rep(j,w) dist[i][j] = INF;
    queue<P>q;
    q.push({0,0});
    dist[0][0] = 1;
    while(!q.empty()) {
        P p = q.front();q.pop();
        int x ,y;
        x = p.first; y = p.second;
        rep(i,4) {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if(ny < 0 || ny >= w || nx < 0 || nx >= h) continue;
            if(c[nx][ny] == '#') continue;
            if(dist[nx][ny] == INF) {
                dist[nx][ny] = dist[x][y] + 1;
                q.push({nx,ny});
            }
        }
    }
    if(dist[h-1][w-1] == INF) cout << -1 << endl;
    else cout << wsum - dist[h-1][w-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF = 0x1fffffffffffffff;
int main(){
    string s;
  cin>>s;
  if(s=="SUN")cout<<"7"<<endl;
  else if(s=="MON")cout<<"6"<<endl;
  else if(s=="TUE")cout<<"5"<<endl;
  else if(s=="WED")cout<<"4"<<endl;
  else if(s=="THU")cout<<"3"<<endl;
  else if(s=="FRI")cout<<"2"<<endl;
  else if(s=="SAT")cout<<"1"<<endl;
}


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

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

    int ans;

    if( (X >= 400) && (X < 600) ){
        ans = 8;
    }
    if( (X >= 600) && (X < 800) ){
        ans = 7;
    }
    if( (X >= 800) && (X < 1000) ){
        ans = 6;
    }
    if( (X >= 1000) && (X < 1200) ){
        ans = 5;
    }
    if( (X >= 1200) && (X < 1400) ){
        ans = 4;
    }
    if( (X >= 1400) && (X < 1600) ){
        ans = 3;
    }
    if( (X >= 1600) && (X < 1800) ){
        ans = 2;
    }
    if( (X >= 1800) && (X < 2000) ){
        ans = 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>

using namespace std;

int main()
{
	int x;
	int i = 1;
	while(true) {
		cin >> x;
		if(x == 0) break;
		else {
			cout << "Case " << i << ": " << x << endl;
		}
		++i;

	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {    
    ll k;
    cin >> k;
    string ans="";
    string x="ACL";
    for(ll i=0;i<k;i++){
        ans+=x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll H,W;
  cin>>H>>W;
  for(ll i=0;i<W+2;i++) {
cout<<'#';
  }
  cout<<endl;
  for(ll i=0;i<H;i++) {
    string S;
    cin>>S;
    S='#'+S+'#';
    cout<<S<<endl;
  }
   for(ll i=0;i<W+2;i++) {
cout<<'#';
  }
  cout<<endl;
}
  
  
  
  
  

  

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

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

        final String s = sc.next();
        final char[] c = s.toCharArray();

        if (   (c[0] == c[1] && c[0] != c[2] && c[0] != c[3] && c[2] == c[3])
            || (c[0] == c[2] && c[0] != c[1] && c[0] != c[3] && c[1] == c[3])
            || (c[0] == c[3] && c[0] != c[1] && c[0] != c[2] && c[1] == c[2])) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int N = 3005, mo = 1e9 + 7 ;
using namespace std ;

int n, m, f[N][N][2] ;

void upd(int &x, int y) {
	x = (x + y) % mo ;
}

int main() {
	scanf("%d%d", &n, &m) ;
	f[0][0][1] = 1 ; rep(i, 1, n) f[0][i][0] = 1 ;
	rep(i, 1, m) rep(j, 0, n) {
		if (j) upd(f[i][j - 1][(j == 1 ? 1 : 0)], f[i - 1][j][0]), upd(f[i][j - 1][1], f[i - 1][j][1]) ;
		if (j) upd(f[i][j][(j == 1 ? 1 : 0)], f[i - 1][j][0]), upd(f[i][j][1], f[i - 1][j][1]) ;
		if (j < n) upd(f[i][j][0], f[i - 1][j][0]), upd(f[i][j][1], f[i - 1][j][1]) ;
		if (j < n) upd(f[i][j + 1][0], f[i - 1][j][0]), upd(f[i][j + 1][1], f[i - 1][j][1]) ;
	}
	int ans = 0 ;
	rep(i, 0, n) upd(ans, f[m][i][1]) ;
	printf("%d\n", ans) ;
	return 0 ;
}

Measured memory_bytes: 70656
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args){
        Scanner ir=new Scanner(System.in);
        for(;;){
            int n=ir.nextInt();
            int l=ir.nextInt();
            int r=ir.nextInt();
            if(n==0){
                return;
            }
            int[] a=new int[n];
            for(int i=0;i<n;i++){
                a[i]=ir.nextInt();
            }
            int ct=0;
            outer:
            for(int i=l;i<=r;i++){
                for(int j=0;j<n;j++){
                    if(i%a[j]==0){
                        if(j%2==0){
                            ct++;
                        }
                        continue outer;
                    }
                }
                if(n%2==0){
                    ct++;
                }
            }
            System.out.println(ct);
        }
    }
}


Measured memory_bytes: 31836
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define mkp make_pair

int32_t main()
{
 int t=1;
 //cin>>t;
while(t--)
{
	int n,k;
    cin>>n>>k;
   int a[n+1],dp[n+1];
   for(int i=1;i<=n;i++)cin>>a[i];
     for(int i=1;i<=n;i++)dp[i]=INT_MAX;
          dp[1]=0;
     dp[2]=abs(a[1]-a[2]);  
     for(int i=1;i<=n;i++)
     {
           for(int j=1;j<=k&&i+j<=n;j++)
           {
			   dp[i+j]=min(dp[i]+abs(a[i+j]-a[i]),dp[i+j]); 
		   }        
	 }
         	cout<<dp[n]<<endl;
    
}
   
}


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

void foo(int n){
	if(0<n){
		foo(n/4);
		cout<<(n%4);
	}
}

main(){
	while(true){
		int n;
		cin>>n;
		
		if(n<0){
			break;
		}
		
		if(0<n){
			foo(n);
			cout<<endl;
		}else{
			puts("0");
		}
	}
}


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

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i=0; i<N; i++) cin >> P.at(i);
  int m = P.at(0), ans = 1; // 部分列の最小値
  for (int i=0; i+1<N; i++) {
    if (P.at(i+1)<=m) {
      m = min(m, P.at(i+1));
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<climits>
using namespace std;
int main(){
  int n;
  int minus=0;
  int minimum=INT_MAX;
  long long sum=0;

  cin>>n;
  for(int i=0;i<n;i++){
    int data;
    cin>>data;
    sum+=abs(data);
    if(data<0){
      minus++;
    }
    minimum=min(minimum,abs(data));
  }

  if(minus%2==0){
    cout<<sum<<endl;
  }else{
    cout<<sum-minimum*2<<endl;
  }
  return(0);
}



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

int main() {
    int N;
    vector<int> X;
    vector<int> sortedX;

    cin >> N;
    for(int i=0; i<N; i++) {
        int x;
        cin >> x;
        X.push_back(x);
        sortedX.push_back(x);
    }

    sort(sortedX.begin(), sortedX.end());
    
    auto itr = sortedX.end();
    for(int i=0; i < N/2; i++) {
        itr--;
    }

    for(int i=0; i<N; i++) {
        if(X[i] < *itr) {
            cout << *itr << endl;
        } else {
            cout << *(itr-1) << endl;
        }
    }
}

Measured memory_bytes: 3948
// AOJ 0320: Quality Management
// 2017.11.14 bal4u@uu

#include <stdio.h>

int n, n1, n2;

char m[1002][1002];
char s[502][502];

char *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int sum(int r, int c)
{
	return s[r][c] = (m[r][c]+m[n1-r][c]+m[r][n1-c]+m[n1-r][n1-c]) & 3;
}

int main()
{
	int t, d, r, c, f1, f2, diff, ans;
	char buf[20];

	fgets(p=buf, 20, stdin), t = getint(), p++, n = getint();
	n1 = n-1, n2 = n >> 1;
	diff = 0, ans = 0;

	for (r = 0; r < n; r++) fgets(m[r], 1002, stdin);
	for (r = 0; r < n2; r++) for (c = 0; c < n2; c++)
		if (sum(r, c)) diff++;
	if (!diff) ans++;

	while (--t) {
		fgets(p=buf, 20, stdin), d = getint();
		while (d--) {
			fgets(p=buf, 20, stdin);
			r = getint()-1, p++, c = getint()-1;
			m[r][c] = '1' - (m[r][c] & 0xf);
			if (r >= n2) r = n1-r;
			if (c >= n2) c = n1-c;
			f1 = s[r][c], f2 = sum(r, c);
			if      ( f1 && !f2) diff--;
			else if (!f1 &&  f2) diff++;
		}
		if (!diff) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2964
#include<iostream>

using namespace std;

int ban[100][100];
int h, w;
int MAX;

int saiki(int x, int y, int cont)
{
	ban[y][x] = 0;
	cont++;
	/*
	cout << x << " "<<y << endl;
	
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cout << ban[i][j] <<" " << flush;
		}
		cout << endl;
	}
	
	cout << endl;
	
	getchar();
	*/
	if(ban[y+1][x] == 1 && y+1 < h){
		saiki(x,y+1,cont);
		ban[y+1][x] = 1;
	}
	if(ban[y-1][x] == 1 && y-1 > -1){
		saiki(x,y-1,cont);
		ban[y-1][x] = 1;
	}
	if(ban[y][x+1] == 1 && x+1 < w){
		saiki(x+1, y, cont);
		ban[y][x+1] = 1;
	}
	if(ban[y][x-1] == 1 && x-1 > -1){
		saiki(x-1, y, cont);
		ban[y][x-1] = 1; 
	}
	
//	ban[y][x] = 1; 
	
	if(MAX < cont){
		MAX = cont;
	}
//	cout << "ツ終ツ猟ケ" << endl;
	return cont;
	
}

int main()
{
	for(;;){
		int cont = 0;
		int ban_temp[100][100];
		MAX = 0;
		
		cin >> w >> h;
		
		if(w == 0){
			break;
		}
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> ban[i][j];
				ban_temp[i][j] = ban[i][j];
			}
		}
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				
	//			printf("ツ始ツ点ツ：(%d,%d)\n",j,i);
				if(ban[i][j] == 1){
					saiki(j,i,0);
					for(int i = 0; i < h; i++){
						for(int j = 0; j < w; j++){
							ban[i][j] = ban_temp[i][j];
						}
					}
				}
			}
		}
		
		cout << MAX << endl;
	}
}

Measured memory_bytes: 936
# -*- utf8 -*-

arg = gets.chomp

arg = arg.split(" ")

a = arg[0].to_i
b = arg[1].to_i
c = arg[2].to_i

pens = []

if !pens.include?(a)
    pens.push(a)
end

if !pens.include?(b)
    pens.push(b)
end

if !pens.include?(c)
    pens.push(c)
end

puts pens.size

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    int a = 0;
    each(c, s) {
        if (a == 0 && c == 'C')++a;
        else if (a == 1 && c == 'F')++a;
    }
    cout << (a == 2 ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	String[] str=line.split(" ");
            	int a=Integer.parseInt(str[0]);
            	int b=Integer.parseInt(str[1]);
            	int c=Integer.parseInt(str[2]);
            	int max=Integer.max(Integer.max(a,b), c);
            	int min=Integer.min(Integer.min(a,b), c);
            	int mid=0;
            	
            	if(max==a||min==a){
            		if(max==b||min==b){
            			mid=c;
                	}else{
                		mid=b;
                	}
            	}
            	if(max==b||min==b){
            		if(max==a||min==a){
            			mid=c;
                	}else{
                		mid=a;
                	}
            	}
            	System.out.println(min+" "+mid+" "+max);
            	break;
            }
        }
    }
}

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

#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation;
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define puf push_front
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){ll c; while(b!=0){c=a%b; a=b; b=c;} return a;}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a * c%mod;} a=a * a%mod; b>>=1;} return c;}
vi calc(ll x){vi res; while(x>0){res.pb(x%10); x/=10;} reverse(all(res)); return res;}

void solve() {
  ll n; cin>>n;
  vi D(n); rep(i,n) cin>>D[i];
  sort(all(D)); ll ans=1;
  rep(i,n-1){
    if(D[i]<D[i+1]) ans++;
  }
  out(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

// DAME:
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans  = 0;
    for(ll i = 0; i<60; i++){
        int x = 0;
        int y = 0;
        rep(j, n){
            if(a[j] & (1LL<<i)){
                x++;
            }else{
                y++;
            }
        }
        if(x==n or y==n) continue;
        ll tmp = (1L << i) % mod;
        tmp *= (x % mod);
        tmp %= mod;
        tmp *= (y % mod);
        tmp %= mod;
        ans += tmp;
        ans %= mod;
    }

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

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

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

    int n, k;
    cin >> n >> k;

    if (n >= k * 2 - 1) {
        cout << "YES"  << '\n';
    } else {
        cout << "NO"  << '\n';
    }


    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::BinaryHeap;

struct Graph {
    node: usize,
    directed: bool,
    graph: Vec<Vec<(usize, i64)>>,
}

impl Graph {
    fn new(n: usize, flag: bool) -> Graph {
        Graph { node: n, directed: flag, graph: vec![vec![]; n] }
    }

    fn add_edge(&mut self, start_node: usize, end_node: usize, cost: i64) -> () {
        self.graph[start_node].push((end_node, cost));
        if !self.directed { self.graph[end_node].push((start_node, cost)); }
    }
    fn dijkstra(&self, start_node: usize) -> Vec<i64> {
        let mut dist = vec![std::i64::MAX; self.node];
        dist[start_node] = 0;

        let mut queue: BinaryHeap<(i64, usize)> = BinaryHeap::new();
        queue.push((0, start_node));

        while !queue.is_empty() {
            let (min_dist, idx) = queue.pop().unwrap();
            if dist[idx] < -min_dist {
                continue;
            }
            for &(to, weight) in &self.graph[idx] {
                let cost_cand = dist[idx] + weight;
                if dist[to] > cost_cand {
                    dist[to] = cost_cand;
                    queue.push((-cost_cand, to));
                }
            }
        }
        dist
    }
    fn dijkstra_max(&self, start_node: usize) -> Vec<i64> {
        let mut dist = vec![0; self.node];
        dist[start_node] = 0;

        let mut queue: BinaryHeap<(i64, usize)> = BinaryHeap::new();
        queue.push((0, start_node));

        while !queue.is_empty() {
            let (max_dist, idx) = queue.pop().unwrap();
            if dist[idx] < -max_dist {
                continue;
            }
            for &(to, weight) in &self.graph[idx] {
                let cost_cand = dist[idx] + weight;
                if dist[to] < cost_cand {
                    dist[to] = cost_cand;
                    queue.push((-cost_cand, to));
                }
            }
        }
        dist
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let x: usize = read();
    let y: usize = read();

    let mut g = Graph::new(n+1, false);
    for i in 1..n {
        g.add_edge(i, i+1, 1);
    }
    g.add_edge(x, y, 1);

    let mut ans_vec: Vec<usize> = (0..n+1).map(|_| 0).collect();
    for i in 1..n+1 {
        let v = g.dijkstra(i);
        for hop_num in v.into_iter().skip(i+1) {
            ans_vec[hop_num as usize] += 1;
        }
    }

    for ans in ans_vec.into_iter().skip(1).take(n-1) {
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))


N, M = MI()
C = [tuple(MI()) for _ in range(M)]

start = 0 if N == 1 else 10 ** (N - 1)
for i in range(start, 10 ** N):
    num = str(i)
    flg = True
    for s, c in C:
        if int(num[s - 1]) != c:
            flg = False
    if flg:
        print(num)
        exit(0)
print(-1)


Measured memory_bytes: 40048
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        int count = 0;
        for (double i=1; i<=N; i++) {
            if (i%2 != 0) {
                count++;
            }
        }
        double result = (double) count/N;
        System.out.println(String.format("%.10f", result));
    }
}


Measured memory_bytes: 23508
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N, M;
    cin >> N >> M;
    ll A[N], B[N];
    REP(i, N) cin >> A[i] >> B[i];

    pair<ll, int> p[N];
    REP(i, N) p[i] = make_pair(A[i], B[i]);
    sort(p, p + N);
    ll cur = 0;
    ll cost = 0;
    REP(i, N) {
        if (cur >= M) break;
        if (cur + p[i].second <= M) {
            cost += p[i].first * p[i].second;
            cur += p[i].second;
        }
        else {
            cost += p[i].first * (M - cur);
            cur = M;
        }
    }
    cout << cost << endl;
    return 0;
}


Measured memory_bytes: 3328
import math
n, x, y = map(int,input().split())
dif = y-x
ans = [0]*(n-1)

for i in range(1,n):
    for j in range(i+1,n+1):
        dist = abs(x-i)+abs(y-j)+1
        ans[min(dist,(j-i))-1] += 1

for i in ans:
    print(i)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

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

	vpll W(n);
	for (int i = 0; i < n; i++)
		cin >> W[i].second >> W[i].first;
	sort(all(W));

	bool ans = true;
	ll A = 0;
	for (int i = 0; i < n; i++)
	{
		A += W[i].second;
		if (A > W[i].first)
			ans = false;
	}
	cout << (ans ? "Yes" : "No") << endl;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	ll n; cin>>n;
	int ans = 20;
	for(ll i=1; i*i<=n; i++){
	// reps(i,pow(n,0.5)+5){
		if(n%i) continue;
		ll a=i, b=n/i;
		a = log10(a)+1; b=log10(b)+1;
		// if(i==1) cerr << b << endl;
		chmin(ans,max(a,b));
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 1e9
#define MOD 1000000007
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main(void) {
    string sdash, t;
    cin >> sdash;
    cin >> t;

    vector<string> strSet;

    int slen = sdash.size();
    int tlen = t.size();

    for (int i = 0; i < slen; i++)
    {
        if(i + tlen > slen) break;
        string s = sdash;
        bool match = true;
        for (int j = 0; j < tlen; j++)
        {
            if(s[i+j] != t[j]){
                if(s[i+j] == '?'){
                    s[i+j] = t[j];
                } else {
                    match = false;
                    break;
                }
            }
        }
        if(match) {
            for (int j = 0; j < slen; j++)
            {
                if(s[j] == '?') s[j] = 'a';
            }
            //strSet.push_back(s);
            strSet.emplace_back(s);
        }
    }

    if(strSet.empty()){
        cout << "UNRESTORABLE" << endl;
    } else {
        sort(strSet.begin(), strSet.end());
        cout << *strSet.begin() << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
ll N,M;
#define INF 2000000000100
#define MAXN 1001
#define MAXM 2001
ll d[MAXN];
ll a[MAXM],b[MAXM],c[MAXM];
int main(){
    cin >> N >> M;
    rep(i,N)d[i] = -INF;
    rep(i,M){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--,b[i]--;
    }
    d[0] = 0;
    bool ch = true;
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            if(d[b[j]]<d[a[j]]+c[j]){
                d[b[j]] = d[a[j]]+c[j];
                if(i==N-1&&b[j]==N-1)ch =false;
            }
        }
    }
    if(ch){
        cout << d[N-1] << endl;
    }else{
        cout << "inf" << endl;
    }
    
    return 0;

}

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

using namespace std;

int main(void){
  int n;
  int vecx[100], vecy[100];
  double d1, d2, d3, dinf, d;
  d1 = d2 = d3 = dinf = d = 0.0;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> vecx[i];
  }
  for(int i = 0; i < n; i++){
    cin >> vecy[i];
  }
  for(int i = 0; i < n; i++){
    d = abs(vecx[i] - vecy[i]);
    d1 += d;
    d2 += pow(d, 2.0);
    d3 += pow(d, 3.0);
    if(d >= dinf){
      dinf = d;
    }
  }
  d2 = sqrt(d2);
  d3 = cbrt(d3);
  cout << setprecision(11) << d1 << endl;
  cout << setprecision(11) << d2 << endl;
  cout << setprecision(11) << d3 << endl;
  cout << setprecision(11) << dinf << endl;
  return 0;
}



Measured memory_bytes: 3484
#include <stdio.h>

long long aaa(long long, long long);
long long t[100] = {};

long long aaa(long long x, long long y)
{
	long long r, x1, y1;
	if (x < y)
	{
		x1 = y;
		y1 = x;
	}
	else
	{
		x1 = x;
		y1 = y;
	}
	r = x1 % y1;
	while (r != 0)
	{
		x1 = y1;
		y1 = r;
		r = x1 % y1;
	}
	return y1;
}

int main()
{
	int n;
	long long ans;
	long long g;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &t[i]);
	}
	ans = t[0];
	for (int i = 0; i < n-1; i++)
	{
		g = aaa(ans, t[i + 1]);
		ans *= t[i + 1] / g;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 128
import sys
def input(): return sys.stdin.readline().strip()

def main():
    n = int(input())
    k = int(input())
    x = int(input())
    y = int(input())
    if n <= k:
        print(x * n)
    else:
        print(x * k + (n - k) * y)

if __name__ == "__main__":
    main()


Measured memory_bytes: 61896
program buffet
  implicit none
  integer :: n, a(20) = 0, b(20) = 0, c(19) = 0, ans, i
  read(*,*) n
  read(*,*) a(1:n)
  read(*,*) b(1:n)
  read(*,*) c(1:n-1)
  ans = b(a(1))
  do i = 2, n
    if (a(i) == a(i-1)+1) ans = ans+c(a(i-1))
    ans = ans+b(a(i))
  end do
  write(*,'(i0)') ans
end program buffet

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

namespace atcoder
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            string indata1;
            
            indata1 = Console.ReadLine();
            int c = int.Parse(indata1);

            while (c > 1000)
            {
                c -= 1000;
            }
			c = 1000 - c;
            Console.WriteLine(c);
        }
    }
}

Measured memory_bytes: 27500
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	long long a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
  	string ans = "NO";
  	long long distance = abs(a-b);
  	long long speed = v-w;
    if(distance<=speed*t){
    	ans="YES";
    }
  
	cout<<ans<<endl;
}


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

int main(){
string s; cin >> s;
  if (s == "SSS") {
    cout << 0;
  } else if (s == "SSR") {
    cout << 1;
  } else if (s == "SRR") {
    cout << 2;
  } else if (s == "RRR") {
    cout << 3;
  } else if (s == "SRS") {
    cout << 1;
  } else if (s == "RRR") {
    cout << 2;
  } else if (s == "RRS") {
    cout << 2;
  } else if (s == "RSR") {
    cout << 1;
  } else if (s == "RSS") {
    cout << 1;
  }
    return 0;

}

Measured memory_bytes: 3580