akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

int main() {
  int N;
  scanf("%d", &N);
  auto dsum=[](int n) {
    int d=0;
    while (n) {
      d += n%10;
      n /= 10;
    }
    return d;
  };
  printf("%s\n", N%dsum(N)? "No":"Yes");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  
  vector<int> d(N);
  
  for (int i = 0; i < N ; i++) {
    cin >> d.at(i);
  }
  
  vector<int> KM;
  KM = {d.at(0)};
  int size = 0;
  
  for (int i = 1; i < N ; i++) {
    
    size = KM.size();
    
    for (int j = 0; j < size ; j++) {
      
      if (d.at(i) == KM.at(j)) {
        break;
      }
      
      if (j == size - 1) {
        KM.push_back(d.at(i));
      }
      
    }
    
  }
  
  cout << KM.size() << endl;
  
}

Measured memory_bytes: 3620
#include <stdio.h>

int main (){
  int a;
  int op;
  int b;
  int c;
  while(1){
  scanf("%d %c %d", &a,&op,&b);

  if(op == '+'){
      c = a + b;
      printf ("%d\n" , c);
  }else if(op == '-'){
    c = a- b;
    printf("%d\n" , c);}
  else if (op == '*'){
    c = a * b;
    printf("%d\n" , c);}
  else if(op == '/'){
    c = a / b;
    printf("%d\n" , c);
  }else if(op == '?' ){
    break;}}
  return 0;

}

Measured memory_bytes: 600
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int inf=1e9+7;//0x3f
//
int main(){
	int N,M,X,Y;
	cin>>N>>M>>X>>Y;
	int mx=-10000,my=10000;
	for(int  i=0;i<N;i++){
		int x;
		cin>>x;
		mx=max(mx,x);
	}
	for(int i=0;i<M;i++){
		int y;
		cin>>y;
		my=min(my,y);
	}
	if(X<Y&&mx<my&&X<my&&mx<Y){
		cout<<"No War"<<endl;
	}else{
		cout<<"War"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
// input macro
// ref: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;

#[allow(unused_mut)]
fn main() {
    input!(
        n: usize,
    );

    let mut coins: HashSet<usize> = HashSet::with_capacity(30);
    for i in 0..10 {
        coins.insert(6usize.pow(i));
        coins.insert(9usize.pow(i));
    }

    let mut dp: Vec<usize> = vec![std::usize::MAX; n+1];
    dp[0] = 0;
    for i in 1..n+1 {
        for coin in coins.iter() {
            let c: usize = coin.clone();
            if i < c {
                continue;
            }
            else {
                dp[i] = std::cmp::min(dp[i], dp[i-c] + 1);
            }
        }
    }

    println!("{}", dp[n]);

}


Measured memory_bytes: 4352
a1, a2, a3 = [int(x) for x in input().split()]


def majikuso(a1, a2, a3):
    s1 = 0
    s1 += abs(a1-a2)
    s1 += abs(a2-a3)

    s2 = 0
    s2 += abs(a1-a3)
    s2 += abs(a3-a2)

    s3 = 0
    s3 += abs(a2-a1)
    s3 += abs(a1-a3)

    s4 = 0
    s4 += abs(a2-a3)
    s4 += abs(a3-a1)

    s5 = 0
    s5 += abs(a3-a2)
    s5 += abs(a2-a1)

    s6 = 0
    s6 += abs(a3-a1)
    s6 += abs(a1-a2)

    return min([s1, s2, s3, s4, s5, s6])

print(majikuso(a1, a2, a3))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    vector<ll> plus, xy, yx;
    rep(i, n){
        ll x, y;
        cin >> x >> y;
        plus.push_back(x+y);
        xy.push_back(x-y);
        yx.push_back(y-x);
    }
    sort(plus.begin(), plus.end());
    sort(xy.begin(), xy.end());
    sort(yx.begin(), yx.end());
    ll res=plus[n-1]-plus[0];
    res = max(res, xy[n-1]+yx[n-1]);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8200
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int tmp=i,num=0;
        while(tmp)
        {
            num++;
            tmp/=10;
        }
        if(num%2)
            ans++;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
n=int(input())
data=[]


for i in range(n):
    tmp=[0]*3
    tmp[0],tmp[1]=map(int,input().split())
    data.append(tmp)

for i in range(n):
    tmp=[1]*3
    tmp[0],tmp[1]=map(int,input().split())
    data.append(tmp)    

data.sort(key=lambda x:x[0])

ans=0
j=2*n-1
while(data[j][2]==0):
    j-=1

ttmp=[]
while(1):
    tmp=[data[j]]
    while(1):
        j-=1
        if(j==-1):
            break
        tmp.append(data[j])
        if(data[j][2]==0):
            break
    while(1):
        j-=1
        if(j<=-1):
            break
        if(data[j][2]==1):
            break
        else:
            tmp.append(data[j])
    ttmp+=tmp
    ttmp.sort(key=lambda x:x[1])
    red=0

    tttmp=[ttmp[i] for i in range(len(ttmp))]
    delnum=0
    for i in range(len(tttmp)):
        if(tttmp[i][2]==0):
            red+=1
            ttmp.pop(i-delnum)
            delnum+=1
        else:
            if(red>=1):
                ans+=1
                red-=1
                ttmp.pop(i-delnum)
                delnum+=1
    if(j<=-1):
        break

print(ans)

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

// merge-sort
// As we define n is the size of list, calculation will take O(nlogn) time.
template<typename T>
void m_sort(vector<T> &list){
    
    if(list.size() <= 1) return; // 終了条件

    int n = list.size();
    
    vector<T> m1,m2;
    for(int i = 0; i < n; ++i){
        if(i%2) m1.push_back(list[i]);
        else m2.push_back(list[i]);
    }
    
    m_sort(m1);
    m_sort(m2);

    for(int i = 0, m1_cnt = 0, m2_cnt = 0; i < n; ++i){
        if(m1_cnt == m1.size()) list[i] = m2[m2_cnt++];
        else if(m2_cnt == m2.size()) list[i] = m1[m1_cnt++];            
        else{
            if(m1[m1_cnt] < m2[m2_cnt]) list[i] = m1[m1_cnt++];
            else list[i] = m2[m2_cnt++];
        }
    }

}

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

    
    vector<int> a(100000);
    rep(i,100000) a[i] = 100000-i;
    m_sort(a);

    int r; cin >> r;
    cout << r*r << endl;

}

Measured memory_bytes: 4332
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Thu Jan 10 22:07:30 2019
//
package main

import "fmt"

type graph [][]int

func dfs(from int, to int, g graph, n int) bool {
	if n == 0 {
		for i := range g[from] {
			if g[from][i] == to {
				return true
			}
		}
		return false
	}

	for i := range g[from] {
		if dfs(g[from][i], to, g, n-1) {
			return true
		}
	}
	return false
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	g := make(graph, N+1)
	for i := 0; i < M; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	if dfs(1, N, g, 1) {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


Measured memory_bytes: 17792
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	string s; cin >> s;
	map<char, int> freq;
	for (auto i : s) freq[i]++;

	bool flg = (freq.size() == 2);

	int st = 0;
	for (auto i : freq) {
		if (st == 0) st = i.ss;
		else {
			flg = flg and (st == i.ss);
		}
	}

	cout << ((flg) ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 3020
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int Q = sc.nextInt();
    for (int i = 0; i < Q; i++) {
      long A = sc.nextInt();
      long B = sc.nextInt();
      long C = (long) (Math.sqrt(A * B) - 1e-5);
      long ans = 0;
      if (C * (C + 1) < A * B) {
        ans += C - (A <= C ? 1 : 0);
        ans += C - (B <= C ? 1 : 0);
      } else {
        ans += C - 1 - (A < C ? 1 : 0);
        ans += C - 1 - (B < C ? 1 : 0);
        if (A != C && B != C) ++ans;
      }
      System.out.println(ans);
    }
  }

}


Measured memory_bytes: 22228
#include <iostream>

using namespace std;

/** Problem0071 : Bombs Chain **/
char field[8][8];

void exprosion(int x, int y)
{
	field[x][y] = '0';

	for (int i=1; i<4; i++) {
		if (0<=x-i && field[x-i][y]=='1')	exprosion(x-i, y);
		if (x+i<8 && field[x+i][y]=='1')	exprosion(x+i, y);
		if (0<=y-i && field[x][y-i]=='1')	exprosion(x, y-i);
		if (y+i<8 && field[x][y+i]=='1')	exprosion(x, y+i);
	}
}

int main()
{
	int n, x, y;
	
	cin >> n;
	for (int i=0; i<n; i++) {
		for (int i=0; i<8; i++)
			for (int j=0; j<8; j++)
				cin >> field[i][j];
		cin >> x >> y;
	
		exprosion(y-1, x-1);
		
		cout << "Data " << i+1 << ":" << endl;
		for (int i=0; i<8; i++) {
			for (int j=0; j<8; j++)
				cout << field[i][j];
			cout << endl;
		}
	}
}

Measured memory_bytes: 1160
function main(input) {
  var sp = input.split("\n");
  var spLength = sp.length;
  var NQ = sp[0].split(" ");
  var N = Number(NQ[0]);
  // var NLengthHalf = N / 2;
  var Q = NQ[1];
  var S = sp[1];

  // NまでのACの配列
  var arr = [0, 0];
  for(i=2; i<=N; i++){
    if(S.charAt(i-2) === "A" && S.charAt(i-1) === "C"){
      arr.push(arr[i-1]+1);
    }else{
      arr.push(arr[i-1]);
    }
  }

  for(j=0; j<Q; j++){
    var lr = sp[j+2].split(" ");
    var l = lr[0];
    var r = lr[1];

    console.log(arr[r]-arr[l]);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
// main("8 3\n"
// +"ACACTACG\n"
// +"3 7\n"
// +"2 3\n"
// +"1 8\n")


Measured memory_bytes: 35468
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	static int[] a1 = {1,3,5,7,8,10,12};
	static int[] a2 = {4,6,9,11};
	static int[] a3 = {2};
	
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] strs = br.readLine().split(" ");
		int x = Integer.parseInt(strs[0]);
		int y = Integer.parseInt(strs[1]);
		
		if(search(x) == search(y)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
	}
	
	public static int search(int x){
		for(int a : a1){
			if(a == x){
				return 1;
			}
		}
		for(int a : a2){
			if(a == x){
				return 2;
			}
		}
		for(int a : a3){
			if(a == x){
				return 3;
			}
		}
		
		
		return -1;
	}
}


Measured memory_bytes: 21076
#include<iostream>
using namespace std;
int main(){
  char b;
  cin>>b;
  if(b=='A'){cout<<'T'<<endl;}
  else if(b=='T'){cout<<'A'<<endl;}
  else if(b=='C'){cout<<'G'<<endl;}
  else if(b=='G'){cout<<'C'<<endl;}
  return 0;
}

Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    if i == 0:
        ans += B[i]
    elif i == N-1:
        ans += B[i-1]
    else:
        ans += min(B[i], B[i-1])
print(ans)


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

 using namespace std;

  char S[12];
  char NS[12];
  int main(){
   scanf("%s",S);
   int len = strlen(S);
   int in = 0 ;
   for(int i=0;i<len;i++){
    if(S[i]=='B'){
        if(in!=0)in--;
    }
    else{
        NS[in++] = S[i];
    }
   }
   for(int i=0;i<in;i++){
    printf("%c",NS[i]);
   }
  }



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
string S; 

int dp[100010][13];
int calc(int x, int n) {
    //cout << x << " " << n << endl;
    n %= 13;
    if (x >= S.length()) {
        if(n == 5) return 1;
        else return 0;
    }
    if (dp[x][n] != -1) return dp[x][n];
    if (S[x] != '?') {
        return dp[x][n] = calc(x + 1, n * 10 + S[x] - '0');
    }
    int sum = 0;
    rep(i, 10) {
        sum += calc(x + 1, n * 10 + i);
        sum %= mod;
    }
    return dp[x][n] = sum;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> S;
    rep(i, 100010) rep(j, 13) dp[i][j] = -1;
    cout << calc(0, 0) << endl;


    return 0;
}


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

#define MOD 1000000007
typedef long int ll;

#define rep(i, n) for(i=0;i<(int)(n);i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define bit(n) (1LL<<(n))
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(void){
  ll h,w;
  ll result;
  
  scanf("%ld %ld", &h,&w);
  
  if(h==1||w==1) printf("1");
  else{
    result = ceil(h/2.0)*ceil(w/2.0)+floor(h/2.0)*floor(w/2.0);
    printf("%ld", result);
  }
  
  return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T = int > T in() {
  T x;
  cin >> x;
  return (x);
}
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
  int from, to, cost;
};
vec< vec< int > > Graph;
vec< vec< int > > rGraph;
vec< edge > E;
void dfs1(int id, vec< bool > &flgV, vec< vec< int > > &G) {
  flgV[id] = true;
  FORA(e, G[id]) {
    if (!flgV[e]) {
      dfs1(e, flgV, G);
    }
  }
  return;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M, P;
  cin >> N >> M >> P;
  Graph.resize(N, vec< int >());
  rGraph.resize(N, vec< int >());
  E.resize(M);
  REP(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    E[i].from = a;
    E[i].to = b;
    E[i].cost = c - P;
    Graph[a].pb(b);
    rGraph[b].pb(a);
  }
  vec< bool > flgA(N, false);
  vec< bool > flgB(N, false);
  vec< bool > flgV(N, false);
  vec< bool > flgE(M, false);
  dfs1(N - 1, flgA, rGraph);
  dfs1(0, flgB, Graph);
  int count = 0;
  REP(i, N) {
    flgV[i] = flgA[i] && flgB[i];
    if (flgV[i])
      count++;
    //  DEBUG(flgV[i]);
  }
  int index = 0;
  FORA(e, E) {
    if (flgV[e.from] && flgV[e.to]) {
      flgE[index] = true;
    }
    index++;
  }
  vec< int > d(N, -INF);
  d[0] = 0;
  int tmp = 0;
  REP(i, N) {
    if (!flgV[i])
      continue;
    tmp++;
    REP(j, M) {
      if (!flgE[j])
        continue;
      struct edge eleE = E[j];
      if (d[eleE.to] < d[eleE.from] + eleE.cost) {
        //  cout << eleE.from << " " << eleE.to << " "
        //      << "\n";
        d[eleE.to] = d[eleE.from] + eleE.cost;
        if (tmp == count) {
          cout << -1 << "\n";
          return 0;
        }
      }
    }
  }
  print(max(0ll, d[N - 1]));
  //  print
}

Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(void){
    int x1,x2;
    cin>>x1>>x2;
    if(x1<x2){
        cout<<x2-x1<<endl;
    }
    if(x2<x1){
        cout<<x1-x2<<endl;
    }
    if(x2==x1){
        cout<<x1-x2<<endl;
    }
}


Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll N ; cin >> N;
  N--;
  vector<ll> C,S,F;
  
  rep(i,N){
    ll c,s,f; cin >> c >> s >> f;
    C.pb(c) ; S.pb(s); F.pb(f);
  }

  vector<ll> ret;
  for(ll i = 0; i< N; i++){//スタートの時点でiにいる
    ll ans = S[i];
    for(ll j = i; j<N;j++){//現在がjにいる
      //出発時間
      if(ans < S[j]) ans = S[j];
      else{
	ll a = ans-S[j];
	a /= F[j];
	if((ans-S[j])%F[j]!=0) a++;
	ans = (a*F[j]+S[j]);
      }

      //到着時間
      ans += C[j];
    }
    ret.pb(ans);
  }


  for(ll i = 0 ; i < ret.size(); i++)
    cout << ret[i] << endl;
  cout << 0 << endl;

  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

signed main() {
	int a, c; char b;
	while (1) {
		cin >> a >> b >> c;
		switch (b) {
		case '+':cout << a + c << endl; break;
		case '-':cout << a - c << endl; break;
		case '*':cout << a * c << endl; break;
		case '/':cout << a / c << endl; break;
		case '?': goto l;
		}
	}
l:;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int one_yen, sum;
  
  cin >> sum >> one_yen;
  
  if (sum % 500 <= one_yen){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=1;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()

int main() {
  ld n,k;
  cin>>n>>k;
  ld ans=0;
 rep(i,n+1){
   if(i>=k) ans+=1/n;
    rep(j,k/i+1){
    if(i<k&&i*pow(2,j)>=k&&i*pow(2,j)<2*k){
        ans+=pow(0.5,j)/n;
      }
    }
 }
  cout<<fixed<<setprecision(11)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 384
import java.io.*;
import java.math.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null){
double n=Double.parseDouble(line);
double sum=n;
for(int i=0;i<9;i++){
if(i%2==0){
n*=2;
}
else{
n/=3;
}
sum+=n;
}
BigDecimal x=BigDecimal.valueOf(sum);
x=x.setScale(8,BigDecimal.ROUND_HALF_UP);
System.out.println(x);
}
}
}

Measured memory_bytes: 16952
import java.util.*;

public class Main {
    static int n;
    static int[] dp;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            if (map.containsKey(num)) {
                if (map.get(num) == 0) {
                    map.put(num, 1);
                } else {
                    map.put(num, 0);
                }
            } else {
                map.put(num, 1);
            }
        }
        int ans = 0;
        for(Integer i : map.keySet()) {
            if (map.get(i) == 1) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 62524
n,m=map(int,input().split())
a=list(map(int,input().split()))
unta=sum(a)

dsrxq=0
for i in range(n):
  if a[i]*4*m>=unta:
    dsrxq+=1
if dsrxq>=m:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
a=[]
n=int(input())
for tt in range(n):
    j=int(input())
    a.append(j)
a.sort()
print(int(sum(a)-(a[-1]/2)))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

inline void dbg_x(int);
inline void dbg_v(int[], int);
inline void dbg_vstl(vector<int>v);
inline void dash();

int main() {
    long long x, ax = 0, ay = 0, bx = 1000000000LL, by, cx = 1LL, cy;
    cin >> x;
    cy = x / bx;
    cy += 1 - (x % bx == 0);
    by = cy * bx - x;

    cout << ax << ' ' << ay << ' ' << bx << ' ' << by << ' ' << cx << ' ' << cy;
    //cerr << (ax * by + bx * cy + cx * ay - ax * cy - bx * ay - cx * by) / 2 << '\n';
    return 0;
}

inline void dbg_x(int x) {
    dash();
    cerr << x;
    dash();
}
inline void dbg_v(int v[], int n) {
    dash();
    cerr << n << '\n';
    for (int i = 0; i < n; ++i) {
        cerr << v[i] << ' ';
    }
    dash();
}
inline void dash() {
    cerr << "\n\n";
    for (int i = 0; i < 100; ++i) {
        cerr << '-';
    }
    cerr << "\n\n";
}

inline void dbg_vstl(vector<int>v) {
    dash();
    for (auto it : v)
        cerr << it << ' ';
    dash();

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
using namespace std;
int main(){
	int n;
	cin>>n;
	map<string, int>mp;
	for(int i=0; i<n; i++){
		 string s;
		 cin>>s;
		 mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<"\n";
	cout<<"WA x "<<mp["WA"]<<"\n";
	cout<<"TLE x "<<mp["TLE"]<<"\n";
	cout<<"RE x "<<mp["RE"]<<"\n";
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstring>

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)

using namespace std;

const int MAX_N = 10*10*10*10*10+10;
const int MAX_HAPPY = 10*10*10*10+10;

int dp[3][MAX_N];

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

    int a[n], b[n], c[n];
    rep(i, n) {
        cin >> a[i] >> b[i] >> c[i];
    }
    memset(dp, -1, sizeof(dp));
    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];

    rep1(i, n) {
        // a
        dp[0][i] = max(dp[0][i], a[i] + dp[1][i-1]);
        dp[0][i] = max(dp[0][i], a[i] + dp[2][i-1]);
        // b
        dp[1][i] = max(dp[1][i], b[i] + dp[0][i-1]);
        dp[1][i] = max(dp[1][i], b[i] + dp[2][i-1]);
        // c
        dp[2][i] = max(dp[2][i], c[i] + dp[0][i-1]);
        dp[2][i] = max(dp[2][i], c[i] + dp[1][i-1]);
    }

    int _max = -1;
    rep(i, 3) {
        _max = max(_max, dp[i][n-1]);
    }

    cout << _max << endl;
}

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

public class Problem_B
{
  public static void Main()
  {
    var inputs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    var K = int.Parse(Console.ReadLine());
    int A = inputs[0], B = inputs[1], C = inputs[2];
    var max = Math.Max(A, Math.Max(B, C));
    var n = max;
    for (var i = 0; i < K; i++) n *= 2;
    Console.WriteLine($"{inputs.Sum() - max + n}");
  }
}


Measured memory_bytes: 11220
(D,),C,*I=[[*map(int,t.split())]for t in open(0)]
s=sum(C)
for d,q in I[D-~D:]:
 I[d-1+D][0]=q;i,R,P,*L=[0]*29
 while i-D:t=I[i+D][0]-1;P+=s+(~i+L[t])*C[t];R+=I[i][t]-P;i+=1;L[t]=i
 print(R)

Measured memory_bytes: 88716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define opt ios_base::sync_with_stdio(false); cin.tie(NULL);

void freak__()
{
    int n,l,i;
    string s;
    vector<string> v;
    cin >> n >> l;
    while(n--)
    {
        cin >> s;
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++) cout << v[i];
    cout << "\n";
}

int main()
{
    opt;
    freak__();
    return 0;
}

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

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}


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

    double res = R*2*3.141592653589;
    printf("%.8f\n", res);
    return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    char a;
    cin >> a;
    if(a >= 'a' && a <= 'z')cout << "a" << endl;
    else cout << "A" << endl;
    return 0;
}

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

int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    ll ans = 1e+9;
    if ( A%2==0 || B%2==0 || C%2==0 )ans = 0;
    else{
        ans = min(min((A/2+1)*B*C-B*C*(A/2),(B/2+1)*A*C-A*C*(B/2)),(C/2+1)*A*B-A*B*(C/2));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        string A, B, C;
        cin >> A >> B >> C;

        if (A.back() == B.front() && B.back() == C.front())
        {
                cout << "YES" << endl;
        }
        else
        {
                cout << "NO" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#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)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,m,ans = 0;
    cin >> n >> m;
    int k,a,c[m];
    rep(i, m)c[i] = 0;
    rep(i, n){
        cin >> k;
        rep(j, k){
            cin >> a;
            ++c[a - 1];
        }
    }
    rep(i, m){
        if (c[i] == n) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
  
  int n;
  cin >> n;
  long long ans=(LLONG_MAX	);
  long long a[200000];
  long long total[200001];
  total[0]=0;
  long long sum=0;
  for (int i = 0; i < n; i++) {
    cin >>a[i];
    sum+=a[i];
    total[i+1]=sum;
  }
  //cout << sum << endl;
  for(int i=0;i<n-1;i++){
      // cout << (total[i+1]) << endl;
    ans=min(ans,abs(total[i+1]-(sum-(total[i+1]))));
 }
  
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include<stdio.h>

int main(){
  int N ;
  scanf("%d", &N);
  int i,j,m;
  int count=0;
  for(i=1;i<=N;i += 2){
    m = 0;
   
      for(j=1;j<=N; j++){
       if(i%j == 0){
        m++;
       }
      }
       if(m == 8){
        count++; 
       }
  }
  printf("%d",count);
  return 0;  
}


Measured memory_bytes: 128
import java.io.PrintWriter;
import java.util.*;

public class Main {
    PrintWriter out = new PrintWriter(System.out);
    final long mod = 1000000000+7;
    int maxn;
    long[] frac;
    long[] inv;
    public static void main(String[] args) {
        Main main = new Main();
        System.out.println(main.solve());
    }
    // segment tree to record minimum value
    // Each point has a infinite distance from 0 (except itself)
    long solve() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt(), Y = sc.nextInt();
        if((X+Y)%3!=0) return 0;
        // suppose in the x-direction, a moves of +1 and b moves of +2
        // then in the y-direction, a*(+2) and b*(+1)
        // a+2*b = X, 2*a+b = Y
        int a3 = 2*Y-X, b3 = 2*X-Y;
        if(a3<0||a3%3!=0||b3<0||b3%3!=0) return 0;
        int a = a3/3, b = b3/3;
        this.maxn = Math.max(X,Y)+10;
        ini();
        long ans = frac[a+b]*inv[a]%mod*inv[b]%mod;
        return ans;
    }
    void ini(){
        frac = new long[maxn+1];
        frac[0] = 1;
        for(int i=1;i<=maxn;i++) frac[i] = i*frac[i-1]%mod;
        inv = new long[maxn+1];
        inv[0] = 1;
        inv[maxn] = power(frac[maxn], mod-2);
        for(int i=maxn-1;i>0;i--){
            inv[i] = (i+1)*inv[i+1]%mod;
        }
    }
    long power(long base, long q){
        long ans = 1;
        while(q>0){
            if(q%2==1) ans = ans*base%mod;
            base = base*base%mod;
            q /= 2;
        }
        return ans;
    }
}



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

int main() {
	int X;
	cin >> X;
	cout << (X == 3 || X == 5 || X == 7 ? "YES" : "NO");
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

やるだけ
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define Q int tt,qq; cin>>tt ;for(qq=1;qq<=tt;qq++)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main()
{
    int n;
    cin>>n;
    vector<ll>v(n+1),u(n);
    for(auto &it:v)    cin>>it;
    for(auto &it:u)    cin>>it;
    ll ans=0;
    for(int i=0;i<n;i++){
       if(v[i]>u[i]){
         ans+=u[i];
         u[i]=0;
       }
       else{
         ans+=v[i];
         u[i]-=v[i];
       }
       if(u[i]>0){
         if(v[i+1]>u[i]){
            ans+=u[i];
            v[i+1]-=u[i];
         }
         else{
            ans+=v[i+1];
            v[i+1]=0;
         }
       }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4824
#include <iostream>

using namespace std;


int linerSearch( const int *S, const int n,  int key ) {
    for ( int i = 0; i < n; ++i ) {
        if ( S[i] == key ) {
            return 1;
        }
    }
    return 0;
}

int binarySearch( const int *S, int L, int R, int key ) {
    int mid = (L + R) / 2;

    if (L >= R) {
        if(S[L] == key )  return 1;
        else return 0;
    }
    else {
        if ( key == S[mid] ) return 1;
        else if ( key > S[mid] ) {
            return binarySearch(S,mid+1,R,key);
        }
        else {
             return binarySearch(S,L,mid,key);
        }
    }

}

int main() {
    int n;
    int q;

    int S[100000];
    int T[50000];

    int cnt = 0;

    cin >> n;
    for ( int i = 0; i < n; ++i ) {
        cin >> S[i];
    }

    cin >> q;
    for ( int i = 0; i < q; ++i ) {
        cin >> T[i];
    }

    for ( int i = 0; i < q; ++i ) {
        cnt += binarySearch(S,0,n,T[i]);
    }

    cout << cnt << endl;
    return 0;

}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

template<typename T>
void cmpmax(T* reference, T value) {
	*reference = max(*reference, value);
}

template<typename T>
void cmpmin(T* reference, T value) {
	*reference = min(*reference, value);
}

const ll mod = 1000000007;

static const ll INF = 1e15;

class Primes {
private:
	vector<int> Prime_Number;
	vector<bool> is_prime_;
public:
	Primes(int N) {
		is_prime_.resize(N + 1, true);
		is_prime_[0] = is_prime_[1] = false;
		for (int i = 0; i < N + 1; i++) {
			if (is_prime_[i]) {
				Prime_Number.push_back(i);
				for (int j = 2 * i; j <= N; j += i) is_prime_[j] = false;
			}
		}
	}
	int operator[](int i) { return Prime_Number[i]; }
	int size() { return Prime_Number.size(); }
	int back() { return Prime_Number.back(); }
	bool isPrime(int q) { return is_prime_[q]; }
};

class Divisor {
private:
	vector<ll> F;
	vector<pair<ll, ll>> pfactorize;
public:
	Divisor(ll N) {
		for (ll i = 1; i * i <= N; i++) {
			if (N % i == 0) {
				F.push_back(i);
				if (i * i != N) F.push_back(N / i);
			}
		}
		sort(begin(F), end(F));
		Primes p((ll)sqrt(N) + 1);
		for (int i = 0; i < p.size(); i++) {
			pfactorize.emplace_back(p[i], 0);
			while (N % p[i] == 0) {
				N /= p[i];
				pfactorize.back().second++;
			}
			if (pfactorize.back().second == 0) pfactorize.pop_back();
		}
		if (N > 1) pfactorize.emplace_back(N, 1);
	}
	int size() { return F.size(); }
	const vector<pair<ll, ll>>& pfac() { return pfactorize; } const
		ll operator[](int k) { return F[k]; }
};

ll n;
vector<P> es;

P Take(int index) {
	ll enter = 0;
	ll leave = 0;
	ll start = 0;
	for (auto e : es) {
		if (!e.second) {
			enter++;
			if (index == enter) {
				start = e.first;
			}
		}
		else {
			leave++;
			if (leave >= index) {
				//cout << index << " " << start << " " << e.first << endl;
				return { start, e.first };
			}
		}
	}
}

int main() {
	cin >> n;
	rep(i, n) {
		ll a, b;
		cin >> a >> b;
		es.emplace_back(a,0);
		es.emplace_back(b,1);
	}
	sort(es.begin(), es.end());
	if (n % 2 == 1) {
		auto r = Take((n + 1) / 2);
		cout << r.second - r.first + 1 << endl;
	}
	else {
		auto r1 = Take((n + 1) / 2);
		auto r2 = Take((n + 1) / 2 + 1);
		auto low = r1.first + r2.first;
		auto high = r1.second + r2.second;
		cout << high - low + 1 << endl;
	}
	return 0;
}
	


Measured memory_bytes: 11632
#include <string>
#include <algorithm>
#include <iostream>

using namespace std;
int main(){
    int N;
    string S;
    cin>>N;
    cin>>S;
    int ans=0;

    for(int i=0; i<N; i++){
        int cnt=0;
        for(char c='a'; c<='z'; c++){
            bool left=false,right=false;
            for(int j=0; j<i; j++){
                if(S[j]==c) left=true;
            }
            for(int j=i; j<N; j++){
                if(S[j]==c) right=true;
            }
            if(left&&right) cnt++;

        }
        if(cnt>ans) ans=cnt;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        S: chars,
    }
    let mut cnt = 0;
    for i in 1..S.len() {
        if S[i-1] != S[i] {
            cnt += 1;
        }
    }

    println!("{}", cnt);
}


Measured memory_bytes: 4352
//#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>

using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

const int MAXN = 8;

int n, answer = 0, v[1 + MAXN];
bool edge[1 + MAXN][1 + MAXN], seen[1 + MAXN];

void Backtracking(int x) {
    if (x == n + 1) {
        answer++;
        return;
    }
    for (int i = 1; i <= n; i++)
        if (!seen[i] && edge[v[x - 1]][i]) {
            v[x] = i;
            seen[i] = true;
            Backtracking(x + 1);
            seen[i] = false;
        }
}

int main() {
    int m;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int a, b;
        cin >> a >> b;
        edge[a][b] = edge[b][a] = true;
    }
    v[1] = 1;
    seen[1] = 1;
    Backtracking(2);
    cout << answer << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

ll a[100001],sum[100001];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    rep(i,n){
        sum[i]=a[i]*2+(i>0?sum[i-1]:0);
    }
    int ans=0;
    rep(i,n-1){
        if(a[i+1]>sum[i]) ans=i+1;
    }
    cout<<n-ans<<endl;
    return 0;
}

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

int main()
{

	int a, b, c;
	int mid;
	cin >> a >> b >> c;

	if (a >= b)
	{
		mid = a;
		a = b;
		b = mid;
	}

	if (b >= c)
	{
		mid = b;
		b = c;
		c = mid;
	}

	if (a >= b)
	{
		mid = a;
		a = b;
		b = mid;
	}

	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 1168
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	vector<ll> ans = { b * d, a * c, a * d, b * c};
	cout << *max_element(All(ans)) << endl;
	return 0;
}

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

shougen = [[]for i in range(0,N+1,1)]
A = [0]*(N+1)
for i in range(1,N+1,1):
    A[i] = int(input())
    for j in range(0,A[i],1):
        shougen[i].append(list(map(int,input().split())))

maxshoujiki =0
for i in range(0,pow(2,N),1):
    is_shoujiki = [0]*(N+1)
    for j in range(0,N,1):
        if((i>>j)&1):
            is_shoujiki[j+1]=1

    isBAD = False
    for j in range(1,N+1,1):
        if is_shoujiki[j] == 1:
            for k in range(0,A[j],1):
                if is_shoujiki[shougen[j][k][0]]!=shougen[j][k][1]:
                    isBAD = True
    if not isBAD:
        maxshoujiki = max(maxshoujiki,sum(is_shoujiki))

print(maxshoujiki)



Measured memory_bytes: 44124
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

count = 0
(0..A).each { |a|
  xa = a * 500
  break if xa > X
  (0..B).each { |b|
    xb = xa + b * 100
    break if xb > X
    (0..C).each { |c|
      x = xb + c*50
      break if x > X
      count += 1 if x == X
    }
  }
}

p count

Measured memory_bytes: 1788
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] cards = new int[N];
		
		for(int i=0; i<cards.length; i++) 
			cards[i] = sc.nextInt();
		
		int work;
		for(int i= 0 ;i< N; i++) 
			for(int k= i;k< N;k++) 
				if(cards[i] < cards[k])
				{
					work = cards[i];
					cards[i] = cards[k];
					cards[k] = work;
				}
		
		int sum=0;
		for(int i=0; i< N ;i++) 
			if(i % 2 ==0) sum+=cards[i];
			else			  sum-=cards[i];
		
		System.out.println(sum);
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

void isStable(vector<string>& a,vector<string>& b){
    int n=a.size();
    F(i,0,n)
        if(a[i][1]==b[i][1] && a[i]!=b[i]){
            cout << "Not stable" << endl;
            return;
        }
    cout << "Stable" << endl;
    return;
}

void bubbleSort(vector<string>& a){
    int n=a.size();
    F(i,0,n){
        for(int j=n-1;j>i;--j){
            if(a[j][1]<a[j-1][1]){
                string t=a[j];
                a[j]=a[j-1];
                a[j-1]=t;
            }
        }
    }
}

void selectionSort(vector<string>& a){
    int n=a.size();
    F(i,0,n){
        int minj=i;
        F(j,i,n){
            if(a[j][1]<a[minj][1]){
                minj=j;
            }
        }
        if(i!=minj){
            string t=a[i];
            a[i]=a[minj];
            a[minj]=t;
        }
    }
}

void print(vector<string>& a){
    int n=a.size();
    F(i,0,n){
        cout << a[i];
        if(i!=n-1) cout << ' ';
    }
    cout << endl;
}

int main()
{
    int n;
    cin >> n;
    vector<string> a(n);
    F(i,0,n) cin >> a[i];
    vector<string> b(a);

    bubbleSort(a);
    print(a);
    cout << "Stable" << endl;
    selectionSort(b);
    print(b);
    isStable(a,b);

    return 0;
}


Measured memory_bytes: 3216
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        ab: [(i64, i64); n],
    }
    let mut res = -ab.iter().map(|(_, b)| b).sum::<i64>();
    for (i, c) in ab.iter().map(|(a, b)| -(a + b)).sorted().enumerate() {
        // println!("{}", c);
        if i % 2 == 0 {
            res -= c;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 6804