akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define Check system("pause")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)



int main()
{
	ios::sync_with_stdio(false);
	ll a,k,w;
	int b,c;
	scanf("%lld %d.%d",&a,&b,&c);
	k=b*100+c;
	w=a*k/100;
	cout<<w;
	return 0;
}




Measured memory_bytes: 3784
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	digit := len(strconv.Itoa(N))
	ans := 0
	var dfs func(nums []int, n int)
	dfs = func(nums []int, n int) {
		if 3 <= n {
			if check(nums) && toInt(nums) <= N {
				ans++
			}
		}
		if n == digit {
			return
		}
		dfs(append(nums, 3), n+1)
		dfs(append(nums, 5), n+1)
		dfs(append(nums, 7), n+1)
	}
	dfs([]int{}, 0)
	fmt.Println(ans)
}

func check(nums []int) bool {
	set := make(map[int]bool)
	for _, v := range nums {
		set[v] = true
	}
	return len(set) == 3
}

func toInt(nums []int) int {
	res := 0
	for _, n := range nums {
		res *= 10
		res += n
	}
	return res
}


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

int calc(int a) {
    int ret = 0;
    for (int i = 0; i < 40; i++) {
        int cycle = 2LL << i;
        int t = (a / cycle) * (cycle / 2);
        t += max(0LL, a % cycle - cycle / 2 + 1);
        ret += t % 2 * (1LL << i);
    }
    return ret;
}
signed main() {
    int A, B;
    cin >> A >> B;

    cout << (calc(B) ^ calc(A - 1)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  int r;
  cin >> r;
  double ans = 2*r*acos(-1);
  printf("%.10f\n", ans);

  return 0;
}

Measured memory_bytes: 3760
import sys
def input(): return sys.stdin.readline().rstrip()

K = int(input())
A, B = map(int, input().split())

ans = False
count = K
while count <= B:
    if A <= count and count <= B:
        ans = True
    count += K

if ans:
    print('OK')
else:
    print('NG')

Measured memory_bytes: 9172
/**
 * Title:
 * Url:
 */
#include<iostream>

using namespace std;

#define ll long long

int main() {

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

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

const int MOD = 1000000007;

int main(){
	int N;
	static long long fact[8001];
	static long long inv[8001];
	static long long factInv[8001];
	fact[0] = inv[1] = factInv[0] = 1;
	for(int i=2;i<=8000;i++) inv[i] = inv[MOD%i] * (MOD - MOD/i) % MOD;
	for(int i=1;i<=8000;i++){
		fact[i] = fact[i-1] * i;
		fact[i] %= MOD;
		factInv[i] = factInv[i-1] * inv[i];
		factInv[i] %= MOD;
	}
	static int path[4001][4001];
	while(cin >> N){
		memset(path, 0, sizeof(path));
		vector<int> A(N), B(N);
		for(int i=0;i<N;i++){
			cin >> A[i] >> B[i];
			path[2000-A[i]][2000-B[i]]++;
		}
		for(int i=0;i<=4000;i++){
			for(int j=0;j<=4000;j++){
				if(i+1 <= 4000){
					path[i+1][j] += path[i][j];
					path[i+1][j] %= MOD;
				}
				if(j+1 <= 4000){
					path[i][j+1] += path[i][j];
					path[i][j+1] %= MOD;
				}
			}
		}
		long long res = 0;
		for(int i=0;i<N;i++){
			res += path[2000+A[i]][2000+B[i]];
			res %= MOD;
			int a = 2 * (A[i] + B[i]);
			int b = 2 * A[i];
			res += MOD - fact[a] * factInv[b] % MOD * factInv[a-b] % MOD;
			res %= MOD;
		}
		res *= inv[2];
		res %= MOD;
		cout << res << endl;
	}
}


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

 
int main() {
  int m;
  cin >> m;
  ll now = 0;
  ll nine_count = 0;
  ll d = 0;
  rep(i,m){
    ll a,b;
    cin >> a >> b;
    d += b;
    nine_count += (a * b)/9;
    now += (a * b) % 9;
  }
  nine_count += now/9;
  
  if(now%9 == 0) cout << nine_count + d - 2 << endl;
  else cout << nine_count + d - 1 << endl;  

  return 0;
}



Measured memory_bytes: 256
s=list(input())
m=set(s)
if len(m)==4:
  print("Yes")
elif len(m)==2:
  c1="S" in m and "N" in m
  c2="W" in m and "E" in m
  if c1 or c2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include<complex>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;


int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a,b) * c + max(0,a - b)*d << endl;
	return 0;
}
//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
vi v;

void solve(){
	cin >> n;
	vector<string>s = {"hon","pon","bon"};
	v = {1,1,0,2,0,0,1,0,1,0};
	cout << s[v[n%v.size()]];

}

int main(){

	int t= 1;
	while(t--){
		solve();
	}
	
	return 0;
}

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

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

string S;
int idx;
int N, M;
string alphas;
int curr;

void consume(char c) {
  if(idx >= N) throw exception();
  if(S[idx] != c) throw exception();
  idx ++;
}

bool try_consume(char c) {
  try {
    consume(c);
  } catch(exception e) {
    return false;
  }
  return true;
}

int E();

int convert(string const& b) {
  int n = b.size();
  int ret = 0;
  for(int i=0; i<n; i++) {
    ret *= 2;
    assert(isdigit(b[i]));
    ret += b[i] - '0';
  }
  return ret;
}

string B() {
  string ret;
  while(1) {
    if(S[idx] == '0') ret += '0';
    else if(S[idx] == '1') ret += '1';
    else break;
    idx++;
  }
  return ret;
}

int Nu() {
  if(try_consume('0')) return 0;
  consume('1');
  return convert("1" + B());
}

int F() {
  if(try_consume('-')) {
    return -F();
  }
  else if(try_consume('(')) {
    int r = E();
    consume(')');
    return r;
  }
  else {
    return Nu();
  }
}

int T() {
  int num1 = F();
  while(try_consume('*')) {
    int num2 = F();
    num1 *= num2;
  }
  return num1;
}

int E() {
  int term1 = T();
  while(1) {
    bool cont = 0;
    while(try_consume('+')) {
      cont = 1;
      int term2 = T();
      term1 += term2;
    }
    while(try_consume('-')) {
      cont = 1;
      int term2 = T();
      term1 -= term2;
    }
    if(!cont) break;
  }
  return term1;
}

bool Q() {
  int expr1 = E();
  consume('=');
  int expr2 = E();
  return expr1 == expr2 && idx == N;
}

int main() {

  string T = "01+-*()=";
  sort(T.begin(), T.end());
  string RS; cin >> RS;
  N = RS.size();
  for(auto c: RS) if(isalpha(c)) alphas.push_back(c);
  sort(alphas.begin(), alphas.end());
  alphas.erase(unique(alphas.begin(), alphas.end()), alphas.end());
  M = alphas.size();

  if(M > T.size()) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 0;
  set<string> st;
  do {
    S = RS;
    rep(i, N) {
      if(isalpha(S[i])) S[i] = T[alphas.find(S[i])];
    }
    if(!st.count(S)) {
      st.insert(S);
      idx = curr = 0;
      try { ans += Q(); } catch (exception e) {}
    }
  } while(next_permutation(T.begin(), T.end()));
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 7616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define YESNO(i) puts((i)?"YES":"NO");
#define YesNo(i) puts((i)?"Yes":"No");
#define yesno(i) puts((i)?"yes":"no");
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a;cin>>a;
  print(a+a*a+a*a*a);
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  set<string> S;
  for(int ii=0; ii<N; ii++){
    string s;
    cin >> s;
    S.insert(s);
  }
  cout << S.size() << endl;
  return 0;
}


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

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

	int ans = 0;
	rep(i, 0, n) {
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200005;
const int MOD=1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	map<char,int>M;string s;cin>>s;
	FOR(i,0,3)M[s[i]]++;
	if(sz(M)!=2){
		cout<<"No\n";
		return 0;
	}
	for(auto i:M){
		if(i.snd!=2){
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
}
/*
*/


Measured memory_bytes: 764
import java.util.*;
public class Main {
public static void main(String[] args){
  	Scanner sc = new Scanner(System.in);
  	int[][] a = new int[3][3];
  	for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
      	a[i][j] = sc.nextInt();
	  }
    }
	int N = sc.nextInt();	
  	int[] b = new int[N];
  	for(int k=0;k<N;k++){
      	b[k] = sc.nextInt();
	}
  	for(int t=0;t<N;t++){
      for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
          if(a[i][j] == b[t]){
            a[i][j] = 0;
          }
        }
      }
    }

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

	}
}

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

int hantei(int x){
	for(int i=1;i<=1000;i++){
    	if(x==i*i){
          	cout<<i<<endl;
        	return 1;
        }
    }
  return 0;
}


int main() {

  int a,b,c,d,sum;
  string s,t;
  cin>>a>>b>>c>>d;
  
  sum=0;
  for(int i=0;i<=a;i++){
  	for(int j=0;j<=b;j++){
    	for(int k=0;k<=c;k++){
        	if(d==i*500+j*100+k*50)sum++;
        }
    }
  }
  
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  CppTest
//
//  Created by M_Sugawara on 2019/12/22.
//  Copyright © 2019 Sugawar. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    int caseA;
    int caseB;

    long caseAL;
    long caseBL;
    long result = 0;

    cin >> caseA >> caseB;
    caseAL = long(caseA);
    caseBL = long(caseB);
    long max = caseAL * caseBL;
    long maxCase = 0L;
    if (caseA > caseB) {
        maxCase = caseAL;
    } else {
        maxCase = caseBL;
    }

    for(long i=maxCase;i>0;i--) {
        long testCase = max / i;

        if(testCase % caseAL == 0) {
            if (testCase % caseBL == 0) {
                result = testCase;
                break;
            }
        }
    }

    cout << result;

    return 0;
}


Measured memory_bytes: 256
S = input()

p = 0

for i in range(len(S)):
  if i % 2 == 0:
    if S[i] == 'L':
      p += 1
  elif i % 2 == 1:
    if S[i] == 'R':
      p += 1
  if p == 1:
    break
      
if p != 0:
  print('No')
elif p == 0:
  print('Yes')

Measured memory_bytes: 3060
n, m  = gets.strip.split.map(&:to_i)
as = gets.strip.split.map(&:to_i)

candidates = [2,5,5,4,5,6,3,7,6].map.with_index {|e, i| [e, i+1] }.select {|e, i| as.include?(i) }.to_h

dp = Array.new(n+1)

(n+1).times do |i|
  tmp = candidates[i].to_s
  candidates.each do |cost, num|
    next if i-cost<0 || dp[i-cost].to_i.zero?

    exists = dp[i-cost]
    c = num.to_s > exists ? num.to_s + exists : exists + num.to_s
    tmp = c if tmp.length < c.length || c.length==tmp.length && c>tmp
  end
  dp[i]=tmp
end

#p dp
puts dp[n]


Measured memory_bytes: 48892
#include<iostream>
#include<string>

using namespace std;

int main()
{
  string s, t;
  int n;
  cin >> n;
  cin >> s >> t;
  for (int i = 0; i < n; i++){
    cout << s[i] << t[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<iomanip>
#include<set>
#include<unordered_map>
using namespace std ;

#define MAXN 100007

int r , c ;
vector < pair < int , int > > topside ;
vector < pair < int , int > > rightside ;
vector < pair < int , int > > bottomside ;
vector < pair < int , int > > leftside ;

bool used[ MAXN ] ;

stack < int > st ;
vector < int > v ;

void add_pt ( int x , int y , int id ) {
    if ( x == 0 ) {
        topside.push_back ( { y , id } ) ;
    }
    else if ( y == c ) {
        rightside.push_back ( { x , id } ) ;
    }
    else if ( x == r ) {
        bottomside.push_back ( { - y , id } ) ;
    }
    else if ( y == 0 ) {
        leftside.push_back ( { - x , id } ) ;
    }
}

bool on_side ( int x , int y ) {
    if ( x == 0 || x == r ) { return true ; }
    if ( y == 0 || y == c ) { return true ; }
    return false ;
}

void input ( ) {
    scanf ( "%d%d" , &r , &c ) ;
    int n ;
    scanf ( "%d" , &n ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        int x , y , z , t ;
        scanf ( "%d%d%d%d" , &x , &y , &z , &t ) ;
        if ( on_side ( x , y ) == true && on_side ( z , t ) == true ) {
            add_pt ( x , y , i ) ;
            add_pt ( z , t , i ) ;
        }
    }
    sort ( topside.begin ( ) , topside.end ( ) ) ;
    sort ( rightside.begin ( ) , rightside.end ( ) ) ;
    sort ( bottomside.begin ( ) , bottomside.end ( ) ) ;
    sort ( leftside.begin ( ) , leftside.end ( ) ) ;
}

void solve ( ) {
    int sz = topside.size ( ) ;
    for ( int i = 0 ; i < sz ; ++ i ) {
        v.push_back ( topside[ i ].second ) ;
    }
    sz = rightside.size ( ) ;
    for ( int i = 0 ; i < sz ; ++ i ) {
        v.push_back ( rightside[ i ].second ) ;
    }
    sz = bottomside.size ( ) ;
    for ( int i = 0 ; i < sz ; ++ i ) {
        v.push_back ( bottomside[ i ].second ) ;
    }
    sz = leftside.size ( ) ;
    for ( int i = 0 ; i < sz ; ++ i ) {
        v.push_back ( leftside[ i ].second ) ;
    }

    sz = v.size ( ) ;
    for ( int i = 0 ; i < sz ; ++ i ) {
        if ( used[ v[ i ] ] == false ) {
            used[ v[ i ] ] = true ;
            st.push ( v[ i ] ) ;
        }
        else {
            if ( st.empty ( ) == true || st.top ( ) != v[ i ] ) {
                printf ( "NO\n" ) ;
                return ;
            }
            st.pop ( ) ;
        }
    }
    printf ( "YES\n" ) ;
}


int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 3812
#include <stdio.h>

int pearent(int i){
  return i / 2;
}

int left(int i){
  return 2*i;
}
int right(int i){
  return (2*i)+1;
}

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

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,a[i]);
    
    if(pearent(i) >= 1){
      printf("parent key = %d, ",a[pearent(i)]);
    }

    if(left(i) <= n){
      printf("left key = %d, ",a[left(i)]);
    }

    if(right(i) <= n){
      printf("right key = %d, ",a[right(i)]);
    }
      printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int n;
string s;

ll search(char s1, char s2, char s3, vint ls) {
    ll res = 0;
    rep(i, n) {
        if (s[i] != s1) continue;
        srep(j, i+1, n) {
            if (s[j] != s2) continue;
            res += ls[n]-ls[j+1];
            int idx = j+j-i;
            if (idx >= n) continue;
            if (s[idx] == s3) res--;
        }
    }
    return res;
}

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

    vint r(n+1, 0);
    vint g(n+1, 0);
    vint b(n+1, 0);
    rep(i, n) if (s[i] == 'R') r[i+1]++;
    rep(i, n) r[i+1] += r[i];
    rep(i, n) if (s[i] == 'G') g[i+1]++;
    rep(i, n) g[i+1] += g[i];
    rep(i, n) if (s[i] == 'B') b[i+1]++;
    rep(i, n) b[i+1] += b[i];

    ll ans = 0;
    ans += search('R', 'G', 'B', b);
    ans += search('R', 'B', 'G', g);
    ans += search('G', 'R', 'B', b);
    ans += search('G', 'B', 'R', r);
    ans += search('B', 'R', 'G', g);
    ans += search('B', 'G', 'R', r);

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

Measured memory_bytes: 3668
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main () {

    ll A,B,C; cin >> A >> B >> C;
    ll a1 = abs(A - B) + abs(B - C);
    ll a2 = abs(A - C) + abs(C - B);
    ll a3 = abs(B - A) + abs(A - C);
    ll a4 = abs(B - C) + abs(C - A);
    ll a5 = abs(C - A) + abs(A - B);
    ll a6 = abs(C - B) + abs(B - A);
    vector < ll > ans = {a1, a2, a3, a4, a5, a6};
    sort(ans.begin(), ans.end());
    cout << ans.front() << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n];
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum=sum^arr[i];
    }
    ll ans[n];
    for(int i=0;i<n;i++)
    {
        ans[i]=sum^arr[i];
        cout<<ans[i]<<" ";
    }


    
    return 0;
}

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

int table[26];
int N;

void solve(){
    bool skip = false;
    
    for(int i=0; i<N; i++){
        char c; cin >> c;
        if(skip) continue;
        
        table[c-'A']++;
        vector<pair<int, int>> vec;
        for(int i=0; i<26; i++)
            vec.emplace_back(table[i], i);
        sort(vec.rbegin(), vec.rend());
        
        int diff = vec[0].first - vec[1].first;
        if(diff > N-i-1){
            cout << char('A'+vec[0].second) << " " << i+1 << endl;
            skip = true;
        }
    }
    if(!skip)
        cout << "TIE" << endl;
}

int main(){
    while(cin >> N, N){
        memset(table, 0, sizeof(table));
        solve();
    }
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3==0)cout<<" "<<i;
        else{
            int l=i;
            while(l>1){
                if(l%10==3){
                    cout<<" "<<i;
                    break;
                }   
                l/=10;
            }
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>
int main(void)
{
	int i, j;
	int ans;
	
	for(i = 1; i < 10; i++)
	{
		for(j = 1; j < 10; j++)
		{
			ans = i * j;
			printf("%dx%d=%d\n", i, j, ans);
		}
	}
	
	return 0;
}

Measured memory_bytes: 524
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int N, K;
    cin >> N >> K;
    vi V(N);
    rep(i, N)cin >> V[i];

    int ans = 0;
    rep(l, N + 1) {
        for (int r = l; r <= N; ++r) {
            int m = K - l - (N - r);
            if (m < 0)continue;
            vi A;
            int sum = 0;
            rep(i, l) {
                A.push_back(V[i]);
                sum += V[i];
            }
            for (int i = r; i < N; ++i) {
                A.push_back(V[i]);
                sum += V[i];
            }
            sort(all(A));
            rep(i, min(sz(A), m)) {
                if (A[i] < 0)sum -= A[i];
            }
            smax(ans, sum);
        }
    }
    cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a;
	int b[10];
	int sum=0;
	for(int i=0;i<5;i++){
		cin>>a;
		sum+=a/10*10;
		b[i]=a%10;
	}
	int p=0;
	int min=125;
	for(int i=0;i<5;i++){
		if(b[i]==0) p++;	
		if(b[i]!=0&&b[i]<min) min=b[i];
	}
	if(p==5){
		min=0;
		p=4;
	}
	cout<<sum+(4-p)*10+min<<endl;
} 

Measured memory_bytes: 256
n,m=map(int,input().split())
ab=[[int(i)for i in input().split()]for _ in range(n)]
ab.sort()
c=0
x=0
for i in range(n):
  m-=ab[i][1]
  c+=1
  if m<=0:
    x-=m
    break
p=0
for i in range(c):
  p+=ab[i][0]*ab[i][1]
print(p-ab[c-1][0]*x)

Measured memory_bytes: 21608
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

const ll MAX = 1LL << 61;

int K, A[101010];

int main() {
    cin >> K;
    for (int j = 0; j < K; ++j) cin >> A[j];

    ll a1, a2;
    {
        ll l = 0, r = MAX;
        while (l+1 < r) {
            ll m = (l+r) / 2, tmp = m;
            for (int j = 0; j < K; ++j) {
                m = m / A[j] * A[j];
            }
            (m >= 2 ? r : l) = tmp;
        }
        a1 = r;
    }

    {
        ll l = 0, r = MAX;
        while (l+1 < r) {
            ll m = (l+r) / 2, tmp = m;
            for (int j = 0; j < K; ++j) {
                m = m / A[j] * A[j];
            }
            (m > 2 ? r : l) = tmp;
        }
        a2 = l;
    }

    if (a1 > a2) {
        cout << "-1" << endl;
        return 0;
    }

    { 
        ll t = a1;
        for (int j = 0; j < K; ++j) {
            t = t / A[j] * A[j];
        }
        if (t != 2) {
            cout << "-1" << endl;
            return 0;
        }
    }

    { 
        ll t = a2;
        for (int j = 0; j < K; ++j) {
            t = t / A[j] * A[j];
        }
        if (t != 2) {
            cout << "-1" << endl;
            return 0;
        }
    }

    cout << a1 << " " << a2 << endl;

    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}
struct __f{
    __f(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    }
};


vector<vector<int>> G;
vector<int> ans;
vector<int> e;

void dfs(int i){
    int m = 0;
    for(int c : G[i]){
        if(ans[i] == ++m) ++m;
        ans[c] = m;
        dfs(c);
    }
}

int main(){

    int n;
    scanf("%d", &n);
    G.resize(n);
    ans.resize(n, 0);
    e.resize(n-1);

    rep(i, n-1){
        int a, b;
        scanf("%d%d", &a, &b);  
        --a; --b;
        G[a].emplace_back(b);
        e[i] = b;
    }
    
    dfs(0);

    printf("%d\n", *max_element(ans.begin(), ans.end()));
    for(int edge : e)
        printf("%d\n", ans[edge]);
    

    return 0;
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
const int N = 1e2 + 2;
const int M = 1e3 + 5;
const int Mod = 1e9 + 7;

int n, a[N], b[N];
int G[N][N];

int main()
{
	GO;
	ll x;
	cin >> x;
	ll ans = 0;
	ll c = 100;
	while (c < x)
		c += c / 100, ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	int n,x,y;
	cin >> n >> x >> y;
	int d[2100] = {};
	x--;
	y--;
	for(int i = 0;i < n;i++){
		for(int j = i+1;j < n;j++){
			int dist = abs(j-i);
			int ix = abs(x-i);
			int iy = abs(y-i);
			int jy = abs(y-j);
			int jx = abs(x-j);
			chmin(dist,ix+jy+1);
			chmin(dist,iy+jx+1);
			d[dist]++;
		}
	}
	for(int i = 1;i < n;i++)cout << d[i] << endl;

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://abc160.contest.atcoder.jp/tasks/abc160_a

Measured memory_bytes: 256
def gcd(a, b):
    while a != 0:
        a, b = b % a, a
    return b


def pf(v):
    result = 1
    for i in range(2, v + 1):
        if v < i * i:
            if v > 1:
                result += 1
            break
        if v % i == 0:
            result += 1
        while v > 1 and v % i == 0:
            v //= i
    return result


a, b = list(map(int, input().split()))
print(pf(gcd(a, b)))


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  int s = S.size();
  int t = T.size();

  string ans;
  bool existAns = false;
  for(int i=0;i<=s-t;i++){
    bool isok = true;
    for(int j=0;j<t;j++){
      if(S[i+j]!=T[j] && S[i+j]!='?'){
        isok = false;
        break;
      }
    }

    if(isok){
      string tmp = S;
      for(int j=0;j<s;j++){
        if(tmp[j] == '?') tmp[j] = 'a';
      }
      for(int j=0;j<t;j++){
        tmp[i+j] = T[j];
      }
      if(!existAns){
        existAns = true;
        ans = tmp;
      }
      else{
        ans = min(ans,tmp);
      }
    }
  }

  if(existAns) cout << ans << endl;
  else cout << "UNRESTORABLE" << endl;

  return 0;
}

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

int main(){
	stack<int> S;
	string str;
	int A,B;
	while(cin >> str){
		if(str=="+"){
			A=S.top();
			S.pop();
			B=S.top();
			S.pop();
			S.push(B+A);
		}else if(str=="-"){
			A=S.top();
			S.pop();
			B=S.top();
			S.pop();
			S.push(B-A);
		}else if(str=="*"){
			A=S.top();
			S.pop();
			B=S.top();
			S.pop();
			S.push(B*A);
		}else{
			A=(int)strtol(str.c_str(),NULL,0);
			S.push(A);
		}
	}
	A=S.top();
	cout << A << endl;
	return 0;
}


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

int main(){
  int ans;
  string s1="qwertasdfgzxcvb";
  string s2="yuiophjklnm";
  string s;

  while(1){
    cin>>s;
    ans=0;
    if(s[0]=='#')break;
    int flag=0;
    for(int i=0;i<(int)s.size();i++){
      for(int j=0;j<(int)s1.size();j++){
	if(s[i]==s1[j]){
	  if(flag==0||flag==2){
	    ans++;
	    flag=1;
	  }
	}
      }
      for(int j=0;j<(int)s2.size();j++){
	if(s[i]==s2[j]){
	  if(flag==0||flag==1){
	    ans++;
	    flag=2;
	  }
	}
      }
    }
    cout<<ans-1<<endl;
    s.clear();
  }
  return 0;
}

Measured memory_bytes: 1188
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll n;
vector<vector<ll>> dist;
vector<vector<ll>> g;

void calcDist(int s) {
  // cout << "s: " << s << endl;

  // Here, calculate distance from v.
  queue<P> q;
  dist[s][s] = 0;
  q.emplace(s, 0);
  while(!q.empty()) {
    auto p = q.front(); q.pop();
    int v = p.first;
    int d = p.second;
    // cout << "(v,d):" << v << "," << d << endl;
    for (int nv : g[v]) {
      if (dist[s][nv] < INF) { continue; } // skip already calculated
      dist[s][nv] = d+1;
      q.emplace(nv, d+1);
    }
  }

  // Here, all dist[s][x] is calculated
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, x, y;
  cin >> n >> x >> y;
  --x; --y;
  g.resize(n);
  dist = vector<vector<ll>>(n, vector<ll>(n, INF)); // min distance of (i, j)

  rep(i, n-1) {
    g[i].push_back(i+1);
    g[i+1].push_back(i);
  }
  g[x].push_back(y);
  g[y].push_back(x);

  // cout << "g:" << endl;
  // printtree(g);

  // Here, calculate the cont of each
  vector<ll> ans(n+1); // ans[i] .. ans for i. 1-indexied
  for (int i = 1; i <= n; ++i) {
    ans[i] = n-i;
  }
  // cout << "ans:" << endl;
  // printvec(ans);

  // Here, we calculate the min distance from each i to j.
  rep(s, n) {
    calcDist(s);
  }

  // cout << "dis:" << endl;
  // printtree(dist);

  rep(l, n) {
    for (int r = l + 1; r < n; ++r) {
      // Here, check (l, r) pair
      ll oldDist = r - l;
      ll newDist = dist[r][l];
      --ans[oldDist];
      ++ans[newDist];
    }
  }

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


Measured memory_bytes: 31744
#include <iostream>
#include <vector>
#include <functional>

template <class Data, class Operator>
class CoSegmentTree {
    using OperatorMerger = std::function<Operator(Operator, Operator)>;
    using Applier = std::function<Data(Data, Operator)>;

public:
    int length;
    std::vector<Operator> ope;
    Data dat_id;
    Operator ope_id;
    OperatorMerger opem;
    Applier app;

    explicit CoSegmentTree(int N, Data dat_id, Operator ope_id, OperatorMerger opem, Applier app)
        : length(1), dat_id(dat_id), ope_id(ope_id), opem(opem), app(app) {
        while (length < N) length *= 2;
        ope.assign(length * 2, ope_id);
    }

    // half-open interval [ql, qr)
    void update(int ql, int qr, Operator e) { return update(ql, qr, e, 1, 0, length); }

    void update(int ql, int qr, Operator e, int nidx, int nl, int nr) {
        if (nr <= ql || qr <= nl) return;
        if (ql <= nl && nr <= qr) {
            ope[nidx] = opem(ope[nidx], e);
            return;
        }
        // 子に作用素を伝播
        ope[nidx * 2] = opem(ope[nidx * 2], ope[nidx]);
        ope[nidx * 2 + 1] = opem(ope[nidx * 2 + 1], ope[nidx]);
        ope[nidx] = ope_id;
        // 子を再帰的に更新
        update(ql, qr, e, nidx * 2, nl, (nl + nr) / 2);
        update(ql, qr, e, nidx * 2 + 1, (nl + nr) / 2, nr);
    }

    Data query(int idx) {
        int nidx = idx + length;
        Data ret = app(dat_id, ope[nidx]);
        while (nidx > 0) {
            nidx /= 2;
            ret = app(ret, ope[nidx]);
        }
        return ret;
    }
};

int main() {
    int N, Q;
    std::cin >> N >> Q;
    CoSegmentTree<int, int> seg(N, 0, 0,
                                [](int e, int f) { return e + f; },
                                [](int a, int e) { return a + e; });

    for (int q = 0; q < Q; ++q) {
        int k;
        std::cin >> k;
        if (k == 0) {
            int l, r, x;
            std::cin >> l >> r >> x;
            seg.update(l - 1, r, x);
        } else {
            int i;
            std::cin >> i;
            std::cout << seg.query(i - 1) << std::endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3876
#include <iostream>


int func(int n){
	int count = 0;

	for (int a = 0; a <= 9; a++){
		for (int b = 0; b <= 9; b++){
			for (int c = 0; c <= 9; c++){
				for (int d = 0; d <= 9; d++){
					if (a + b + c + d == n){
						count++;
					}
				}
			}
		}
	}

	return count;
}



int main(){
	int input;

	while (std::cin >> input){
			std::cout << func(input) << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  rep(i,n) scanf("%d", &vec[i]);
  int sum=0;
  rep(i,n) sum+=vec[i];
  int m;
  cin>>m;
  rep(i,m){
    int p,x;
    scanf("%d %d", &p, &x);
    p--;
    printf("%d\n", sum-vec[p]+x);
  }

  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <map>
#include <iostream>
#include <algorithm>
#define MAXN 111111
#define ll long long
using namespace std;

int V[22];

int main() {
    int N;
    cin>>N;
    for(int i=1;i<=N;i++) {
        cin>>V[i];
    }
    vector<int> diffs;
    for(int i=1;i<=N;i++) {
        int C;
        cin>>C;
        diffs.push_back(V[i]-C);
    }
    sort(diffs.begin(),diffs.end());
    int ans=0;
    for(int i=N-1;i>=0;i--) {
        if (diffs[i]<=0)
            break;
        ans += diffs[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main_old(): 
    N = II()
    
    dp = {'a': [1,1,4,16] + [0 for _ in range(N)],
    't': [1,1,4,16] + [0 for _ in range(N)],
    'g': [1,1,4,15] + [0 for _ in range(N)],
    'c': [1,1,4,14] + [0 for _ in range(N)]
    }

    codons = ['a', 't', 'g', 'c']

    # if N < 5:
    # for i in range(4, N+1):
    #     dp['a'][i] = dp['a'][i-1] +  dp['t'][i-1] +  dp['g'][i-1] +  dp['c'][i-1]
    #     dp['t'][i] = dp['a'][i-1] +  dp['t'][i-1] +  dp['g'][i-1] +  dp['c'][i-1]
    #     dp['g'][i] = dp['a'][i-2] * 3 + dp['t'][i-2] * 4 + dp['g'][i-2] * 4 + dp['c'][i-2] * 4
    #     dp['c'][i] = dp['a'][i-3] * 9 + dp['t'][i-3] * 12 + dp['g'][i-3] * 11 + dp['c'][i-3] * 12
    for i in range(4, N+1):
        dp['a'][i] = dp['a'][i-3] * 14 + dp['t'][i-3] * 16 + dp['g'][i-3] * 15 + dp['c'][i-3] * 16
        dp['t'][i] = dp['a'][i-3] * 14 + dp['t'][i-3] * 16 + dp['g'][i-3] * 15 + dp['c'][i-3] * 16
        dp['g'][i] = dp['a'][i-3] * 13 + dp['t'][i-3] * 15 + dp['g'][i-3] * 15 + dp['c'][i-3] * 15
        dp['c'][i] = dp['a'][i-3] * 9 + dp['t'][i-3] * 14 + dp['g'][i-3] * 13 + dp['c'][i-3] * 14

    sum_ = 0
    for x in codons:
        sum_ += dp[x][N] % MOD
    print(sum_ % MOD)
    return

def is_valid(s):
    if s[0:3] == 'AGC' or s[0]+s[2:4] == 'AGC' or s[0:2] + s[3] == 'AGC' or s[1:4] == 'AGC' or s.count('GAC') > 0 or s.count('ACG') > 0:
        return False
    else:
        return True

def main(): 
    N = II()

    if N == 3:
        print(61)
        return
    
    import collections
    dp = collections.defaultdict(int)
    import itertools
    for st in itertools.product('AGCT', repeat=4):
        st = ''.join(st)
        if is_valid(st):
            dp[st] = 1
        else:
            dp[st] = 0

    for i in range(4, N):
        dp2 = collections.defaultdict(int)
        for st in itertools.product('AGCT', repeat=4):
            st = ''.join(st)
            for char in 'AGCT':
                nex = st[1:4] + char
                if is_valid(nex):
                    dp2[nex] = (dp2[nex] + dp[st])%MOD
                else:
                    pass
        dp = dp2

    sum_ = 0
    for st in itertools.product('AGCT', repeat=4):
        st = ''.join(st)
        sum_ = (sum_ + dp[st])%MOD
    print(sum_)

main()

Measured memory_bytes: 46448
n, m = (int(x) for x in input().split())
sub = [0] * (n+1)
ok = ng = 0
for i in range(m):
  p, s = input().split()
  p = int(p)
  if sub[p] == -1:
    continue
  if s == 'WA':
    sub[p] += 1
  if s == 'AC':
    ok += 1
    ng += sub[p]
    sub[p] = -1
print(ok, ng)

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

const long long mod = 1e9 + 7;

int main()
{
	int s;
	cin >> s;
	vector<long long> dp(s + 1);
	dp[0] = 1;
	for(int i = 3; i <= s; i++) {
		dp[i] = (dp[i - 1] + dp[i - 3]) % mod;
	}
	cout << dp[s] << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  int n;cin>>n;
  int x[n+10];rep(i,0,n)cin>>x[i];
  int cp[n+10];memcpy(cp,x,sizeof(cp));

  int med=n/2-1;
  sort(cp,cp+n);
  rep(i,0,n){
    int d=lower_bound(cp,cp+n,x[i])-cp;

    out(cp[med+((d<=med)?1:0)]);
  }

  return 0;
}


Measured memory_bytes: 3840
import numpy as np
import math

n, d = input().split()
n = int(n)
d = int(d)

points = np.zeros((n, d))

for i in range(n):
    hoge = np.array([int(x) for x in input().split()])
    points[i, :] = hoge

total = 0

# calc distance
for i in range(n):
    for j in range(i+1, n):
        foo = (points[i, :] - points[j, :]) ** 2
        foo_sum = foo.sum()
        if int(foo_sum) == int(math.sqrt(foo_sum)) ** 2:
            total += 1

print(total)


Measured memory_bytes: 12504
s = gets.chomp

if s.size.odd?
  puts 'No'
  exit
end

0.upto(s.size - 1) do |i|
  if (i.even? && s[i] != 'h') || (i.odd? && s[i] != 'i')
    puts 'No'
    exit
  end
end
puts 'Yes'

Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;
  int max = 0;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i = 1; i <= n; i++){
    scanf("%d",&A[i]);
    if(A[i] > max)max = A[i];
  }

  for(i = 0; i <= max; i++)
    C[i] = 0;

  for(j = 1; j <= n; j++)
    C[A[j]]++;
  for(i = 1; i <= max; i++)
    C[i] = C[i] + C[i - 1];

  for(j = n; j >= 1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i = 1; i <= n; i++){
    if(i > 1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");


  return 0;
}



Measured memory_bytes: 9580