akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
        int D = sc.nextInt();
      int R = 0;
      while(A > 0 && C > 0){
        if(R % 2 == 0)
          C -= B;
        else
          A -= D;
        R++;
      }
        if(A <= 0)
			System.out.println("No");
        else
          System.out.println("Yes");
	}
}

Measured memory_bytes: 35764
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) fixed << setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

//素因数分解する
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  //引数にretを入れてn回使う時用
  if (n != 1 && ret.find(n) == ret.end())
    ret[n] = 1;
  else if (n != 1)
    ret[n] += 1;
  return ret;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  ll ans = 0;
  FOR(i, 1, N + 1) {
    ll po = N / i;
    ans += (i + (po * i)) * (po) / 2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<functional>
#define int long long

using namespace std;

signed main() {
	int n;
	int Ap, Bp;
	int Akg, Bkg[1010] = { 0 };
	int p, kg;
	int ans = 0;
	cin >> n;
	cin >> Ap >> Bp;
	cin >> Akg;
	p = Ap; kg = Akg;
	for (int i = 0; i < n; i++)cin >> Bkg[i];
	sort(Bkg, Bkg + n, greater<int>());
	for (int i = 0; i < n; i++) {
		p += Bp;
		kg += Bkg[i];
		int t = kg / p;
		if (ans <= t)ans = t;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
	float r;
	cin>>r;
    float d=2*3.141592653589793238462*r;
    cout << fixed <<setprecision(20) << d;
    
    return 0;
}

Measured memory_bytes: 3772
<?php
    $num = intval(trim(fgets(STDIN)));
    
    $num_array = array_map('intval',str_split(trim(fgets(STDIN))));
    
    //暗号の種類
    $count = 0;
    
    //調査したい文字列は3桁しかないので000～999の1000通りしかない
    for($i=0;$i<=9;$i++){
        for($j=0;$j<=9;$j++){
            for($k=0;$k<=9;$k++){
                //$num_arrayの左端から調査していく
                $key[0]=$k;
                $key[1]=$j;
                $key[2]=$i;
                for($x=0;$x<count($num_array);$x++){
                    if($key[0] == $num_array[$x]){
                        goto niketa;
                    }
                }
                niketa:
                for($x=$x+1;$x<count($num_array);$x++){
                    if($key[1] == $num_array[$x]){
                        goto sanketa;
                    }
                }
                sanketa:
                for($x=$x+1;$x<count($num_array);$x++){
                    if($key[2] == $num_array[$x]){
                        // $key = (string)$k.(string)$j.(string)$i;
                        // echo $key."\n";
                        $count++;
                        goto next;
                    }
                }
                next:
                // $key = (string)$k.(string)$j.(string)$i;
                // echo $key."\n";
            }
        }
    }
    echo $count."\n";
?>

Measured memory_bytes: 18840
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
ans = 0

for i in range(n):
    ans = ans + b[i]

for i in range(n-1):
    if a[i]==(a[i+1]-1):
        ans = ans + c[a[i]-1]

print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

string S;

int main(){
  cin >> S;
  int res = 0;
  for(int i=0;i<S.size();i++){
    if(S[i]!='J') continue;
    int jc,oc,ic; jc=oc=ic=0;
    int j;
    for(j=i;j<S.size();j++){
      if(S[j]!='J') break;
      jc++;
    }
    //    if(S[j]!='O') continue;
    for(;j<S.size();j++){
      if(S[j]!='O') break;
      oc++;
    }
    for(;j<S.size();j++){
      if(S[j]!='I') break;
      ic++;
    }
    //    res = max(res, min(jc, min(oc,ic)));
    if(oc <= ic && oc <= jc) res = max(res, oc);
    i = j-1;
  }

  cout << res << endl;
}

Measured memory_bytes: 2052
#include <stdio.h>

int main() {
  long a,b,temp;
  scanf("%ld %ld", &a, &b);

  if(b>a) {
    temp = a;
    a = b;
    b = temp;
  }
  while(b != 0) {
    temp = b;
    b = a%b;
    a = temp;
  }
  printf("%ld\n", a);

  return 0;
}

Measured memory_bytes: 592
#include <iostream>
    using namespace std;
     
    int main() {
        long long n,d;
        cin >> n >> d;
     
        long int x,y;
        int count = 0;
        for (int i=1; i<=n ; i++) {
            cin >> x >> y;
            if ((x*x + y*y) <= (d*d)){
                count++;
            }
        }
        cout << count << endl;
        return 0;
    }

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
inline int read(){
	int f=1,w=0;char x=0;
	while(!(x>='0'&&x<='9'))
	{
		x=getchar();
		if(x=='-') f=-1;
	}
	while(x!=EOF&&x>='0'&&x<='9')
	{
		w=(w<<3)+(w<<1)+(x^48);
		x=getchar();
	}
	return f*w;
}
int n,k,l,r[N],t[N];
map < pair < int,int >,int > mp;
int find(int x,int *f){
	if(f[x]==x) return x;
	else return f[x]=find(f[x],f);
}
void join(int x,int y,int *f){
	int px=find(x,f),py=find(y,f);
    if(px!=py) f[px]=py;
}
int main(){
	n=read(),k=read(),l=read();
	for(int i=1;i<=n;i++)
        r[i]=i,t[i]=i;
	for(int i=1;i<=k;i++)
	{
		int x=read(),y=read();
		join(x,y,r);
	}
	for(int i=1;i<=l;i++)
	{
		int x=read(),y=read();
		join(x,y,t);
	}
	for(int i = 1;i<=n;i++)
    {
        find(i,r);
        find(i,t);
    }
    for(int i = 1;i<=n;i++)
	    mp[make_pair(r[i],t[i])]++;
	for(int i = 1;i<=n;i++)
		cout<<mp[make_pair(r[i],t[i])]<<" ";
	return 0;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int gcd( int x, int y ){ return y ? gcd(y, x%y) : x; }
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
int a=0,b=0;
std::vector< pairint > v(6);
std::cin >> x>>y>>z;
if((x==1&&y==1)||z==1)std::cout << "Open" << '\n';
else std::cout << "Close" << '\n';
}



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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

int main() {
    int n;
    cin >> n;
    int a[n];
    int ans = 0;
    int ans2 = 0;
    std::vector<int> v;
    rep(i, n) {
        cin >> a[i];

        if ( a[i]%2 == 0 ) {
            ans++;
            if ( a[i]%3 == 0 || a[i]%5 == 0 ) {
                ans2++;
            }
        }
    }

    cout << (ans == ans2 ? "APPROVED" : "DENIED" ) << endl;
    return 0;
}


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

int main() {
    long long N;
    cin >> N;
    vector <long long> a(N);
    for (long long i=0; i<N; i++) cin >> a.at(i);
    long long cnt=1;
    long long ans=0;
    for (long long i=0; i<N; i++) {
        if (cnt!=a.at(i)) ans++;
        else cnt++;
    }
    if (cnt==1) cout << "-1\n";
    else cout << ans << endl;
}

Measured memory_bytes: 4832
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val z = sc.nextInt()
    val w = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    if (n == 1) {
        println(Math.abs(a[0] - w))
    } else {
        println(Math.max(Math.abs(a[n - 1] - w), Math.abs(a[n - 1] - a[n - 2])))
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define spc printf(" ")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007
#define FI freopen("input.txt","r",stdin)
#define FO freopen("output.txt","w",stdout)
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

using namespace std;

int main (){
	int n;
	si(n);
	if(n==1){
		printf("No\n");
		return 0;
	}
	string s1, s2;
	cin>>s1;
	int len = s1.length();
	for(int i=0; i<len/2; i++)
		s2 += s1[i];
	
	s1.erase(0, len/2);

	if(s1 == s2)
		printf("Yes\n");
	else printf("No\n");
	return 0;
}

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


int main ()
{

int a;
cin >> a;

if(a%2==0)
{
	cout << a << endl;
}
else
{
	cout << a*2 << endl;
}

 	return 0;
}












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

signed main() {
  ios::sync_with_stdio(false);

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

  vector<string> G(N);
  for (int i = 0; i < N; ++i) cin >> G[i];

  queue<tuple<int, int, int>> que;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      if (G[i][j] == '#') que.emplace(0, i, j);
    }
  }

  int ans = 0;
  while (que.size()) {
    int t, x, y;
    tie(t, x, y) = que.front();
    que.pop();
    ans = max(ans, t);
    for (int di = 0; di < 4; ++di) {
      const int dx[] = {1, 0, -1, 0};
      const int dy[] = {0, 1, 0, -1};
      int nx = x + dx[di];
      int ny = y + dy[di];
      if (nx < 0 || nx == N || ny < 0 || ny == M) continue;
      if (G[nx][ny] == '#') continue;
      G[nx][ny] = '#';
      que.emplace(t + 1, nx, ny);
    }
  }

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


Measured memory_bytes: 13456
#include<cstdio>
#include<cstring>
const int MAXN=3010;

long double p[MAXN],f[MAXN][MAXN>>1][2];

int main(){
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%Lf",&p[i]);
	f[1][0][0]=(1-p[1]);f[1][1][1]=p[1];
	for(int i=2;i<=n;i++){
		for(int j=0;j<=(n>>1);j++){
			if(j)
				f[i][j][1]=(f[i-1][j-1][0]+f[i-1][j-1][1])*p[i];
			f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])*(1-p[i]);
		}
	}
	long double ans=0;
	for(int i=0;i<=(n>>1);i++)
		ans+=f[n][i][0]+f[n][i][1];
	printf("%.17Lf\n",1-ans);
	return 0;
}

Measured memory_bytes: 141440
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

ll a,b;
string s;

/* add your algorithm here */

int main() {
  cin >> a;
  if (a % 2 == 0) {
    b = a / 2;
    b *= b;
    cout << b << endl;
  } else {
    b = a / 2;
    int c = b * (b + 1);
    cout << c << endl;
  }
}


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

int main(void)
{
    int n,a,b=0,i,j,h,l;
    scanf("%d",&n);
    int p[2][n];
    for(i=0; i<2; i++)
        for(j=0; j<n; j++)
            scanf("%d",&p[i][j]);
    for(i=n-1; i>=0; i--)
    {
        a=0;
        for(h=0; h<=i; h++)
        {
            a=a+p[0][h];
        }
        for(l=i; l<n; l++)
        {
            a=a+p[1][l];
        }
        if(a>b)
            b=a;
    }
    printf("%d\n",b);
    return 0;
}


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

int main() {
    int n,m;cin>>n>>m;
    
    int r1=100001,l1=0;
    
    for(int i=0;i<m;++i){
        int l,r;cin>>l>>r;
        r1=min(r1,r);
        l1=max(l1,l);
        }
    int ans=max(r1-l1+1,0);
    
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
 class Program
{
        static void Main()
{
int[,,]a=new int[4,3,10];
int b=int.Parse(Console.ReadLine());
for(int c=0;c<b;c++)
{
	int[]d= Console.ReadLine().Split().Select(int.Parse).ToArray();
	a[d[0]-1,d[1]-1,d[2]-1]+=d[3];
}
for(int e=0;e<4;e++){
	for(int f=0;f<3;f++){
    for(int g=0;g<10;g++){
		Console.Write(" "+a[e,f,g]);
		
		}
	Console.WriteLine();
	}
	if(e!=3)Console.WriteLine("####################");
	
}}}

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define vuni(v) v.erase(unique(v.begin(), v.end()), v.end());
#define mins(m, s) m.insert(make_pair(s, 1));
#define mfin(m, s) m.find(s) != m.end()

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9 + 7;

int main() {
    ll n;
    ll a[200005], cnt[200005];
    ll ans = 0;

    cin >> n;
    cnt[0] = 0;
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
        cnt[i + 1] = (cnt[i] + a[i]) % mod;
    }

    ll now;
    for(ll i = 0; i < n; i++) {
        now = cnt[n] - cnt[i + 1];
        if(now < 0)
            now += mod;
        ans += a[i] * now;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6680
# -*- coding:utf-8 -*-

def main():
    LIST=[]
    while True:
        try:
            IN=int(input())
            if IN==0:
                print(LIST[len(LIST)-1])
                del LIST[len(LIST)-1]
            else:
                LIST.append(IN)

        except:
            break
            
    
if __name__ == '__main__':
    main()

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m, ans =0;
	cin >>n >>m;
	
	ans = m * (m-1) /2;
	ans += n * (n-1)/2;
	cout <<ans <<"\n";
	
	return 0;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long 
#define ld long double
//=======================================================================================================
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
//=================================================================
#define vi vector<int>
#define vll vector<ll>
#define vvi vector< vector<int> >
#define vvll vector< vector<ll> >
#define vs vector<string>
#define si set<int>
#define sll set<ll>
#define ss set<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define pb push_back
#define fxsp(a) fixed<<setprecision(a)
//=============================================================
#define rFor(i,a,b) for(int i=a;i>b;i--)
#define For(i,a,b) for(int i=a;i<b;i++)
//=============================================================
void inout_fast(){
    //input output file && fast input
    ios::sync_with_stdio(0); 
    cin.tie(0);

    //freopen("input.txt","r",stdin);

      
}
//=====================================================================================================

int main(){
    inout_fast();
 //start coding :):):)  


    ll n;
    ll sum=0;
    cin>>n;
    for(ll i=1;i<=n;i++){
        if(i==1){
            sum+=1;
            continue;
        }
        else if(i%3==0||3%i==0||i%5==0||5%i==0||i%(3*5)==0)
            sum+=0;
        else
            sum+=i;
    }
    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>

using namespace std;

int main(){
    int A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;
    A*=100;
    B*=100;
    double condence,max_=0.0;
    int Weight=0,Sugar=0;

        for(int a=0;F>=a*A;++a){
            for(int b=0;F-a*A>=b*B;++b){
                for(int c=0;F-a*A-b*B>=c*C;++c){
                    for(int d=0;F-a*A-b*B-c*C>=d*D;++d){
                        if(c*C+d*D<=(a*A+b*B)/100*E){
                            condence=(double)(c*C+d*D)/(double)(a*A+b*B+c*C+d*D)*100.0;
                            if(condence>=max_){
                                max_=condence;
                                Weight=a*A+b*B+c*C+d*D;
                                Sugar=c*C+d*D;

                            }
                        }
                    }
                }
            }
        }
    cout<<Weight<<" "<<Sugar;

}

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

using namespace std;

// 1次元累積和で解けるのか？
int main()
{
  int n, k;
  cin >> n >> k;

  vector<int> a;
  a.resize(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }

  for (int p = 0; p < k; p++)
  {
    vector<int> b;
    b.resize(n);

    for (int i = 0; i < n; i++)
    {
      int l = max(0, i - a[i]);
      int r = min(n - 1, i + a[i]);

      b[l]++;
      if (r + 1 < n)
      {
        b[r + 1]--;
      }
    }

    for (int i = 1; i < n; i++)
    {
      b[i] += b[i - 1];
    }

    if (a == b)
    {
      break;
    }

    // 更新
    a = b;
  }

  for (int i = 0; i < n; i++)
  {
    cout << a[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 4808
let readInt _ = stdin.ReadLine() |> int

let readIntArray _ =
    stdin.ReadLine().Split(" ") |> Array.map int

()
|> readInt
|> readIntArray
|> fun x ->
    let sum = x |> Array.sum
    readInt ()
    |> fun x -> [| 1 .. x |]
    |> Array.map readIntArray
    |> Array.map (fun [| p; z |] -> sum - x.[p - 1] + z)
    |> Array.map string
    |> String.concat "\n"
    |> printfn "%s"


Measured memory_bytes: 29784
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    lint n,k;
    cin>>n>>k;
    set<lint> s;
    vec c(k);
    rep(i,k)cin>>c[i];
    rep(i,k)s.insert(c[i]);
    for(lint i=n;;i++){
        lint tmp=i;
        bool f=1;
        while(tmp){
            if(s.count(tmp%10))f=0;
            tmp/=10;
        }
        if(f){
            cout<<i;
            return 0;
        }
    }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

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

func main() {
	var s string
	fmt.Scan(&s)

	ans := 1000
	l := len(s)
	for i := 0; i+3 <= l; i++ {
		n, _ := strconv.Atoi(s[i : i+3])
		ans = min(ans, abs(753-n))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
five_hand = int(input())
one_hand = int(input())
fifty = int(input())
x = int(input())

count = 0

for i in range(five_hand+1):
    for j in range(one_hand+1):
        for k in range(fifty+1):
            res = 500*i + 100*j + 50*k
            if x == res:
                count += 1

print(count)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

void UF_init_set(int* set, long long int* size, int n){
    for(int k=0; k<n; k++){
        *(set + k) = k;
        *(size + k)= 1;
    }
}

int UF_set_find(int* set, int i){
    int r = i;
    while(*(set + r) != r){
        *(set + r) = *(set + *(set + r));
        r = *(set + r);
    }
    return r;
}

void UF_set_union(int* set, long long int* size, int i, int j){
    int p, q, tmp;
    p = UF_set_find(set, i);
    q = UF_set_find(set, j);
    if(p == q){
        return ;
    }
    if(*(size + p) < *(size + q)){
        tmp = p; p = q; q = tmp;
    }
    *(set + q) = p;
    *(size + p) += *(size + q);
}

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    int set[n];
    lld size[n];
    UF_init_set(set, size, n);
    int a[m], b[m];
    rep(i, 0, m){
        scanf("%d %d", &a[i], &b[i]);
        a[i]--; b[i]--;
    }
    lld ans[m];
    ans[m-1] = (lld)n * (n-1) / 2;
    revrep(i, m-1, 0){
        /*rep(j, 0, n){
            printf("%d ", group[j]);
        }
        printf("\n");*/
        int p = UF_set_find(set, a[i]);
        int q = UF_set_find(set, b[i]);
        if(p == q){
            ans[i-1] = ans[i];
        }else{
            ans[i-1] = ans[i] - size[p] * size[q];
            UF_set_union(set, size, p, q);
        }
    }
    rep(i, 0, m){
        printf("%lld\n", ans[i]);
    }

    return 0;
}

Measured memory_bytes: 3968
n = int(input())
array =[]

for i in range(n):
  num = int(input())
  array.append(num)

sorta = sorted(array)
max1 = sorta[-1]
max2 = sorta[-2]

for x in array:
  if x != max1:
    print(max1)
  else:
    print(max2)


Measured memory_bytes: 14112
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
#define _GLIBCXX_DEBUG
                    
using ll = long long;
using ull = unsigned long long;
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; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}


int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  string S; cin >> S;
  int N = S.length();
  string T;
  
  rep(i, N) {
    T += S.at(N-1-i);
  }
  cerr << T << " " << S;
  

  //元の文と回文に比較
  int count = 0;
  rep(i, N) {
    if(T.at(i) != S.at(i)) count++;
  cerr << T.at(i) << " " << S.at(i) << endl;
   }
  
  cout << count/2 << endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n, k;
    std::cin >> n >> k;
    std::vector<i64> a(n + 1);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i + 1];
        a[i + 1] += a[i];
    }
    std::map<i64, i64> s;
    i64 ma = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            auto k = a[j] - a[i];
            ma = std::max(ma, k);
            s[k]++;
        }
    }

    i64 b = 1;
    while (ma >= (1ll << (b + 1))) b++;

    i64 ret = 0;
    i64 cnt = n * (n + 1) / 2;
    for (i64 i = b; i >= 0; i--) {
        auto m(s);
        auto tmp = cnt;
        for (auto it = m.begin(); it != m.end(); it++) {
            if ((it->first >> i) & 1ll) continue;
            tmp -= it->second;
            m.erase(it);
        }
        if (tmp >= k) {
            ret += (1ll << i);
            std::swap(s, m);
            cnt = tmp;
        }
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 62848
#include <iostream>

int main(){
    int a,b,c;
    std::cin>>a>>b>>c;
    int ans=3;
    if(a==b)ans--;
    if(b==c)ans--;
    if(c==a)ans--;
    std::cout<<(ans==0?1:ans)<<std::endl;
    return 0;
}

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

int main(){
  int N; cin >> N;
  int a[N]; REP(i,N){cin>>a[i];}
  int count = 0;
  REP(i,N){
    int r = i+1;
    int love = a[i];
    int lovelove = a[love-1];
    if(r==lovelove){count++;}
  }
  cout << count/2 << "\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; (i) < ((int)(n)); ++(i))
const ll INF = 1e10;
const ll MOD = 1e9 + 7;

int main() {
    int ans;
    cin >> ans;
    ans = abs(1 - ans);

    cout << ans << endl;
}

Measured memory_bytes: 3628
# include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
 
const int N = int(2e5) + 2; 
const int LG = 20;
const ll mod = 998244353;
const int INF = 2147483647;
const ll linf = 1e18;
const ld pi = acos(-1);
const ld EPS = 1e-10;

int a, b;
int main (){
	cin >> a >> b;
	int ans = 0, curlen = 1;
	while (curlen < b){
		++ans;
		curlen = curlen + a - 1;
	}
	return !printf ("%d\n", ans);	
}

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

int main(){
    double a,b;
    cin >> a >> b;
    int answer = 1500;
    for(int i = 10; i <= 1250; i++){
        if(a <= floor(i*0.08) && a+1 > floor(i*0.08)){
            if(b <= floor(i*0.1) && b+1 > floor(i*0.1)){
                answer = i;
                break;
            }
        }
    }
    if(answer == 1500){
        cout << "-1";
    } else {
        cout << answer;
    }
}

Measured memory_bytes: 256
N = int(input())
xy = []

for i in range(N):

    newxy = list(map(int,input().split()))
    xy.append(newxy)

ans = -1
now = 0

for i in range(N):

    for j in range(i):

        now = 0

        p = xy[j][0] - xy[i][0]
        q = xy[j][1] - xy[i][1]


        #print ("p:",p,"q:",q)
        

        xydic = {}

        for k in xy:

            if str(k) in xydic:

                continue
                #print (k,"はすでにxydicに含まれています！")

            else:

                now += 1

                xydic[str(k)] = 1

                #print(k,"をxydicに始点として含めました")

                plbul = True

                cnt = 1
                while plbul:

                    if [ k[0] + cnt * p , k[1] + cnt * q ] in xy :

                        xydic [str([k[0] + cnt * p , k[1] + cnt * q])] = 1
                        #print ([k[0] + cnt * p , k[1] + cnt * q],"を+でxydicに含めました")
                        cnt += 1

                    else:
                        plbul = False

                cnt = -1

                plbul = True
                
                while plbul:

                    if [ k[0] + cnt * p , k[1] + cnt * q ] in xy :

                        xydic [str([k[0] + cnt * p , k[1] + cnt * q])] = 1
                        #print ([k[0] + cnt * p , k[1] + cnt * q] ,"を-でxydicに含めました" )
                        cnt -= 1

                    else:
                        plbul = False

                #print ("now",now)

                                
        if now < ans or ans < 0:
            ans = now
            #print (xydic)

if N == 1:
    ans = 1

print (ans)
            


Measured memory_bytes: 3064
n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]
true_buy = float("inf")
for i in range(2**n):
  buy = []
  buy_sum = 0
  for j in range(n):
    if (i>>j) & 1:
      buy.append(ca[j])
      buy_sum += ca[j][0]
  for k in range(m):
    gain = 0
    for l in range(len(buy)):
      gain += buy[l][k+1]
    if gain < x:
      buy_sum = float("inf")
  true_buy = min(buy_sum,true_buy)
if true_buy == float("inf"):
  print(-1)
else:
  print(true_buy)

Measured memory_bytes: 68868
import java.util.Scanner;
 
class Main {
        public static void main(String[] args) {
               Scanner sc = new Scanner(System.in);
               while (true) {
                      int x = sc.nextInt();
                      if (x == 0){
                              break;
                      }
                      double sum = 0;
                      int[] y = new int[x];
                      for (int i = 0; i < x; i++) {
                              y[i] = sc.nextInt();
                              sum += y[i];
                      }
                      double c = sum / x;
                      double d = 0;
                      for (int i = 0; i < x; i++) {
                              d += Math.pow(y[i] - c, 2) / x;
                      }
                      System.out.println(Math.sqrt(d));
               }
 
        }
}

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

using namespace std;


#define PI 3.14159265
#define int long long


const int EPS = 80 * 80 * 2;

main(){

	int h, w; cin >> h >> w;

	int zero = EPS / 2;

	vector < vector <int> > a(h, vector <int> (w)), b(h, vector <int> (w));

	vector < vector < bitset <EPS> > > d(h, vector < bitset <EPS> > (w));

	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> a[i][j];
		}
	}

	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> b[i][j];
		}
	}

	d[0][0][zero + abs(a[0][0] - b[0][0])] = 1;
	d[0][0][zero - abs(a[0][0] - b[0][0])] = 1;

	for(int i = 1; i < w; i++){

		int shift = (a[0][i] - b[0][i]);

		auto left = d[0][i - 1] << abs(shift);
		auto right = d[0][i - 1] >> abs(shift);

		d[0][i] = left | right;
	}

	for(int i = 1; i < h; i++){

		int shift = (a[i][0] - b[i][0]);

		auto left = d[i - 1][0] << abs(shift);
		auto right = d[i - 1][0] >> abs(shift);

		d[i][0] = left | right;
	}

	for(int i = 1; i < h; i++){
		for(int j = 1; j < w; j++){

			int shift = (a[i][j] - b[i][j]);

			d[i][j] |= (d[i - 1][j] << abs(shift));
			d[i][j] |= (d[i - 1][j] >> abs(shift));

			d[i][j] |= (d[i][j - 1] << abs(shift));
			d[i][j] |= (d[i][j - 1] >> abs(shift));
		}
	}

	int ans = 1e9;

	for(int i = 0; i < EPS; i++){
		if(d[h - 1][w - 1][i]){
			ans = min(ans, abs(zero - i));
		}
	}


	cout << ans << endl;

	return 0;
}

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

int N, x;
vector<int> A;

int main(void) {
	cin >> N >> x;
	int sz = 2 * N - 1;
	if (x <= 1 || x >= sz) {
		cout << "No\n";
		return 0;
	}
	
	if (N == 2) {
		A.resize(3);
		A[0] = 1; A[1] = 2; A[2] = 3;
	}
	else {
		A.resize(sz);
		int cp = sz / 2;
		int lv, rv;
		if (x == 2) {
			A[cp - 2] = 5; A[cp - 1] = 3; A[cp] = 2; A[cp + 1] = 1; A[cp + 2] = 4;
			lv = 1; rv = 5;
		}
		else if (x == 4) {
			A[cp - 2] = 1; A[cp - 1] = 3; A[cp] = 4; A[cp + 1] = 5; A[cp + 2] = 2;
			lv = 1; rv = 5;
		}
		else {
			A[cp - 2] = x + 2; A[cp - 1] = x - 1; A[cp] = x; A[cp + 1] = x + 1; A[cp + 2] = x - 2;
			lv = x - 2; rv = x + 2;
			if (x + 2 > sz) {
				A[cp - 2] = x - 3; lv = x - 3; rv = x + 1;
			}
			if (x - 2 < 1) {
				A[cp + 2] = x + 3; lv = x - 1; rv = x + 3;
			}
		}
		int val = 1;
		for(int i = 0; i < cp - 2; ++i) {
			if (val == lv) val = rv + 1;
			A[i] = val++;
			if (val == lv) val = rv + 1;
			A[sz - i - 1] = val++;
		}
	}
	
	cout << "Yes\n";
	for(int i = 0; i < sz; ++i)
		cout << A[i] << '\n';
	return 0;
}


Measured memory_bytes: 2304
use std::io::{ stdin, stdout, BufRead, Write };

const SP   : u8 = b' ';
const LF   : u8 = b'\n';
const ZERO : u8 = b'0';

#[inline(always)]
fn uitoa(mut n: usize, buf: &mut Vec<u8>) {
  buf.clear();
  if n == 0 {
    buf.push(ZERO);
    return;
  }

  while n > 0 {
    buf.push((n % 10) as u8 + ZERO);
    n /= 10;
  }

  buf.reverse();
}

#[inline(always)]
fn atoui(s: &[u8]) -> usize {
  let mut n = 0;
  for b in &s[..] { n = n * 10 + (b - ZERO) as usize; }
  n
}

#[inline(always)]
fn vec_write_with(buf: &mut Vec<u8>, s: &mut Vec<u8>, b: u8) {
  s.push(b);
  buf.write(s).unwrap();
}

macro_rules! input {
  ($stdin:ident, $delim:expr, $buf:ident) => {
    {
      $buf.clear();
      let len = $stdin.read_until($delim, &mut $buf).unwrap();
      $buf.truncate(len - 1);
      atoui(&$buf)
    }
  };
}

macro_rules! subroutine {
  ($buf:ident, $ans:ident, $odd:ident, $n:ident, $i:ident, $j:ident, $x:ident, $y:ident, $num:ident) => {
    if $odd != 0 {
      uitoa($y + 1, &mut $num);
      vec_write_with(&mut $ans, &mut $num, SP);

      uitoa($x + 1, &mut $num);
      vec_write_with(&mut $ans, &mut $num, SP);

      uitoa($i + 1, &mut $num);
      vec_write_with(&mut $ans, &mut $num, SP);

      uitoa($j + 1, &mut $num);
      vec_write_with(&mut $ans, &mut $num, LF);

      $n += 1;
    }
    $odd ^= $buf[$j * 2] & 1;
    $y = $i;
    $x = $j;
  };
}

fn main() {
  let stdin = stdin();
  let mut stdin = stdin.lock();

  let mut buf = Vec::with_capacity(500 * 2);
  let h = input!(stdin, SP, buf);
  let w = input!(stdin, LF, buf);

  let mut num = Vec::with_capacity(3);
  let mut ans = Vec::with_capacity(8 * 500 * 500);
  let mut n   = 0;

  let mut odd = 0;
  let mut x   = 0;
  let mut y   = 0;

  for i in 0..h {
    buf.clear();
    stdin.read_until(LF, &mut buf).unwrap();

    if i % 2 == 0 {
      for j in 0..w {
        subroutine!(buf, ans, odd, n, i, j, x, y, num);
      }
    } else {
      for mut j in 0..w {
        j = w - 1 - j;
        subroutine!(buf, ans, odd, n, i, j, x, y, num);
      }
    }
  }

  let stdout = stdout();
  let mut stdout = stdout.lock();

  uitoa(n, &mut buf);
  buf.push(LF);
  stdout.write(&buf).unwrap();

  stdout.write(&ans).unwrap();
  stdout.flush().unwrap();
}


Measured memory_bytes: 8188
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    int n;
    cin >> n;
    cout << ((n % 2 == 0) ? (n / 2 - 1) : n / 2) << endl;
}

Measured memory_bytes: 256
n = int(input())
A,B = map(int,input().split())
p = list(map(int,input().split()))
a1 = 0
for i in range(A+1):
    a1 += p.count(i)
a2 = 0
for i in range(A+1,B+1):
    a2 += p.count(i)
a3 = 0
for i in range(B+1,21):
    a3 += p.count(i)

print(min(a1,a2,a3))

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

int main() {
    ll X;
    cin >> X;
    int ans = 0;
    ll dep = 100;
    while(dep < X) {
        dep *= 1.01;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  ll n,m,ans=0,cun;
  string s[1000],t[1000];
  cin>>n;
  for(ll i=0;i<n;i++){
    cin>>s[i];
  }
  cin>>m;
  for(ll i=0;i<m;i++){
    cin>>t[i];
  }
  for(ll i=0;i<n;i++){
    cun = 0;
    for(ll j=0;j<n;j++){
      if(s[i]==s[j]){
        cun++;
      }
    }
    for(ll j=0;j<m;j++){
      if(s[i]==t[j]){
        cun--;
      }
    }
    ans = max(ans,cun);
  }
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int ara[n+5];
  memset(ara,0,sizeof ara);
  for(int i=1;i<=m;i++)
  {
    int a,b;
    cin>>a>>b;
    ara[a]++;
    ara[b]++;
  }
  for(int i=1;i<=n;i++)cout<<ara[i]<<endl;
}

Measured memory_bytes: 256
import collections

N = int(input())
A = list(map(int, input().split()))
a_dic = collections.Counter(A)
Q = int(input())
sum_a = sum(A)
for i in range(Q):
    b, c = list(map(int, input().split()))
    sum_a += (c-b) * a_dic[b]
    if b not in a_dic:
        pass
    else:
        if c not in a_dic:
            a_dic[c] = a_dic[b]
        else:
            a_dic[c] += a_dic[b]
        a_dic[b] = 0
    print(sum_a)

Measured memory_bytes: 21380
#include <iostream>
#include <algorithm>
#include <string>
#include <cctype>
using namespace std;

string decode (string S,int a,int b){
	for(string ::iterator it=S.begin() ;it!=S.end();it++)
		if(islower(*it))
			*it=(((*it-'a')*a+b)%26)+'a';
	return S;
} 

int main(){
	int n;
	cin >> n;
	cin.ignore();
	for(int i=0;i<n;i++){
		string S,T;
		getline(cin,S);
		for(int j=0;j<26;j++){
			for(int k=0;k<26;k++){
				T=decode(S,j,k);
				if(T.find("that")!=-1||T.find("this")!=-1)
				k=27,j=27;
			}
		}
		cout << T << endl;
	}
}

Measured memory_bytes: 1216
/**
 * Created by hiramekun at 23:55 on 2019-10-20.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n) {
        cin >> s[i];
    }
    sort(all(s));
    string ans;
    rep(i, n) {
        ans += s[i];
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
N = int(input())
B = list(map(int,input().split()))

A = [-1]*N
ans = 0
for i in range(N-1):
    b = B[i]
    B[i] = (b, i)

B.sort()

for i in range(N-1):
    index = B[i][1]
    b = B[i][0]
    
    if A[index] == -1:
        A[index] = b
    if A[index+1] == -1:
        A[index+1] = b   

print(sum(A))


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
const int p=1e9+7;
int n,fac[N],inv[N];
inline int pw(int x,int y){
	int ans=1;
	while(y){
		if(y&1)ans=1ll*ans*x%p;
		x=1ll*x*x%p; y>>=1;
	}
	return ans;
}
inline int C(int n,int m){
	if(m<0||m>n)return 0;
	return 1ll*fac[n]*inv[m]%p*inv[n-m]%p;
}
int main(){
	fac[0]=inv[0]=1; for(int i=1; i<N; ++i)fac[i]=1ll*fac[i-1]*i%p,inv[i]=pw(fac[i],p-2);
	scanf("%d",&n);
	int ans=0;
	for(int i=n-2; i>=0; --i){
		int tmp=(C(n-2,i)+C(n-2,i-1)-C(i-1,2*i-n))%p;
		tmp=1ll*tmp*fac[i]%p*fac[n-i-1]%p;
		if(!i)tmp=fac[n-i-1];
		ans=(ans+tmp)%p;
	}
	printf("%d",(ans+p)%p);
	return 0;
}

Measured memory_bytes: 8064
#include <stdio.h>
#include <stdlib.h>
int main()
{
    long long   A,B,K;
    scanf("%lld%lld%lld",&A,&B,&K);
    long long sum=A+B;
    if(sum<=K)
    {
        A=0; B=0;
    }
    else
    {
        if(A>K)
        {
            A=A-K;
            B=B;
        }
        else
        {
            A=0;
            B=sum-K;
        }
    }
    printf("%lld %lld",A,B);
    return 0;
}


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

using namespace std;
using ll = long long;

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

  ll sum1 = 0, ans1 = 0;

  for (int i = 0; i < N; ++i) {
    sum1 += a[i];

    if (i%2 == 0) {
      // +
      if (sum1 > 0) continue;
      ans1 += 1-sum1;
      sum1 = 1;
    } else {
      // -
      if (sum1 < 0) continue;
      ans1 += sum1+1;
      sum1 = -1;
    }
  }

  ll sum2 = 0, ans2 = 0;

  for (int i = 0; i < N; ++i) {
    sum2 += a[i];

    if (i%2 == 1) {
      // +
      if (sum2 > 0) continue;
      ans2 += 1-sum2;
      sum2 = 1;
    } else {
      // -
      if (sum2 < 0) continue;
      ans2 += sum2+1;
      sum2 = -1;
    }
  }

  cout << min(ans1, ans2) << endl;

}

Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in(),m=in();
    vec u(m),v(m);
    rep(i,m){
        u[i]=in()-1;
        v[i]=in()-1;
    }
    int S=in()-1,T=in()-1;
    vector<vec>edge(n);
    priority_queue<pair<int,pii>> que;
    rep(i,m){
        edge[u[i]].pb(v[i]);
        if(u[i]==S){
            que.push(mp(-1,mp(S,v[i])));
        }
    }
    vector<vector<bool>> ans(n,vector<bool>(3,false));
    ans[S][0]=true;
    while(!que.empty()){
        int cost=-que.top().first,to=que.top().second.second;
        que.pop();
        if(cost%3==0&to==T){
            cout<<cost/3<<endl;
            return 0;
        }
        if(!ans[to][cost%3]){
            ans[to][cost%3]=true;
            REP(e,edge[to]){
                que.push(mp(-cost-1,mp(to,e)));
            }
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 13568