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

#define ms(s, n) memset(s, n, sizeof(s))
#define f(i, a, b) for (int i = (a); i <=(b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	vi a(n);
	ll sum = 0;
	map<ll, ll>cnt;
	f(i, 0, n - 1) {
		cin >> a[i];
		sum += a[i];
		cnt[a[i]]++;
	}
	int q;
	cin >> q;
	f(c, 1, q) {
		ll curv, newv;
		cin >> curv >> newv;
		auto it = cnt.find(curv);
		if (it != cnt.end()) {
			ll count = (*it).se;
			sum -= curv * count;
			sum += newv * count;
			cnt[newv] += count;
			cnt.erase(it);
		}
		cout << sum << endl;
	}
	// read the stuff at the bottom
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* use int when constraints limits are tight
	* Time taken : global variable < pass by refernce < pass by value
	* It takes significant amt. of time in pass by value
*/





























Measured memory_bytes: 7844
import java.io.*;
import java.util.*;
class Program{
    
}
class Main{
    public static void main(String[] args) {
        Program obj = new Program();
        Scanner in = new Scanner(System.in);
        int N = Integer.parseInt(in.nextLine());
        ArrayList<String> S = new ArrayList<String>();
        for(int i=0;i<N;i++) S.add(in.nextLine());
        boolean flag = true;
        for(int i = 0;i<S.size()-1;i++){
            if (S.get(i).charAt( S.get(i).length()-1 ) != S.get(i+1).charAt(0) ){
                flag = false; break;
            }
        }
        //System.out.println(new HashSet<String>(S).size());
        if (flag==true && new HashSet<String>(S).size()==N) System.out.println("Yes");
        else System.out.println("No");    
    }
}

Measured memory_bytes: 23892
n = gets.to_i
t = x = y = 0
n.times do
  ti, xi, yi = gets.split.map(&:to_i)
  td = ti - t
  d = (xi - x).abs + (yi - y).abs
  m = d - td
  if m > 0 || m % 2 != 0
    puts 'No'
    exit
  end

  t = ti
  x = xi
  y = yi
end
puts 'Yes'

Measured memory_bytes: 14256
#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950288419716939937510
int main(){
  //入力
  double a,b,x;
  cin>>a>>b>>x;

  double thr=a*a*b/2;
  double ans;
  if(x<=thr){
    ans=atan(a*b*b/(2*x))*180/PI;
  }else{
    ans=atan((2*(a*a*b-x))/(a*a*a))*180/PI;
  }
  cout<<fixed<<ans<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
	int W,H,x,y;
  	cin >> W >> H >> x >> y;
  	int check = 0;
  	if(W==x*2 && H==y*2) check = 1;
  	
  	double ans;
  	//キャスト演算子を使用
  	ans = (double)W*H/2;
  	printf("%0.6f %d\n",ans, check);
}

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

#define MOD 1000000007

using ll = long long;


int main(void) {
    int x,y,z;
    cin >> x >> y >> z;
    int ans;
    ans = (x - z) / (y + z);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
n=int(input())
flag=0
w=[]
used=[]
for _ in range(n):
    w.append(str(input()))
for i in range(n):
    if i==0:
        used.append(w[i])
    else:
        if (w[i] not in used) and (w[i-1])[-1]==(w[i])[0:1]:
            used.append(w[i])
        else:
            print('No')
            flag+=1
            break
if flag>0:
    pass
else:
    print('Yes')


Measured memory_bytes: 3064
import java.util.*;

/*
問題文


*/

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        String temp[] = new String[s.length()];
        String Flg = "No";
        for (int i = 0; i < s.length(); i++) {
            temp[i] = String.valueOf(s.charAt(i));
        }

        // 配列のインデックスを利用して、文字列を変換
        if (temp[2].equals(temp[3]) && temp[4].equals(temp[5])) {
            Flg = "Yes";
        }
        System.out.println(Flg);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>

using namespace std;

int main(void) {
  int N, A, B;
  string str;

  cin >> N >> A >> B;
  cin >> str;


  for(int i = 0; i < str.size(); i++) {
    switch(str[i]) {
      case 'a':
        if(A > 0) {
          cout << "Yes" << endl;
          A--;
        } else if(B > 0) {
          cout << "Yes" << endl;
          B--;
        } else {
          cout << "No" << endl;
        }
        break;
      case 'b':
        if(B > 0) {
          cout << "Yes" << endl;
          B--;
        } else {
          cout << "No" << endl;
        }
        break;
      case 'c':
        cout << "No" << endl;
    }

  }


  return 0;
}



Measured memory_bytes: 896
#include <iostream>
#include<algorithm>
#include<stack>
#include<string>
#include<cstdlib>
#include<stdio.h>

int binarysearch(int a[],int n,int key){
    int left=0;
    int right=n;
    int mid;
    while(left<right){
        mid=(left+right)/2;
        if(key==a[mid])return 1;
        if(key>a[mid])left=mid+1;
        else if(key<a[mid])right=mid;
    }
    return 0;
}
using namespace std;
int main(){
    int i,n,a[100001],q,key,sum=0;
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    scanf("%d",&q);
    for(i=0; i<q; i++){
        scanf("%d",&key);
        if(binarysearch(a,n,key))sum++;
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 3492
import sys
readline=sys.stdin.readline

N=int(readline())
# 1～(N - 1)の約数を数える

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
  
ans = 0
for i in range(1, N):
  for j in range(i, N, i):
    ans += 1

print(ans)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (int) 1e9+7
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vi vector<int>
ll xpow(ll a, ll b)
{
	if (b == 0)
		return 1;
	if (b % 2 == 0)
	{
		ll k = xpow(a, b / 2);
		return k * k;
	}
	if (b % 2 != 0)
		return a * xpow(a, b - 1);
}
int main()
{

#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out1.txt", "w", stdout);
#endif
	fio;
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i])
			cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3804
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);   
    //金額
    int x = sc.nextInt();
    //購入できる数
    int num = x/100;
    //端数
    int a = x - num*100;
    //num=2の時200～210円の中で買える
    //端数が購入できる数*5以内の時、可とする
    if(num*5>=a ){
        System.out.println(1);
      }else{
        System.out.println(0);
      }
  }
}

Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
    vec.at(i) -= i+1;
  }
  sort(vec.begin(), vec.end());
  int b = 0;
  if(N %2 == 0){
    b = (vec.at(N/2) + vec.at((N-1)/2) )/2;
  }
  else{
    b = vec.at(N/2);
  }
  int64_t ans = 0;
  for(int i=0; i<N; i++){
    ans += abs(vec.at(i) - b);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
/* ex2_3
   kento_titech*/
#include <stdio.h>
 
int main(void){
  int N,A;
  
  scanf("%d\n",&N);//N入力
  scanf("%d",&A);//A入力
  if((1<=N<=100)&&(0<=A<=(N*N))){ 
    printf("%d\n",N*N-A);//N*N-A出力
  }
  return 0;
 
}


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, K;
    cin >> N >> K;
    ull n = N/K;
    auto res = n*n*n;
    if(K%2==0){
        n = (N+K/2)/K;
        res += n*n*n;
    }
    cout<< res <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i,n) for(int i = 0; i < n; i++)
using namespace std;

int gcd(int a, int b){
    if(a==0)return b;
    return gcd(abs(b%a),a);
}
int main(void){
    // Your code here!
    int n, m;
    int x[100001];
    cin>>n>>m;
    REP(i,n)cin>>x[i];
    int result = abs(m-x[0]);
    REP(i,n)result=gcd(result,m-x[i]);
    cout<<result;
}

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

using namespace std;

int main() {
  string r,g,b;
  cin >> r >> g >> b;

  int sum = stoi(r + g + b);
  if(sum % 4 == 0)
    cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  long  L0=2,L1=1;
  if(N==0)cout<<L0<<endl;
  if(N==1)cout<<L1<<endl;
  for(int i=2; i<=86; i++){
    long L2=L0+L1;
    if(N==i)cout<<L2<<endl;
    L0=L1;
    L1=L2;
  }
}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;

const long mod = 1000000007;
const long indlim = 5368709119;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long res;
	long P, Q, R; cin >> P >> Q >> R;
	res = P + Q + R - max(max(P, Q), R);
	cout << res;
}

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

int WaterBill(int w){
	int bill=1150;
	
	if(w>=10 && w<=20)bill += 125*(w-10);
	else if(w>=20 && w<=30)bill += 1250 + 140*(w-20);
	else if(w>=30)bill += 1250 + 1400 + 160*(w-30);
	
	return bill;
}

int main() {
	int w;
	while(cin>>w,w+1){
		cout << 4280 - WaterBill(w) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
using System;

namespace XCubic
{
	class MainClass
	{
		static private int x;
		static private int cubic;

		private static void getIntValue()
		{
			x = int.Parse(Console.ReadLine());
			if (1 > x || 100 < x)
			{
				x = 0;
			}
		}

		private static void calcCubic()
		{
			cubic = x * x * x;
		}

		private static void puts()
		{
			Console.WriteLine(cubic);
		}

		public static void Main(string[] args)
		{
			getIntValue();
			calcCubic();
			puts();
		}
	}
}

Measured memory_bytes: 9124
def nCr(n, r)
  return 1 if r == 0
  return $c[n][r]
end

N, K = gets.split(" ").map(&:to_i)
$c = Array.new(N+1){Array.new(N+1)}
1.upto(N) do |i|
  1.upto(i) do |j|
    if i == j
      $c[i][j] = 1
    elsif j == 1
      $c[i][j] = i
    else
      $c[i][j] = $c[i-1][j-1] + $c[i-1][j]
    end
  end
end
1.upto(K) do |i|
  if N-K+1 < i
    puts 0
  else
    div = nCr(K-1, i-1)
    puts (nCr(N-K+1, i)*div)%(10**9+7)
  end
end

Measured memory_bytes: 394984
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if(A+B < C+D) cout << "Right" << endl;
  if(A+B == C+D) cout << "Balanced" << endl;
  if(A+B > C+D) cout << "Left" << endl;
}

Measured memory_bytes: 256
N,W=map(int,input().split())
dp=[[float("inf")]*(10**5+1) for i in range(N+1)]
dp[0][0]=0
for i in range(N):
  w_,v_=map(int,input().split())
  for v in range(10**5+1):
    dp[i+1][v]=min(dp[i][v],dp[i][v-v_]+w_)
for v in range(10**5+1)[::-1]:
  if dp[N][v]<=W:
    print(v)
    exit()

Measured memory_bytes: 312984
#include<stdio.h>
int main(void){
	int n,m,l,i,j,k;
	scanf("%d %d %d",&n,&m,&l);
	int a[n][m],b[m][l];
	long long int c[n][l];
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			scanf("%d",&b[i][j]);
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			c[i][j]=0;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			for(k=0;k<m;k++){
				c[i][j]+=a[i][k]*b[k][j];
			}
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			printf("%lld",c[i][j]);
			if(j!=l-1)printf(" ");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2096
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		var r = Console.ReadLine().Split().ToArray();
		string s = r[0];
		string t = r[1];
		
		string[] u = new string[2*n];
		for(int i=0;i!=n;i++){
			u[2*i] = s.Substring(i,1);
			u[2*i+1] = t.Substring(i,1);
		}
		
		Console.WriteLine(string.Join("",u));
		
	}
}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	if (A + B >= C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
map<ll,ll> a;
int main(){
  int n;cin>>n;
  rep(i,n){
    ll x;cin>>x;
    a[x]++;
  }
  ll cnt=0;
  for(auto itr=a.begin();itr!=a.end();++itr){
    ll a=itr->first;
    ll b=itr->second;
    if(a>b){
      cnt+=b;
    }else{
      cnt+=(b-a);
    }
  }
  cout<<cnt;
}

Measured memory_bytes: 9388
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int N, R;
	cin >> N >> R;
	cout << R + 100 * (10 - min(10, N));
		 
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int INF = 10000000;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> E(N * 3);
  for (int i = 0; i < M; i++){
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    E[u * 3].push_back(v * 3 + 1);
    E[u * 3 + 1].push_back(v * 3 + 2);
    E[u * 3 + 2].push_back(v * 3);
  }
  int S, T;
  cin >> S >> T;
  S--;
  T--;
  vector<int> d(N * 3, INF);
  d[S * 3] = 0;
  queue<int> Q;
  Q.push(S * 3);
  while (!Q.empty()){
    int v = Q.front();
    Q.pop();
    for (auto w : E[v]){
      if (d[w] == INF){
        d[w] = d[v] + 1;
        Q.push(w);
      }
    }
  }
  if (d[T * 3] == INF){
    cout << -1 << endl;
  } else {
    cout << d[T * 3] / 3 << endl;
  }
}

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

int n;
ll X, D;
unordered_map<ll, vector<pair<ll,ll>>> mp;

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n>>X>>D;
    if (D==0) {
        if (X!=0) cout<<n+1;
        else cout<<1;
        return 0;
    }

    for (int k=0; k<=n; ++k) {
        ll L=X*k+D*k*(k-1)/2;
        ll R=X*k+D*k*(2*n-k-1)/2;
        if (R<L) swap(L,R);
        ll du=L%abs(D);
        if (du<0) du+=abs(D);
        mp[du].emplace_back(L, R);
    }

    D=abs(D);
    ll ans=0;
    for (auto p: mp) {
        auto &v=p.second;
        vector<pair<ll,ll>> q;

        sort(v.begin(), v.end());
        for (auto &x: v) {
            ll tmp=(x.first-v[0].first)/D;
            q.emplace_back(tmp, tmp+(x.second-x.first)/D);
        }
        sort(q.begin(), q.end());

        ll last=LLONG_MIN;
        for (auto &x: q) {
            if (x.second<=last) continue;
            ans+=x.second-max(last, x.first);
            if (x.first>last) ++ans;
            last=max(last, x.second);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 17864
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define Boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const long MOD = 1000000007;

long long Power(long long a,long long b) {
    long long x=1;
    long long MOD = 1000000007;
    for(;b;b>>=1) {
        if(b&1) x = x*a%MOD;
        a = a*a%MOD;
    }
    return x;
}

long long ModInverse(long long c) {
    return Power(c,MOD-2);
}

void Crack() {
	long n;
    cin >> n;
    vector <long> A(n);
    for(int i=0;i<n;i++) cin >> A[i];
    long long sm=0;
    for(int i=0;i<n;i++) sm += A[i];
    long long ans = 0;
    for(int i=0;i<n;i++) {
        ans = ans + (((sm-A[i])%MOD)*A[i])%MOD;
        ans = ans%MOD;
    }
    ans = (ans*ModInverse(2))%MOD;
    cout << ans << endl;
}

int main() {
	Boost;
    Crack();
	return 0;
}

Measured memory_bytes: 4772
N, L = map(int, input().split())
A = [int(a) for a in input().split()]

CanRemain = []
CutFirst = []
for i in range(N-1):
    if A[i] + A[i+1] >= L: CanRemain.append(i+1)
    else: CutFirst.append(i+1)

if not CanRemain: print("Impossible")
else:
    print("Possible")
    for num in CutFirst:
        if num < CanRemain[-1]: print(num)
        else: break
    for i in reversed(range(len(CutFirst))):
        if CutFirst[i] > CanRemain[-1]: print(CutFirst[i])
        else: break
    for num in CanRemain: print(num)

Measured memory_bytes: 14068
#include "stdio.h"
int main()
{
    int ret,num1,num2,product;
  
    ret = scanf("%d",&num1);
	ret = scanf("%d",&num2);
  
	product = num1*num2;
  
 	if((product % 2) == 0)
		printf("Even");
	  else
		printf("Odd");
	return 0;
}

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

int main() {
	long long n;
	cin >> n;
	long long ans = 0;
	for (long long i = 1; i <= n; i++) {
		long long m = n / i;
		ans += i * m * (m+1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int N,K;
int change_number;
cin>>N>>K;
int A[N];
vector<int> data(200000);
  for(int i=0;i<N;i++){
cin>>A[i];
data[A[i]]++;
  }
  sort(data.begin(),data.end());
  change_number=data.size()-K;
  int res=0;
 if(change_number>0){ 
   for(int i=0;i<change_number;i++){
    res+=data[i];
  }
     }
  cout<<res;
 
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    string s;
    cin>> s;


    if( count (s.begin(), s.end(),s[0])== 2  && count (s.begin(), s.end(),s[1])== 2  && count (s.begin(), s.end(),s[2])== 2  && count (s.begin(), s.end(),s[3])== 2  )
cout << "Yes";
else
    cout << "No";
nl;

    return 0;
}




Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
       ll n,i;
       cin>>n;
       vector <ll> pref(n+1);
       for(i=1;i<=n;i++)
        cin>>pref[i];
       for(i=1;i<=n;i++)
        pref[i]+=pref[i-1],pref[i]%=Mod,pref[i]+=Mod,pref[i]%=Mod;
       ll ans=0; 
       for(i=1;i<=n;i++)
       {
           ans+=(pref[n]-pref[i])*(pref[i]-pref[i-1]);
           ans%=Mod;
           ans+=Mod;
           ans%=Mod;
       }  
       cout<<ans;
   }
}

Measured memory_bytes: 4784
N = int(input())
S1 = input()
S2 = input()

if S1[0] == S2[0]:
    result = 3
else:
    result = 6
x = 0
W = len(S1)
while x < W:
    if S1[x] == S2[x]:
        if x + 1 == W:
            break
        result *= 2
        result %= 1000000007
        x += 1
    else:
        if x + 2 == W:
            break
        if S1[x + 2] != S2[x + 2]:
            result *= 3
            result %= 1000000007
        x += 2
print(result)


Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
int a,b,j,c,max,d;
  max=0;
  scanf("%d",&a);
int q[a];
  for(j=0;j<a;++j)
  {scanf("%d",&q[j]);
  }
c=0;
 while(c<a-1)
 {d=0;
    while(q[c]>=q[c+1] && c<a-1) {
      c++;
      d++;
     }
 if(d>max) max=d;
 c++;
 }

  printf("%d",max);
  
return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
//________
#define pb push_back
#define fi first
#define se second
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define err(...) fprintf(stderr, __VA_ARGS__ )
#define show(x) cerr << #x << ':' << (x) << endl
#define outl(x) cout << (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
inline bool inside(int y, int x, int H, int W){return(y>=0 && x>=0 && y<H && x<W);}
const int dx[] = {1, 0, -1, 0,  1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1,  -1, 1, 1, -1};
#define INF  0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define NIL -1
//________


signed main()
{
   FAST();
   int x ,a,b;
   cin >> x >> a >> b;
   x -= a;
   x -= b * (x / b);
   outl(x);
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	y := getNextInt(scanner)

	for i := 0; i < n+1; i++ {
		for j := 0; j < n+1; j++ {
			if i+j > n {
				continue
			}
			cur := 10000*i + 5000*j
			if cur > y {
				continue
			}
			if i+j+(y-cur)/1000 != n {
				continue
			}

			fmt.Fprintf(writer, "%d %d %d\n", i, j, (y-cur)/1000)
			writer.Flush()
			return
		}
	}

	fmt.Fprintln(writer, "-1 -1 -1")
	writer.Flush()
}


Measured memory_bytes: 640
module DoublyLinkedList = struct
  type t = {
    mutable data : int;
    mutable next : t;
    mutable prev : t;
  }

  let make () =
    let rec head = { data = 0; next = head; prev = head } in
    head

  let insert data head =
    let x = { data = data; next = head.next; prev = head } in
    head.next.prev <- x;
    head.next <- x

  let delete x =
    x.next.prev <- x.prev;
    x.prev.next <- x.next

  let delete_first head = delete head.next

  let delete_last head = delete head.prev

  let delete_node data head =
    let rec doit ite =
      if ite == head then None
      else if ite.data = data then Some ite
      else doit ite.next in
    match doit head.next with
    | None -> ()
    | Some ite -> delete ite

  let iteri f head =
    let rec doit i ite =
      if ite != head then begin
        f i ite.data;
        doit (i + 1) ite.next
      end in
    doit 0 head.next
end

module L = DoublyLinkedList

let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in
  doit str []

let () =
  let n = read_int () in
  let head = L.make () in
  let rec read i =
    if i < n then begin
      begin match split (read_line ()) ' ' with
      | ["insert"; n] -> L.insert (int_of_string n) head
      | ["delete"; n] -> L.delete_node (int_of_string n) head
      | ["deleteFirst"] -> L.delete_first head
      | _ -> L.delete_last head
      end;
      read (i + 1)
    end in
  read 0;
  L.iteri (fun i n -> if i <> 0 then print_string " "; print_int n) head;
  print_newline ()

Measured memory_bytes: 39076
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int n;
    cin >> n;
    vector <long long> a(n);
    rep(i,n) cin >> a[i];
    int cur = 0;
    long long money = 1000;
    while(cur < n-1){
        if(a[cur] < a[cur+1]){
            money = money - (money/a[cur])*a[cur] + (money/a[cur])*a[cur+1];
            cur ++;
        }
        else cur ++;
    }
    cout << money << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/stck:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.1415926535897932384626433832
#define ios() ios::sync_with_stdio(true)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
int main()
{
    int x,y;
    cin>>x>>y;
    cout<<x+y/2<<endl;
    return 0;
}


Measured memory_bytes: 256
from sys import setrecursionlimit
#setrecursionlimit(10**5)
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [i for i in range(n + 1)]
        # rank
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    def find(self, x):
        # 根の番号を返す(所属する集合を確認する)
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return
        # rankの小さいものを大きいほうにくっつける
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def count_group(self, n):
        return len({self.find(x) for x in range(1, n + 1)})

v ,e = map(int, input().split())
stw = [list(map(int, input().split())) for i in range(e)]
stw.sort(key=lambda x:x[-1])
uf = UnionFind(v)

rec = 0
for s, t, w in stw:
    if not uf.check(s, t):
        uf.union(s, t)
        rec += w
print(rec)


Measured memory_bytes: 28212
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	N := getStdinInt()
	W := getStdinIntArr()

	min := math.MaxInt32
	for T := 0; T < N; T++ {
		S1 := 0
		S2 := 0
		for w := 0; w <= T; w++ {
			S1 += W[w]
		}
		for w := T + 1; w < N; w++ {
			S2 += W[w]
		}
		S := 0
		if S1 < S2 {
			S = S2 - S1
		} else {
			S = S1 - S2
		}
		if S < min {
			min = S
		}
	}

	fmt.Printf("%d\n", min)
}

func getStdin() string {
	return readLine()
}
func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))

A_even = A[0:N:2]
A_odd = A[1:N:2]

X = []
X.append(sum(A_even) - sum(A_odd))
for i in range(1, N):
    X.append(2*A[i-1] - X[i-1])
    
print(*X)


Measured memory_bytes: 14488
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define SIZE 1000100
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define int long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
const int mod = 998244353;
int n, inv[SIZE] = { 0,1 }, cnt[SIZE], tp, maxx = 0, ans[SIZE], res = 0;
signed main() {
    io(); cin >> n;
    rep(i, 1, n) {
        cin >> tp;
        cnt[tp]++;
        maxx = max(maxx, tp);
    }
    rep(i, 2, maxx) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
    for (int i = maxx; i; --i) {    //求出gcd为i的所有pair的乘积之和
        int s1 = 0, s2 = 0;
        for (int j = i; j <= maxx; j += i) {
            s1 = (s1 + cnt[j] * j % mod) % mod;
            s2 = (s2 + cnt[j] * j % mod * j % mod) % mod;
        }
        ans[i] = (s1 * s1 % mod - s2 + mod) % mod;
        // s1 - s2 的作用是使得gcd为j的pair对数为 cnt * (cnt - 1)
        for (int j = i + i; j <= maxx; j += i) {
            ans[i] = (ans[i] - ans[j] + mod) % mod;
            //去重，删除gcd为ik (k > 1)的pair
        }
    }
    rep(i, 1, maxx) {   //计算 ans[i] / i % mod
        res = (res + ans[i] * inv[i] % mod) % mod;
    }
    cout << res * inv[2] % mod; //枚举了两遍gcd，res / 2
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> cnt(m,0);
    for(int i=0;i<n;i++){
        int k;
        cin >> k;
        for(int j=0;j<k;j++){
            int a;
            cin >> a;
            cnt[a-1]++;
        }
    }
    int ans = 0;
    for(int i=0;i<m;i++){
        if(cnt.at(i)==n)ans++;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll a[100000];
ll f[100000];
ll b[100000];
ll l[100000];
int main(void){
    int n, k; cin >> n >> k; for(int i = 0;i < n;i++)cin >> a[i];
    if(a[0] > 0)f[0] = a[0];
    else f[0] = 0;
    for(int i = 1;i < n-k;i++){
        f[i] = f[i-1];
        if(a[i] > 0)f[i] += a[i];
    }
    if(a[n-1] > 0)b[n-1] = a[n-1];
    else b[n-1] = 0;
    for(int i = n-2;i >= k;i--){
        b[i] = b[i+1];
        if(a[i] > 0)b[i] += a[i];
    }
    l[0] = 0;
    for(int i = 0;i < k;i++)l[0] += a[i];
    for(int i = 1;i <= n-k;i++)l[i] = l[i-1] + a[i+k-1] - a[i-1];
    ll ans = b[k];
    if(l[0] > 0)ans += l[0];
    for(int i = 1;i < n-k;i++){
        ll t = f[i-1] + b[i+k];
        if(l[i] > 0)t += l[i];
        ans = max(ans, t);
    }
    ll t = f[n-k-1]; if(l[n-k] > 0)t += l[n-k];
    ans = max(ans, t);
    cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
 
int main(void){
  int i,e;
  static int n[26];
  char st,al[53] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   
  do{
    e = scanf("%c", &st);
 
    for(i=0;i<52;i++)
      if(al[i] == st){
        n[ i%26 ]++;
      }
 
  }while(e != EOF);
 
  for(i=0;i<26;i++)
    printf("%c : %d\n", al[i] , n[i]);
 
  return 0;
}


Measured memory_bytes: 2100
def pow2(n):
	v = 1
	for i in range(0, n):
		v *= 2
	return v

S = input()
opspattern = pow2(len(S)-1)
sum = 0
for i in range(0, opspattern):
	m = i
	psum = 0
	number = S[0]
	for j in range(0, len(S)-1):
		if m%2 == 1:
			psum += int(number)
			number = ''
		number = number + S[j+1]
		m = m // 2
	psum += int(number)
	sum += psum
print(sum)

Measured memory_bytes: 39408
burger = [1 for i in range(52)]
for i in range(1,52):
    burger[i] = burger[i-1]*2+3
patty = [1 for i in range(52)]
for i in range(1,52):
    patty[i] = patty[i-1]*2 + 1
def solve(L,X):
    if X == 0:
        return 0
    if burger[L] == X:
        return patty[L]
    elif (burger[L]-1)//2 + 1 == X:
        return patty[L-1] + 1
    elif (burger[L]-1)//2 + 1 > X:
        return solve(L-1,X-1)
    elif (burger[L]-1)//2 + 1 < X:
        return patty[L-1] + 1 + solve(L-1,X-burger[L-1]-2)

N,X = list(map(int,input().split()))
print(solve(N,X))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int A,B,C,D,E,F;
	scanf("%d %d %d %d %d %d",&A,&B,&C,&D,&E,&F);

	bool can_water[F+1];

	//作れる水の量を調べる
	for(int i = 0; i <= F; i++){

		can_water[i] = false;

		for(int k = 0; 100*A*k <= i; k++){
			if((i-(100*A*k))%(100*B) == 0){

				can_water[i] = true;
				break;
			}
		}
	}

	bool can_sugar[F+1];

	//作れる砂糖の量を調べる
	for(int i = 0; i <= F; i++){

		can_sugar[i] = false;

		for(int k = 0; C*k <= i; k++){

			if((i-C*k)%D == 0){

				can_sugar[i] = true;
				break;
			}
		}
	}

	int ans_bunshi = 0,ans_bunbo = F;

	for(int water = 0; water <= F; water++){

		if(can_water[water] == false)continue;

		for(int sugar = 0; sugar <= F-water && water/100*E >= sugar; sugar++){
			if(!can_sugar[sugar])continue;

			if(sugar*ans_bunbo >= (sugar+water)*ans_bunshi){
				ans_bunshi = sugar;
				ans_bunbo = sugar+water;
			}
		}
	}

	printf("%d %d\n",ans_bunbo,ans_bunshi);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int X, N;
    cin >> X >> N;
    set<int> s;
    for(int i = 0; i < N; i++) {
        int val;
        cin >> val;
        s.insert(val);
    }

    int best = 999, ans;
    for(int i = -500; i <= 500; i++) {
        if (s.count(i) == 0) {
            if (abs(X-i) < best) {
                best = abs(X-i);
                ans = i;
            }
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<stdio.h>
using namespace std;


int main(){
  int n,i,t,s,u=1,w;
 int x[5][4][11]={{{}}};
  string str(20,'#');
  cin >> n;
  int b[n+1],f[n+1],r[n+1],v[n+1];
  for(i=1;i<n+1;i++){
    cin >> b[i] >> f[i] >> r[i] >> v[i];
  }
  for(w=0;u<n+3;w++){
  for(t=1;t<5;t++){
   for(s=1;s<4;s++){
     for(i=1;i<11;i++){
       if(u!=n+1 && t==b[u] && s==f[u] && i==r[u]){
         x[t][s][i]+= v[u];
         u++;
       }
         else if (u==n+2){
       cout << " " <<  x[t][s][i];
     }
   }
   if(u==n+1){
     break;
   } else if (u==n+2){
     cout << endl;
    }
 }
 if(u==n+1){
   break;
 } else if (u==n+2){
   switch(t){
   case 4:
   break;
   default:
     cout << str << endl;
   }
 }
}
if(u>=n+1){
  u+=1;
}
}
return 0;
}



Measured memory_bytes: 3152
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // qsort()
#include <stdbool.h>

#define MAX_N 100000

typedef struct record_tbl
{
	int id;
	int time;
} record_t;

record_t records[MAX_N];

int
cmp_func(const void *l_, const void *r_)
{
	const record_t *l = (const record_t*) l_;
	const record_t *r = (const record_t*) r_;

	if (l->time < r->time)
		return -1;

	if (l->time > r->time)
		return 1;

	return 0;
}

int
main(int argc, char **argv)
{
	while (true)
	{
		int n;
		scanf("%d", &n);
		if (n == 0)
			break;

		for (int i = 0; i < n; ++i)
		{
			scanf("%d", &records[i].id);
			records[i].time = 0;
			for (int j = 0; j < 4; ++j)
			{
				int min, sec;
				scanf("%d%d", &min, &sec);
				records[i].time += min * 60 + sec;
			}
		}

		qsort(records, n, sizeof(record_t), cmp_func);

		printf("%d\n", records[0].id);
		printf("%d\n", records[1].id);
		printf("%d\n", records[n - 2].id);
	}

	return 0;
}


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

string s;

int main() {
  cin >> s;

  int sum = 0;
  for (int i = 0; i < s.size(); i++) {
    sum += s[i] - '0';
  }
  
  if (sum % 9 == 0) cout << "Yes";
  else cout << "No";
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

int f(int x){
  string s = "255456376";
  x--;
  return s[x]-'0';
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for(int i=0; i<m; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vector<int> dp(n+1, -100000000);
  dp[0] = 0;
  for(int i=1; i<=n; i++){
    for(int j=0; j<m; j++){
      if(i-f(a[j])>=0) dp[i] = max(dp[i-f(a[j])]+1, dp[i]);
    }
  }
  string ans;
  int remain = dp[n];
  int match = n;
  while(match>0){
    for(int i=m-1; i>=0; i--){
      if(match-f(a[i])<0) continue;
      if(dp[match-f(a[i])]==remain-1){
        remain -= 1;
        match -= f(a[i]);
        ans.append(to_string(a[i]));
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> exist(101, 0);
    int emin = N;
    int emax = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        exist[a]++;
        emin = min(emin, a);
        emax = max(emax, a);
    }
    if (exist[emin] >= 3) {
        cout << "Impossible" << endl;
        return 0;
    }
    if (exist[emin] == 2 && emax+1 != emin*2) {
        cout << "Impossible" << endl;
        return 0;
    }
    if (exist[emin] == 1 && emax != emin*2) {
        cout << "Impossible" << endl;
        return 0;
    }
    for (int i = emin+1; i <= emax; i++) {
        if (exist[i] <= 1) {
            cout << "Impossible" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
class CTravelingSalesmanAroundLake {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int K = 0;
	    int N = 0;
	    in >> K >> N;

	    set<int> A;
	    int input = 0;
	    for (int n = 0; n < N; ++n) {
	        in >> input;
	        A.insert(input);
	    }
	    int maxDistance = K - *prev(A.end()) + *A.begin();
	    for (auto itr = A.begin(); itr != prev(A.end()); itr++) {
	        maxDistance = max(*next(itr) - *itr, maxDistance);
	    }

	    out << K - maxDistance << endl;
	}
};


int main() {
	CTravelingSalesmanAroundLake solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

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

  if (R < 1200) {
    cout << "ABC" << endl;
  } else if (R < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return 0;
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

vector<vector<pair<int,int>>> Edge;
vector<int> node;

bool bellman_ford(int n,int s) {
	node = vector<int>(n,INF);
	node[s] = 0;
	REP (i,n) {
		REP (j,Edge.size()) {
			REP (k,Edge[j].size()) {
				int from = j,to = Edge[j][k].F;
				int cost = Edge[j][k].S;
				if (node[from] != INF && node[to] > node[from] + cost) {
					node[to] = node[from] + cost;
					if (i == n - 1 && to == n - 1) return true;
				}
			}
		}
	}
	return false;
}

signed main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int bn = 0;
	REP (i,n) {
		if (s[i] == '#') bn++;
	}
	int spos = 0;
	if (bn == 0) {cout << 0 << endl; return 0;}
	int koremade = 0;
	int ans = INF;
	REP (i,n) {
		if (s[i] == '#') {
			ans = min(ans,n - i - bn + 2 * koremade);
			koremade++;
		}
	}
	cout << min(ans,bn) << endl;
}

Measured memory_bytes: 640