akhauriyash/Code-Regression huggingface dataset:
/*
    Ujjawal Pabreja
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
using ll = long long;
using ld = long double;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define rev             reverse
#define Y				"YES"
#define N 				"NO"
#define nl              "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

// ====== int_1024t begins ======
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// ====== int_1024t ends ======

// ====== pbds begins ======
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, 
//         tree_order_statistics_node_update> 
//         pbds; 
// ====== pbds ends ======

// ====== Useful functions begin ======
inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}
ll pwr(ll x,ll n){
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
ll modinv(ll n){ 
    return pwr(n,mod - 2); 
}
// ====== Useful functions end ======
 
// ====== Variables begin ======

// ====== Variables end ======
void speed_solve(){
    ll n;
    cin >> n;
    ll ans = 0;
    repe(i,1,n + 1){
        repe(j,1,n + 1){
            repe(k,1,n + 1){
                ans += gcd(i,gcd(j,k));
            }
        }
    }
    cout << ans;
}
int main()
{
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
struct node {
	vector<int> child;
	vector<int> parent;
	int flag;
	int indeg;
};
int main() {
	int N, M;
	cin >> N >> M;
	node*T = new node[N];
	int A, B;
	for (int i = 0; i < N - 1 + M; i++) {
		cin >> A >> B;
		T[A-1].child.push_back(B-1);
		T[B-1].parent.push_back(A-1);
	}
	for (int i = 0; i < N; i++) {
		T[i].flag = 0;
		T[i].indeg = T[i].parent.size();
	}
	vector<int>ts;
	queue<int>q;
	for (int i = 0; i < N ; i++) {
		if (T[i].indeg == 0 && T[i].flag == 0) {
			q.push(i);
			T[i].flag = 1;
			while (!q.empty()) {
				int now = q.front();
				q.pop();
				ts.push_back(now);
				for (int tmp : T[now].child) {
					T[tmp].indeg--;
					if (T[tmp].indeg == 0 && T[tmp].flag == 0) {
						q.push(tmp);
						T[tmp].flag = 1;
					}
				}
			}
		}
	}
	vector<int>out(N);
	for (int i = 0; i < N; i++) {
		out[ts[i]] = i+1;
	}
	for (int i = 0; i < N; i++) {
		if (T[i].parent.size() == 0) {
			cout << 0 << endl;
			continue;
		}
		int ans = 0;
		int max = 0;
		for (int tmp : T[i].parent) {
			if (max < out[tmp]) {
				max = out[tmp];
				ans = tmp;
			}
		}
		cout << ans+1 << endl;
	}
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007
// #define harmonic(n) 0.57721566490153286l+log(n)

#define mem(a,b) memset( a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

inline bool checkBit(ll n, int i) { return n & (1LL << i); }
inline ll setBit(ll n, int i) { return n | (1LL << i); }
inline ll resetBit(ll n, int i) { return n & (~(1LL << i)); }

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

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }



int main() {
    optimize();
    int n, m;
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
N,K = gets.split.map &:to_i
P = 10**9+7
S = (0..N).to_a
A = S.map{0}
A[0]=A[N+1] = 1
i=l=r = 0
while i < N-i
  l += S[i]
  r += S[N-i]
  i += 1
  A[i] = A[N-i+1] = r-l+1
  break if K > N-i
end
p A[K..-1].inject {|s,i| (P < s+=i) ? s%=P : s}

Measured memory_bytes: 18292
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    ll a[1010],b[1010],c[1010];
    for(int i=0;i<x;i++) cin>>a[i];
    for(int i=0;i<y;i++) cin>>b[i];
    for(int i=0;i<z;i++) cin>>c[i];
    sort(a,a+x,greater<>());
    sort(b,b+y,greater<>());
    sort(c,c+z,greater<>());
    ll d[1000010];
    int s=0;
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            d[s]=a[i]+b[j];
            s++;
        }
    }
    sort(d,d+x*y,greater<>());
    ll ans[3000010];
    s=0;
    for(int i=0;i<k;i++){
        for(int j=0;j<z;j++){
            ans[s]=d[i]+c[j];
            s++;
        }
    }
    sort(ans,ans+k*z,greater<>());
    for(int i=0;i<k;i++) cout<<ans[i]<<endl;
}

Measured memory_bytes: 31616
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn main() {
    let n = read::<usize>();
    let v = read_vec::<usize>();
    let d = v[0];
    let mut ans = n + v[1];
    for i in 0..n {
        let a = read::<usize>();
        ans += (d-1)/a;
    }
    println!("{}",ans);
}


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

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

    long long n, a, b;
    cin >> n >> a >> b;

    long long ans;
    long long t = n / (a + b);
    long long k = n % (a + b);

    long long aans = t * a;
    if(a <= k) aans += a;
    else aans += k;

    cout << aans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
using ll = long long;

int A, B, C, X, Y;

int main() {
  scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);

  ll sum = 0;

  // AピザとBピザを1枚ずつ買う場合とABピザを2枚買う場合にどちらが高いかを調べる
  if (A + B <= 2 * C) {
    sum = A * X + B * Y;
  }
  else {
    // 出来る限りABピザを買う
    if (X < Y) {
      sum = 2 * C * X + B * (Y - X);
      if (sum > 2 * C * Y) sum = 2 * C * Y;
    }
    else {
      sum = 2 * C * Y + A * (X - Y);
      if (sum > 2 * C * X) sum = 2 * C * X;
    }
  }

  printf("%lld\n", sum);
  return 0;
}

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

int main(){
  ll a,b,c,x,y,d=1000000001,e=0,f=0;
  cin>>a>>b>>c>>x>>y;
  if(a+b<=2*c) cout<<(x*a+y*b);
  else{
    if(x<=y){
      for(int i=x;i<=y;i++){
        d=min(d,2*i*c+(y-i)*b);
      }
      cout<<d;
    }
    else{
      for(int i=y;i<=x;i++){
        d=min(d,2*i*c+(x-i)*a);
      }
      cout<<d;
    }
  }
}

Measured memory_bytes: 256
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Map<String, Long> voteMap = new HashMap<>();
        long N = Long.parseLong(sc.nextLine());
        long maxCount = 0L;
        for (long i = 0; i < N; i++) {
            String voteName = sc.nextLine();
            Long count = voteMap.get(voteName);
            if (Objects.isNull(count)) {
                voteMap.put(voteName, 1L);
            } else {
                long newCount = count + 1;
                if (newCount > maxCount) {
                    maxCount = newCount;
                }
                voteMap.put(voteName, newCount);
            }
        }
        sc.close();
        List<String> maxNames = new ArrayList<>();
        for (String name : voteMap.keySet()) {
            long count = voteMap.get(name);
            if (count == maxCount || maxCount == 0) {
                maxNames.add(name);
            }
        }
        Collections.sort(maxNames);
        for (String name : maxNames) {
            System.out.println(name);
        }
    }

}


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

int main() {

  int N;
  cin >> N;

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

  X2 = X;

  sort(X.begin(), X.end());

  // 中央値
  int center = X[N / 2 - 1];
  
  int answer1 = X[N / 2];
  int answer2 = center;

  for (int i = 0; i < N; i++) {
    if (X2[i] <= center) {
      // 中央値以下場合は中央値より1つ大きいものが回答
      cout << answer1 << endl;
    } else {
      // 中央値を超える場合は中央値が回答
      cout << answer2 << endl;
    }
  }

  return 0;

}

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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	
	int N;
	cin >> N;
	map<string, int> mp;
	mp["AC"] = 0;
	mp["WA"] = 0;
	mp["TLE"] = 0;
	mp["RE"] = 0;
	rep(i,N){
		string s;
		cin >> s;
		mp[s]++;
	}

	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;

}

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

Measured memory_bytes: 3656
N = int(input())
A = list(map(int, input().split()))
N = len(A) // 3
A = A[:3*N]
#print(N, A)
A.append(0)
A.append(0)

ans = 0
def ind(a, b):
  t = sorted((a, b))
  return t[0] * (N+1) + t[1]
def inv(i):
  b = i % (N+1)
  a = i // (N + 1)
  return a, b

dp = [-1] * (N+1)**2
dp[ind(A[0],A[1])] = 0
current_max = 0
dp1 = [-1] * (N+1)
dp1[A[0]] = 0
dp1[A[1]] = 0

ans = 0
for i in range(0, N):
  a = A[2+3*i] 
  b = A[2+3*i+1]
  c = A[2+3*i+2]
  #print(a,b,c)
  if a == b == c:
    ans+=1
    continue
  dp_new = {}
  for x, y, z in [(a, b, c), (b, c, a), (c, a, b)]:
    # choose 1 (x), leave y, z
    i = ind(y, z)
    if i not in dp_new:
      dp_new[i] = 0
    dp_new[i] = max(dp_new[i], current_max)
    if dp[ind(x, x)] >= 0:
      dp_new[i] = max(dp_new[i], dp[ind(x, x)] + 1)
    
    # choose 2 (x, y), leave t, z
    for t in range(1, N+1):
      i = ind(t,z)
      # Not making three
      if dp1[t] >= 0:
        if i not in dp_new:
          dp_new[i]=0
        dp_new[i] = max(dp_new[i], dp1[t])
      # Making three (x==y)
      if x == y and dp[ind(t, x)] >= 0:
        if i not in dp_new:
          dp_new[i] = 0
        dp_new[i] = max(dp_new[i], dp[ind(t, x)] + 1)
        
  #print(a,b,c)
  #print({inv(i):v for i, v in dp_new.items() })
  for i, s in dp_new.items():
    dp[i] = max(dp[i], s)
    ta, tb = inv(i)
    dp1[ta] = max(dp1[ta], s)
    dp1[tb] = max(dp1[tb], s)
    current_max = max(current_max, s)

#print(doubles)
print(ans + max(dp1))
    
    
        

Measured memory_bytes: 179984
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(v1, v2)     cout << v1 << " " << v2 << endl
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

//----------------------------------------------------------------

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

  if(n%2==1){
    prt(0); return 0;
  }

  ll ans=0;
  ll div=10;
  while(n>=div){
    ans+=n/div;
    div*=5;
  }

  prt(ans);
}


Measured memory_bytes: 256
#coding: utf-8;

data = input()
#\nは？

K = 0
count = 0
prev = ""
now = ""
i = 0

if len(data)==1:
  print("1")
  exit()

while True:
  if count==len(data):
    if len(now)==0:
      break
    if now!=prev:
      K+=1
      break
    #こっからが問題
    break

  now += data[count]
  count += 1
  if now != prev:
    prev = now
    now = ""
    K += 1

print(K)

Measured memory_bytes: 3500
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	private static final String SHARP = "#";
	private static final String DOT = ".";

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[] sH = new String[H];
		String[][] s = new String[H + 2][W + 2];
		boolean can = true;

		for (int i = 0; i < H + 1; i++) {
			Arrays.fill(s[i], DOT);
		}

		for (int i = 0; i < H; i++) {
			sH[i] = sc.next();
		}

		for (int i = 1; i < H + 1; i++) {
			for (int j = 1; j < W + 1; j++) {
				s[i][j] = sH[i - 1].split("")[j - 1];
			}
		}

		for (int i = 1; i < H + 1; i++) {
			for (int j = 1; j < W + 1; j++) {
				if (SHARP.equals(s[i][j])) {
					if (DOT.equals(s[i - 1][j]) &&
						DOT.equals(s[i + 1][j]) &&
						DOT.equals(s[i][j - 1]) &&
						DOT.equals(s[i][j + 1])) {
						can = false;
					}
				}
			}
		}
		if (can) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

int GCD(int n1, int n2)
{
    if (n2 != 0)
       return GCD(n2, n1 % n2);
    else 
       return n1;
}

int main()
{
	int K,a=1,b=1,c=1;
  long long int sum;
  	cin>>K;
  	while(c<=K)
    {
    	if(!(a==b && b==c))
        {
            //cout<<a<<" "<<b<<" "<<c<<endl;
        	sum=sum+GCD(c,GCD(b,a));
        }
          	a++;
          	if(a>K)
            {
            	a=1;
              	b++;
              	if(b>K)
                {
                	b=1;
                  	c++;
                }
            }
        
    }
  K=K*(K+1);
  
  K=K/2;
  sum=sum+K;
  cout<<sum;
	return 0;	
}

Measured memory_bytes: 3624
//#define _USE_MATH_DEFINES
//#include <math.h>
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    
    char s;
    int a[26] = {0};
    while(cin >> s){
        if(s == 0) break;
        if(s == 65 || s == 97) a[0]++;
        if(s == 66 || s == 98) a[1]++;
        if(s == 67 || s == 99) a[2]++;
        if(s == 68 || s == 100) a[3]++;
        if(s == 69 || s == 101) a[4]++;
        if(s == 70 || s == 102) a[5]++;
        if(s == 71 || s == 103) a[6]++;
        if(s == 72 || s == 104) a[7]++;
        if(s == 73 || s == 105) a[8]++;
        if(s == 74 || s == 106) a[9]++;
        if(s == 75 || s == 107) a[10]++;
        if(s == 76 || s == 108) a[11]++;
        if(s == 77 || s == 109) a[12]++;
        if(s == 78 || s == 110) a[13]++;
        if(s == 79 || s == 111) a[14]++;
        if(s == 80 || s == 112) a[15]++;
        if(s == 81 || s == 113) a[16]++;
        if(s == 82 || s == 114) a[17]++;
        if(s == 83 || s == 115) a[18]++;
        if(s == 84 || s == 116) a[19]++;
        if(s == 85 || s == 117) a[20]++;
        if(s == 86 || s == 118) a[21]++;
        if(s == 87 || s == 119) a[22]++;
        if(s == 88 || s == 120) a[23]++;
        if(s == 89 || s == 121) a[24]++;
        if(s == 90 || s == 122) a[25]++;
    }
    cout << "a" << " : " << a[0] << endl;
    cout << "b" << " : " << a[1] << endl;
    cout << "c" << " : " << a[2] << endl;
    cout << "d" << " : " << a[3] << endl;
    cout << "e" << " : " << a[4] << endl;
    cout << "f" << " : " << a[5] << endl;
    cout << "g" << " : " << a[6] << endl;
    cout << "h" << " : " << a[7] << endl;
    cout << "i" << " : " << a[8] << endl;
    cout << "j" << " : " << a[9] << endl;
    cout << "k" << " : " << a[10] << endl;
    cout << "l" << " : " << a[11] << endl;
    cout << "m" << " : " << a[12] << endl;
    cout << "n" << " : " << a[13] << endl;
    cout << "o" << " : " << a[14] << endl;
    cout << "p" << " : " << a[15] << endl;
    cout << "q" << " : " << a[16] << endl;
    cout << "r" << " : " << a[17] << endl;
    cout << "s" << " : " << a[18] << endl;
    cout << "t" << " : " << a[19] << endl;
    cout << "u" << " : " << a[20] << endl;
    cout << "v" << " : " << a[21] << endl;
    cout << "w" << " : " << a[22] << endl;
    cout << "x" << " : " << a[23] << endl;
    cout << "y" << " : " << a[24] << endl;
    cout << "z" << " : " << a[25] << endl;
}



Measured memory_bytes: 3096
import java.util.*;
import java.io.*;

public class Main{

	private static final int mod =(int)1e9+7;
	public static void main(String[] args) throws Exception  {
	      Scanner  sc=new Scanner(System.in);
	      PrintWriter out=new PrintWriter(System.out);
	      int n=sc.nextInt();
	      int T=sc.nextInt();
	      int interval[]=new int[n];
	      for(int i=0;i<n;i++) {
	        interval[i]=sc.nextInt();
	      }
	     long totaltm=0;
	      for(int i=1;i<n;i++) {
	        if(interval[i]-interval[i-1]>=T) {
	          totaltm+=T;
	        }else {
	          totaltm+=interval[i]-interval[i-1];
	        }
	      }
	      totaltm+=T;
	      System.out.println(totaltm);
	}


	static boolean vis[]=new boolean[10001];
	      static long gcd(long a, long b) 
	      { 
	          if (a == 0) 
	              return b; 
	          return gcd(b % a, a); 
	      } 

static long nCr(int n,int r) {
  int dp[][]=new int[2001][2001];
  for(int i=0;i<2001;i++) {
    dp[0][i]=0;
  }
  for(int i=0;i<2001;i++) {
    dp[i][0]=1;
  }
  for(int i=1;i<2001;i++) {
    for(int j=1;j<2001;j++) {
      if(i==j) {
        dp[i][j]=1;
      }else {
        dp[i][j]=dp[i-1][j-1]+dp[i][j-1];
      }
    }
  }
  return dp[n][r];
}
      
}

Measured memory_bytes: 59344
N = int(input())
S = input()
MOD = 10**9+7

if S[0]=="W" or S[-1]=="W":
    print(0)
else:
    l = [0]*(2*N)
    for i in range(1, 2*N):
        if S[i]==S[i-1]:
            l[i] = 1 if l[i-1]==0 else 0
        else:
            l[i] = 0 if l[i-1]==0 else 1
    pair = sum(l)

    fac = [None]*(N+1)
    fac[1] = 1
    for i in range(2, N+1):
        fac[i] = fac[i-1] * i
        fac[i] %= MOD

    ans = 0
    if pair==N:
        buf = 0
        ans = 1
        for i in l[::-1]:
            if i:
                buf += 1
            else:
                ans *= buf
                ans %= MOD
                buf -= 1
        
        ans *= fac[N]
        ans %= MOD
    print(ans)


Measured memory_bytes: 16344
#include<stdio.h>
struct Node {int p, l, r;};
struct Node T[10000];
int n;
void preParse(int u){
  if(u == -1) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}
void inParse(int u){
  if(u == -1) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}
void postParse(int u){
  if(u == -1) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}
int main() {
  int i, v, l, r, root;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
	T[i].p = -1;
  }
  for(i = 0; i < n; i++){
	scanf("%d %d %d", &v, &l, &r);
	T[v].l = l;
	T[v].r = r;
	if( l != -1 ) T[l].p = v;
	if( r != -1 ) T[r].p = v;
  }
  for(i = 0; i < n; i++) if ( T[i].p == -1) root = i;
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
  return 0;
}

Measured memory_bytes: 1852
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	int n, m, l;
	int *a_A, *a_B;
	long long tmp;

	cin >> n >> m >> l;
	a_A = new int[n*m];
	a_B = new int[m*l];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a_A[i*m + j];
		}
	}
	
	for (int j = 0; j < m; j++) {
		for (int k = 0; k < l; k++) {
			cin >> a_B[j*l + k];
		}
	}

	for (int i = 0; i < n; i++) {
		for (int k = 0; k < l; k++) {
		    
			tmp = 0;
			for(int j=0; j < m; j++){
			    tmp += a_A[i*m+j] * a_B[j*l+k]; 
			}
			if(k!=0) cout << " ";
			cout << tmp;
		}
		cout << endl;
	}

	delete[] a_A;
	delete[] a_B;

	return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

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

  int cnt = 0;
  while (a >= b) b *= 2, cnt++;
  while (b >= c) c *= 2, cnt++;
  cout << (cnt <= k ? "Yes" : "No") << '\n';
  

  




  
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
#define the_num 1000000007
#define ano_num 998244353
#define forn(n) for(int i=0;i<n;i++)
#define For(i,start_i,n) for(int i=start_i;i<n;i++)
#define test int t;cin >> t;while(t--)
#define all(v) v.begin(),v.end()
#define in_arr(arr,n) int arr[n];forn(n) cin >> arr[i];
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define take(data_type,n) data_type n;cin >> n;
#define swap(a,b) a = a+b;b = a-b;a = a-b;
using namespace std;
 
int main(){
    fast
    string S;
    cin >> S;
    cout << S.substr(0,3) << '\n';
}

Measured memory_bytes: 3608
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(problem148a(a, b))
}

fun problem148a(a: Int, b: Int): Int {
    if ((a == 1 || b == 1) && (a == 2 || b == 2)) {
        return 3
    } else if ((a == 1 || b == 1) && (a == 3 || b == 3)) {
        return 2
    } else if ((a == 2 || b == 2) && (a == 3 || b == 3)) {
        return 1
    }
    return 0
}

Measured memory_bytes: 29352
#include <cstdio>
#include <algorithm>
#include <vector>

#define NMAX (50 + 7)

using namespace std;
int N, M, a[NMAX], b[NMAX], c[NMAX], d[NMAX], minim, p;

int dist(int x, int y)
{
    return max(a[x] - c[y], c[y] - a[x]) + max(b[x] - d[y], d[y] - b[x]);
}

int main()
{
    scanf("%d %d", &N, &M);
    for(int i = 1; i<= N; ++i) scanf("%d %d", &a[i], &b[i]);
    for(int i = 1; i<= M; ++i) scanf("%d %d", &c[i], &d[i]);
    for(int i = 1; i<= N; ++i)
    {
        minim = dist(i, 1);
        //printf("i = %d min = %d\n", i, minim);
        p = 1;
        for(int j = 2; j<= M; ++j)
        {
            int cand = dist(i, j);
            if(cand < minim)
            {
                minim = cand;
                p = j;
            }
        }
        printf("%d\n", p);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
struct edge { int to; long long cost; };
typedef pair<long long, int> P;  // first は最短距離, second は頂点番号
typedef pair<long long ,long long> pll;
vector<long long> dijkstra(int v,int s,vector<vector<pll>> tree) {
    const long long INF = 1e15;
    priority_queue<P, vector<P>, greater<P> > que;
    vector<long long> d;
    rep(i,v) d.push_back(INF);
    d[s] = 0;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) { continue; }
        for (int i = 0; i < tree[v].size(); i++) {
            long long to = tree[v][i].first;
            long long cost = tree[v][i].second;
            if (d[to] > d[v] + cost) {
                d[to] = d[v] + cost;
                que.push(P(d[to], to));
            }
        }
    }
    return d;
}
//aを始点とする、v頂点e辺の全ての点に対する最短経路(dijkstra法)
vector<long long> dijkstra2(long long v, long long e,long long a,vector<vector<pll>> edge){
    const long long INF = 1e15;
    //vector<vector<pll>> edge=makedata(v,e);// first:B second:cost
    priority_queue<pll,vector<pll>,greater<pll>> que;//first:distance second:A
    vector<long long> dist(v+1,INF);
    dist[a] = 0;
    que.push(make_pair(0,a));
    while(!que.empty()){
        pll pr = que.top();
        que.pop();
        if(pr.first>dist[pr.second]) continue;
        for(long i = 0;i<edge[pr.second].size();i++){
            if(dist[edge[pr.second][i].first] > dist[pr.second]+edge[pr.second][i].second){
                que.push(make_pair(dist[pr.second]+edge[pr.second][i].second,edge[pr.second][i].first));
                dist[edge[pr.second][i].first]=dist[pr.second]+edge[pr.second][i].second;
            }
        }
    }
    return dist;
}
int main(){
    int n,m,s,t;
    cin >> n >> m >> s >> t;
    vector<vector<pll>> edge[2];//0:yen 1:snuuk
    rep(i,2) rep(j,n+1) edge[i].push_back({});
    long long u,v;
    long long a[2];
    rep(i,m){
        cin >> u >> v >> a[0] >> a[1];
        u--;v--;
        rep(j,2){
            edge[j][u].push_back(make_pair(v,a[j]));
            edge[j][v].push_back(make_pair(u,a[j]));
        }
    }
    vector<long long> yendict = dijkstra(n,s-1,edge[0]);
    vector<long long> snudict = dijkstra(n,t-1,edge[1]);
    vector<pair<long long,int>> data;
    long long money = 1e15;
    rep(i,n) data.push_back({yendict[i]+snudict[i],i+1});
    sort(data.begin(),data.end());
    int year = 0;
    int cnt = 0;
    rep(i,n){
        long long cost = data[i].first;
        int cnum = data[i].second;
        while(year<cnum){
            cout << money - cost << endl;
            cnt++;
            if(cnt==n) break;
            year++;
        }
        if(cnt==n) break;
    }
}

Measured memory_bytes: 26864
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long N = scanner.nextLong();
        long K = scanner.nextLong();

        long answer = N - ((N / K) * K);
        if (answer != 0) {
            long check = answer - K;
            if (check < 0) {
                check *= -1;
            }
            if (check < answer) {
                answer = check;
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 23892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		scan.close();
		int ans=0;
		for(int i=1;i<=n;i+=2) {
			int cnt=2;
			for(int j=2;j<i;j++) {
				if(i%j==0)cnt++;
			}
			if(cnt==8)ans++;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 21844
#include<cstdio>
#include<queue>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<iostream>
using namespace std;
char s[1010000];
int  main(){
	scanf("%s",s+300000);
	int ll=strlen(s+300000),i,f=0;
	int q;
	scanf("%d",&q);
	int l=300000,r=l+ll;
	for(i=1;i<=q;i++){
		int ccp;
		scanf("%d",&ccp);
		if(ccp==1){
			f=1-f;
		}
		else{
			int ff;
			scanf("%d",&ff);
			char cp[10];
			scanf("%s",cp);
			if(f)
			ff=3-ff;
			if(ff==1){
				l--;
				s[l]=cp[0];
			}
			else{
				s[r]=cp[0];
				r++;
			}
		
		}
	}
	if(f==0){
		for(i=l;i<r;i++)
		printf("%c",s[i]); 
	}
	else{
		for(i=r-1;i>=l;i--)
		printf("%c",s[i]);
	}
}




Measured memory_bytes: 896
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine
    

main = do
    (r, d, x2) <- readTuple3
    let xs = tail $ scanl (\acc _ -> acc * r - d ) x2 [1..10]
    forM_ xs print




Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807/5;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
ll n,m,l;
ll d[310][310];

ll nd[310][310];
void warshall_floyd(){
	for(ll k=1;k<=n;k++)
		for(ll i=1;i<=n;i++)
			for(ll j=1;j<=n;j++)chmin(d[i][j],d[i][k]+d[k][j]);
}
void nwarshall_floyd(){
	for(ll k=1;k<=n;k++)
		for(ll i=1;i<=n;i++)
			for(ll j=1;j<=n;j++)chmin(nd[i][j],nd[i][k]+nd[k][j]);
}
int main(){
	cin>>n>>m>>l;
	REP(i,310)
		REP(j,310)d[i][j]=1000000000000;
	REP(i,310){
		d[i][i]=0;
		nd[i][i]=0;
	}
	REP(i,m){
		ll a,b,c;
		cin>>a>>b>>c;
		d[a][b]=c;
		d[b][a]=c;
	}
	warshall_floyd();
	REP(i,310)
		REP(j,310)nd[i][j]=1000000000000;
	REP(i,310)
		REP(j,310){
			if(i==j){
				nd[i][j]=0;
				nd[j][i]=0;
				
			}else if(d[i][j]<=l){
				chmin(nd[i][j],1LL);
				chmin(nd[j][i],1LL);
				
				//cout<<i<<" "<<j<<endl;
			}
		}
	nwarshall_floyd();
	ll q;
	cin>>q;
	while(q--){
		ll s,t;
		cin>>s>>t;
		if(nd[s][t]==1000000000000){
			cout<<-1<<endl;
		}else{
			cout<<nd[s][t]-1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{	
	int x, t;
	cin >> x >> t;
	cout << max(0, x - t);		
}


 
 
int main()
{
 //	freopen("sparse.in", "r", stdin);
	//freopen("sparse.out", "w", stdout);
	   Red;
  	//int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

bool ok[108000];
Int a[108000], b[108000], y[108000], w[108000];
Int x[108000];
vector<P> edges;
vector<Int> edge[108000];
class UnionFind{
public:
  Int n;
  vector<Int> u;
  UnionFind(Int _n = 0){
    n = _n;
    u = vector<Int>(n);
    for(Int i = 0;i < n;i++)u[i] = i;
  }
  Int r(Int x){
    if(u[x] == x)return x;
    return u[x] = r(u[x]);
  }
  Int unite(Int x, Int y){
    x = r(x);
    y = r(y);
    if(x != y)u[y] = x;
  }
};

UnionFind uf(108000);
bool done[108000];
void dfs(Int x, Int w){
  if(done[x])return;
  done[x] = true;
  for(Int i = 0;i < edge[x].size();i++){
    Int id = edge[x][i];
    if(y[id] > w)continue;
    ok[id] = true;
    Int to = a[id] + b[id] - x;
    dfs(to, w);
  }
}
Int res, n, m;

int main(){
  cin >> n >> m;
  for(Int i = 0;i <n ;i++)cin >> x[i], w[i] = x[i];
  for(Int i = 0;i < m;i++){
    cin >> a[i] >> b[i] >> y[i];a[i]--,b[i]--;
    edge[a[i]].push_back(i);
    edge[b[i]].push_back(i);
    edges.push_back(P(y[i],i));
  }
  sort(edges.begin(), edges.end());
  for(Int i = 0;i < m;i++){
    Int id = edges[i].second;
    Int ar = uf.r(a[id]);
    Int br = uf.r(b[id]);
    if(ar != br){
      w[ar] += w[br];
      uf.unite(ar, br);
    }
    if(w[ar] >= y[id])ok[id] = true;
    else ok[id] = false;
  }
  for(Int i = m-1;i >= 0;i--){
    Int id = edges[i].second;
    if(!ok[id])continue;
    dfs(a[id], y[id]);
  }
  for(Int i = 0;i < m;i++){
    if(!ok[i])res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 17264
#include<stdio.h>

int main(void){
	int r,c,sheet[101][101],sum,sum2;
	int i,j;

	scanf("%d %d",&r,&c);
	for(i=0;i<r;i++){
		scanf("%d",&sheet[i][0]);
		for(j=1;j<c;j++){
			scanf(" %d",&sheet[i][j]);
		}
	}

	for(i=0;i<r;i++){
		sum=0;
		for(j=0;j<c;j++){
			sum=sum+sheet[i][j];
			printf("%d ",sheet[i][j]);
		}
		printf("%d\n",sum);
	}
	sum2=0;
	for(i=0;i<c;i++){
		sum=0;
		for(j=0;j<r;j++){
			sum=sum+sheet[j][i];
		}
		sum2=sum2+sum;
		printf("%d ",sum);
	}printf("%d\n",sum2);
	return 0;
}

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

typedef pair<long long, long long> P;
void solve(int n, int m){
	int sum = 0;
	int ans = 0;
	vector<P> v;
	for(int i=0; i<n; ++i){
		int d, p;
		cin >> d >> p;
		v.push_back(P(p, d));
	}
	sort(v.begin(), v.end());
	for(int i=n-1; i>=0; --i){
		int d = v[i].second;
		int p = v[i].first;
		if(m - sum >= d) sum += d;
		else if(m == sum) ans += d * p;
		else{
			ans += (d - m + sum) * p;
			m = sum;
		}
	}
	cout << ans << "\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int n, m;
		cin >> n >> m;
		if(n == 0 && m == 0) return 0;
		solve(n, m);
	}
}


Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5005;
int ga,sa,ba,gb,sb,bb;
ll n,dp[N*N];
int main()
{
    scanf("%lld",&n);
    scanf("%d%d%d%d%d%d",&ga,&sa,&ba,&gb,&sb,&bb);
    for(int i=1;i<=n;i++)
    {
        if(i>=ga) dp[i]=max(dp[i],dp[i-ga]+gb-ga);
        if(i>=sa) dp[i]=max(dp[i],dp[i-sa]+sb-sa);
        if(i>=ba) dp[i]=max(dp[i],dp[i-ba]+bb-ba);
    }
    n+=dp[n];
    for(int i=1;i<=n;i++)
    {
        dp[i]=0;
        if(i>=gb) dp[i]=max(dp[i],dp[i-gb]+ga-gb);
        if(i>=sb) dp[i]=max(dp[i],dp[i-sb]+sa-sb);
        if(i>=bb) dp[i]=max(dp[i],dp[i-bb]+ba-bb);
    }
    printf("%lld\n",n+dp[n]);
}


Measured memory_bytes: 195584
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;

int main() {
	int a;
	cin >> a;
	cout << a / 30 << " " << a % 30 / 30.0 * 60 << endl;
	return 0;
}



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

int main() {
    int N;
  	cin >>N;
  
    vector<int> p(N);
    rep(i,0,N) cin >> p[i];

	int cnt = 0;
  	rep(i,0,N) if(p[i]!=i+1) cnt++;
 
  	string ans;
	cnt<=2 ? ans = "YES": ans = "NO";
  	cout <<ans<< endl;
}

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

int main() {
	int s;
    cin >> s;
    int S1 = s/100;
    int S2 = (s-S1*100)/10;
    int S3 = s%10;
    int count = 0;
    if(S1 == 1){
      count++;
    }
    if(S2 == 1){
      count++;
    }
    if(S3 == 1){
      count++;
    }
    cout << count << endl;
}


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

static const int MAX = 1000;

void trace(int A[], int N){ 
    int i;
    for (i=0;i<N;i++){
        if(i>0) cout << " ";
        cout << A[i];
    }   
    cout << endl;
}

void bubbleSort(int A[],int N){ 
    int flag = 1;
    int v0; 
    int cnt = 0;
    while (flag == 1){ 
        flag = 0;
        for (int j=N-1;j>=1;j--){
            if(A[j] < A[j-1]){
                //v0 = A[j-1];
                //A[j-1] = A[j];
                //A[j] = v0;
                swap(A[j-1],A[j]);
                flag = 1;
                cnt ++; 
            }
        }
    }   
    trace(A,N);
    cout << cnt << endl;;
}

int main(){
    int n, A[MAX];
    cin >> n;
    for (int i=0;i<n;i++) cin >> A[i];
    bubbleSort(A,n);
    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

void n() {
    cout << "No" << endl;
    exit(0);
}

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;
bool is_prime[ 50000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main() {
    IOS;
    int n;
    cin>>n;
    Int sum=0;
    vector<int> b(n-1);

    for (int i = 0; i < n-1; ++i) {
        cin>>b[i];
    }
    sum=b[0];
    for (int j = 1; j < n-1; ++j) {
        sum+=min(b[j-1],b[j]);
    }
    cout<<b[n-2]+sum;
    //printV(b);



    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace   std;
#define ff        first
#define ss        second
#define ll        int
#define inf       ((ll)1e18)
#define double    long double
#define ull       unsigned long long
#define mod       1000000007
#define vi        vector<ll>
#define ppi       pair<ll,pair<ll,ll>>
#define pb        push_back
#define mp        make_pair
#define str       string
#define pi        2*acos(0.0)
#define pr(a,x,n) for(int i=x;i<n;i++){cout<<a[i]<<" ";}
#define p(a)      cout<<a;
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define endl      '\n'
#define all(v)    v.begin(), v.end()
#define test      cout<<"THIS_AND_THIS"<<endl;
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
int32_t main(){
	kehsihba();
	str s;cin>>s;
	for(int i=0;i<3;i++){
		if(s[i]==s[i+1]){cout<<"Bad";return 0;}
	}
	cout<<"Good";
}

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

int main(){
  int n,k,ans=0,c;
  cin>>n>>k;
  vector<int> a(n,0),b(n+1,0);
  REP(i,n){
    cin >> a.at(i);
    b.at(a.at(i))++;
  }
  sort(b.begin(),b.end(),greater<int>());
  for(int i=k;i<n;i++) ans+=b.at(i);  
  cout<<ans;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<int> A;
int main() {
  cin >> N;
  A.resize(N);
  for (auto &val : A){
    cin >> val;
  }
  ll pre = 0;
  ll result = 0;
  for (int i = 0; i < N; i++){
    ll x = A[i];
    if (pre == 0){
      result += (x - 1);
      pre = 1;
    }else if(x == pre + 1){
      pre++;
    }else if(x > pre + 1){
      result += (x - 1) / (pre + 1);
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 640
import heapq
from operator import itemgetter

n,k = map(int, input().split())
td = sorted([list(map(int, input().split())) for i in range(n)],key=itemgetter(1),reverse=True)
neta = [0] * (n+1)
hq = []
kind = 0
ans = 0
for t,d in td[:k]:
  if neta[t]:
    hq.append(d)
  else:
    kind += 1
  neta[t] += 1
  ans += d
ans += kind ** 2
heapq.heapify(hq)
now = k
new_ans = ans
while hq and now < n:
  t,d = td[now][0],td[now][1]
  if not neta[t]:
    MIN = heapq.heappop(hq)
    new_ans += d - MIN + 2 * kind + 1
    ans = max(ans,new_ans)
    kind += 1
    neta[t] += 1
  now += 1	
print(ans)

Measured memory_bytes: 30016
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    class Program
    {
        
        static void Main()
        {
            //ここから
            int[] vs = ReadLineToIntArray();
            int ans = 1001;
            for(int i = 0; i < vs[0]; i++)
            {
                int[] str = ReadLineToIntArray();
                if (str[1] <= vs[1])
                {
                    ans = ans > str[0] ? str[0]:ans;
                }
            }

            if (ans == 1001)
            {
                Console.WriteLine("TLE");
                return;
            }
            //ここまで
            Console.WriteLine(ans);
            Console.ReadKey();
        }


        static public void Swap<T>(ref T a,ref T b) { T temp = a;a = b;b = temp; }
        static public long GCD(int a, int b){ return b != 0 ? GCD(b, a % b) : a;}
        static public long LCM(int a, int b){ return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n,int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }


        
        static public string ReadLineToString(){return Console.ReadLine();}
        static public int ReadLineToInt(){return int.Parse(Console.ReadLine());}
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray(){return Console.ReadLine().Split(' ').ToArray();}
        static public int[] ReadLineToIntArray(){return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();}
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList(){return Console.ReadLine().Split(' ').ToList();}
        static public List<int> ReadLineToIntList(){return Console.ReadLine().Split(' ').Select(int.Parse).ToList();}
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    }
    
}


Measured memory_bytes: 13396