akhauriyash/Code-Regression huggingface dataset:
use proconio::input;

fn main() {
  input! {
    n: usize,
    ais: [isize;n]
  }

  let mut sum = 0;
  for (i, v) in ais.iter().enumerate() {
    if i % 2 == 0 {
      sum += *v;
    } else {
      sum -= *v;
    }
  }
  
  let mut result = vec![0;n];
  result[0] = sum;
  let mut last = sum / 2;
  
  for i in 0..n-1 {
    last = ais[i] - last;
    result[i+1] = 2 * last;
  }
  
  let result: Vec<String> = result.into_iter().map(|v| v.to_string()).collect();
  println!("{}", result.join(" "));
}

Measured memory_bytes: 10400
#include<bits/stdc++.h>
#define int long long
#define deb(x) cout<<#x<<" = "<<x<<"\n";
using namespace std;

signed main()
{
//	freopen("input.txt", "r", stdin);
	
	int a, b; cin>>a>>b;
  	cout<< max({ a+b, a-b, a*b});
	
	
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int score[100000];

int main() {
	int i,n;
	for(i=1;scanf("%d,%d",&n,score+i),n;i++){
	}
	n=i-1;
	for(;cin>>i;){
		int res=0;
		int k;
		for(k=30;k>score[i];k--){
			int j;
			for(j=1;j<=n;j++){
				if(score[j]==k){
					res++;
					break;
				}
			}
		}
		cout<<res+1<<endl;
	}
	return 0;
}

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

int main() {
  int a,b,c,d;cin>>a>>b>>c>>d;
  if(abs(a-c) <= d) cout << "Yes" << endl;
  else if(abs(a-b) <= d && abs(b-c) <= d) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
n = int(input())
p_ = list(input().split())

p = [int(p) for p in p_]

res = 0

for i in range(1, n - 1):
    if p[i - 1] < p[i] and p[i] < p[i + 1]:
        res += 1
    elif p[i + 1] < p[i] and p[i] < p[i - 1]:
        res += 1
        
print(res)

Measured memory_bytes: 3060
N, M = map(int, input().split())
acs = [0] * N
was = [0] * N
for m in range(M):
    p, S = input().split()
    # print(p, S)
    if S == 'AC':
        acs[int(p) - 1] = 1
    else:
        if acs[int(p) - 1] == 0:
            was[int(p) - 1] += 1

ac_count = sum(acs)
# 正答してないWAはペナルティではない
for n in range(N):
    if acs[n] == 0:
        was[n] = 0
wa_count = sum(was)
print(ac_count, wa_count)
# print(acs)
# print(was)


Measured memory_bytes: 4596
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, k) = readIntegerList()
    val aList = readLongList().sorted()

    val mod = 1000000007L
    val combination = Combination(n, mod)

    var minSum = 0L
    for ((i, a) in aList.dropLast(k - 1).withIndex()) {
        val right = n - i - 1
        val comb = combination.value(right, k - 1)
        minSum = (minSum + ((a * comb) % mod)) % mod
    }

    var maxSum = 0L
    for ((i, a) in aList.drop(k - 1).withIndex()) {
        val left = k - 1 + i
        val comb = combination.value(left, k - 1)
        maxSum = (maxSum + ((a * comb) % mod)) % mod
    }

    var ans = (maxSum  - minSum) % mod
    if (ans < 0) ans += mod
    out.println(ans)
}

/** n <= 20000000 */
class Combination(n: Int = 20000000, val MOD: Long = 1000000007L) {
    val fact = LongArray(n + 1)
    val ifact = LongArray(n + 1)

    /** O(n) */
    init {
        fact[0] = 1L
        for (i in 1..n) { fact[i] = (fact[i - 1] * i) % MOD }
        ifact[n] = modInverse(fact[n], MOD)
        for (i in n downTo 1) { ifact[i - 1] = (ifact[i] * i) % MOD }
    }

    /** O(1) */
    fun value(n: Int, k: Int) = if (k < 0 || k > n) 0 else (((fact[n] * ifact[k]) % MOD) * ifact[n-k]) % MOD

    /**
     * O(log(MOD))
     */
    fun modInverse(n: Long, mod: Long = 1000000007L): Long {
        var a = n % mod
        if (a < 0) a += mod

        if (a == 0L) throw ArithmeticException("n is not relatively prime to mod")

        var b = mod
        var u = 1L
        var v = 0L
        while (b > 0) {
            val t = a / b
            a -= t * b
            a = b.also { b = a } // swap(a, b)
            u -= t * v
            u = v.also { v = u } // swap(u, v)
        }
        u %= mod
        if (u < 0) u += mod
        return u
    }
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 64732
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
const int inf = 0x3f3f3f3f;
typedef long long ll;
typedef pair<ll,ll> ii;
ll n,mxr[55];
struct 
{
	ll value;
	ll biao;
}maxx,minn;
vector<ii>tt;
int main()
{
	int ans=0;
	scanf("%lld",&n);
	maxx.value=-inf;
	minn.value=inf;
	for(ll i=1;i<=n;i++)
	{
		scanf("%lld",&mxr[i]);
		if(maxx.value<mxr[i])
		{
			maxx.value=mxr[i];
			maxx.biao=i;
		}
		if(minn.value>mxr[i])
		{
			minn.value=mxr[i];
			minn.biao=i;
		}
	}
	if(minn.value==maxx.value)
	{
		printf("0\n");
		return 0;
	}
	else if(-minn.value<maxx.value)
	{
		for(ll i=2;i<=n;i++)
		{
			while(mxr[i]<mxr[i-1])
			{
				ii dui(maxx.biao,i);
				tt.push_back(dui);
				mxr[i]+=maxx.value;
				if(mxr[i]>maxx.value)
				{
					maxx.value=mxr[i];
					maxx.biao=i;
				}
			}
		}
			
	}
	else {
		for(ll i=n-1;i>0;i--)
		{
			while(mxr[i]>mxr[i+1])
			{
				ii dui(minn.biao,i);
				tt.push_back(dui);
				mxr[i]+=minn.value;
				if(mxr[i]<minn.value)
				{
					minn.value=mxr[i];
					minn.biao=i;
				}
			}
		}
	}
	printf("%d\n",tt.size());
	for(ll i=0;i<tt.size();i++)
	{
		printf("%lld %lld\n",tt[i].first,tt[i].second);
	}
	return 0;
}

Measured memory_bytes: 256
// Aaradhya Beri
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
 

signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int x = 0;
    int res = 0;
    rep(i,0,n)
    {
        if(s[i] == 'I')
            x += 1;
        else 
            x -= 1;
        res = max(res,x);
    }
    cout<<res<<endl;
    return 0;
}

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

using namespace std;

int main(void) {
    string s;
    int p;
    map<string, set<int> > mp;

    while (cin >> s >> p)
        mp[s].insert(p);
    
    for (map<string, set<int> >::iterator itm = mp.begin(); itm != mp.end(); itm++) {
        int flag = 0;
        cout << (*itm).first << '\n';
        for (set<int>::iterator its = (*itm).second.begin(); its != (*itm).second.end(); its++) {
            if (flag) printf(" ");
            printf("%d", (*its));
            flag = 1;
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 3244
H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])
d = {i: 0 for i in range(-1, 10)}
for _ in range(H):
    A = map(int, input().split())
    for i in A:
        d[i] += 1
ans = 0
for i in range(10):
    if i == 1:
        continue
    ans += c[i][1] * d[i]
print(ans)


Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class program{
  static void Main(string[] args){
    program p = new program();
    p.Run();
  }
  void Run(){
	int[] inp = Readint();
    int[] a = {inp[0]+inp[1],inp[0]-inp[1],inp[0]*inp[1]};
   	WriteLine(a.Max().ToString());
  }

  int[] Readint(){
    string[] s = ReadLine().Split();
    int[] res=new int[s.Length];
    Parallel.For(0,s.Length,i=>{
      res[i]=int.Parse(s[i]);
    });
    return res;
  }
}

Measured memory_bytes: 13908
sx,sy,tx,ty = map(int,input().split())
ans = ''
s1 = (sx,sy+1)
s2 = (sx+1,sy)
s3 = (sx-1,sy)
s4 = (sx,sy-1)
t1 = (tx-1,ty)
t2 = (tx,ty-1)
t3 = (tx,ty+1)
t4 = (tx+1,ty)
l = [s1,t1,s2,t2,s3,t3,s4,t4]
for i in range(4):
    xs,ys = l[i*2]
    xt,yt = l[i*2+1]
    if i%2==0:
        if i == 0:
            ans += 'U'
        else:
            ans += 'L'
        ans += 'U'*(yt-ys)
        ans += 'R'*(xt-xs)
        if i == 0:
            ans += 'R'
        else:
            ans += 'D'
    else:
        if i == 1:
            ans += 'D'
        else:
            ans += 'R'
        ans += 'D'*(yt-ys)
        ans += 'L'*(xt-xs)
        if i == 1:
            ans += 'L'
        else:
            ans += 'U'
    #print(ans)
    #print(yt-ys,xt-xs)
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int maxn=500,mod=998244353;
struct point{
	int x,y;
}p[maxn];
int n;
long long po[maxn],ans;

int main(){
	scanf("%d",&n);
	po[0]=1;for(int i=1;i<=n;i++){po[i]=po[i-1]*2%mod;}
	for(int i=1;i<=n;i++){scanf("%d%d",&p[i].x,&p[i].y);}
	ans=po[n]-n-1;
	for(int i=1;i<n;i++){
		for(int j=i+1;j<=n;j++){
			int cnt=0;
			for(int k=j+1;k<=n;k++){
				if((p[i].x-p[k].x)*(p[j].y-p[k].y)==(p[j].x-p[k].x)*(p[i].y-p[k].y)){cnt++;}
			}
			ans=(ans-po[cnt]+mod)%mod;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s.at(0) == '7' || s.at(1) == '7' || s.at(2) == '7') {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(){
  int N;
  string S;
  string T;
  cin>> N >> S;
  if (N % 2 != 0) {
    cout << "No" << '\n';
  } else{
      for (int i = 0; i < N/2 ; i++) {
      T[i] = S[i];
      if (T[i] != S[i + N/2] ) {
        cout << "No" << '\n';
        break;
      } else if (i == N/2 - 1) {
        cout << "Yes" << '\n';
      }
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a[10000][4], n[10000], z[10000] = {0};
	int i, I, x, y, b, c;
	for(i = 0 ;  ; i++)
	{
	    scanf("%d%d", &a[i][0], &n[i]);
	    if(a[i][0] == 0 && n[i] == 0)
        {
            x = i;
            break;
        }
	}
	for(i = 0 ; i < x ; i++)
    {
        for(I = 0 ;  ; I++)
        {
            a[i][1] = a[i][0] - I;
            y = n[i] - a[i][1];
            c = a[i][1]*3+3;
            if(c < n[i]) break;
            if(a[i][1] == 0) break;
            for(b = 1 ;  ; b++)
            {
                a[i][2] = y - b;
                a[i][3] = b;
                if(a[i][1] > a[i][2] && a[i][2] > a[i][3] && a[i][2] != 0 && a[i][3] != 0)
                {
                    z[i] += 1;
                }
                else if(a[i][2] < a[i][3] || a[i][2] == a[i][3])
                {
                    break;
                }
            }
        }
    }
    for(i = 0 ; i < x ; i++)
    {
        printf("%d\n", z[i]);
    }
	return 0;
}



Measured memory_bytes: 2044
// Problem : 
// 			B - Making Triangle
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N;
	cin>>N;
	vl v(N);
	
	F0R(x,N)
		cin>>v[x];
	ll ans=0;
	F0R(x,N)
	{
		FOR(y,x+1,N)
		{
			FOR(z,y+1,N)
			{
				if(v[x]+v[y]>v[z] && v[x]+v[z]>v[y] && v[y]+v[z]>v[x] && v[x]!=v[y] && v[y]!=v[z] && v[z]!=v[x])
				{
					ans++;
					// cout<<v[x]<<' '<<v[y]<<' '<<v[z]<<nl;
				}
			}
		}
	}
	cout<<ans<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

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


def solve(N: int, A: "List[int]"):
    left = [A[0]] * N
    right = [A[-1]] * N

    for i in range(1,N):
        if(A[i] > left[i-1]):
            left[i] = A[i]
        else:
            left[i] = left[i-1]

    for i in reversed(range(0,N-1)):
        if(A[i] > right[i+1]):
            right[i] = A[i]
        else:
            right[i] = right[i+1]

    for i in range(N):
        if(i == 0):
            print(right[1])
        elif(i == N-1):
            print(left[N-2])
        else:
            print(max(left[i-1], right[i+1]))


    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

void q_sort(int[] ,int ,int );
bool isPrime(int );

int main(void)
{
    int n;
    int result=0;
    cin>>n;
    int num[n];
    for(int i=0;i<n;i++)
    {
        cin>>num[i];
    }
    q_sort(num,0,n-1);
    for(int i=0;i<n;i++)
    {
        if(num[i]!=0)
        {
            if(isPrime(num[i]))
            {
                result++;
            }
            for(int k=i+1;k<n;k++)
            {
                if(num[k]%num[i]==0)num[k]=0;
            }
        }
    }
    cout<<result<<endl;
    return 0;
}
void q_sort(int num[],int low,int high)
{
    int mid=num[(low+high)/2];
    int i=low,j=high;
    do{
        while(num[i]<mid)i++;
        while(num[j]>mid)j--;
        swap(num[i],num[j]);
        i++;
        j--;
    }while(i<=j);
    if(i<high)q_sort(num,i,high);
    if(j>low)q_sort(num,low,j);
}
bool isPrime(int n)
{
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)return false;
    }
    return true;
}



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

using namespace std;

int max(int a,int b)
{
	return a > b ? a : b;
}
int max2(int a,int b,int c)
{
	if( a > b && a > c)
		return a;
	return b > c ? b : c;
}
int const size=100000;
int matrix[size][3];

int main()
{
	std:ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int row;
	cin >> row;
	for(int i=0;i<row;i++)
		cin >> matrix[i][0] >> matrix[i][1] >> matrix[i][2];
	for(int i=1;i<row;i++)
	{
		matrix[i][0]+=max(matrix[i-1][1],matrix[i-1][2]);
		matrix[i][1]+=max(matrix[i-1][0],matrix[i-1][2]);
		matrix[i][2]+=max(matrix[i-1][0],matrix[i-1][1]);
	}
	
	cout<<max2(matrix[row-1][0],matrix[row-1][1],matrix[row-1][2])<<endl;	
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

void printans(int player) {
  if (player == 0) {
    printf("Alice\n");
  } else {
    printf("Brown\n");
  }
  exit(0);
}

int main() {
  ll x, y;
  scanf("%lld%lld", &x, &y);
  if (x > y) {
    swap(x, y);
  }
  if (y - x <= 1) {
    printans(1);
  } else {
    printans(0);
  }

  return 0;
}


Measured memory_bytes: 760
S = list(input())
s = set(S)

A ={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}

ans = A - s

ANS = list(ans)

ANS.sort()

if ANS != []:
    print(ANS[0])
else:
    print("None")


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

int main() {
    int N; cin >> N;
    long long res = 1;
    vector<long long> A(N);
    for(int i=0; i<N; ++i) {
        cin >> A[i];
        if(A[i] == 0) {
            res = 0;
        }
    }

    if(res == 0) {
        cout << "0\n";
        return 0;
    }
    
    for(int i=0; i<N; ++i) {
        if(res > (1000000000000000000) / A[i]) {
            res = -1;
            break;
        }
        res *= A[i];
    }
    cout << res << '\n';
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,m,k,ans,n,a,b,g,h;
    	cin>>h>>n;
    	ans=0;
    	rep(i,0,n)
    	{
    		cin>>k;
    		ans+=k;
		}
    	if(ans>=h)
    	cout<<"Yes";
    	else
    	cout<<"No";
    	
    	
    } 
	return 0;
}

Measured memory_bytes: 256
def main():
    N,K = map(int,input().split())
    A = list(map(int, input().split()))

    tele_num = 0
    check = [0]*(N+1)
    check[1] = 1
    temp = 1
    i = 2
    roop_num = 0
    sho = 0
    amari = 0

    while i != K+2:
        temp1 = A[temp-1]
        if check[temp1] != 0:
            roop_num = check[temp] - check[temp1] + 1
            tele_num = K + 2 - i - 1
            sho = tele_num // roop_num
            amari = tele_num % roop_num
            break

        check[temp1] = i
        i += 1
        temp = temp1

    #print(roop_num,tele_num,sho,amari)

    j = 0
    temp = temp1
    while j != amari:
        temp1 = A[temp-1]
        #check[temp1] = i
        j += 1
        temp = temp1

    print(temp)
    #print(i,temp, check)

main()


Measured memory_bytes: 32256
#include <bits/stdc++.h>
#define endl        '\n'
#define db          double
#define ld          long double
#define ll          long long
#define ull         unsigned long long
#define sqr(x)      (x) * (x)
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)   ((a/gcd(a,b)) * b)
#define pf(x) 		push_front(x)
#define pb(x)       push_back(x)
#define eb(x)		emplace_back(x)
#define all(x)      (x).begin(), (x).end()
#define rall(x) 	(x).rbegin(), (x).rend()
#define sz(x) 		(int)x.size()
#define debug(x) 	cerr << #x << " = " << (x) <<endl
#define unsyncIO    ios_base::sync_with_stdio(0); cin.tie(0)

const ld PI = acos((ld)-1);
const int MOD = 1e9+7;
const ll INF = 1e18; 

using namespace std;

int main()
{
    //freopen("/home/taalpatar_shepai/Documents/my_codes/out.txt", "w", stdout);
    int n;
    cin >> n;
    ll power = 1;
    for (int i = 1; i <= n; i++) {
        power = ( power * i ) % MOD;

    }
    cout << power << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void)
{
  int score[200][3]={0}, total[200]={0}, i, j, k, n, flag;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
    scanf("%d %d %d", &score[i][0], &score[i][1], &score[i][2]);

 for(k = 0; k < n; k++){
   for(j = 0; j < 3; j++){
     flag = 0;
     for(i = 0; i < n; i++){
       if(k !=i && score[k][j] == score[i][j])
	 flag = 1;
     }
     if(flag != 1)
       total[k] += score[k][j];
   }
 }
 for(i = 0; i < n; i++)
   printf("%d\n", total[i]);

 return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    double x[N];
    string u[N];
    for(int i=0;i<N;i++){
        cin>>x[i]>>u[i];
    }
    
    double money=0;
    for(int i=0;i<N;i++){
        if(u[i]=="JPY"){
            money+=x[i];
        }else{
            money+=x[i]*380000;
        }
    }

    cout<<money<<endl;

    return(0);
}

Measured memory_bytes: 256
def mincos(n,ab):
    aball=[]
    aball+=[(ab[i][0],i+1,'a') for i in range(n)]
    aball+=[(ab[i][1],i+1,'b') for i in range(n)]
    aball.sort()
    
    ans1=sum([i[0] for i in aball[:n]])

    hen=aball[n][0]
    hen2=aball[n+1][0]
    d=set()
    t=None
    hantei=True
    for i,c,mab in aball[:n]:
        if t!=None and t!=mab:
            hantei=False
        if  c in d:
            print(ans1)
            exit()
        d.add(c)
        t=mab

    if hantei:
        print(ans1)
        exit()

    ans2=[]
    for i,c,aorb in aball[:n]:
        if aball[n][1]!=c:
            ans2+=[ans1-i+hen]
        else:
            ans2+=[ans1-i+hen2]
    print(min(ans2))
    exit()

n=int(input())
print(mincos(n,[list(map(int,input().split())) for i in range(n)]))

Measured memory_bytes: 59940
while True:
    m,f,r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break

    if m == -1 or f == -1:
        print('F')
    elif m+f >= 80:
        print('A')
    elif m+f >= 65:
        print('B')
    elif m+f >= 50:
        print('C')
    elif m+f >= 30:
        
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')



Measured memory_bytes: 5592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia,a=sc.Ia2;
		long[] dp=new long[s[1]+1];
		long ans=0,m=1;
		Array.Sort(a,(u,v)=>v-u);
		for(int i = 2;i<=s[0];i++) {m=(m*i)%mod;}
		dp[s[1]]=m;
		for(int i = s[1],j=0;i>=0;i--) {
			while(a[j]!=0&&a[j]>i){j++;}
			if(a[j]==0){ans=(ans+dp[i]*i)%mod;}
			else if(dp[i]!=0){
				for(int k = j;k<s[0];k++) {dp[i%a[k]]=(dp[i%a[k]]+dp[i]*Mi(s[0]-j))%mod;}
			}
		}
		Console.WriteLine(ans);
	}
	static long Mi(long a){
		long b=mod,u=1,v=0;
		while(b>0){
			long t=a/b;
			a-=t*b;a^=b;b^=a;a^=b;
			u-=t*v;u^=v;v^=u;u^=v;
		}
		u%=mod;
		if(u<0){u+=mod;}
		return u%mod;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll((Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 13268
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];
		String out = "";
		for(int i = 0; i < N; i++) {
			A[sc.nextInt()-1] = i + 1;
		}
		for(int i = 0; i < N; i++) {
			System.out.println(A[i]);
		}
		System.out.println(out);
		sc.close();
	}

}


Measured memory_bytes: 56640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  string ans;
  for(int i = 0; i < s.size(); i += 2){
    ans.push_back(s.at(i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n,m;
    cin >> n >> m;
    if(n==m)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
char kan[501][501],gou[501];
int main(void){
	int n,m,i,j,sas,a,b;

	while(1){
		scanf("%d%d",&n,&m);
		if(!n && !m)break;
		memset(kan,0,sizeof(kan));
		memset(gou,0,sizeof(gou));
		for(i=0;i<m;i++){
			scanf("%d%d",&a,&b);
			kan[a][b]=kan[b][a]=1;
		}
		for(i=2;i<=n;i++){
			if(kan[1][i]==1){
				gou[i]=1;
				for(j=1;j<=n;j++){
					if(kan[i][j]==1)gou[j]=1;
				}
			}
		}
		sas=0;
		for(i=2;i<=n;i++){
			if(gou[i]==1)sas++;
		}
		printf("%d\n",sas);
	}
	return 0;
}

Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
const int maxn =  1e5+ 10 ;
int n,k;
long long a[maxn], ans = 2e15;
int main()
{

    cin>>n>>k;
    for(int i=1;i<=n;i++)
    cin>>a[i];
     for(int i=1;i+k-1<=n;i++)
    {  
        int l=i,r=i+k-1;
        ans=min(ans , a[r]-a[l] + min(abs(a[l]) , abs(a[r])));
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
string s,t;cin >> s >> t ;
int a,b;
cin >> a >>b;
string z;
cin >> z;
if(z==s){
    a--;
    cout << a <<" "<<b<<endl;
}
else {
    b--;
    cout << a <<" "<<b<<endl;
}
}





Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

queue<P> q1;
char ca[1005];
int used[1005][1005];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	int s=0;
	cin>>n>>m;
	memset(used,-1,sizeof(used));
	for(i=0;i<n;i++){
		cin>>ca;
		for(j=0;j<m;j++){
			if(ca[j]=='#')q1.push(make_pair(i,j));
		}
	}
	for(k=0;!q1.empty();k++){
		c=q1.size();
		for(i=0;i<c;i++){
			a=q1.front().first,b=q1.front().second,q1.pop();
			if(a<0 || n<=a || b<0 || b>=m)continue;
			if(used[a][b]!=-1)continue;
			used[a][b]=k;
			if(s<k)s=k;
			q1.push(make_pair(a,b+1));
			q1.push(make_pair(a,b-1));
			q1.push(make_pair(a+1,b));
			q1.push(make_pair(a-1,b));
		}
	}
	cout<<s<<endl;
			
}


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

int main(){
	int N;
	cin >> N;
	int A[N];
	vector<int> a;
	for(int i=0; i<N; i++) cin >> A[i];
	for(int i=0; i<N; i++){
		if(A[i] < 0) a.push_back(A[i]);
	}
	sort(a.begin(), a.end());
	if(a.size() % 2 == 0){
		long long ans = 0;
		for(int i=0; i<N; i++){
			if(A[i] < 0) ans += (-A[i]);
			else ans += A[i];
		}
		cout << ans << endl;
	}else{
		long long ans = 0;
		int min = 0;
		for(int i=1; i<N; i++){
			if(abs(A[min]) > abs(A[i])) min = i;
		}
		if(A[min] < 0){
			for(int i=0; i<N; i++){
				if(i != min){
					if(A[i] < 0) ans += (-A[i]);
					else ans += A[i];
				}
			}
			ans += A[min];
			cout << ans << endl;
		}else{
			for(int i=0; i<N; i++){
				if(i != min){
					if(A[i] < 0) ans += (-A[i]);
					else ans += A[i];
				}
			}
			ans -= A[min];
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1276
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	int n = readln.chomp.to!int;
	BigInt[] as, bs;
	for(int i = 0; i < n; i ++){
		ulong[] tmp = readln.chomp.split.map!(to!ulong).array;
		as ~= BigInt(tmp[0]), bs ~= BigInt(tmp[1]);
		}
	BigInt ans = 0;
	for(int i = n - 1; i >= 0; i --){
		BigInt x = ans;
		x += as[i];
		x = x % bs[i];
		if(x > 0) ans += bs[i] - x;
		}
	
	ans.writeln;
	}

Measured memory_bytes: 28156
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;

int m[4]={10,50,100,500};

int calcOtsuri(int cost,int money){
    int leftMoney=money-cost;
    return leftMoney;
    //int cnt=0;
    //for(int i = 3; i >= 0; i--){
    //    cnt+=leftMoney/m[i];
    //    leftMoney-=(leftMoney/m[i])*m[i];
    //}
    //return cnt;
}

int main(){

    int cost;
    bool f=true;
    while(cin>>cost&&cost!=0){
        if(!f)
            cout<<endl;
        else
            f=false;
        int havingMoney[4];
        int sumKoka=0;
        int sumMoney=0;
        for(int i = 0; i < 4; i++){
            cin>>havingMoney[i];
            sumKoka+=havingMoney[i];
            sumMoney+=havingMoney[i]*m[i];
        }
        int left=calcOtsuri(cost,sumMoney);
        //int left=sumMoney-res;
        int a[4];
        for(int i = 3; i >= 0; i--){
            a[i]=left/m[i];
            left-=a[i]*m[i];
        }
        for(int i = 3; i >= 0; i--){
            a[i]=max(havingMoney[i]-a[i],0);
        }

        int num=10;
        for(int i = 0; i < 4; i++){
            if(a[i]!=0)
                cout<<num<<" "<<a[i]<<endl;
            if(i%2==0)
                num*=5;
            else
                num*=2;
        }
    }
    return 0;
}

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

using namespace std;

using int64 = long long;

int main() {
  int H, W, D, A[300][300];
  int X[1000000], Y[1000000];
  cin >> H >> W >> D;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> A[i][j];
      X[A[i][j]] = j;
      Y[A[i][j]] = i;
    }
  }

  vector< int > add[1000000];
  for(int i = 1; i <= H * W; i++) {
    add[i % D].emplace_back(i);
  }
  vector< int64 > sum[1000000];
  for(int i = 0; i < D; i++) {
    sum[i].resize(add[i].size());
    for(int j = 1; j < add[i].size(); j++) {
      sum[i][j] += sum[i][j - 1];
      sum[i][j] += abs(X[add[i][j - 1]] - X[add[i][j]]);
      sum[i][j] += abs(Y[add[i][j - 1]] - Y[add[i][j]]);
    }
  }


  int Q;
  cin >> Q;
  while(Q--) {
    int L, R;
    cin >> L >> R;
    int p = L % D;
    int latte = lower_bound(begin(add[p]), end(add[p]), L) - begin(add[p]);
    int malta = lower_bound(begin(add[p]), end(add[p]), R) - begin(add[p]);
    cout << sum[p][malta] - sum[p][latte] << endl;
  }
}


Measured memory_bytes: 57088
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 基準となる数字 */
	private static final int N = 753;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray();
			System.out.println(IntStream.range(0, s.length - 2)
					.map(i -> (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0')).map(n -> Math.abs(n - N))
					.min().getAsInt());
		}
	}
}


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

using namespace std;

string res;

string go()
{
    if(res.size()==0) return "";
    string t;
    for(int i=0;i<res.size()-1;i++) t+=res[i];
    return t;
}

int main()
{
    int n; cin>>n;
    int *a=new int[n+1];
    for(int i=1;i<=n;i++) cin>>a[i];
    int res=1e9;
    for(int i=-100;i<=100;i++)
    {
        int akt=0;
        for(int j=1;j<=n;j++)
        {
            akt+=(a[j]-i)*(a[j]-i);
        }
        res=min(res,akt);
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int lcm(int a,int b){
	return((a*b)/__gcd(a,b));
}

int32_t main(){
	IOS;
	int n,m;
	cin>>n>>m;
	int a[n];
	int o=0,e=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]=a[i]/2;
		if(a[i]%2==1) o=1;
		else e=1; 
	}
	if(o==1&&e==1){
		cout<<0<<endl;
		return 0;
	}
	sort(a,a+n);
	int x=a[n-1];
	for(int i=n-1;i>=0;i--){
			x=lcm(a[i],x);
			if(x>m){
				cout<<0<<endl;
				return 0;
			}
	}
	for(int i=0;i<n;i++){
		if((x/a[i])%2==0){
			cout<<0<<endl;
			return 0;
		}
	}
	int ans=m/x;
	ans=(ans-1)/2+1;
	cout<<ans<<endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  for (int i = 0; i < M; ++i)
    cin >> a[i];

  vector<bool> flag(N + 1);
  for (int i = 0; i < M; ++i)
    flag[a[i]] = true;

  vector<long long> dp(N + 1);
  dp[0] = 1, dp[1] = 1;
  if (flag[1])
    dp[1] = 0;

  for (int i = 2; i <= N; ++i) {
    if (flag[i])
      continue;
    dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
  }

  cout << dp[N] << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <unordered_set>
#include <climits>
using namespace std;

void _DEBUG() {
    #ifndef _DEBUG
    freopen("input.in", "r", stdin);
    #endif
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // _DEBUG();

    int x {}, n {};
    cin >> x >> n;

    unordered_set<int> st {};
    for (int i {}; i < n; ++i) {
        int num {};
        cin >> num;
        st.emplace(num);
    }

    int mn_diff {INT_MAX};
    int ans {};
    for (int i {200}; i >= -10000; --i) {
        if (!st.count(i)) {
            if (mn_diff >= abs(x - i)) {
                mn_diff = abs(x - i);
                ans = i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

/**
 * Created by huzhejie on 2016/10/10.
 */
public class Main {
    @SuppressWarnings("unchecked")
    private static void dijkstra(Vertex source){
        source.minDistance = 0;
        PriorityQueue<Vertex> queue = new PriorityQueue<Vertex>();
        queue.add(source);
        while(!queue.isEmpty()){
            Vertex v = queue.poll();

            for(Edge edge:v.nighbors){
                int newDist = v.minDistance +edge.weight;
                if(edge.target.minDistance>newDist){
                    queue.remove(edge.target);
                    edge.target.minDistance = newDist;

                    queue.add(edge.target);
                }
            }
        }
    }

    public static void main(String args[]){
//        long startTime = System.currentTimeMillis();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int l = 1;
        String str=null;
        try {
            str = br.readLine();
            Graph g = new Graph(Integer.parseInt(str.split(" ")[0]));
            int source  = Integer.parseInt(str.split(" ")[2]);
            int edge = Integer.parseInt(str.split(" ")[1]);
            while ((str = br.readLine()) != null&&l<=edge){
                String record[] = str.split(" ");
                g.addEdge(Integer.parseInt(record[0]),Integer.parseInt(record[1]),Integer.parseInt(record[2]));
                l++;
            }
            br.close();
            dijkstra(g.vertices.get(source));
            for(Vertex v:g.vertices.values()){
                if(v.minDistance == Integer.MAX_VALUE)
                    System.out.println("INF");
                else
                System.out.println(v.minDistance);
            }
//            System.out.println((System.currentTimeMillis()-startTime)/1000);
        }catch (IOException e){
            e.printStackTrace();
        }
    }

}
class Edge{
    public final Vertex target;
    public final int weight;
    public Edge(Vertex target,int weight){
        this.target = target;
        this.weight = weight;
    }
}
class Graph{
    Map<Integer,Vertex> vertices;
    public Graph(int vertexNumber){
        vertices = new LinkedHashMap<Integer, Vertex>();
        for(int i = 0;i<vertexNumber;i++){
            vertices.put(i,new Vertex(i));
        }
    }
    public void addEdge(int source,int target,int weight){
        Vertex v = vertices.get(source);
        Edge edge = new Edge(vertices.get(target),weight);
        v.nighbors.add(edge);
    }
}
@SuppressWarnings("unchecked")
class Vertex implements Comparable<Vertex>{
    int id;
    int minDistance = Integer.MAX_VALUE;
    ArrayList<Edge> nighbors;
    public Vertex(int id){
        this.id = id;
        this.nighbors = new ArrayList<Edge>();
    }
    public int compareTo(Vertex o) {
        return Integer.compare(minDistance,o.minDistance);
    }
}

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

pair<string, int> parse(const string &letter) {
	int idx = 0;
	while(isalpha(letter[idx])) ++idx;
	return make_pair(letter.substr(0, idx), stoi(letter.substr(idx)));
}

void print(int idx, const vector<int> &next) {
	while(next[idx] != idx) {
		cout << idx + 1 << "\n";
		idx = next[idx];
	}
	cout << idx + 1 << "\n";
}

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

	for(int n; cin >> n && n;) {
		map<pair<string, int>, int> jump;
		vector<int> next(n);

		iota(next.begin(), next.end(), 0);

		for(int i = 0; i < n; ++i) {
			string letter;
			cin >> letter;

			if(letter == "-") {
				print(i, next);
			}
			else {
				const bool re_mark = letter.back() == 'v';
				if(re_mark) {
					next[i + 1] = i;
					letter.erase(letter.begin() + letter.size() - 1);
				}

				if(letter.size() > 1) {
					const auto cur = parse(letter);
					const auto dest = make_pair(cur.first, cur.second + 1);
					const auto it = jump.find(dest);

					if(it != jump.end()) {
						const int dest_idx = it->second;
						jump.erase(it);
						next[i] = dest_idx;
					}

					if(cur.second > 1) {
						jump.insert(make_pair(cur, i));
					}
					else if(!re_mark) {
						print(i, next);
					}
				}
			}
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1908
#include <iostream>
int main(){
    int N;
    int ans = 0;
    std::cin>>N;
    for(int i = 1;i<N;++i){
        for(int j = 1;j<N/i+1;++j){
            int c = N -i*j;
            if(c>0){
                ans = ans +1;
            }
        }
    }
    std::cout<<ans<<std::endl;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  long long a[3];

  int K;
  
  std::cin >> a[0] >> a[1] >> a[2] >> K;

  std::sort(a, a + 3);

  std::cout << (a[2] << K) + a[0] + a[1] << std::endl;

  return 0;
}


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

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

int gcd(int a, int b) {
  if(a % b == 0) {
    return b;
  }
  return gcd(b, a % b);
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

vector<vector<int>> all_comb(int n, int k) {
  vector<vector<int>> combs(nCr(n, k), vector<int>(k));
  for(int i=0; i<k; i++) {
    combs[0][i] = i;
    combs[1][i] = i;
  }
  
  for(long i=1; i<nCr(n, k); i++) {
    int p = 1;
    while(combs[i][k - p] == n - p) {
      p++;
      if(p > k) {
        break;
      }
    }
    combs[i][k - p]++;
    int q = combs[i][k - p];
    for(int j=1; j<p; j++) {
      combs[i][k - p + j] = q + j;
    }

    if(i < nCr(n, k) - 1) {
      for(int j=0; j<k; j++) {
        combs[i + 1][j] = combs[i][j];
      }
    }
  }

  return combs;
}

int main() {
  std::cout << std::setprecision(9);
  int n;
  cin >> n;

  vector<pair<int, int>> jobs(n);
  for(int i=0; i<n; i++) {
    cin >> jobs[i].second >> jobs[i].first;
  }
  sort(jobs.begin(), jobs.end());

  long sum = 0;
  string ans = "Yes";
  for(int i=0; i<n; i++) {
    sum += jobs[i].second;
    if(sum > jobs[i].first) {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4820
#ABC079C - Train Ticket
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            # 答えは1つ出力すれば良いので =7 になれば終了
            print(f + "=7")
            exit()

    else:
        dfs(i + 1, f + "-" + s[i + 1], sum - int(s[i + 1]))
        dfs(i + 1, f + "+" + s[i + 1], sum + int(s[i + 1]))

s = list(str(input()))

dfs(0, s[0], int(s[0]))

Measured memory_bytes: 3064
def examA():
    N = S()
    ans = "ABC" + N
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


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

const int INF = 1e8;
int main(){
  int n,k;
  int a[8888];
  int dp[8888];

  cin >> n >> k;
  for(int i=0;i<n;i++)cin >> a[i];

  int amax = 0, ans = 0;
  for(int i=0;i<n;i++){
    if(amax<a[i]){
      for(int j=0;j<=n;j++)dp[j] = INF;
      for(int j=i;j<a[i];j++){
	if(a[i]<a[j])*lower_bound(dp,dp+n+1,a[j]) = a[j];
      }
      ans = max(ans, (int)(lower_bound(dp,dp+n+1,INF) - dp));
    }
  }

  cout << min(ans+1+k,n/2) << endl;
}

Measured memory_bytes: 1228
#include <stdio.h>
// #include <float.h>
 
int main(){
  int input;
  float probability;
  scanf("%d", &input);
  if(input%2==0)
    probability = (float)1/2;
  else{
    probability = (float)(input/2+1)/input;
  }
  printf("%f", probability);
}

Measured memory_bytes: 128