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

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, A, B, C;
  string S[SIZE];

  cin >> N >> A >> B >> C;

  vector<char> ans;

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

  for (int i = 0; i < N; i++) {
    int* x[2];

    for (int j = 0; j < 2; j++) {
      if (S[i][j] == 'A') x[j] = &A;
      if (S[i][j] == 'B') x[j] = &B;
      if (S[i][j] == 'C') x[j] = &C;
    }

    if (*x[0] < *x[1]) {
      swap(x[0], x[1]);
      swap(S[i][0], S[i][1]);
    } else if (*x[0] == *x[1]) {
      if (i + 1 < N && (S[i + 1][0] == S[i][0] || S[i + 1][1] == S[i][0])) {
        swap(x[0], x[1]);
        swap(S[i][0], S[i][1]);
      }
    }

    (*x[0])--;
    (*x[1])++;
    ans.push_back(S[i][1]);

    debug(A, B, C);

    if (*x[0] < 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  for (char c : ans) {
    cout << c << '\n';
  }

  return 0;
}

Measured memory_bytes: 10000
import numpy as np
l, a, b, m = map(int, input().split())
# l = 107
# a = 10000000000007  # 10**13 + 7
# b = 1000000000000007  # 10**15 + 7
# m = 998244353

s_max = a + b * (l - 1)

# ten_pow[i] = 10**i
ten_pow = [1]
while ten_pow[-1] <= s_max:
    ten_pow.append(ten_pow[-1] * 10)

# d[i] = (s_j <= 10**i - 1 なるjの数)
D_MAX = len(ten_pow)
d = [0] * D_MAX
for i in range(D_MAX):
    if ten_pow[i] >= a:
        d[i] = max((ten_pow[i] - 1 - a) // b, 0)
d[-1] = l - 1

# cd[i] = ((i+1)桁のsの要素数(s_0を除く))
cd = [d[i + 1] - d[i] for i in range(len(d) - 1)]
# print(ten_pow)
# print(d)
# print(cd)

y = np.array([a, a + b, 1]).T % m
for i in range(len(cd)):
    x = np.array([[ten_pow[i + 1] % m, 1, 0], [0, 1, b], [0, 0, 1]])
    x %= m
    # print(x)
    # print('y', y)
    k = cd[i]
    while k > 0:
        if k & 1:
            y = np.dot(x, y) % m
            # print('y', y)
        x = np.dot(x, x) % m
        k = k >> 1

ans = y[0] % m
print(ans)


Measured memory_bytes: 12496
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF =(ll)(1e18) +5; 

int main() {
    ll N;
    cin >> N;
    vector<ll> num;
    num.push_back(1);
    ll t=6;
    while(t<=N){
        num.push_back(t);
        t*=6;
    }
    t =9;
    while(t<=N){
        num.push_back(t);
        t*=9;
    }
    ll dp[N+1];
    // for(ll n:num){
    //     cerr << n << endl;
    // }
    for(int i=0;i<N+1;i++){
        dp[i] = INF;
    }
    dp[0] =0;
    for(int i=1;i<N+1;i++){
        for(ll n:num){
            if(n>i){
                continue;
            }
            dp[i] = min(dp[i],dp[i-n]+1);
        }
    }
    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 1024
import sys


def input():
    return sys.stdin.readline().strip()


N, M = map(int, input().split())
drinks = sorted(tuple(map(int, input().split())) for _ in range(N))
ans = 0
for A, B in drinks:
    if M > B:
        ans += A * B
        M -= B
    else:
        ans += A * M
        break
print(ans)


Measured memory_bytes: 16976
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
            String tmp = br.readLine();

            if(tmp == null){
                break;
            }

            String[] tmpArray = tmp.split(" ");
            int a = Integer.parseInt(tmpArray[0]);
            int b = Integer.parseInt(tmpArray[1]);

            int GCD = gcd(a, b);

            int LCM = lcm(a, b, GCD);
            System.out.println(GCD + " "+ LCM);
        }
    }

    static int gcd(int a, int b){
    	int tmp;

    	while (a % b != 0)
    	{
    		tmp = b;
    		b = a % b;
    		a = tmp;
    	}
    	return b;
    }

    static int lcm(int a, int b, int gcd){
    	return a*(b/gcd);
    }

    static int lcm(int a, int b){
    	int g = gcd(a, b);

    	return lcm(a,b,g);
    }

}

Measured memory_bytes: 23992
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	vector<int> ball(n, 0);

	int m = 0;
	vector<int> ans;
	for (int i = n - 1; i >= 0; --i) {
		int sum = 0;
		for (int j = i; j < n; j += i + 1) {
			sum += ball[j];
		}
		int even_or_odd = sum % 2;
		if (a[i] != even_or_odd) {
			++ball[i];
			++m;
			ans.push_back(i + 1);
		}
	}
	cout << m << "\n";
	for (int i = 0; i < m; ++i) {
		if (i == 0) cout << ans[i];
		else cout << " " << ans[i];
		if (i == m - 1) cout << "\n";
	}
	return 0;
}

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

#define MAX 101

int main() {
    int n;
    int M[MAX][MAX];
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            M[i][j] = 0;
        }
    }
    
    for (int i = 1; i <= n; i++) {
        int id, k;
        scanf("%d %d", &id, &k);
        if (k == 0) continue;
        else {
            for (int j = 1; j <= k; j++) {
                int v; scanf("%d", &v);
                M[id][v] = 1;
            }
        }
    }
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (j == n) printf("%d\n", M[i][j]);
            else printf("%d ", M[i][j]);
        }
    }
    
    return 0;
}



Measured memory_bytes: 3204
package main

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

var sc = bufio.NewScanner((os.Stdin))

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	l := nextLine()
	i, e := strconv.Atoi(l)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N, a := nextInt(), []int{}

	for i := 0; i < N; i++ {
		a = append(a, nextInt())
	}

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

// ABC065B ...
func ABC065B(a []int) int {
	res, curr, done := 0, 1, map[int]bool{1: true}
	for {
		curr = a[curr-1]
		res++

		if curr == 2 {
			return res
		}

		_, contains := done[curr]
		if contains {
			return -1
		}

		done[curr] = true
	}
}


Measured memory_bytes: 7932
import math
N, X = map(int, input().split())

dp = [0] * (N + 1)
p_dp = [0] * (N + 1)
dp[0] = 1
p_dp[0] = 1
for i in range(1, N + 1):
    dp[i] = dp[i - 1] * 2 + 3
    p_dp[i] = p_dp[i - 1] * 2 + 1
patties = p_dp[N]
burger_len = dp[N]

tmp = X
middle = -(-dp[N]//2)
n = N - 1
ans = 0
while True:
    #print("middle:", middle)
    #print("tmp:", tmp)
    if tmp == 1:
        if middle == 1:
            ans += 1
        break
    if tmp == middle:
        ans += p_dp[n] + 1
        break
    if tmp == dp[n + 1]:
        ans += p_dp[n] * 2 + 1
        break
    if 1 < tmp < middle:
        middle = -(-dp[n]//2)
        tmp -= 1
        n -= 1
    if middle < tmp < dp[n + 1]:
        tmp -= middle
        middle = -(-dp[n]//2)
        ans += p_dp[n] + 1
        n -= 1
print(ans)


Measured memory_bytes: 3064
const input = require('fs').readFileSync('/dev/stdin', 'UTF-8');

const sortingThreeNumbers = input => {
  const inputArray = input.split(' ').map(val => Number(val));
  const sorter = (a, b) => a - b;
  console.log(inputArray.sort(sorter).join(' '));
};

sortingThreeNumbers(input);



Measured memory_bytes: 15132
#include <bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7; 
int main(){
	IOS;
	string s,t;
	cin>>s>>t;
	int n=s.length();
	int m=t.length();
	int ans=1002;
	for(int i=0;i<=n-m;i++){
		int temp=0;
		for(int j=0;j<m;j++){
			if(s[i+j]!=t[j]) temp++;
		}
		ans=min(ans,temp);
	}
	cout<<ans;
}

Measured memory_bytes: 3660
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int K,T; cin>>K>>T;
	map<int,int> cake;
	rep(i,T){
		int t; cin>>t;
		cake[i] = t;
	}
	int bf = inf;
	rep(i,K){
		if(cake.size() == 1){
			break;
		}
		int nax = 0;
		int ind;
		for(auto x:cake){
			if(x.second>nax && x.first != bf){
				ind = x.first;
				nax = x.second;
			}
		}
		--cake[ind];
		bf = ind;
		if(cake[ind] == 0){cake.erase(ind);}
	}
	for(auto x: cake)cout<<x.second-1<<endl;
	return 0;
}

Measured memory_bytes: 256
from scipy.spatial import distance


def solve(string):
    n, d, *x = map(int, string.split())
    x = [tuple(c) for c in zip(*[iter(x)] * d)]
    dist = distance.cdist(x, x)
    return str(((dist == dist.astype("int32")).sum() - n) // 2)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m)+'\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 19892
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	string s;
	re(s);
	int cnt = 0;
	for(int i = 0; i < s.size()/2; i++)
	{
		if(s[i]!=s[s.size()-i-1])
			cnt++;
	}
	cout<<cnt<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    int a, sum = 0;
    int tmp[h * w];
    REP(i,n){
        cin >> a;
        REP(j,a){
            tmp[sum + j] = i + 1;
        }
        sum += a;
    }
    int now = 0;
    int c[h][w];
    REP(i,h){
        if(i % 2 == 0){
            REP(j,w){
                c[i][j] = tmp[now];
                now++;
            }
        }else{
            for(int j = w - 1; j >= 0; j--){
                c[i][j] = tmp[now];
                now++;
            }
        }
    }
    REP(i,h){
        REP(j,w){
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<cmath>
#include<bitset>
#include<cassert>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<fstream>

using namespace std;
typedef long long ll;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast_io;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    
    string str;
    cin >> str;

    int c = 0;
    if (str == "RSR")
        cout << "1" << endl;
    else
    {
        for (int i = 0; i < str.size(); i++)
        {
            if (str[i] == 'R') c++;
        }

        cout << c << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 3224
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
//#define int ll
#define pb push_back
using pii = pair<int,int>;
const int N = 105;
const int Inf = 1e9+7;

vector<vector<int>> v;
vector<vector<bool>> used;

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
	int n, x, y;
	cin >> n >> x >> y;
	v.resize(n);
	used.resize(n);--x;--y;
	for (int i = 0; i < n; ++i)
	{
		used[i].resize(n);
		used[i][i] = 1;
		v[i].pb(i);
	}
	for (int k = 0; k < n - 1; ++k)
	{
		int ans= 0 ;
		for (int i = 0; i < n; ++i)
		{
			vector<int> nb;
			for (int t: v[i])
			{
				if (t != 0 && !used[i][t - 1])
				{
					nb.pb(t - 1);
					used[i][t - 1] = true;
					++ans;
				}
				if (t != n - 1 && !used[i][t + 1])
				{
					nb.pb(t + 1);
					used[i][t + 1] = true;
					++ans;
				}
				if (t == y && !used[i][x])
				{
					nb.pb(x);
					used[i][x] = 1;
					++ans;
				}
				if (t == x && !used[i][y])
				{
					nb.pb(y);
					used[i][y] = 1;
					++ans;
				}
			}
			v[i] = nb;
		}
		cout << ans / 2 << endl;
	}
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

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

    int n_max = min(a, b);
    int n_min = max(0, a + b - n);

    cout << n_max << " " << n_min << endl;
}


Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;cin>>s;
    int cnt=0;
    for(int i=0;i<3;i++)
        if(s[i]=='o')
            cnt++;
    cout<<700+100*cnt<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL n,a,b;
vector<LL> vec(100000);

bool solve(LL m){
    LL bd = b*m;
    LL dist = a - b;
    for(int i = 0; i < n; i++){
        if(vec[i] > bd){
            m -= (vec[i] - bd)/dist + ((((vec[i] - bd) % dist) == 0)? 0 : 1 );
        }else{
            break;
        }
    }
    if(m >= 0){
        return true;
    }else{
        return false;
    }
}

LL binary(LL ng,LL ok){
    while(abs(ok-ng) > 1){
        LL middle = (ok+ng)/2;
        if(solve(middle)){
            ok = middle;
        }else{
            ng = middle;
        }
    }
    return ok;
}

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

    cin >> n >> a >> b;

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

    sort(vec.begin(),vec.begin()+n,greater<LL>());

    cout << binary(0,1000000000) << endl;
    
    return 0;
}

Measured memory_bytes: 1024
def tree(s,pls):
	dep[s] += pls
	pls += 1
	if main[s][1] != -1:
		ju1 = tree(main[s][1],pls)
		ju1 += 1
	else:
		ju1 = 0
		hei[s] = 0
		
	if main[s][2] != -1:
		ju2 = tree(main[s][2],pls)
		ju2 += 1
	else:
		ju2 = 0
		hei[s] = 0


	if ju1 > ju2:
		ju = ju1
	else:
		ju = ju2

	del ju1
	del ju2

	#print(str(s) + ":" + str(ju))

	if ju > hei[s]:
		hei[s] = ju
	return ju

def sib(m):
	b = main[m][0]
	if b == -1:
		return -1
	elif m == main[b][1]:
		return main[b][2]
	else :
		return main[b][1]

def deg(w):
	r = 2
	if main[w][1] == -1:
		r -= 1
	if main[w][2] == -1:
		r -= 1
	
	return r



n = int(input())
main = [[-1] * 1 for i in range(n+1)]
for i in range(n):
	a = input().split()
	for j in range(1,3):
		main[int(a[j])][0] = int(a[0])
		main[int(a[0])].append(int(a[j]))
	#print(main)

del a

dep = [-1] * n
hei = [-1] * n


for i in range(n):
	if main[i][0] == -1:
		hei[i] = tree(int(i),1)
		break


for i in range(n):
	print("node " + str(i) + 
		": parent = " + str(main[i][0]) +
		", sibling = " + str(sib(i)) +
		", degree = " + str(deg(i)) +
		", depth = " + str(dep[i]) + 
		", height = " + str(hei[i]) ,end='')
	if main[i][0] == -1:
		print(", root")
	elif main[i][1] == -1 and main[i][2] == -1:
		print(", leaf")
	else:
		print(", internal node")

#print(main)


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

void solve(){
	int n;
	cin >> n;
	if(n%1000 == 0){
		cout << "0\n";
	}
	else cout << 1000*((n/1000)+1) - n << "\n";
	return ;	
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		
	int t = 1;

	while(t--){
		solve();
	}

	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
long long a,b;
string n;
int main()
{
	cin>>a>>b;
	for(int s=1;s<=a;s++)
	{
		for(int v=0;v<b;v++)
		{
			cin>>n;
			if(n=="snuke")
			{
				cout<<char('A'+v)<<s<<endl;
			}
		}
	}
}

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

using namespace std;


template <int p>
struct Modint
{
	int value;

	Modint() : value(0) {}
	Modint(long x) : value(x >= 0 ? x % p : (p + x % p) % p) {}

	inline Modint &operator+=(const Modint &b)
	{
		if ((this->value += b.value) >= p)
			this->value -= p;
		return (*this);
	}
	inline Modint &operator-=(const Modint &b)
	{
		if ((this->value += p - b.value) >= p)
			this->value -= p;
		return (*this);
	}
	inline Modint &operator*=(const Modint &b)
	{
		this->value = (int)((1LL * this->value * b.value) % p);
		return (*this);
	}
	inline Modint &operator/=(const Modint &b)
	{
		(*this) *= b.inverse();
		return (*this);
	}

	Modint operator+(const Modint &b) const { return Modint(*this) += b; }
	Modint operator-(const Modint &b) const { return Modint(*this) -= b; }
	Modint operator*(const Modint &b) const { return Modint(*this) *= b; }
	Modint operator/(const Modint &b) const { return Modint(*this) /= b; }

	inline Modint &operator++(int) { return (*this) += 1; }
	inline Modint &operator--(int) { return (*this) -= 1; }

	inline bool operator==(const Modint &b) const { return this->value == b.value; }
	inline bool operator!=(const Modint &b) const { return this->value != b.value; }
	inline bool operator<(const Modint &b) const { return this->value < b.value; }
	inline bool operator<=(const Modint &b) const { return this->value <= b.value; }
	inline bool operator>(const Modint &b) const { return this->value > b.value; }
	inline bool operator>=(const Modint &b) const { return this->value >= b.value; }

	//requires that "this->value and p are co-prime"
	// a_i * v + a_(i+1) * p = r_i
	// r_i = r_(i+1) * q_(i+1) * r_(i+2)
	// q == 1 (i > 1)
	// reference: https://atcoder.jp/contests/agc026/submissions/2845729 (line:93)
	inline Modint inverse() const
	{
		assert(this->value != 0);
		int r0 = p, r1 = this->value, a0 = 0, a1 = 1;
		while (r1)
		{
			int q = r0 / r1;
			r0 -= q * r1;
			swap(r0, r1);
			a0 -= q * a1;
			swap(a0, a1);
		}
		return Modint(a0);
	}

	friend istream &operator>>(istream &is, Modint<p> &a)
	{
		long t;
		is >> t;
		a = Modint<p>(t);
		return is;
	}
	friend ostream &operator<<(ostream &os, const Modint<p> &a)
	{
		return os << a.value;
	}
};

const int MOD = 1e9 + 7;

using Int = Modint<MOD>;

void solve(void)
{
	int n, m;
	cin >> n >> m;
	vector<int> s(n), t(m);
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> t[i];
	}
	vector<vector<Int>> dp(n+1, vector<Int>(m+1, 1));
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1];
			if (s[i-1] == t[j-1])
			{
				dp[i][j] += dp[i-1][j-1];
			}
		}
	}
	cout << dp[n][m] << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 16000
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC141C
{
    class Program
    {
        static void Main(string[] args)
        {
            var NKQ = ReadInt();
            int N = NKQ[0];
            int K = NKQ[1];
            int Q = NKQ[2];

            int[] Seikai = new int[N];
            for (int i = 0; i < Q; i++)
            {
                var input = int.Parse(Console.ReadLine()) - 1;
                Seikai[input]++;
            }

            for (int i = 0; i < N; i++)
            {
                int count = K - Q + Seikai[i];
                if (count > 0) Console.WriteLine("Yes");
                else Console.WriteLine("No");
            }



            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 17884
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 10**6
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
X,Y = map(int,input().split())

if (X+Y)%3==0:
  _sum = (X+Y)//3
  a = Y-_sum
  b = X-_sum
  print(cmb(_sum,a,1000000007))
  
else:
  print(0)

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

int main() {
  int N, a, b, c, n;
  cin >> N;
  b = 0;
  n = N;
  
  for (int i = 0; i < 8; i++) {
    a = N % 10;
    b += a;
    N = (N - a) / 10;
  }
  
  c = n % b;
  
  if (c == 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;


int main(){
	while(1){
		int n; cin >> n;
		int m; cin >> m;
		int p; cin >> p;
		if (n == 0 and m == 0 and p == 0) break;
		
		int sum = 0;
		int atr;
		for (int i = 0; i < n; i++){
			int x; cin >> x;
			if (i == m - 1){
				atr = x;
			}
			sum += x;
		}
		if (atr == 0){
			cout << 0 << endl;
		}else{
			cout << (int)sum*(100-p)/atr << endl;
		}
	}

	
return 0;
}

Measured memory_bytes: 3052
while(True) :
    H,W=map(int,input().split())
    if H==0 and W==0 : break
    for i in range(H) :
        for j in range(W) :
            if (i+j)%2==0 :
                print("#",end="")
            else :
                print(".",end="")
        print("")
    print("")


Measured memory_bytes: 7016
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
  int n,ans=0;
  cin >> n;
  if(n % 1000 != 0){
  ans = 1000 - n % 1000 ;
  }
  cout << ans << endl; 
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int N;

int idx(int l, int r){
    if(0<=l && l<r && r<=N)
        return N*r+l;
    else
        return N*(N+1);
}

int main(){
    static ll dp[400*401+1];
    ll a[400], sum[401];
    cin >> N;
    for(int i=0;i<N;i++) cin >> a[i];
    sum[0] = 0;
    for(int i=1;i<=N;i++) sum[i] = sum[i-1] + a[i-1];

    for(int i=0;i<N;i++) dp[idx(i,i+1)] = 0;
    dp[N*(N+1)] = 1e17;

    for(int len=2;len<=N;len++){
        for(int l=0;l+len<=N;l++){
            dp[idx(l, l+len)] = 1e17;
            for(int sep=l+1;sep<l+len;sep++){
                dp[idx(l, l+len)] = min(dp[idx(l, l+len)], dp[idx(l, sep)]+dp[idx(sep, l+len)]+sum[l+len]-sum[l]);
            }
        }
    }

    cout << dp[idx(0, N)] << endl;
    
    return 0;
}

Measured memory_bytes: 1664
fun main(args: Array<String>) {
    var D = readLine()!!.toInt()
    var c = readLine()!!.split(" ").map{it.toInt()}

    val s = mutableListOf<List<Int>>()
    for(i in 0 until D) {
        s.add(readLine()!!.split(" ").map{it.toInt()})
    }

//    var t = mutableListOf<Int>()
//    for(i in 0 until D) {
//        t.add(readLine()!!.toInt())
//    }
    var last = Array(366){Array(26){0}}
    var point = Array(26){0}
    var t = Array(365){0}

    for(i in 0 until 26) {
        point[i] = s[0][i]
        for(j in 0 until 26) {
            if(i == j) continue
            point[i] -= c[i]
        }
        if(point[t[0]] < point[i]) t[0] = i
    }
    for(i in 0 until 26) {
        if(i != t[0]) last[1][t[0]]++
    }
    for(i in 1 until D) {
        for(j in 0 until 26) {
            point[j] = s[i][j]
            for(k in 0 until 26) {
                if(j == k) continue
                point[j] -= c[j] * (i + 1 - last[i][j])
            }
            if(point[t[i]] < point[j]) t[i] = j
        }
        for(j in 0 until 26) {
            if(j != t[i]) last[i + 1][j] + last[i][j]
        }
//        println(point[t[i]])
    }

    for(i in 0 until D) {
        println(t[i] + 1)
    }

}

Measured memory_bytes: 45568
#include <stdio.h>

struct Node {int p,l,r;};

struct Node T[100005];
int n,D[100005],H[100005];

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  if(T[u].p==-1)printf("sibling = -1, ");
  else if(T[T[u].p].r!=u&&T[T[u].p].r!=-1) printf("sibling = %d, ",T[T[u].p].r);
  else if(T[T[u].p].l!=u&&T[T[u].p].l!=-1) printf("sibling = %d, ",T[T[u].p].l);
  else printf("sibling = -1, ");
					     
  c=0;
  if(T[u].l!=-1) c++;
  if(T[u].r!=-1) c++;
  printf("degree = %d, ",c);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].p==-1) printf("root\n");
  else if(T[u].l==-1&&T[u].r==-1) printf("leaf\n");
  else printf("internal node\n");
}

void De(int u,int d){
  if(u==-1) return;
  D[u]=d;
  De(T[u].r, d+1);
  De(T[u].l, d+1);
}

int He(int u){
  int a=0,b=0;
  if(T[u].l!=-1) a=He(T[u].l)+1;
  if(T[u].r!=-1) b=He(T[u].r)+1;
  if(a>b) return H[u]=a;
  else return H[u]=b;
}


int main(){
  int i,j,a,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",&a,&l,&r);
    T[a].l=l;
    T[a].r=r;
    if(l!=-1)T[l].p=a;
    if(r!=-1)T[r].p=a;
    
  }
  for(i=0;i<n;i++){
    if(T[i].p==-1) root=i;
  }

  De(root,0);
  He(root);

  for(i=0;i<n;i++)print(i);

  return 0;
}



Measured memory_bytes: 2100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		int[][] matrix = new int[n+1][n+1];
		
		for(int i = 0; i <= n; i++){
			Arrays.fill(matrix[i], 0);
		}
		for(int i = 1 ; i <= n; i++){
			String[] tmpArray = br.readLine().split(" ");
			
			for(int j = 2 ; j < tmpArray.length ; j++){
				int tmp = Integer.parseInt(tmpArray[j]);
				matrix[i][tmp] = 1;
			}
		}
		
		for(int i = 1; i <= n; i++){
			for(int j = 1 ; j <= n ; j++){
				if(j == 1){
					System.out.print(matrix[i][j]);
				}
				else {
					System.out.print(" "+matrix[i][j]);
				}
			}
			System.out.println();
		}
	}

}

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

long int max(long int x, long int y){
    if(x<y)
        return y;
    return x;
}

int main(){
    long int N, W;
    cin >> N >> W;
    long int wt[N];
    long int val[N];

    for(long int i = 0; i < N; i++){
        cin >> wt[i] >> val[i];
    }
    long int dp[N+1][W+1];

    for (long int i = 0; i <= N; i++){
        for(long int j = 0; j <= W; j++){
            if (i == 0 || j == 0){
                dp[i][j] = 0;
            }
            else if (wt[i-1] <= j){
                dp[i][j] = max(
                    val[i-1] + dp[i-1][j-wt[i-1]],
                    dp[i-1][j]
                );
            }
            else
                dp[i][j] = dp[i-1][j];
        }
    }

        
    cout << dp[N][W] << endl;
}

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

bool is_tasai(std::string s) {
    bool ans = true;
    char a[26];
    for(int i = 0; i < 26; ++i) {
        a[i] = 0;
    }
    for(int i = 0; i < s.size(); ++i){
        if (a[s[i] - 97] == 1) {
            return false;
        }else{
            a[s[i] - 97] = 1;
        }
    }
    return true;
}

int main() {
    std::string s, ss;
    int length;
    bool b = true;

    std::cin >> s;

    s.push_back('a');
    length = s.size();
    if (is_tasai(s)) {
        std::cout << s << "\n";
        b = false;
    }
    while (b) {
        if (length == 0) {
            printf("-1\n");
            break;
        }
        if (s[length - 1] != 'z') {
            s[length - 1] += 1;
            if (is_tasai(s)) {
                std::cout << s << "\n";
                break;
            }
        } else {
            s.pop_back();
            length = s.size();
        }
    }
    return 0;
}

Measured memory_bytes: 256
n,m,x,y=map(int,input().split())
xl=list(map(int,input().split()))
yl=list(map(int,input().split()))
cnt=0
for i in range(x+1,y+1):
    if max(xl)<i and i<=min(yl):
        cnt+=1
if cnt == 0:
    print('War')
else:
    print('No War')

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<algorithm>
typedef long long ll;
int inf = 1000000000;
using namespace std;
int main(void) {
	ll l, r;
	cin >> l >> r;
	if (r - l >= 2019) {
		cout << 0 << endl;
		return 0;
	}
	else {
		int ans = inf;
		l = l % 2019;
		r = r % 2019;
		for (int i = l; i < r; i++) {
			for (int j = i + 1; j <= r; j++) {
				ans = min(ans, i * j % 2019);
			}
		}
		cout << ans << endl;
		return 0;
	}
}

Measured memory_bytes: 256
dic_lst=[]
lst_a=input().split()
lst_b=list(map(int,input().split()))
wd=input()
for i in range(2):
    dic_lst.append([lst_a[i],lst_b[i]])
    if dic_lst[i][0]==wd:
        dic_lst[i][1]-=1
ans=[]
for i in range(2):
    ans.append(str(dic_lst[i][1]))
print(" ".join(ans))

Measured memory_bytes: 3064
n,t = map(int,input().split())
li = [list(map(int,input().split())) for i in range(n)]

cost = 1001
flag = False

for i in range(n):
    if li[i][1] <= t:
        flag = True
        if li[i][0] < cost:
            cost = li[i][0]

if flag == True:
    print(cost)
else:
    print("TLE")


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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int x = sc.nextInt();
		int y = sc.nextInt();

		int[][] g = {
				{1, 3, 5, 7, 8, 10, 12},
				{4, 6, 9, 11},
				{2},
		};

		int gx = 0;
		out:
		for (int i = 0; i < 3; i++) {
			for (int e : g[i]) {
				if (x == e) {
					gx = i;
					break out;
				}
			}
		}

		int gy = 0;
		out:
		for (int i = 0; i < 3; i++) {
			for (int e : g[i]) {
				if (y == e) {
					gy = i;
					break out;
				}
			}
		}

		if (gx == gy) {
			pr.println("Yes");
		} else {
			pr.println("No");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

ll gcd(ll n, ll m){
  if(n%m == 0) return m;
  return gcd(m, n%m);
}

ll lcm(ll n, ll m){
  return n * m / gcd(n, m);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll K; cin >> K;
  ll ans = 0;
  for(ll i = 1; i <= K; i++){
    for(ll j = 1; j <= K; j++){
      for(ll k = 1; k <= K; k++){
        ans += gcd(gcd(i, j), k);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
n,*l=map(int,open(0).read().split())
a=l[:n];b=l[n:2*n];c=l[2*n:]
bef=a[0]
ans=b[bef-1]
for i in a[1:]:
	ans+=b[i-1]
	if i==bef+1:
		ans+=c[i-2]
	bef=i
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(int i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
  int n; string s; cin >> n >> s;
  if(n % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  if(s.substr(0, n/2) == s.substr(n/2, n)) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <deque>
using namespace std;
int main(){
    string s;
    string ans="";
    cin >> s;
    size_t size = s.length();
    for(int i=0;i<size/2;i++){
        ans = ans + "hi";
    }
    if(ans==s){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//ここから始めよう
int n,a[3333],dp[3333][3333];
int dfs(int i,int j,bool k){
    int &ret=dp[i][j];
    if(~ret)return ret;
    if(i==j){
        return ret=(k?a[i]:0);
    }
    if(k){
        return ret=max(dfs(i+1,j,0)+a[i],dfs(i,j-1,0)+a[j]);
    }else{
        return ret=min(dfs(i+1,j,1),dfs(i,j-1,1));
    }
}
signed main(){
    cin>>n;
    int sum=0;
    rep(i,0,n){
        cin>>a[i];sum+=a[i];
    }
    rep(i,0,3333)rep(j,0,3333)dp[i][j]=-1;

    cout<<dfs(0,n-1,1)-(sum-dfs(0,n-1,1))<<endl;return 0;
}

Measured memory_bytes: 87168
import string
import itertools as it
import math
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))


def sum_comb(n):
    result = []
    data = range(1,n+1)
    for i in range(len(data)):
        for j in range(i, len(data)):
            for k in range(j, len(data)):
                result.append([data[i], data[j], data[k]])
    return result

H1,M1,H2,M2 ,K = nums()
start = H1 * 60 + M1
end = H2 * 60 + M2
t = end - start
print(t - K)

Measured memory_bytes: 9988
/*
Problem Statement

There are N

people living on a number line.

The i
-th person lives at coordinate Xi

.

You are going to hold a meeting that all N

people have to attend.

The meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P
, the i-th person will spend (Xi−P)2

points of stamina to attend the meeting.

Find the minimum total points of stamina the N
people have to spend.

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

int getavg(vector<int> a, int total){

}

int main(){
	int n; cin>>n;
	vector<int> a(n);
	int ans = INT_MAX;

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

	for(int i = 1; i <= 100; i++){

		int cost =0;
		for(int j = 0; j < n; j++){
			cost += pow(a[j]-i,2);
		}
		ans = min(ans,cost);
	}
	cout<<ans;
}

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

int main()
{
  ll N,K;
  cin>>N>>K;
  vector<ll> v(N);
  loop(i,N) cin>>v[i];
  sort(v.begin(),v.end());
  ll mi=LLONG_MAX;
  loop(i,N-K+1){
    mi=min(mi,abs(v[i]-v[i+K-1]));
  }
  cout<<mi<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int h[100100];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&h[i]);
	}
	int fg=1;
	for(int i=1;i<=n;i++){
		if(h[i]>h[i-1]){
			h[i]--;
		}
		else if(h[i]<h[i-1]){
			fg=0;
			break;
		}
	}
	if(fg){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


		for(;;){

			int sum =0;

			String[] input = br.readLine().split("");

			if(input[0].equals("0")){break;}

			for(int i=0;i<input.length;i++){

				sum += Integer.parseInt(input[i]);


			}System.out.println(sum);



		}



		//??????

	}
}

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

using namespace std;

void fill(char b, char c, int n){
    for(int i=0;i<100;i++) cout << b;
    cout << endl;
    for(int j=0;j<49;j++){
        for(int i=0;i<100;i++){
            if(n>0 && j%2==1 && i%2 == 0){
                n--;
                cout << c;
            } else cout << b;
        }
        cout << endl;
    }
}

int main(void){
    int A, B;
    cin >> A >> B;
    cout << 100 << " " << 100 << endl;
    fill('#', '.', A-1);
    fill('.', '#', B-1);
    return 0;
}


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

using namespace std;

typedef long long int64;
const int64 INF = 1LL << 58;

int main()
{
  int64 A, B, N;
  cin >> A >> B >> N;

  vector< int64 > prime;
  for(int64 i = 1; i * i <= B; i++) {
    if(B % i == 0) {
      prime.push_back(i);
      if(i != B / i) prime.push_back(B / i);
    }
  }



  int64 ret = INF;
  for(int64 k : prime) {
    if(B / k > N) continue;
    int64 prev = A / k * k;
    int64 next = (A + k - 1) / k * k;
    int64 gcd1 = __gcd(prev, B);
    int64 gcd2 = __gcd(next, B);
    if(prev > 0 && B / gcd1 <= N && prev / gcd1 <= N) ret = min(ret, llabs(prev - A));
    if(next > 0 && B / gcd2 <= N && next / gcd2 <= N) ret = min(ret, llabs(next - A));
  }
  for(int64 k = B; k / B <= N; k += B) {
    ret = min(ret, llabs(k - A));
  }
  cout << ret << endl;
}

Measured memory_bytes: 3156
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int y = Integer.parseInt(a+b);
		double r = (Math.sqrt(y));
	if(r-(int)r==0) {
		System.out.println("Yes");
	}
	else { 
		System.out.println("No");
		}
    }
}





Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define LL long long
#define ULL unsigned long long
#define P 1000000007
#define H 10007
#define mod(a,b) a-a/b*b
#define debug(x) cerr<<#x<<"="<<x<<endl
using namespace std;

int a,b,c;
bool f[110];

int main()
{
	for(int i=1;i<=100;i++)f[i]=0;
	cin>>a>>b>>c;
	for(int i=1;;i++)
	{
		if((a*i)%b==c)
		{
			puts("YES");
			return 0;
		}
		if(f[(a*i)%b]==1)
		{
			puts("NO");
			return 0;
		}
		f[(a*i)%b]=1;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double t,m,n,i,j,sum=0;
    vector<long long int> ara;
    string str1,str;
    cin>>m>>n;

    for(i=0;i<n;i++)
    {
        cin>>t;
        sum+=t;
    }
    if(sum>m)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<fixed<<setprecision(0)<<m-sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ans = max(a*b,c*d);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////
class UnionFind {
public:
	int cNum;//要素数
	vector<int> parent;
	vector<int> count;
	vector< vector<int> > GList;
	UnionFind(int n) {
		cNum = n;
		parent = vector<int>(n);
		count = vector<int>(n, 1);
		GList.resize(n);
		for (int i = 0; i < n; ++i) {
			parent[i] = i;
			GList[i].push_back(i);
		}
	}
	int find(int x) {
		if (parent[x] == x) { return x; }
		return parent[x] = find(parent[x]);
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int Count(int x) { return count[find(x)]; }
	void add(int x, int y) {//union
		x = find(x);
		y = find(y);
		if (x == y)return;
		parent[x] = y;

		count[y] += count[x];
		if (GList[y].size() < GList[x].size()) {
			swap(GList[x], GList[y]);
		}
		GList[y].insert(GList[y].end(),
			GList[x].begin(), GList[x].end());
	}
};

void solve() {
	int N, M;
	cin >> N >> M;
	UnionFind uf(N);
	for (int i = 0; i < M; ++i) {
		int x, y, z;
		cin >> x >> y >> z;
		x--; y--;
		uf.add(x, y);
	}
	vector<bool> use(N, false);
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int ter = uf.find(i);
		if (use[ter] == false) {
			++ans;
			use[ter] = true;
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 10112