akhauriyash/Code-Regression huggingface dataset:
#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;
typedef long long ll;

int main() {
	
	int h, w, n;
	cin >> h >> w >> n;
	vector<int> a(n);
	vector<vector<int>> hw(h, vector<int>(w));
	rep(i, n) cin >> a[i];
	int now_a = 0;
	rep(i, h){
		int suji = now_a;
		if(i%2==0){
			for(int j=0; j<w; j++){
				hw[i][j] = suji;
				a[now_a]--;
				if(a[now_a] <= 0){
					now_a++;
					suji = now_a;
				}
			}
		}else{
			for(int j=w-1; j>=0; j--){
				hw[i][j] = suji;
				a[now_a]--;
				if(a[now_a] <= 0){
					now_a++;
					suji = now_a;
				}
			}
		}
	}
	rep(i, h){
		rep(j, w){
			cout << hw[i][j]+1 << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;

signed main() {
    string s;
    cin >> s;
    int n = s.size();
    string t;
    rep (i, 0, n) {
        if (s[i] != 'x') t = s[i] + t;
    }
    string t_r = t;
    reverse (t_r.begin(), t_r.end());
    if (t != t_r) {
        cout << "-1\n";
        return 0;
    }
    int ans = 0;
    int i = 0, j = n - 1;
    while (j - i > 0) {
        // cout << i << " " << j << "\n";
        if (s[i] != 'x' && s[j] != 'x') {
            j--, i++;
        } else if (s[i] != 'x') {
            j--;
            ans++;
        } else if (s[j] != 'x') {
            i++;
            ans++;
        } else {
            j--, i++;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define DEBUG
#define PI 3.141592653589793238462643383279

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define INF 1e9+123
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin()+1, v.end()-9
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
int main(){
    ll N;
    cin>>N;
    
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    
    ll min=INF*INF*INF*INF*INF*INF;
    //<<min;
    REP(i,ret.size()/2+1){
        ll t=ret[i-1]+ret[ret.size()-i]-2;
        //sl(ret[i-1],ret[ret.size()-i],t);
        min=t<min?t:min;
    }
    cout<<min;
    
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

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

int main(){
  int H, W;
  cin >> H >> W;

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

  int sx = 0;
  int sy = 0;
  int gx = W-1;
  int gy = H-1;

  vector<vector<int>> dist(H, vector<int>(W, -1));

  queue<pair<int, int>> que;
  que.push(make_pair(sy,sx));
  dist[sy][sx] = 0;

  while(!que.empty()){
    pair<int, int> cp = que.front();
    int cx = cp.second;
    int cy = cp.first;
    que.pop();

    for(int i = 0; i < 4; i++){
      int nx = cx + dx[i];
      int ny = cy + dy[i];
      if(nx < 0 || nx > W || ny < 0 || ny >= H)continue;
      if(dist[ny][nx] != -1)continue;
      if(field[ny][nx] == '#')continue;
      dist[ny][nx] = dist[cy][cx] + 1;
      que.push(make_pair(ny,nx));
    }
  }

  int iW = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0 ; j < W; j++){
      if(field[i][j] == '.') iW += 1;
    }
  }

  if(dist[gy][gx]==-1) cout << "-1" << endl;

  else cout << iW - dist[gy][gx] -1 << endl;



  return 0;
}



Measured memory_bytes: 256
/* ?????\????????? */
#include<stdio.h>

/* ??????????´???¨??? */
void trace(int A[], int N){
    int i;
    for (i=0; i<N; i++){
        if(i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

/* ?????\????????? */
void insertionSort(int A[], int N){
    int j, i, v;
    for (i=1; i<N; i++){
        v = A[i];
        j = i-1;
        while(j>=0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A, N);
    }
}

int main(){
    int N, i, j;
    int A[100];

    scanf("%d", &N);
    for(i=0; i<N; i++) scanf("%d", &A[i]);

    trace(A, N);
    insertionSort(A, N);

    return 0;
}

Measured memory_bytes: 1032
n = int(input())
DifMax = -9999999999999

R = [int(input())]
RMin = R[0]
for i in range(1, n):
  if RMin > R[i-1]:
      RMin = R[i-1]
  R.append(int(input()))
  if DifMax < R[i] - RMin:
    DifMax = R[i] - RMin

print(DifMax)

Measured memory_bytes: 19080
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<string> s(2);
	while (cin >> s[0]) {
		if (s[0] == ".")break;
		cin >> s[1];
		vector<vector<string>> a(2), b(2);
		REP(k, 2) {
			bool f = false;
			string tmp;
			REP(i, s[k].size()) {
				if (s[k][i] == '\"') {
					if (f) {
						b[k].push_back(tmp);
						tmp = "";
					}
					else {
						a[k].push_back(tmp);
						tmp = "";
					}
					f = !f;
				}
				else {
					tmp += s[k][i];
				}
			}
			if (tmp != "")a[k].push_back(tmp);
		}
		if (a[0] != a[1]) {
			cout << "DIFFERENT" << endl;
		}
		else {
			
			if (b[0].size() != b[1].size()) {
				cout << "DIFFERENT" << endl;
			}
			else {
				int cnt = 0;
				REP(i, b[0].size()) {
					if (b[0][i] != b[1][i])cnt++;
				}
				if (cnt == 0)cout << "IDENTICAL" << endl;
				else if (cnt == 1)cout << "CLOSE" << endl;
				else cout << "DIFFERENT" << endl;
			}
		}
	}
}


Measured memory_bytes: 3164
a = [0] * 3
a[0] = list(map(int, input().split()))
a[1] = list(map(int, input().split()))
a[2] = list(map(int, input().split()))
N = int(input())

bingo = [[0,0,0],
        [0,0,0],
        [0,0,0]]
for i in range(N):
    b = int(input())

    for j in range(3):
        for k in range(3):
            if(a[j][k] == b): bingo[j][k] = 1

if(bingo[0][0] == bingo[1][1] == bingo[2][2] == 1 or
   bingo[0][2] == bingo[1][1] == bingo[2][0] == 1 or
   bingo[0][0] == bingo[0][1] == bingo[0][2] == 1 or
   bingo[1][0] == bingo[1][1] == bingo[1][2] == 1 or
   bingo[2][0] == bingo[2][1] == bingo[2][2] == 1 or
   bingo[0][0] == bingo[1][0] == bingo[2][0] == 1 or
   bingo[0][1] == bingo[1][1] == bingo[2][1] == 1 or
   bingo[0][2] == bingo[1][2] == bingo[2][2] == 1) :
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int INF2 = 1e15;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int n,m,s,t;
    cin >> n >> m >> s >> t;
    s--;t--;
    vector<vector<pair<int,P>>>cnt(n);
    for(int i = 0; i < m; i++) {
        int u,v,a,b;
        cin >> u >> v >> a >> b;
        u--;v--;
        cnt[u].push_back({v,{a,b}});
        cnt[v].push_back({u,{a,b}});
    }
    priority_queue<P,vector<P>,greater<P>> que;
    vector<int>sum(n,INF);sum[s] = 0;
    vector<int>sum2(n,INF);sum2[t] = 0;
    que.push({s,0});
    while(!que.empty()) {
        P X = que.top();
        que.pop();
        if(sum[X.first] < X.second) {
            continue;
        }
        for(int i = 0; i < cnt[X.first].size(); i++) {
            if(sum[cnt[X.first][i].first] > X.second+cnt[X.first][i].second.first) {
                sum[cnt[X.first][i].first] = X.second+cnt[X.first][i].second.first;
                que.push({cnt[X.first][i].first,sum[cnt[X.first][i].first]});
            }
        }
    }
    priority_queue<P,vector<P>,greater<P>> que2;
    que2.push({t,0});
    while(!que2.empty()) {
        P X = que2.top();
        que2.pop();
        if(sum2[X.first] < X.second) {
            continue;
        }
        for(int i = 0; i < cnt[X.first].size(); i++) {
            if(sum2[cnt[X.first][i].first] > X.second+cnt[X.first][i].second.second) {
                sum2[cnt[X.first][i].first] = X.second+cnt[X.first][i].second.second;
                que2.push({cnt[X.first][i].first,sum2[cnt[X.first][i].first]});
            }
        }
    }
    vector<int>ans(n);
    for(int i = n-1; i >= 0; i--) {
        ans[i] = sum[i]+sum2[i];
        if(i+1 != n) {
            ans[i] = min(ans[i+1],ans[i]);
        }
    }
    for(int i = 0; i < n; i++) {
        cout << INF2-ans[i] << endl;
    }
}

Measured memory_bytes: 21832
X, N = map(int, input().split())
nums = list(map(int, input().split()))

if N == 0:
    print(X)
    exit()
else:
    for i in range(200):

        if X-i not in nums:
            print(X-i)
            exit()

        if X+i not in nums:
            print(X+i)
            exit()

Measured memory_bytes: 61940
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
        String str2 = sc.next();		
        int a = sc.nextInt();
		int b = sc.nextInt();
        String s = sc.next();
       if(s.equals(str)){a--;                                                
                            }else{b--;}
        
		System.out.println(a + " " + b);
	}
}


Measured memory_bytes: 23636
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include<string>
#include<cstring>
#include<ctype.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	new_data_set;
//   <<implemented_sorted_vector>>  new_data_set p;
//   <<insert_like_set>>           insert(key):log(n)
//<<accessing_iterator_by_index>> find_by_order(idx):log(n)
//	    <<accessing_by_value>>   order_of_key(key):log(n)
// << replace less<int> by greater<int> for descending order>>
// find(key), erase(find(key)) works the same!
typedef long long ll;
typedef long l;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ERR(x) cout<<"#x:"<<x<<endl
#define ERR2(x,y) cout<<"#x:"<<x<<" "<<"#y:"<<y<<endl;
#define ERR3(x,y,z) cout<<"#x:"<<x<<" "<<"#y:"<<y<<" "<<"#z:"<<z<<endl;
#define show(v) for(auto e: v) cout<<e<<" ";
#define showArr(A,n) for(int i=0;i<n;i++) cout<<A[i]<<" ";
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define mp make_pair
#define ff first
#define ss second
#define umpit unordered_map<ll,ll>::iterator
#define mpit map<ll,ll>::iterator
#define setit set<ll>::iterator
#define all(v) v.begin(),v.end()
const int N = 15;// 26**15 > 10**15
vector<ll>P;
void preprocess()
{
	ll p = 1;
	ll s = 1;
	FOR(i,0,15)
	{
		P.pb(s);
		p*=26;
		s += p;
		// p[i] = 1+26+2626...ith	
	}
}

int main()
{
	preprocess();
	ll n;
	cin>>n;
	ll start = upper_bound(all(P), n) 
	              - P.begin() - 1; //ie  <=
	n -= P[start];
	//cout<<start<<" "<<P[start];
	// now set digits
	ll tst = start;
	vector<char>digits(start+1,'a');
	while(n > 0)
	{
		ll power = (ll)pow(26,tst);
		ll tn = n;
		//cout<<power<<" "<<n<<endl;
		while(tn > 0)
		{
			if(tn - power >= 0)
			{
				digits[tst]++;
				tn -= power;
			}
			else
			{
				break;
			}
		}
		n = tn;
		tst--;
	}
	
	FOR(i,0,start+1)
	{
		cout<<digits[start-i];
	}
 	return 0;
}


Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define f first
#define s second
#define pb push_back
#define endl '\n'

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string st;
	cin>>st;
	int sum=0;
	for(int i=0; i<st.size(); i++){
		sum+=(st[i]-'0');
	}
	if(sum%9==0){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main()
{
   char s,s1;
   cin>>s>>s1;
   if(s=='H'&&s1=='H')
    cout<<"H";
   else if(s=='H'&&s1=='D')
    cout<<"D";
   else if(s=='D'&&s1=='H')
    cout<<"D";
   else if(s=='D'&&s1=='D')
    cout<<"H";
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	
	int c = 0;

	for (int i = a; i<= b; i++) {
		int s = i / 10000;
		int t = i / 1000 % 10;
		int v = i / 10 % 10;
		int w = i % 10;

		if (s == w && t == v) c++;
	}
	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int case_num = 1;

		while(scanner.hasNextLine()) {
			String input_str = scanner.nextLine();
			int x = Integer.parseInt(input_str);

			if(x >= 1  && x <= 10000) {
				System.out.println("Case " +case_num+": "+x);
				case_num++;
			}
		}

    	scanner.close();
    }
}



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


int main(){
    /*#ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif*/
    
    int n,m;
    scanf("%d %d",&n,&m);

    int arr[n+5];
    int total=0;
    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
        total+=arr[i];
    }
    sort(arr,arr+n,greater<int>());
    //for(int i=0;i<n;i++)cout<<arr[i]<<" ";cout<<endl;

    bool yes=true;
    for(int i=0;i<m && yes;i++){
        if(4*m*arr[i]<total){
            yes=false;
        }
    }
    yes?printf("Yes\n"):printf("No\n");

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <bitset>

#define INF 100100100
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

 
int main(){
    int n; cin >> n;
    
    vector<vector<int>> x(n, vector<int>());
    vector<vector<int>> y(n, vector<int>());
    rep(i,n){
        int A; cin >> A;
        rep(j,A){
            int a,b; cin >> a >> b;
            a--;
            x[i].push_back(a);
            y[i].push_back(b);
            
        }
    }
    int ans = 0;
    for(int tmp = 0; tmp < (1 << n); tmp++) {
        bitset<16> s(tmp);
        bool ok = true;
        for(int i=0; i<n; i++){
            if(s.test(i)){
                for(int j=0; j<x[i].size(); j++){
                    if(s.test(x[i][j])){
                        if(y[i][j] != 1){
                            ok = false;
                        }
                    }else{
                        if(y[i][j] != 0){
                            ok = false;
                        }
                    }
                }
            }
        }
        int t = s.count();
        if(ok){
            ans =max(ans,t);
            
        }
        
     
    }
     
    cout << ans << endl;
    
}


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

using namespace std;

using ll = long long;

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

    int N, W;
    cin >> N >> W;

    vector<vector<ll>> dp(2, vector<ll>(W + 1, -1));
    auto &cur = dp[0], &nxt = dp[1];
    cur[0] = 0;
    for (int i = 0; i < N; ++i) {
        ll w, v;
        cin >> w >> v;
        for (int j = 0; j <= W; ++j) {
            if (cur[j] == -1) continue;
            nxt[j] = max(nxt[j], cur[j]);
            if (j + w <= W)
                nxt[j + w] = max(nxt[j + w], cur[j] + v);
        }
        swap(cur, nxt);
    }

    cout << *max_element(cur.begin(), cur.end()) << endl;

    return 0;
}


Measured memory_bytes: 2560
import java.util.*;
import java.util.stream.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(), k = in.nextInt();
		long a = 0;
		for (int i = 1; i <= n; i++) {
			if(i % k == 0) {
				a++;
			}
		}
		if(k % 2 == 0) {
			long b = 0;
			for (int i = 1; i <= n; i++) {
				if(i % k == k / 2) {
					b++;
				}
			}
			System.out.println((long)(Math.pow(a, 3) + Math.pow(b, 3)));
		} else {
			System.out.println((long)Math.pow(a, 3));
		}
	}
}
	


Measured memory_bytes: 21844
#include<stdio.h>
#pragma warning(disable:4996)

int main() {
	int N;
	scanf("%d", &N); 
	N = N % 10;
	switch (N)
	{
	case 3:
		printf("bon");
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		printf("pon");
		break;

	default:
		printf("hon");
		break;

	}

	return 0;


	


}

Measured memory_bytes: 1728
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
  if A[i]!=B[i] and A[i]!=C[i] and B[i]!=C[i]:
    ans += 2
  elif A[i]!=B[i] or A[i]!=C[i] or B[i]!=C[i]:
    ans += 1
print(ans)

Measured memory_bytes: 3064
g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
g3 = [2]
gs = [g1, g2, g3]

x, y = map(int, input().split())
x_i = y_i = -1
for (i, g) in enumerate(gs):
    for num in g:
        if num == x:
            x_i = i
for (i, g) in enumerate(gs):
    for num in g:
        if num == y:
            y_i = i
if x_i == y_i:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>

const long long MOD = 1000000007;
long long N, n[100002], lf[100002], rf[100002], df[100002];

int main()
{
	scanf("%lld", &N);
	for(int i = 1; i <= N; i++)
		scanf("%lld", &n[i]);

	lf[1] = 1; rf[N] = N; lf[0] = rf[N + 1] = 1;
	for(long long i = 2; i <= N; i++)
		lf[i] = (lf[i - 1] * i) % MOD;
	for(long long i = N - 1; i > 0; i--)
		rf[i] = (rf[i + 1] * i) % MOD;

	long long ans = 0, cur, ad = 2, md = N;
	for(int i = 1; i <= N; i++)
		cur = (cur + (df[i] = (lf[i - 1] * rf[i + 1]) % MOD)) % MOD;
	for(int i = 1; i <= N; i++){
		ans = (ans + n[i] * cur) % MOD;
		cur = (cur + df[ad++] - df[md--] + MOD) % MOD;
	}
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 3328
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Reverse,Ordering};
use std::time::{Duration, Instant};
use rand::Rng;
 
use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn main() {
    input!{
        n:usize,
        q:usize,
        a:[usize;n],
        query:[(usize,usize,usize);q],
    }

    let mut T = FenwickTree::new(n,0);
    for (i,a) in a.iter().enumerate(){
        T.add(i, *a);
    }

    for (a,b,c) in query{
        if a==0{
            T.add(b, c);
        } else {
            println!("{}",T.sum(b,c));
        }
    }

}


struct FenwickTree<T> {
    n: usize,
    ary: Vec<T>,
    e: T,
}

impl<T: Clone + std::ops::AddAssign<T>> FenwickTree<T>{
    fn new(n: usize, e: T) -> Self{
        FenwickTree{
            n,
            ary:vec![e.clone(); n],
            e,
        }
    }
    fn accum(&self, mut idx: usize) -> T{
        let mut sum = self.e.clone();
        while idx > 0 {
            sum += self.ary[idx -1].clone();
            idx &= idx - 1;
        }
        sum
    }
    /// performs data[idx] += val.
    fn add<U: Clone>(&mut self, mut idx: usize, val: U)
    where
        T: std::ops::AddAssign<U>,
    {
        let n = self.n;
        idx += 1;
        while idx <= n{
            self.ary[idx -1] += val.clone();
            idx += idx & idx.wrapping_neg();
        }
    }
    /// returns data[l] + ... + data[r-1].
    fn sum(&self, l: usize, r: usize) -> T
    where
        T: std::ops::Sub<Output = T>,
    {
        self.accum(r) - self.accum(l)
    }
}

Measured memory_bytes: 37092
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        System.out.println(Math.max(Math.max(A * 10 + B + C, A + B * 10 + C),C*10+A+B));
    }
}

Measured memory_bytes: 21588
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e3+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }
  
int dp[N][N];
vector<pi> a;

int go(int pos,int l,int r) {
	  if(pos==sz(a)) return 0;
	  int &ans=dp[pos][l];
	  if(ans!=-1) return ans;
	  return ans=max(go(pos+1,l+1,r)+a[pos].fe*abs(a[pos].se-l),go(pos+1,l,r-1)+a[pos].fe*abs(a[pos].se-r)); 
	}

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

   rep(i,0,n) {
	    int x;
	    cin>>x;
	    a.pb({x,i});
	}
	
	sort(a.rbegin(),a.rend());	
	memset(dp,-1,sizeof(dp));
    
    cout<<go(0,0,n-1);
   	cout<<endl;  	  
						   
 }

    
int32_t main() {
	cool;
	int t=1;

	//cin>>t;
	while(t--)
	solve();


return 0;	   
}


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

int main(){
    vector<vector<int>> bingo(3,vector<int>(3));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> bingo.at(i).at(j);
        }
    }

    int N;
    cin >> N;

    vector<vector<bool>> check(3,vector<bool>(3, false));
    
    for(int i = 0; i < N; i++){
        int bingoNum;
        cin >> bingoNum;
        for(int j = 0;j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(bingoNum == bingo.at(j).at(k)){
                    check.at(j).at(k) = true;
                    break;
                }
            }
        }
    }
    //縦横
    for(int i = 0; i < 3; i++){
        int countH = 0;
        int countV = 0;
        bool flag = false;
        for(int j = 0; j < 3; j++){
            if(check.at(i).at(j) == true){
                countH++;
            }
            if(check.at(j).at(i) == true){
                countV++;
            }   
        }
        if(countH == 3 || countV == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    //斜め
    if(check.at(0).at(0) == true && check.at(1).at(1) == true && check.at(2).at(2) == true){
        cout << "Yes" << endl;
        return 0;
    }
    if(check.at(0).at(2) == true && check.at(1).at(1) == true && check.at(2).at(0) == true){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int n;
    cin >> n;
    int mod = pow(10, 9) + 7;
    ll ans = 1;
    rep(i, n) {
        ans *= i + 1;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>

using namespace std;

long long cnt[500][500];
int ch[500][500][2];
bool used[500][500];
char s[500][500];
int dx[]={0,0,-1,1};
int dy[]={-1,1,0,0};
int h,w;

long long dfs(int x, int y, int px, int py){
  used[x][y]=true;
  ch[x][y][0]=px;
  ch[x][y][1]=py;
  long long sum = 0;
  for(int i=0;i<4;i++){
    if(x+dx[i]<0 || x+dx[i]>=h || y+dy[i]<0 || y+dy[i]>=w)continue;
    if(used[x+dx[i]][y+dy[i]])continue;
    if(s[x+dx[i]][y+dy[i]]!=s[x][y]){
      sum += dfs(x+dx[i],y+dy[i],px,py);
    }
  }
  if(s[x][y]=='#')sum++;
  return sum;
}

int main(){
  long long int i,j,k,ret=0;
  cin >> h >> w;
  for(i=0;i<h;i++)for(j=0;j<w;j++)cin >> s[i][j];
  for(i=0;i<h;i++)for(j=0;j<w;j++){
    if(!used[i][j])cnt[i][j]=dfs(i,j,i,j);
  }
  for(i=0;i<h;i++)for(j=0;j<w;j++){
    if(s[i][j]=='.')ret+=cnt[ch[i][j][0]][ch[i][j][1]];
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 16768
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";

int main()
{
  long long N;
  cin >> N;

  long long ans = 0;
  for (long long i = 1; i < N / 2; i++)
  {
    long long m = N / i - 1;
    if (m <= i) break;
    if (N % i == 0) ans += m;
    //cout << m << " " << i << endl;
  }
  
  cout << ans << endl;
}

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

bool solve(
  long ts, long xs, long ys,
  long td, long xd, long yd
)
{
  long dist = std::abs(xs - xd) + std::abs(ys - yd);
  long dt = td - ts;
  if (dist > dt) return false;
  return ((dt - dist) % 2) == 0;
}

int main(int argc, char **argv)
{
  unsigned N;
  std::cin >> N;
  
  long ts = 0, xs = 0, ys = 0;
  
  for (unsigned n = 0; n < N; ++n) {
    long td, xd, yd;
    std::cin >> td >> xd >> yd;
    
    if (!solve(ts, xs, ys, td, xd, yd)) {
      std::cout << "No" << std::endl;
      return 0;
    }
    
    ts = td; xs = xd; ys = yd;
  }
  
  std::cout << "Yes" << std::endl;
  
  return 0;
}

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

int main() {
  long long int N, i, j;
  int count = 0;
  cin >> N;

  for(int i=1; i<N; i++){
    if(i*i >= N){
      break;
    }
    count++;
  }

  for(i=1; i<N; i++){
    for(j=(i+1); j<N; j++){
      //cout << i << " " << j << endl;
      if(i*j >= N){
        break;
      }
      count += 2;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define N 2005
using namespace std;

vector<int>vertices[N]; 
int vis[N], dist[N]; 
map<int, int>m;

void bfs(int x){
	
	queue<int>fila;
	fila.push(x); 
	vis[x] = 1;  
	dist[x] = 0;	

	int v  = 0, u  = 0;
	while(!fila.empty()){
			
		v = fila.front(); 
		fila.pop();  
		
		for(int i=0; i < vertices[v].size(); i++){
			u = vertices[v][i];
			if(vis[u] == 0){ 
				dist[u] = dist[v] + 1;
				fila.push(u);
				vis[u] = 1;
			}
		}
	}

}


int main(){

	int n, x, y;
	cin >> n >> x >> y;

	for(int i=2; i <= n; i++){
		vertices[i-1].push_back(i);
		vertices[i].push_back(i-1);
	}

	vertices[x].push_back(y);
	vertices[y].push_back(x);

	for(int i=1; i<n; i++){
		memset(vis, 0, sizeof vis);
		memset(dist, 0, sizeof dist);
		bfs(i);
			
		for(int j=i; j<=n; j++) m[dist[j]]++;

	}

	
	for(int i=1; i<n; i++) cout << m[i] << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    long x, y, ans1 = 3000000000, ans2 = 3000000000, ans3 = 3000000000, ans4 = 3000000000;
    cin >> x >> y;
    if(x <= y)
        ans1 = y - x;
    if(-x <= y)
        ans2 = y + x + 1;
    if(x <= -y)
        ans3 = - y - x + 1;
    if(-x <= -y)
        ans4 = -y + x + 2;
    cout << min(ans1, min(ans2, min(ans3, ans4))) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
typedef pair<int,int> P;
const int MOD = 998244353;
const ll mod = 1e9 + 7;
const int mxN = 1e6 + 9;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
    int n,k,tmp;
    cin >> n >> k;
    vector<int> v(n,0);
    for(auto &c: v){
        cin >> tmp;
        c = tmp;
    }
    int ans = 0;
    sort(v.begin(), v.end());
    for(int i=0; i < k; i++) ans += v[i];
    cout << ans;

}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 100000000000000000
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, t;
P a[3010];
int dp[3010][6010];
int ans;

signed main() {
	cin >> n >> t;
	for (int i = 0; i < n; i++)cin >> a[i].first >> a[i].second;
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < t; j++) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			dp[i + 1][j + a[i].first] = max(dp[i + 1][j + a[i].first], dp[i][j] + a[i].second);
		}
		for (int j = 0; j < t + a[i].first; j++)ans = max(ans, dp[i + 1][j]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 141568
def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)


def merge(A, left, mid, right):
    global Comp_count
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid]
    R = A[mid:right]
    L.append(1000000001)
    R.append(1000000001)
    i = 0  # L[]??¨?????????????????????
    j = 0  # R[]??¨?????????????????????
    for k in range(left, right):
        Comp_count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1


from array import array
def merge_with_array(A, left, mid, right):
    global Comp_count
    n1 = mid - left
    n2 = right - mid
    L = array('I', A[left:mid])
    R = array('I', A[mid:right])
    L.append(1000000001)
    R.append(1000000001)

    i = 0  # L[]??¨?????????????????????
    j = 0  # R[]??¨?????????????????????
    for k in range(left, right):
        Comp_count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

from ctypes import *
class DATA(Structure):
    _fields_ = ("d", c_int * 250002),
L = DATA()
R = DATA()

def merge_with_ctypes(A, left, mid, right):
    global Comp_count
    n1 = mid - left
    n2 = right - mid
    for i in range(n1):
        L.d[i] = A[left+i]
    for i in range(n2):
        R.d[i] = A[mid+i]
    L.d[n1] = 1000000001
    R.d[n2] = 1000000001

    i = 0  # L[]??¨?????????????????????
    j = 0  # R[]??¨?????????????????????
    for k in range(left, right):
        Comp_count += 1
        if L.d[i] <= R.d[j]:
            A[k] = L.d[i]
            i += 1
        else:
            A[k] = R.d[j]
            j += 1



Comp_count = 0
if __name__ == '__main__':
    # ??????????????\???
    num_of_data = int(input())
    S = [int(x) for x in input().split(' ')]
    #with open('ALDS1_5_B_in10.txt') as f:
    #    for line in f:
    #        if ' ' not in line:
    #            num_of_data = int(line)
    #        else:
    #            S = [int(x) for x in line.split(' ')]
    #S = [8, 5, 9, 2, 6, 3, 7, 1, 10, 4]

    # ????????????????????????
    merge_sort(S, 0, num_of_data)

    # ???????????????
    print('{0}'.format(' '.join(map(str, S))))
    print(Comp_count)

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

def get_input() -> int:
    """
    標準入力を取得する.

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def divisor_count(n: int) -> int:
    """
    引数の約数の個数を取得する.

    Args:\n
        n (int): 引数

    Returns:\n
        int: 約数の個数
    """
    ans = 0
    i = 1
    while i * i <= n:
        if n % i == 0:
            ans += 1
            if i != n // i:
                ans += 1
        i += 1
    return ans


def main(N: int) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 整数（1 <= N <= 200）
    """
    # 求解処理
    ans = 0
    for n in range(1, N + 1, 2):
        if divisor_count(n) == 8:
            ans += 1

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N = get_input()

    # メイン処理
    main(N)


Measured memory_bytes: 9096
#include <iostream>

using namespace std;

int main() {
  int64_t X;
  cin >> X;
  int result = 0;
  for (int64_t x = 100LL; x < X; x += (x / 100LL)) {
    ++result;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3624
N, M = map(int, input().split())

def check(i): #i個のSccが作れるかどうか
    S = i
    c = 2 * i
    S -= N #Sはとりあえず使えるもので処理
    S = max(S, 0)
    return M >= (2 * S + c)


la = -1
ua = 10 ** 12
while ua - la > 1:
    mid = (la + ua)//2
    if check(mid):
        la = mid
    else:
        ua = mid

print (la)


Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std;
const long INF=1000000000000000;
const long MOD=1000000007;

int main(){
    string O,E;
    cin>>O>>E;
    for(int i=0;i<O.size()+E.size();i++){
        if(i%2==0) cout<<O.at(i/2);
        else cout<<E.at(i/2);
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N, A, i;
    int buka[200000] = {0};

    scanf("%d", &N);
    for(i=0; i<N-1; i++){
        scanf("%d", &A);
        buka[A-1]++;
    }

    for(i=0; i<N; i++)
        printf("%d\n", buka[i]);

    return 0;
}


Measured memory_bytes: 2512
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;
int cnt[4];
int main() {
  string s; cin >> s;
  for ( int i = 0; i < s.length(); i++ ) {
    if ( s[i] == 'N' ) cnt[0]++;
    else if ( s[i] == 'W' ) cnt[1]++;
    else if ( s[i] == 'S' ) cnt[2]++;
    else if ( s[i] == 'E' ) cnt[3]++;
  }
  int count = 0;
  for ( int i = 0; i < 4; i++ ) {
    if ( cnt[i] > 0 ) count++;
  }

  if ( count % 2 == 1 ) {
    cout << "No" << endl;
  } else {
    if ( count == 2 ) {
      if ( (cnt[0] > 0 && cnt[2]>0) || ( cnt[1]>0 && cnt[3]>0) ) {
	cout << "Yes" << endl;
      } else {
	cout << "No" << endl;
      }
    } else if ( count == 4 ) {
	cout << "Yes" << endl;
    }
  }
  return 0;
}


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


#include<vector>

namespace ProconLib{

    template<typename cost_t>
    constexpr cost_t INF(){return cost_t(1e15);}
    template<class graph_t,class cost_t,cost_t INF=INF<cost_t>()>
    bool BellmanFord(int s,graph_t& g,std::vector<cost_t> &d){
        int n=g.size();
        d.assign(n,INF);
        bool update=true;
        d[s]=0;
        for(int loop=0;update;loop++){
            if(loop>=n+1){
                return false;
            }
            update=false;
            for(int i=0;i<n;i++){
                for(int j=0;j<g[i].size();j++){
                    if(d[i]==INF) continue;
                    int to=g[i][j].to;
                    cost_t w=d[i]+g[i][j].cost;
                    if(d[to]>w){
                        update=true;
                        d[to]=w;
                    }
                }
            }
        }
        return true;
    }

    // using Weight=long long;
    // struct Edge{
    //     int to;
    //     Weight cost;
    // };
    // using Edges=std::vector<Edge>;
    // using Graph=std::vector<Edges>;
}



using namespace std;
using Weight=long long;
struct Edge{
    int to;
    Weight cost;
};
using Edges=std::vector<Edge>;
using Graph=std::vector<Edges>;
using namespace ProconLib;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,r;
    cin>>n>>m>>r;
    Graph g(n);
    for(int i=0;i<m;i++){
        int u,v;
        Weight d;
        cin>>u>>v>>d;
        g[u].push_back(Edge{v,d});
    }
    vector<Weight> d(n);
    if(BellmanFord<Graph,Weight>(r,g,d)){
        for(int i=0;i<n;i++){
            if(d[i]!=INF<Weight>()) cout<<d[i]<<"\n";
            else cout<<"INF\n";
        }
    }
    else{
        cout<<"NEGATIVE CYCLE\n";
    }
    

    return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int a, b;
   cin >> a >> b;
   int d = a / b;
   int r = a % b;
   double f = (double)a / b;
   printf("%d %d %0.5f\n", d, r, f);
   return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <cstdio>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;
#define all(c) c.begin(),c.end()
template <class T>
struct knapsack {
    T c; 
      struct item { T p, w; };
        vector<item> is;
          void add_i(T p, T w) {
                is.push_back({p, w});
                  }
            T det(T a, T b, T c, T d) {
                  return a * d - b * c;
                    }
              T z;
                void expb(T p, T w, int s, int t) {
                      if (w <= c) {
                              if (p >= z) z = p;
                                    for (; t < is.size(); ++t) {
                                              if (det(p - z - 1, w - c, is[t].p, is[t].w) < 0) return;
                                                      expb(p + is[t].p, w + is[t].w, s, t + 1);
                                                            }
                                        } else {
                                                for (; s >= 0; --s) {
                                                          if (det(p - z - 1, w - c, is[s].p, is[s].w) < 0) return;
                                                                  expb(p - is[s].p, w - is[s].w, s - 1, t);
                                                                        }
                                                    }
                        }
                  T solve() {
                        sort(all(is), [](const item &a, const item &b) { 
                                  return a.p * b.w > a.w * b.p;
                                      });
                            T p = 0, w = 0;
                                z = 0;
                                    int b = 0; 
                                        for (; b < is.size() && w <= c; ++b) {
                                                p += is[b].p;
                                                      w += is[b].w;
                                                          }
                                            expb(p, w, b-1, b);
                                                return z;
                                                  }
};
int main() {
    knapsack<long long> solver;
      int n;
        scanf("%d %lld", &n, &solver.c);
          for (int i = 0; i < n; ++i) {
                long long v, w; 
                    scanf("%lld %lld", &v, &w);
                        solver.add_i(w, v);
                          }
            printf("%lld\n", solver.solve());
            }


Measured memory_bytes: 256
N = int(input())

def func(n):
  cake = [4,7]
  for i in cake:
    new_n = n - i
    if new_n == 0:
      print('Yes')
      exit()
    elif new_n < 0:
      return 0
    else:
      func(new_n)

func(N)
print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int n, x, t;
	cin >> n >> x >> t;

	int m;
	if (n % x == 0) {
		m = n / x;
	}
	else {
		m = n / x + 1;
	}
	
	col(m * t);
	return 0;
}

Measured memory_bytes: 3636
/**
 * @Author:      G_bg
 * @DateTime:    2019-08-11 19:33:24
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn = 1e5+10;
vector<LL> to[2510];
vector<LL> rto[2510];
bool from1[2510];
bool toN[2510];
bool ok[2510];

void dfs(LL v) {
  if (from1[v]) return;
  from1[v] = true;
  for (LL u : to[v]) {
    dfs(u);
  }
}
void rdfs(LL v) {
  if (toN[v]) return;
  toN[v] = true;
  for (LL u : rto[v]) {
    rdfs(u);
  }
}
int main() {
  LL n, m, p;
  cin >> n >> m >> p;
  vector<tuple<LL, LL, LL>> edges;
  for(int i = 0;i < m;++i) {
    LL a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    c -= p;
    c = -c;
    edges.emplace_back(a, b, c);
    to[a].push_back(b);
    rto[b].push_back(a);
  }
  dfs(0);
  rdfs(n - 1);
  for(int i = 0;i < n;++i) ok[i] = from1[i] && toN[i];

  vector<LL> d(n, INF);
  d[0] = 0;
  bool upd = true;
  LL step = 0;
  while (upd) {
    upd = false;
    for(int i = 0;i < m;++i) {
      LL a, b, c;
      tie(a, b, c) = edges[i];
      if (!ok[a] || !ok[b]) continue;
      LL newD = d[a] + c;
      if (newD < d[b]) {
        upd = true;
        d[b] = newD;
      }
    }
    step++;
    if (step > n) {
      cout << -1 << endl;
      return 0;
    }
  }
  LL ans = -d[n - 1];
  ans = max(ans, 0LL);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 768
#include <stdio.h>

using namespace std;

void outPut(int Array[],char mark){
	for(int i = 1; i <= 13; i++){
		if(Array[i] == 0) printf("%c %d\n",mark,i);
	}
}

int main(){
	char mark[2];
	int n,S[14],H[14],C[14],D[14],tmp;
	for(int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0;
	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%s %d",mark,&tmp);
		switch(mark[0]){
		case 'S':
			S[tmp] = 1;
			break;
		case 'H':
			H[tmp] = 1;
			break;
		case 'C':
			C[tmp] = 1;
			break;
		case 'D':
			D[tmp] = 1;
			break;
		}
	}
	outPut(S,'S');
	outPut(H,'H');
	outPut(C,'C');
	outPut(D,'D');
}


Measured memory_bytes: 2700
#include<iostream>
using namespace std;
int main(){
	string a,b,c;
	char d,e,f;
	cin>>a>>b>>c;
	d=a[0];
	e=b[0];
	f=c[0];
	d=d+'A'-'a';
	e=e+'A'-'a';
	f=f+'A'-'a';
	cout<<d<<e<<f<<endl;
	
}

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

bool is_palindrome(string s)
{
  for (size_t i = 0; i < s.size() / 2; ++i)
  {
    if (s.at(i) != s.at(s.size() - 1 - i))
      return false;
  }
  return true;
}

int main() {
  string S;
  cin >> S;

  size_t n = S.size();
  size_t m = (n - 1) / 2;
  string s = S.substr(0, m);
  string t = S.substr((n + 3) / 2 - 1, m);
  if (is_palindrome(S) && is_palindrome(s) && is_palindrome(t))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    
  return 0;
}


Measured memory_bytes: 3612
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val t = (1..n).map { Pair(sc.next(), sc.nextInt()) }
    val x = sc.next()

    val sumAll = t.map { it.second }.sum()
    var sum = 0
    for (i in 0 until n) {
        sum += t[i].second
        if (t[i].first == x) {
            break
        }
    }
    println(sumAll - sum)
}

Measured memory_bytes: 31524