akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n; cin >> n;
    vector<ll> ans(n+1, 0);
    frep(x, 1, 100) {
        frep(y, 1, 100) {
            frep(z, 1, 100) {
                ll tmp = x*x + y*y + z*z + x*y + y*z + z*x;
                if(1 <= tmp && tmp <= n) {
                    ans[tmp]++;
                }
            }
        }
    }
    frep(i, 1, n) {
        cout << ans[i] << endl;
    }
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3584
n,x=map(int,raw_input().split())
if x in [1,2*n-1]:
    print "No"
    exit(0)
A=range(1,2*n)
if x<n:
    A[x-2:min(x+2,n-2)],A[n-2:n+2] = A[max(n-2,x+2):n+2],A[x-2:x+2]
    if n>2: A[n-2],A[n-1:n+1] = A[n],A[n-2:n]
if n<x:
    A[n-3:n+1],A[max(x-3,n+1):x+1] = A[x-3:x+1],A[n-3:min(n+1,x-3)]
    if n>2: A[n-2:n],A[n] = A[n-1:n+1],A[n-2]
print "\n".join(["Yes"]+map(str, A))

Measured memory_bytes: 21636
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    cin>>a>>b>>c;
    if(c<=a){
        cout<<"0"<<endl;
        return 0;
    }
    d = c-a;
    if(d>b){
        cout<<"NA"<<endl;
        return 0;
    }
    cout<<d<<endl;
    
}



Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int a[3]={};
    for(int z=0;z<3;z++){
    cin>>a[z];
    }
    sort(a, a+3);
    cout<<a[0]<<' '<<a[1]<<' '<<a[2]<<endl;
}



Measured memory_bytes: 3100
import math
tmp = 0
big_dice = 0
a,b = map(int, input().split())
log2_b = math.log2(b)
if a > b:
  c = b
  big_dice = (a - b) / a
else:
  c = a
for i in range(1, c + 1):
  log2_i = math.log2(i)
  n = math.ceil(log2_b - log2_i)
  tmp = tmp + 0.5**n
print(tmp / a + big_dice)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
  
		int result = 0;

		for (int fiveHundreds = a ; fiveHundreds >= 0 ; fiveHundreds--) {
			int remaining = x - fiveHundreds * 500;
			if (remaining >= 0) {
				for (int oneHundreds = b ; oneHundreds >= 0 ; oneHundreds--) {
					int remaining2 = remaining - oneHundreds * 100;
					if (remaining2 >= 0) {
						for (int fifties = c ; fifties >= 0 ; fifties--) {
							if (remaining2 == fifties * 50) {
								result++;
							}
						}
					}
				}
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	int a, b, c, d, e, f, i, j, k, l, water, suger, ans1=100, ans2=0;
	cin>>a>>b>>c>>d>>e>>f;
	a*=100;
	b*=100;
	for(i=0; a*i<=f; i++){
		for(j=0; a*i+b*j<=f; j++){
			for(k=0; a*i+b*j+c*k<=f; k++){
				for(l=0; a*i+b*j+c*k+d*l<=f; l++){
					water=a*i+b*j;
					suger=c*k+d*l;
					if(100*suger<=e*water && suger*(ans1)>=ans2*(water+suger)){
						ans1=water+suger;
						ans2=suger;
					}
				}
			}
		}
	}
	cout<<ans1<<" "<<ans2<<endl;
	return 0;
}

Measured memory_bytes: 256
import           Control.Monad
import           Data.List

main :: IO ()
main = do
  [m, _] <- map read . words <$> getLine
  d      <- map toInt . words <$> getLine
  print $ minimum $ filter
    (\x -> x >= m && null (findIndices (`elem` show d) (show x)))
    [ 10000 * m1 + 1000 * m2 + 100 * m3 + 10 * m4 + m5
    | m1 <- [0 .. 9]
    , m2 <- [0 .. 9]
    , m3 <- [0 .. 9]
    , m4 <- [0 .. 9]
    , m5 <- [0 .. 9]
    ]
  where toInt s = read s :: Int


Measured memory_bytes: 2428
#include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <ratio>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T, class U> using p = pair<T, U>;

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REP1(i, n) for(int i = 1; i <= n; ++i)

template<class T> T read() { T x{}; cin >> x; return x; }
template<class T> v<T> read(int N){ v<T> x(N); REP(i, N) cin >> x[i]; return x; }

template<class T>
void write(const T &x){ cout << x << endl; }
void write(double x){ printf("%.15f\n", x); }

const ull MOD = 1000'000'007;

int main(){
    ll N, K;
    cin >> N >> K;
    auto H = read<ll>(N);
    sort(H.begin(), H.end());
    ll sum = 0;
    for(ll i = 0; i < N - K; ++i){
        sum += H[i];
    }
    cout << sum << endl;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define LL long long
#define inf 0x3fffffffffffffff
using namespace std;

int a,b,c,d;

bool check(int x,int y)
{
    return abs(x-y)<=d;
}

int main()
{
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if (check(a,c)||check(a,b)&&check(b,c)) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   unik(v)       v.erase(unique(all(v)),v.end())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%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;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll w=0;
    for(auto x:s){
        if(x=='W')
            w++;
    }
    ll r=n-w;
    if(!w){
        cout << 0 <<"\n";
        return;
    }
    ll kk=0;
    for(ll i=0;i<r;i++){
        if(s[i]=='W')
            kk++;
    }
    cout << kk <<"\n";
}
int main()
{
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    unordered_map<string, int> S;
    REP(i, 0, N) {
        string s; cin >> s;
        sort(ALL(s));
        S[s]++;
    }

    ll ans = 0;
    for (auto s : S) {
        ans += (ll)s.second * (s.second - 1) / 2;
    }

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

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

typedef long long ll;
const int MAXN = 1e5+100;
ll Left[MAXN];
ll MaxLeft[MAXN];
ll Right[MAXN];
ll MaxRight[MAXN];
ll x[MAXN],v[MAXN];

int main()
{
    ios::sync_with_stdio(false);
    int N;
    ll C;
    cin>>N>>C;
    for(int i=1;i<=N;++i)   cin>>x[i]>>v[i];
    x[N+1]=C;
    for(int i=1;i<=N;++i)
    {
        MaxLeft[i]=Left[i]=Left[i-1]+v[i]-(x[i]-x[i-1]);
        MaxRight[i]=Right[i]=Right[i-1]+v[N-i+1]-(x[N-i+2]-x[N-i+1]);
    }
    for(int i=2;i<=N;++i)
    {
        MaxLeft[i]=max(MaxLeft[i-1],MaxLeft[i]);
        MaxRight[i]=max(MaxRight[i-1],MaxRight[i]);
    }
    ll ans=0;
    for(int i=1;i<=N;++i)
    {
        ans=max(ans,Left[i]);
        ans=max(ans,Right[i]);
        ans=max(ans,Left[i]-x[i]+MaxRight[N-i]);
        ans=max(ans,Right[i]-(C-x[N-i+1])+MaxLeft[N-i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<string.h>

int main(void){
	char str[128];
	int l,i,count=0;
	scanf("%s",str);
	l=strlen(str);
	for(i=0;i<=(l-1)/2;i++){
		if(str[i]!=str[l-i-1]){
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;


int main(){
    ll n;cin>>n;
    ll a[100010],b[100010];
    rep(i,0,n)cin>>a[i]>>b[i];
    vector<pair<ll,ll> > c(n);
    rep(i,0,n){c.at(i).first=a[i]+b[i];c.at(i).second=i;}
    sort(c.begin(),c.end(),greater<>());
    ll an=0;
    rep(i,0,n){
        if(i%2==0){
            an+=a[c.at(i).second];
        }
        else{
            an-=b[c.at(i).second];
        }
    }
    cout<<an<<endl;
}







Measured memory_bytes: 3328
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int age;
	int than_ten, ten, twen, thir, four, fif, six;
	
	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		than_ten = ten = twen = thir = four = fif = six = 0;
		
		for (i = 0; i < n; i++){
			scanf("%d", &age);
			if (age >= 0 && age <= 9){
				than_ten++;
			}
			else if (age <= 19){
				ten++;
			}
			else if (age <= 29){
				twen++;
			}
			else if (age <= 39){
				thir++;
			}
			else if (age <= 49){
				four++;
			}
			else if (age <= 59){
				fif++;
			}
			else if (age >= 60){
				six++;
			}
		}
		
		printf("%d\n%d\n%d\n%d\n%d\n%d\n%d\n", than_ten, ten, twen, thir, four, fif, six);
		
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <stdio.h>
#define size 4000000
char g[1009][1009];
int visit[1009][1009];
int N, M, ans;
int start, end;
int di[4] = {-1, 1, 0, 0};
int dj[4] = { 0, 0, -1, 1 };
struct store{
	int x, y;
	int cost;
}queue[size];

void init_bfs(){
	start = end = 0;
}

void insert(int si, int sj, int swt){
	queue[end%size].x = si;
	queue[end%size].y = sj;
	queue[end%size].cost = swt;
	end++;
}

void front(int *f, int *fk, int *fg){
	*f = queue[start%size].x;
	*fk = queue[start%size].y;
	*fg = queue[start%size].cost;
	start++;
}

void bfs(){
	int i, j, wt, d, Ni, Nj;
	while (start < end){
		front(&i, &j, &wt);
		if (wt > ans){
			ans = wt;
		}
		for (d = 0; d < 4; d++){
			Ni = i + di[d];
			Nj = j + dj[d];
			if (Ni < 0 || Ni >= N || Nj < 0 || Nj >= M) continue;
			//printf("%d %d\n", Ni, Nj);
			if (visit[Ni][Nj] == 0){
				insert(Ni, Nj, wt + 1);
				visit[Ni][Nj] = 1;
			}
		}
	}
}

int main()
{
	//freopen("input.txt", "r", stdin);
	int i, j;
	ans = -1;
	scanf("%d %d", &N, &M);
	init_bfs();
	for (i = 0; i < N; i++){
		for (j = 0; j < M; j++){
			visit[i][j] = 0;
		}
	}

	for (i = 0; i < N; i++){
		getchar();
		for (j = 0; j < M; j++){
			scanf("%c", &g[i][j]);
			if (g[i][j] == '#'){
				insert(i, j, 0);
				visit[i][j] = 1;
			}
		}
	}
	bfs();
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 19200
# お約束
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1
def parse(*args):
    # (tuple(map(int, input().split())) for _ in range(N))
    return tuple(p(v) for p, v in zip(args, input().split()))

# Union-Find木
class uft:
    def __init__(self, n):
        self.height = [1] * n
        self.group = [-1] * n
    def root(self, v):
        if self.group[v] < 0:
            return v
        self.group[v] = self.root(self.group[v])
        return self.group[v]
    def size(self, v):
        return - self.group[self.root(v)]
    def equal(self, v1, v2):
        v1, v2 = self.root(v1), self.root(v2)
        return v1 == v2
    def merge(self, v1, v2):
        v1, v2 = self.root(v1), self.root(v2)
        if self.equal(v1, v2):
            return False
        if self.height[v1] < self.height[v2]:
            self.group[v2] += self.group[v1]
            self.group[v1] = v2
            self.height[v2] = max(self.height[v1] + 1, self.height[v2])
        else:
            self.group[v1] += self.group[v2]
            self.group[v2] = v1
            self.height[v1] = max(self.height[v1], self.height[v2] + 1)
        return True

# エントリーポイント
def main():
    N, M = parse(int, int)
    AB = [tuple(map(int, input().split())) for _ in range(M)]

    fuben = N * (N - 1) // 2
    g, rs = uft(N), [fuben]
    for a, b in reversed(AB):
        a, b = a - 1, b - 1
        if not g.equal(a, b):
            fuben -= g.size(a) * g.size(b)
            g.merge(a, b)
        rs += [fuben]
    for r in reversed(rs[:-1]):
        print(r)

main()


Measured memory_bytes: 25352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  while(true){
    int n;
    cin >> n;
    if(n == 0)return 0;
    vector<int>cnt(10);
    rep(i,n){
      int tmp;
      cin >> tmp;
      cnt[tmp]++;
    }
    rep(i,10){
      if(cnt[i] == 0)cout << "-" << endl;
      else{
        rep(j,cnt[i])cout << "*";
        cout << endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define ll long long

int main(void){
    int k , x;

    cin >> k >> x;

    if(k*500 < x){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;

int main()

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

    ll n, ans = 1e12;

    cin >> n;

    for (ll i = 1; i*i <= n; i++) {

        if (n%i == 0) {

            ans = min(ans, (n/i)+i-2);
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 384
fun main() {
    // 文字列
    var n = readLine()!!.toInt()
//    val x: String = readLine()!!
    // 数値
//    val int =readLine()!!.toInt()
    // 行
//    val list = readLine()!!.split(" ").map (String::toInt )
//    val (a,b) = readLine()!!.split(" ").map(String::toInt)

    if (n<600){
        print(8)
    }else if (n<800){
        print(7)
    }else if (n<1000){
        print(6)
    }else if (n<1200){
        print(5)
    }else if (n<1400){
        print(4)
    }else if (n<1600){
        print(3)
    }else if (n<1800){
        print(2)
    }else if (n<2000){
        print(1)
    }

}


Measured memory_bytes: 34544
#include<bits/stdc++.h>
#define pi acos(-1.0)
using namespace std;

const int maxn = 3010;
double mina[maxn], maxa[maxn];

double deg2rad(double deg) { return deg * pi * 180; }

int main() {
  #ifdef LOCAL
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
  #endif

  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if ((a + b) & 1) cout << "IMPOSSIBLE\n";
  else cout << (a + b) / 2;
  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

# k=0 -> n*n
if k == 0:
	print(n * n)
	exit()

cnt = 0
for b in range(1, n + 1):
	r_cnt = max(0, b - k)
	cnt += (n // b) * r_cnt
	if n % b >= k:
		cnt += (n % b) - k + 1

print(cnt)


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

using namespace std;

string s;

int main(void)
{
	cin >> s;
	int ans = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == '+') ans++;
		else ans--;
	}
	cout << ans << endl;
	return 0;
}

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

int a,t,now;
long long ans;

int main(){
	cin>>a;
	for (int i=1;i<=a;i++)
	  for (int j=1;j<=a;j++)
	    for (int k=1;k<=a;k++){
	    	t=min(min(i,j),k);
	    	now=0;
	    	for (int n=1;n<=t;n++) {
	    	  if (i%n==0 && j%n==0 && k%n==0) now=n;
			}
			ans+=now;
			//cout<<now<<"\n";
		}	
cout<<ans<<"\n";	
} 
 

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int a[60], b[60], c[60], d[60];

int Q;

long num(int N, int M, int l, vector<int> v){
    if(N == l){
        long ans = 0;
        for(int i=0; i<Q; i++){
            if(v[b[i]] - v[a[i]] == c[i]) ans += d[i];
            //cout << "abcd = " << b[i] << a[i] << c[i] << d[i] << endl;
        }
        return ans;
    }
    if(l == 0){
       long ans = 0;
        for(int i=1; i<=M; i++){
            vector<int> temp = v;
            temp.push_back(i);
            ans = max(ans, num(N, M, l+1, temp));
        }
        return ans; 
    }
    else{
        long ans = 0;
        for(int i=v[l-1]; i<=M; i++){
            vector<int> temp = v;
            temp.push_back(i);
            ans = max(ans, num(N, M, l+1, temp));
        }
        return ans;
    }
}

int main(){
    int N, M;
    cin >> N >> M >> Q;
    for(int i=0; i<Q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }    
    long ans = 0;
    vector<int> ini;
    cout << num(N, M, 0, ini) << endl;
    return 0;
}

Measured memory_bytes: 3632
use std::io::Read;

fn main() {
    let mut buff = String::new();
    std::io::stdin().read_to_string(&mut buff).unwrap();
    let mut iter = buff.split_whitespace();

    let n: i32 = iter.next().unwrap().parse().unwrap();

    let mut sum: i32 = 0;
    let mut m: i32 = n;

    while m != 0 {
        sum += m % 10;
        m /= 10;
    }

    if n % sum == 0 {
        println!("Yes");
    } else {
        println!("No");
    }

    ()
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <climits>
#include <stack>
#include <string>
#include <random>
#include<set>

int main() {
	std::string target;
	int n;
	std::cin >> target >> n;
	std::vector<std::string> rings(n);
	for (auto &ring : rings) {
		std::cin >> ring;
	}
	std::cout << std::count_if(rings.begin(), rings.end(), [&target](const std::string &ring) {
		bool res = false;
		for (auto i = 0; i < ring.size(); ++i) {
			bool temp = true;
			for (auto j = 0; j < target.size(); ++j){
				temp &= ring[(i + j) % ring.size()] == target[j];
			}
			res |= temp;
		}
		return res;
	}) << std::endl;
}
/*



*/



Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
 
 const int nax = 100100;
int fre[nax];
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n; cin>>n;
    vl v(n);
    ll sum  = 0;
    for(int i= 0;i<n;++i){
        cin>>v[i];
        fre[v[i]]++;
        sum += v[i];
    }
    int q; cin>>q;
    while(q--){
        ll b,c; cin>>b>>c;
        ll val = fre[b];
        sum -= (val*b);
        sum += (val*c);
        fre[b] = 0;
        fre[c] += val;
        cout << sum << "\n";
    }
   
   
    return 0;
}

//Химаншу

Measured memory_bytes: 4504
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
const ld eps = 1e-4;

int f(int x,int y){
    if(x > y) swap(x,y);
    int res = y-x;
    return res * (res-1) / 2;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d; cin >> d;
    int c[26];
    REP(i,26) cin >> c[i];
    int lsum = 0;
    REP(i,26) lsum += c[i];
    int v[d][26];
    REP(i,d)REP(j,26) cin >> v[i][j];
    V<> sol;
    V<> loss(26,0);
    V<set<int>> pla(26);
    REP(i,26) pla[i].insert(-1);
	REP(i,26) pla[i].insert(366);
    REP(i,d){
        V<pair<ld,ll>> score(26,{0.0,0});
        REP(j,26) score[j] = {v[i][j] + loss[j] + c[j] * eps, j};
        sort(rall(score));
        int r = score[0].second;
        sol.pb(r);
        pla[r].insert(i);
        REP(j,26){
            if(j == r) loss[j] = 0;
            else loss[j] += c[j];
        }
    }
    int Q = 5000000;
    random_device rnd;
  int sco = 0;
    while(Q--){
        int newi = rnd() % 365;
        int newsol = rnd() % 26;
        int ev = 0;
        if(sol[newi] == newsol) continue;
     /* cout << "newi="<<newi<<" newsol="<<newsol<<endl;
      cout << "ev+=" << *pla[newsol].lower_bound(newi) - newi <<"*"<<c[newsol] << '\n';
       cout << "ev-=" << (*pla[sol[newi]].upper_bound(newi) - newi)<<"*"<<c[sol[newi]] << endl;*/
        auto itr = pla[newsol].lower_bound(newi);
        int aft = *itr;
        itr--;
        int bef = *itr;
        ev += (f(aft,bef) - f(aft,newi) - f(newi,bef)) * c[newsol];
        itr = pla[sol[newi]].upper_bound(newi);
        aft = *itr;
        itr--;
        itr--;
        bef = *itr;
        ev -= (f(aft,bef) - f(aft,newi) - f(newi,bef)) * c[sol[newi]];
        if(ev > 0){
            pla[sol[newi]].erase(newi);
            pla[newsol].insert(newi);
            sol[newi] = newsol;
        }
    }
    REP(i,d) cout << sol[i] + 1 << endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    long long N;
    cin>>N;
    if(N==1){
        cout << 0 << endl;
        return 0;
    }
    if(N==0){
        cout << 0 << endl;
        return 0;
    }
    long long tmp=N;
    map<long long,long long> divcnt;//素因数、個数
    bool over=false;
        for(long long i=2;i<10000000;i++){
            if(over){
                break;
            }
            bool flag=true;
            while(flag){
                if(tmp%i==0){
                    if(divcnt.count(i)){
                        divcnt[i]++;
                    }else{
                        divcnt[i]=1;
                    }
                    tmp=tmp/i;
                    if(tmp==1){
                        over=true;
                    }
                }else{
                    flag=false;
                }
            }
        }
        if(tmp!=1){
        if(divcnt.count(tmp)){
            divcnt[tmp]++;
        }else{
        divcnt[tmp]=1;
        }
        }
    int ans =0;
    // cout << divcnt[2] << divcnt[3] << endl;
    //mapに素数の個数が入った
    for (auto iter = divcnt.begin(); iter != divcnt.end(); iter++) {
        // first: key, second: value
        long long  k =iter->first;
        // cout << "koko" << k << endl;
        for(int j=1;j<100;j++){
            //  cout <<"soko"<< j << "i" <<divcnt[k] << endl;
             
            if(j<=divcnt[k]){
                // cout << "asoko" << endl;
                ans++;
                divcnt[k]=divcnt[k]-j;
            }

        }
    }

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

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main() {
    int n;
    cin>>n;
    cout<<n*800-n/15*200<<endl;
}


Measured memory_bytes: 256
while True:
    try:
        a, b, n = map(int, input().split())
        c = str(a/b)[str(a/b).find(".") + 1:]
        ans = 0
        for i in range(len(c)):
            ans += int(c[i])
            if i + 1 == n:
                break
        print(ans)
    except:
        break



Measured memory_bytes: 5604
#include <iostream>
#include <string>
#include <iomanip>
#include <stdlib.h>
using namespace std;
int main(){
    int h,w;
	while(true){
	cin>>h>>w;
	if(h==0&&w==0)
		break;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)
			cout<<"#";
		cout<<endl;
	}
	cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;
constexpr int64_t kMod1 = 1000000007LL;
constexpr int64_t kMod2 = 998244353LL;
constexpr int64_t kMod3 = 3571L;

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

  constexpr int64_t kN = 26;
  int64_t D;
  cin >> D;
  vector<int64_t> C(kN + 1, 0);
  for (int64_t c = 1; c <= kN; ++c) {
    cin >> C[c];
  }
  vector<vector<int64_t>> S(D + 1, vector<int64_t>(kN + 1));
  for (int64_t d = 1; d <= D; ++d) {
    for (int64_t c = 1; c <= kN; ++c) {
      cin >> S[d][c];
    }
  }
  vector<vector<int64_t>> last(D + 1, vector<int64_t>(kN + 1, 0));
  vector<int64_t> contests(D + 1);
  for (int64_t d = 1; d <= D; ++d) {
    cin >> contests[d];
  }

  auto Score = [&](const int64_t day) -> int64_t {
    int64_t score = 0;
    for (int64_t d = 1; d <= day; ++d) {
      last[d] = last[d - 1];
      last[d][contests[d]] = d;
      score += S[d][contests[d]];
      for (int64_t c = 1; c <= kN; ++c) {
        score -= C[c] * (d - last[d][c]);
      }
    }
    return score;
  };

  auto OutputResults = [&]() {
    for (int64_t d = 1; d <= D; ++d) {
      cout << contests[d] << endl;
    }
  };

  for (int64_t d = 1; d <= D; ++d) {
    int64_t best_score = INT64_MIN;
    int64_t best_conte = -1;
    for (int64_t c = 1; c <= kN; ++c) {
      contests[d] = c;
      int64_t temp_score = Score(d);
      if (temp_score > best_score) {
        best_score = temp_score;
        best_conte = c;
      }
    }
    contests[d] = best_conte;
  }

  int64_t prev_score = Score(D);
  constexpr int64_t kIgnoreBunbo = 5;
  constexpr int64_t kIgnoreBunshi = 0;
  constexpr int64_t kMaxConsecutiveWorse = 3;

  vector<int64_t> best_contests;
  int64_t best_score = INT64_MIN;
  int64_t consecutive_worse = 0;
  vector<int64_t> better_contests;
  for (int64_t i = 0; i < 130000; ++i) {
    const int64_t day_candidate = (rand() % D) + 1;
    const int64_t original_contest = contests[day_candidate];
    const int64_t contest_candidate = (rand() % kN) + 1;
    contests[day_candidate] = contest_candidate;
    const int64_t temp_score = Score(D);
    if (temp_score > prev_score) {
      // KEEP
      consecutive_worse = 0;
      better_contests = contests;
      if (temp_score > best_score) {
        best_score = temp_score;
        best_contests = contests;
      }
    } else if ((rand() % kIgnoreBunbo) <= kIgnoreBunshi && temp_score > prev_score * 0.97 &&
               consecutive_worse <= kMaxConsecutiveWorse) {
      // KEEP
      ++consecutive_worse;
    } else {
      contests[day_candidate] = original_contest;
    }
    if (temp_score < best_score * 0.9) {
      contests = better_contests;
    }
    if (temp_score < best_score * 0.5) {
      contests = best_contests;
    }
  }

  contests = best_contests;
  OutputResults();
  return 0;
}


Measured memory_bytes: 3848
def main():
    import sys
    X, N = map(int, sys.stdin.readline().split())
    P = list(map(int, sys.stdin.readline().split()))
    
    i = 0
    while True:
        if X-i in P:
            pass
        else:
            print(X-i)
            break
        if X +i in P:
            pass
        else:
            print(X+i)
            break
        i+=1
    


if __name__=='__main__':
    main()

Measured memory_bytes: 9188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author vikas.k
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();

            int[] a = new int[n + 1];
            int sum = 0;
            for (int i = 1; i <= n; i++) {
                a[i] = in.nextInt();
                sum += a[i];
            }

            if (sum % 10 != 0) {
                out.print(sum);
                return;
            }

            Arrays.sort(a, 1, n + 1);
            for (int i = 1; i <= n; i++) {
                if (a[i] % 10 != 0) {
                    sum -= a[i];
                    out.print(sum);
                    return;
                }
            }
            out.print(0);
        }

    }

    static class FastScanner {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;

        public FastScanner(InputStream inputStream) {
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  vector<bool> ok(100000);
  for (int i = 0; i * i < 100000; i++) ok[i * i] = true;
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  for (int i = 0; i < n; i++) for (int j = 0; j < d; j++) cin >> x[i][j];
  ll ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      ll sum = 0;
      for (int k = 0; k < d; k++) sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      if (ok[sum]) ans++;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long M = sc.nextLong();
		String S = sc.next();
		String T = sc.next();
		
		int a = 0;
		
		do {
			a = 0;
			for(long i = 2; i <= N; i++) {
				if(N % i == 0 && M % i == 0) {
					N /= i;
					M /= i;
					a = 1;
					break;
				}
			}
		} while(a == 1);
		
		long min = Math.min(S.length(), T.length());
		
		for(long i = 1; i <= min; i++) {
			if(N * i > S.length() - 1 || M * i > T.length() - 1) {
				break;
			}
			if(S.charAt((int)N * (int)i) != T.charAt((int)M * (int)i)) {
				System.out.println(-1);
				return;
			}
		}
		
		if(S.charAt(0) != T.charAt(0)) {
			System.out.println(-1);
			return;
		}
		
		long max = Math.max(S.length(), T.length());
		for(long i = 1; i <= min; i++) {
			if(max * i % min == 0) {
				System.out.println(max * i);
				break;
			}
		}
	}
}


Measured memory_bytes: 26832
//２つの整数 a, b を読み込んで、a と b の大小関係を出力するプログラムを作成して下さい。
#include <iostream>
using namespace std;

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

    if (a == b)
    {
        cout << "a == b" << endl;
    }
    else if (a > b)
    {
        cout << "a > b" << endl;
    }
    else
    {
        cout << "a < b" << endl;
    }

    return 0;
}


Measured memory_bytes: 3120
N,M,X=map(int,input().split())
A=list(map(int,input().split()))

box = [0]*(N+1)

for i in range(M):
    box[A[i]] = 1

cost_l = 0
for i in range(X+1):
    cost_l += box[i]
cost_r = 0
for i in range(X,N+1):
    cost_r += box[i]

print(min(cost_l,cost_r))

Measured memory_bytes: 61792
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.ReadLine();
        }

        public void Solve(ConsoleInput cin)
        {
            int size = cin.ReadInt;
            int[] list = cin.ReadIntArray(size);

            Array.Sort(list);
            int bef = -1;
            int cnt = 0;
            for (int i = 0; i < list.Length; i++)
            {
                if (list[i] != bef) cnt++;
                bef = list[i];
            }

            Console.WriteLine(cnt);
        }


    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long num) { var ret = new string[num]; for (long i = 0; i < num; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long num) { var ret = new int[num]; for (long i = 0; i < num; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long num) { var ret = new long[num]; for (long i = 0; i < num; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))

    a.sort()

    print(sum(a[n::2]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 114260
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

bool change[100010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    string S; cin >> S;
    rep(i, S.length()) {
        if (S[i] == '1' && S[i + 1] == '0') change[i + 1] = true;
    }
    // rep(i, (int)S.length()) cout << change[i];
    // cout << endl;
    int right = 0;
    int cnt = 0;
    int ans = 0;
    for(int left = 0; left < N; left++) {
        if(left > 0 && S[left - 1] == '0') cnt--;
        if (S[left] == '0') cnt++;
        while(right + 1 < N && cnt + change[right + 1] <= K) {
            right++;
            if (change[right]) cnt++;
        }
        //cout << left << " " << right << " " << cnt << endl;
        ans = max(ans, right - left + 1);
        if(right == left) right++;
        if(left + 1 < N && change[left + 1]) cnt--;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
//int dx[] = {0,1,0,-1};
//int dy[] = {-1,0,1,0};

//   cout<<std::setprecision(12)<<

int main()
{
    int i,j,k,l,m,n,sum=0;

    cin >> n >> m;
   int ar[n+10];

   for(i=0;i<n;i++)cin>>ar[i],sum+=ar[i];
   int cnt = 0;
   for(i=0;i<n;i++)
   {
       if(ar[i]*(4*m) >= sum)cnt++;
   }
   if(cnt >= m)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	// a+b==aXORb => aとbで同じ位のbitが立ってることがない
	// x := 「a+b=L」となるものの個数
	// y := 「a+b<L」となるものの確定している個数
	//先頭だけ見た時x=2,y=1
	ll x=2; // 先頭は'1'なのでaかbのどちらかが1だから2通り
	ll y=1; // どっちも0の1パターン
	ll MOD=1e9+7;
	string s;
	cin >> s;
	for(int i=1;i<s.size();i++){
		if(s[i]=='0'){
			//もうL未満になることが確定しているものに関しては、
			//a,bどちらかのibit目を1にしてもOK
			//どっちも0もOK => 3パターン
			(y*=3)%=MOD;
 
		}else{
			//s[i]==0の時と同様にy*=3
			//追加でi-1bit目までで「a+b=L」になる個数を足す
			//ibit目でL未満が確定された分(ibit目がどっちも0になるもの)
			y = (y*3+x)%MOD;
 
			//「a+b=L」になるにはa,bどちらかのibit目を
			//1にする必要がある。2パターン
			(x *= 2)%=MOD;
		}
	}
	//(「a+b=L」となるものの個数)+(「a+b<L」となるものの個数)
	cout << (x+y) % MOD << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	long long a,b,c;
	int n,p;
	cin>>n;
	a=2;
	b=1;
	if(n==0){cout<<a;return 0;}
	if(n==1){cout<<b;return 0;}
	c=a+b;
	for(p=3;p<=n;p++){
		a=b;
		b=c;
		c=a+b;
	} 
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int N, A[100], i, j, k, v;

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

  for( i = 1; i <= N - 1; i++){

    for(k = 0; k <= N - 2; k++){
      printf("%d ", A[k]);
    }
    printf("%d\n", A[N-1]);
    v = A[i];
    j = i - 1;
    while( j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
  }

    for(k = 0; k <= N - 2; k++){
      printf("%d ", A[k]);
    }
    printf("%d\n", A[N-1]);

  return 0;
}

Measured memory_bytes: 600
#include<iostream>
using namespace std;
int main(){
  int n,cnt=0,num[100000]={},a,idl=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    num[--a]++;
  }
  for(int i=0;i<100000;i++){
    if(num[i]>=2){
      if(num[i]%2==1){
        cnt+=num[i]/2;
      }else{
        if(idl>=1){
          cnt += num[i]/2 -1;
          idl--;
        }else{
          cnt += num[i]/2;
          idl++;
        }
      }
    }
  }
  cout << n-2*cnt << endl;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import datetime

s = str(input())

year = int(s[:4])
month = int(s[5:7])
day = int(s[8:10])

a = datetime.date(year, month, day)
b = datetime.date(2019, 4, 30)

if a <= b:
    print("Heisei")
else:
    print("TBD")


Measured memory_bytes: 3312
n,m,x=gets.split.map &:to_i
h={}
a=[]
n.times do
  a<< gets.split.map(&:to_i)
end
a=a.sort{|y,z|y[2]<=>z[2]}
n.times do |i|
  g=a[i][0]*x-a[i][1]*m
  hh=h.dup
  h.each do |e,v|
    if hh[e+g]
      hh[e+g]=a[i][2]+v if hh[e+g]>a[i][2]+v
    else
      hh[e+g]=a[i][2]+v
    end
  end
  hh[g]=a[i][2] if !hh[g]||hh[g]>a[i][2]
  h=hh.dup
end
puts h[0] ? h[0]:-1

Measured memory_bytes: 7164
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); long sum = 0;
		long[] A = new long[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
			sum += A[i];
		}
		long ans = Long.MAX_VALUE, sn_sum = 0;
		for(int i = 0; i < N - 1; i++) {
			sn_sum += A[i];
			ans = Math.min(ans, Math.abs(sn_sum - (sum - sn_sum)));
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 84548
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int n;
    cin >> n;
    vector<pair<string, int> > v;
    rep(i, n){
        string str;
        int a;
        cin >> str >> a;
        v.push_back(make_pair(str, a));
    }
    string x;
    cin >> x;
    ll ans = 0;
    bool ok = false;
    for(auto f: v){
        //cout << f.first << endl;
        if(!ok){
            if(f.first == x){
                ok = true;
            }
            continue;
        }
        ans += f.second;
    }

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


Measured memory_bytes: 256
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    h, w, d = read_int_list()
    a = [[0] * w for _ in range(h)]
    if d % 2 == 1:
        for i in range(h):
            for j in range(w):
                a[i][j] = (i + j) % 2
    else:
        for i in range(h):
            for j in range(w):
                x = (i + j) // d
                y = (i - j) // d
                if x % 2 == 1:
                    a[i][j] += 1
                if y % 2 == 1:
                    a[i][j] += 2

    s = 'RGBY'
    for i in range(h):
        for j in range(w):
            print(s[a[i][j]], end='')
        print()


main()


Measured memory_bytes: 8692
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N,M,C;
    cin >> N >> M >> C;
    int B[M];
    for(int i = 0; i < M; i++)
    {
        cin >> B[i];
    }
    
    int A[N][M];
    int AC = 0;
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < M; j++)
        {
            cin >> A[i][j];
        }
        
    }
    for(int i = 0; i < N; i++)
    {
        int sum = C;
        for(int j = 0; j < M; j++)
        {
            sum += B[j] * A[i][j];
        }
        if(sum > 0){
            AC++;
        }
        
    }
    cout << AC << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;
using Graph = vector<vector<int>>;

int main() {
    int a;
    cin >> a;
    cout << a*a*a + a*a + a << endl ;
}

Measured memory_bytes: 3576