akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

bool isPrime[1000000];

int main(void){
  vector<int> pvec;
  //但多
  fill(isPrime,isPrime+1000000,true);
  for(int i=2;i<=50000;i++){
    if(isPrime[i] == true){
      pvec.push_back(i);
      for(int j=2;i*j<1000000;j++){
	isPrime[i*j] = false;
      }
    }
  }
  int tmp;
  while(cin >> tmp){
    int ret = 0;
    if(!tmp) break;
    for(int i=0;pvec[i]*2 <= tmp;i++){
      if(binary_search(pvec.begin(), pvec.end(), tmp-pvec[i])) ret++;
    }
    cout << ret << endl;
  }
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j); i < (N);i++)
#define _rep(i,j,N) for(int i = (j); i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= 0;i--)
#define _dep(i,j,N) for(int i = (N); i>= 0;i--)
#define ALL(x) x.begin(),x.end()
#define LL long long
#define ULL unsigned LL
#define PB push_back

const int maxn = 2e5+5;
int L;
LL dp[5][maxn];
LL A[maxn];

int main()
{
    scanf("%d",&L);
    _for(i,0,L){
        scanf("%lld",&A[i]);
    }
    _for(i,0,5){
        dp[0][i] = 0;
    }
    _for(i,0,L){
        LL v = A[i];
        LL val1,val2,val3,val4,val5;
        val1 = (val5 = v);
        if(!v) val2 = (val4 = 2);
        else if(v%2) val2 = (val4 = 1);
        else val2 = (val4 = 0);
        if(v%2) val3 = 0;
        else val3 = 1;

        dp[0][i+1] = dp[0][i] + val1;
        dp[1][i+1] = min(dp[0][i+1],dp[1][i] + val2);
        dp[2][i+1] = min(dp[1][i+1],dp[2][i] + val3);
        dp[3][i+1] = min(dp[2][i+1],dp[3][i] + val4);
        dp[4][i+1] = min(dp[3][i+1],dp[4][i] + val5);

    }
    LL ans = 1e15;
    _for(i,0,5){
        ans = min(ans,dp[i][L]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <math.h>
#include <map>
using namespace std;

int main(){
	
	int n;
	cin >> n;
	vector<long long> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end(),greater<long long>());
	int cnt=2;
	int id=1;
	long long ans=a[0];
  	if(n==2){
		cout << ans << endl;
		return 0;
	}
	while(1){
		ans+=a[id];
		cnt++;
		if(cnt>=n)break;
		ans+=a[id];
		cnt++;
		if(cnt>=n)break;
		id++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  vector<int> node(n, -1);
  queue<int> que;
  que.push(0);
  while (!que.empty()) {
    int now = que.front();
    que.pop();
    for (auto next : to[now]) {
      if (node[next] != -1)
        continue;
      node[next] = now;
      que.push(next);
    }
  }
  cout << "Yes" << endl;
  for (int i = 1; i < n; i++)
    cout << node[i]+1 << '\n';
  return 0;
}

Measured memory_bytes: 9944
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
#define  fi first
#define  se second 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1e9+9;


int main()
{
    string s;
    cin>>s;
    cout<<s.substr(0,s.size()-8)<<endl;
    return 0;
}


Measured memory_bytes: 256
def N():
    num=Dice[0]
    Dice[0]=Dice[1]
    Dice[1]=Dice[5]
    Dice[5]=Dice[4]
    Dice[4]=num
def E():
    num=Dice[0]
    Dice[0]=Dice[3]
    Dice[3]=Dice[5]
    Dice[5]=Dice[2]
    Dice[2]=num
def W():
    num=Dice[0]
    Dice[0]=Dice[2]
    Dice[2]=Dice[5]
    Dice[5]=Dice[3]
    Dice[3]=num
def S():
    num=Dice[0]
    Dice[0]=Dice[4]
    Dice[4]=Dice[5]
    Dice[5]=Dice[1]
    Dice[1]=num
Dice=[int(i) for i in input().split()]
Dice2=[int(i) for i in input().split()]
if (Dice[0] in Dice2)==False:
    print('No')
else:
    for j in range(6):
        if j%2==0:
            N()
        else:
            W()
        for i in range(4):
            N()
            W()
            S()
            if Dice==Dice2:
                break
        if Dice==Dice2:
            break 
    if Dice==Dice2:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 7800
A, B=[int(i) for i in input().split()]
from copy import deepcopy as dp
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
a=make_divisors(A)
b=make_divisors(B)
a_b_and = list(set(a) & set(b))
l=dp(a_b_and)
ll=[]
for i in a_b_and:
    if i==1:continue
    for j in l:
        if j%i==0 and j!=i:
            ll.append(j)
    if len(ll)>0:
        for j in ll:
            if j in l:
                l.remove(j)
print(len(l))

Measured memory_bytes: 43872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const ll MAX = 1e7 + 20;
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              "\n"

#define pi acos(-1.0)
#define mod 1000000007

///Library
#define mem(a,b) memset(a,b,sizeof(a))
#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define SortA(ar,s) sort(ar,ar+s)
#define SortD(ar,s) sort(ar,ar+s,greater<int>())
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sq(x) (x)*(x)


///vector
#define Lower_bound(vec,value) lower_bound(vec.begin(),vec.end(),value)
#define Upper_bound(vec,value) upper_bound(vec.begin(),vec.end(),value)


//template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
//template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }


int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/

    fast

    ll a;
    vector<string>v;
    set<string>s;
    string b;
    cin>>a;
    for(int i=0; i<a; i++)
    {
        cin>>b;
        v.push_back(b);
        s.insert(b);
    }
    sort(v.begin(),v.end());
    vector<string>v1(s.begin(),s.end());
    pair<ll,string>p[a];
    for(int i=0; i<s.size(); i++)
    {
        p[i].first=upper_bound(v.begin(),v.end(),v1[i])-lower_bound(v.begin(),v.end(),v1[i]);
        //cout<<p[i].first<<endl;
        p[i].second=v1[i];
    }
    sort(p,p+s.size());
    ll h=p[s.size()-1].first;
    //cout<<h<<endl;
    for(int i=0; i<s.size(); i++)
    {
        if(h==p[i].first)
        {
            cout<<p[i].second<<endl;
        }
    }
}



Measured memory_bytes: 27376
# -*- coding: utf-8 -*-

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline
# from collections import defaultdict
# import bisect

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

N = int(input())

A = [int(x) - 1 for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

ans = sum(B)

for i in range(N - 1):
    if A[i] + 1 == A[i + 1]:
        ans += C[A[i]]

print(ans)

Measured memory_bytes: 3572
#include<stdio.h>
 
int main(){
 
int a,b,n,l,i,j;
 
for(i=0;i<201;i++){
 

 
if(scanf("%d %d",&a,&b)==2){
 
n=a+b;
 
for(j=0;n>0;j++){
n=n/10;
l++;
}
printf("%d\n",l);
l=0;
}

else{
break;
}
 


}
 
 
return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int main()
{
	string s;

	while (true) {
		unsigned int ans = 0;
		getline(cin, s);
		for (unsigned int i = 0; i < s.length(); ++i) {
			ans += s[i] - '0';
		}
		if (ans == 0) break;
		cout << ans << endl;
	}
	return 0;
}


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

int main(void){
    long long int k,a,b;
    cin >> k >> a >> b;
    string s = "NG";
    for(int i = 1;i < 1001;i++){
        if(a <= i*k && i*k <= b)s = "OK";
    }
    cout << s << endl;
    
}

Measured memory_bytes: 3628
#include <stdio.h>

int map[10][10];
int m,n;

int chousa(int kx,int ky,int nokori) {
	int x,y;
	int result=0;
	int house=0;
	if(nokori<0)return 0;
	if(map[kx][ky]==1) {/*今いる家を通ったことにする*/
		map[kx][ky]=0;
		house=1;
	}
	/*左に道順を調査*/
	for(x=kx-1;x>=0;x--) {
		/*家に降りる*/
		if(map[x][ky]==1) {
			result+=chousa(x,ky,nokori-1);
			break;/*家の上を通る場合には必ずプレゼントを拾う*/
		}
		/*教会に戻る*/
		else if(map[x][ky]==2 && nokori==0) {
			result++;
			if(house)map[kx][ky]=1;/*通った家を元に戻す*/
			return result;
		}
		/*通れない*/
		else if(map[x][ky]==3)break;
	}
	/*右に道順を調査*/
	for(x=kx+1;x<m;x++) {
		/*家に降りる*/
		if(map[x][ky]==1) {
			result+=chousa(x,ky,nokori-1);
			break;/*家の上を通る場合には必ずプレゼントを拾う*/
		}
		/*教会に戻る*/
		else if(map[x][ky]==2 && nokori==0) {
			result++;
			if(house)map[kx][ky]=1;/*通った家を元に戻す*/
			return result;
		}
		/*通れない*/
		else if(map[x][ky]==3)break;
	}
	/*上に道順を調査*/
	for(y=ky-1;y>=0;y--) {
		/*家に降りる*/
		if(map[kx][y]==1) {
			result+=chousa(kx,y,nokori-1);
			break;/*家の上を通る場合には必ずプレゼントを拾う*/
		}
		/*教会に戻る*/
		else if(map[kx][y]==2 && nokori==0) {
			result++;
			if(house)map[kx][ky]=1;/*通った家を元に戻す*/
			return result;
		}
		/*通れない*/
		else if(map[kx][y]==3)break;
	}
	/*下に道順を調査*/
	for(y=ky+1;y<n;y++) {
		/*家に降りる*/
		if(map[kx][y]==1) {
			result+=chousa(kx,y,nokori-1);
			break;/*家の上を通る場合には必ずプレゼントを拾う*/
		}
		/*教会に戻る*/
		else if(map[kx][y]==2 && nokori==0) {
			result++;
			if(house)map[kx][ky]=1;/*通った家を元に戻す*/
			return result;
		}
		/*通れない*/
		else if(map[kx][y]==3)break;
	}
	if(house)map[kx][ky]=1;/*通った家を元に戻す*/
	return result;
}

int main(void) {
	int x,y;
	int kx,ky;
	int kazu;
	while(1) {
		scanf("%d %d",&m,&n);
		if(m==0 && n==0)break;
		kazu=0;
		kx=ky=0;
		/*読み込み*/
		for(y=0;y<n;y++) {
			for(x=0;x<m;x++) {
				scanf("%d",&map[x][y]);
				if(map[x][y]==2) {/*教会*/
					kx=x;
					ky=y;
				} else if(map[x][y]==1)kazu++;/*家*/
			}
		}
		/*計算*/
		printf("%d\n",chousa(kx,ky,kazu));
	}
	return 0;
}

Measured memory_bytes: 408
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define x first
#define y second
#define N 131072
#define pi acos(-1)
typedef complex<double> C;
/*int main()
{
	int n;
	scanf("%d",&n);
	char c[200005];
	scanf("%s",c+1);
	int cnt[200005];
	int rev[200005];
	cnt[0]=0;
	rev[n+1]=0;
	for(int i = 1;c[i]!=0;i++){	
		cnt[i]=cnt[i-1];
		if(c[i]=='#')
		cnt[i]++;
	}
	for(int i = n;i>0;i--){
		rev[i]=rev[i+1];
		if(c[i]=='.')
		rev[i]++;
	}
	int ans=1e9;
	for(int i = 0;i<=n;i++){
		ans=min(ans,cnt[i]+rev[i+1]);
	//	printf("%d %d\n",cnt[i],rev[i+1]);
	}
	printf("%d\n",ans);
}*/

int mod=998244353;
LL f_pow(LL a,LL b){
	LL res=1,temp=a;
	while(b){
		if(b&1)res=res*temp%mod;
		temp=temp*temp%mod;
		b>>=1;
	}
	return res;
}
LL dp[305][90005];
int main(){
	int n;
	scanf("%d",&n);
	int a[305];
	int tot=0;
	for(int i = 0;i<n;i++)
	scanf("%d",&a[i]),tot+=a[i];
	dp[0][0]=1;
	for(int i = 0;i<n;i++){
		for(int j =0;j<90005-a[i];j++){
			dp[i+1][j+a[i]]+=dp[i][j];
			dp[i+1][j+a[i]]%=mod;
			dp[i+1][j]+=dp[i][j];
			dp[i+1][j]+=dp[i][j];
			dp[i+1][j]%=mod;
		}
	}
	LL ans=f_pow(3,n);
	for(int i = (tot+1)/2;i<=tot;i++){
		ans-=dp[n][i]*3;
		ans=(ans%mod+mod)%mod;
	}
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i = 0;i<n;i++){
		for(int j =0;j<90005-a[i];j++){
			dp[i+1][j+a[i]]+=dp[i][j];
			dp[i+1][j+a[i]]%=mod;
			dp[i+1][j]+=dp[i][j];
			dp[i+1][j]%=mod;
		}
	}
	if(tot%2==0){
		ans=(ans+dp[n][tot/2]*3)%mod;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 214656
#include <iostream>
#include <stack>

using namespace std;

int main ( void )
{
  stack<int> s;
  int in;

  while( cin >> in )
  {
     if (!in)
     {
        cout << s.top() << endl;
        s.pop();
     }
     else
     {
        s.push(in);
     }
  }
  return 0;
}

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

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

template <class T> struct Dijkstra {

    struct Edge{
        int to;
        T cost;
        Edge(int _to, T _cost) : to(_to), cost(_cost) {}
    };
    
    const T INF = numeric_limits<T>::max() / 2;
    vector< vector< Edge > > G;
    vector< T > d;
    Dijkstra (int n) : G(n), d(n) {}

    void add_directed_edge(int a, int b, T c) {
        G[a].push_back(Edge(b,c));
    }
    
    void add_undirected_edge(int a, int b, T c) {
        G[a].push_back(Edge(b,c));
        G[b].push_back(Edge(a,c));
    }

    void init(int s) {
        priority_queue< pair<T,int>,vector< pair<T,int> >, greater< pair<T,int> > > que;
        fill(d.begin(), d.end(), INF);
        d[s] = 0;
        que.push(make_pair(0,s));
        while (!que.empty()){
            pair<T,int> p = que.top();
            que.pop();
            int v = p.second;
            if (d[v] < p.first) continue;
            for (int i = 0; i < G[v].size(); i++) {
                Edge e = G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(make_pair(d[e.to],e.to));
                }
            }
        }
    }
    
    T dist(int a) {
        return d[a];
    }
    
}; 


int main () 
{
    int K; cin >> K;
    Dijkstra < int > inst(100010);

    for (int i = 1; i < K; i++) {
        inst.add_directed_edge(i, (i + 1) % K, 1);
        inst.add_directed_edge(i, (i * 10) % K, 0);
    }

    inst.init(1);

    cout << 1 + inst.dist(0) << endl;

    return 0;
}


Measured memory_bytes: 6780
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		int x = scan.nextInt();
		
		int ans = 8;
		for(int i = 1; i < 9; i++) {
			if(x > 199 + i*200 && x < 400 + i*200) {
				ans = ans-i+1;
			}
		}
		String s = String.valueOf(ans);
		System.out.print(s);
	}

}


Measured memory_bytes: 35800
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	set<int> s;
	s.insert(a);
	s.insert(b);
	if(s.find(1)==s.end()){
		cout<<1<<endl;
		return 0;
	}
	else if(s.find(2)==s.end()){
		cout<<2<<endl;
		return 0;
	}
	else{
		cout<<3<<endl;
		return 0;
	}
	return 0;
}

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


int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  vector<string> days{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  cout << 7-(find(days.begin(), days.end(), s)-days.begin()) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD  1000000007
#define ll long long
#define int long long 
# define INF 2e5+5
#define ar array
# define fr first
# define sc second
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
//#define cerr if(false)cerr
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> pbds;

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
 
#ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);
  freopen("output1.txt","w",stdout);
#endif
 }
 
int power(int a,int b,int mod){
    a=a%mod;
    if(a==0){
        return 1;
    }
    int res=1;
    while(b){
        if(b&1){
            res=(res*a)%mod;
        }
        b>>=1;
        a=(a*a)%mod;
    }
    return res;
 }
 
int  MMI(int p){
    return power(p,MOD-2,MOD);
}


int32_t main()
{
    c_p_c();
    string s,t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            cnt++;
        }
    }
    cout<<cnt<<"\n";

        



         
 
 
    
      return 0;
       
        }
        
        
 
        
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
        

        


























//abcdef-abcdef
//factorial vs power
//multiplication table
//salary changing
//Obtain a Permutation
//Shift and Replace

Measured memory_bytes: 3740
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for ai in range(a+1):
    for bi in range(b+1):
        for ci in range(c+1):
            if 500*ai+100*bi+50*ci==x:
                ans+=1
print(ans)


Measured memory_bytes: 3060
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

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

int MOD = 1000000007;

ll f(ll x){
    if(x%2==0){
        return x/2;
    } else {
        return 3*x+1;
    }
}

int main(){
    std::ios_base::sync_with_stdio(false);

    int n; cin >> n;
    std::vector<int> h(n,0);
    REP(i,n) cin >> h[i];
    int ans = 0;

    bool ok = true;
    REP(j,n){
        if(h[j] != 0) ok =false;
    }
    if(ok){
        cout << 0 << endl;
        return 0;
    }

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

        int right = 0;

        while(right != n){
            while(h[right]==0 && right != n){
                right++;
            }

            while(h[right] > 0 && right != n){
                h[right]--;
                right++;
            }
            ans++;

            while(h[right]==0 && right != n){
                right++;
            }
        }


        bool ok = true;
        REP(j,n){
            if(h[j] != 0) ok =false;
        }
        if(ok) break;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
x,y;main(a,b,n){while(1){scanf("%d",&n);if(!n)break;for(x=y=0;n--;){scanf("%d%d",&a,&b);a>b?x+=a+b:a<b?y+=a+b:0;;a==b?x+=a,y+=b:0;}printf("%d %d\n",x,y);}exit(0);}

Measured memory_bytes: 0
# coding: utf-8
# Your code here!

while True:
    n, x = map(int, input().split())
    if n==0 and x==0:
        break
    pool = []
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                if(x==i+j+k and i!=j and i!=k and j!=k):
                    tmp = set(list([i,j,k]))
                    if tmp not in pool:
                        pool.append(tmp)
    print(len(pool))




Measured memory_bytes: 5860
process.stdin.resume();
process.stdin.setEncoding('utf8');
// 自分の得意な言語で
// Let's チャレンジ！！

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  const readLines = (input) => input.split('\n')
  var c = (value) => console.log(value)
var x = parseInt(lines[0]);
  if(x >=30){
  	c('Yes');
  }else{
    c('No')
  }
  
});

Measured memory_bytes: 30128
#include <stdio.h>
#include <stdlib.h>

#define UNION_FIND_MAX 1000

int uf_table[UNION_FIND_MAX];

void uf_init(void) {
	int i;
	for(i=0;i<UNION_FIND_MAX;i++)uf_table[i]=0;
}

void uf_merge(int a,int b) {
	int next;
	while(uf_table[a]>0) {
		next=uf_table[a]-1;
		if(uf_table[next]>0)uf_table[a]=uf_table[next];
		a=next;
	}
	while(uf_table[b]>0) {
		next=uf_table[b]-1;
		if(uf_table[next]>0)uf_table[b]=uf_table[next];
		b=next;
	}
	if(a!=b)uf_table[a]=b+1;
}

int uf_issame(int a,int b) {
	int next;
	while(uf_table[a]>0) {
		next=uf_table[a]-1;
		if(uf_table[next]>0)uf_table[a]=uf_table[next];
		a=next;
	}
	while(uf_table[b]>0) {
		next=uf_table[b]-1;
		if(uf_table[next]>0)uf_table[b]=uf_table[next];
		b=next;
	}
	return a==b;
}

typedef struct {
	int s,t,c;
} edge_t;

int qscedge(const void* x,const void* y) {
	int a=((const edge_t*)x)->c;
	int b=((const edge_t*)y)->c;
	if(a>b)return 1;
	if(a<b)return -1;
	return 0;
}

int main(void) {
	int n,m;
	static edge_t edges[10000];
	while(scanf("%d%d",&n,&m)==2 && (n|m)!=0) {
		int i;
		int left,right;
		for(i=0;i<m;i++) {
			scanf("%d%d%d",&edges[i].s,&edges[i].t,&edges[i].c);
		}
		qsort(edges,m,sizeof(edge_t),qscedge);
		left=0;right=m-1;
		while(left<=right) {
			int mid=(left+right)/2;
			int count=0;
			uf_init();
			for(i=0;i<m;i++) {
				if(!uf_issame(edges[i].s,edges[i].t)) {
					uf_merge(edges[i].s,edges[i].t);
					if(mid<i)count++;
				}
			}
			if(count<=n/2-1)right=mid-1; else left=mid+1;
		}
		printf("%d\n",edges[right+1].c);
	}
	return 0;
}

Measured memory_bytes: 884
import collections as col
N,K = map(int,input().split())
d_i = list()
sunuke_have = list()
for i in range(K):
    d_i = int(input())
    sunuke_have.append(list(map(int,input().split())))

sunuke_f = [0]*(N+1)
for i in range(K):
    for j in range(len(sunuke_have[i])):
        sunuke_f[sunuke_have[i][j]] +=1
# print(sunuke_f)
print(sunuke_f.count(0)-1)



Measured memory_bytes: 9488
// https://atcoder.jp/contests/abc058/tasks/abc058_b
#include <bits/stdc++.h>
using namespace std;

int main() {

  string O, E;
  cin >> O;
  cin >> E;
  int N = O.size();

  for (int i = 0; i < N; i++) {
    cout << O[i];

    if (i < E.size())
      cout << E[i];
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<set>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using edge = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<int>> graph(N);
    vector<int> U(N - 1), V(N - 1);
    rep(i, 0, N - 1) {
        cin >> U[i] >> V[i];
        --U[i], --V[i];
        graph[U[i]].push_back(V[i]);
        graph[V[i]].push_back(U[i]);
    }
    map<edge, int> color;
    queue<int> que;
    que.push(0);
    while (!que.empty()) {
        int node = que.front();
        que.pop();
        map<int, bool> used_color;
        rep(i, 0, graph[node].size()) {
            edge e = edge(min(node, graph[node][i]), max(node, graph[node][i]));
            if (color[e] > 0) {
                used_color[color[e]] = true;
            }
        }
        int now_color = 1;
        rep(i, 0, graph[node].size()) {
            edge e = edge(min(node, graph[node][i]), max(node, graph[node][i]));
            if (!color[e]) {
                while (used_color[now_color]) ++now_color;
                color[e] = now_color;
                used_color[now_color] = true;
                que.push(graph[node][i]);
            }
        }
    }
    set<int> ans;
    iter(i, color) {
        ans.insert(i->second);
    }
    cout << ans.size() << endl;
    rep(i, 0, N - 1) {
        edge e = edge(min(U[i], V[i]), max(U[i], V[i]));
        cout << color[e] << endl;
    }
    return 0;
}

Measured memory_bytes: 13056
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

ll T[1007];

int main(){
    ll N,U=1;
    cin>>N;
    REP(j,1,N+1){
        ll M=j;
        REP(i,2,j+1){
            while(M%i==0){
                M/=i;
                T[i]++;
            }
        }
    }
    REP(i,1,N+1){
        U*=T[i]+1;
        U%=MOD;
    }
    cout << U <<  endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

//This problem reminded me of Nabeatsu !!
public class Main{
 public static void main(String[] args){
  Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();

  if(3<=n&&n<=10000){
 //NabeatsuNo. 1<=i<=n
  for(int i=1;i<=n;i++){
    if(i%3==0)  //Output if i is multiple of 3
     System.out.printf(" "+i);
    else{
     int j=i;
     int count =0;
     //Output if i has more than a digit which is 3
     do{
      if(j%10==3){
       System.out.printf(" "+i);
       count++;
     }
      else
       j/=10;
     }while(j>1&&count==0);   //Be careful the duplication
    }
   }
  }
 System.out.printf("\n");
 }
}

Measured memory_bytes: 30808
import heapq

N, M = map(int, input().split())
AB = []
for _ in range(N):
    b, a = map(int, input().split())
    AB.append([a, b])

AB.sort(reverse=True, key=lambda x:x[0])
AB.sort(key=lambda x:x[1])

#print(AB)

ans = 0
p = 0
h = []
heapq.heapify(h)

for i in range(1, M + 1):
    while p < N and AB[p][1] <= i:
        heapq.heappush(h, -AB[p][0])
        p += 1
    if len(h) != 0:
        ans -= heapq.heappop(h)

print(ans)


Measured memory_bytes: 24812
#include<iostream>
using namespace std;
int main()
{
    int card,place[201],m,change,ba[201],ko;
    cin>>card;
    for(int i=1;i<=2*card;i++){
        place[i]=i;
        //cout<<place[i]<<endl;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>change;
        if(change==0){
                ko=1;
           for(int j=1;j<=2*card;j++){
            if(j%2==1){
                ba[j]=place[ko];
            }
        else{
            ba[j]=place[ko+card];
            ko++;
            }
        }
        for(int j=1;j<=2*card;j++)place[j]=ba[j];
           }

        else{
                ko=1;
                for(int j=1;j<=2*card;j++){
                    if(2*card-j>=change){
                        ba[j]=place[change+j];
                    //    cout<<"1"<<endl;
                    }
                    else{
                        ba[j]=place[ko];
                  //      cout<<"2"<<endl;
                  ko++;
                    }
                }
                for(int j=1;j<=card*2;j++)place[j]=ba[j];
        }
    }
    for(int i=1;i<=2*card;i++)cout<<place[i]<<endl;

}

Measured memory_bytes: 1160
n, m, s = [int(i) for i in input().split()]

e = []
for _ in range(m):
    u, v, a, b = [int(i) for i in input().split()]
    u -= 1
    v -= 1
    e.append([u, v, a, b])

co = [[int(i) for i in input().split()] for _ in range(n)]

dp = [[10 ** 18] * 6000 for _ in range(n)]
dp[0][min(5999,s)] = 0
for i in range(6000):
    if i + co[0][0] < 6000:
        dp[0][i + co[0][0]] = min(dp[0][i + co[0][0]], dp[0][i] + co[0][1])

for _ in range(n):
    for u, v, a, b in e:
        for j in range(a, 6000):
            dp[v][j - a] = min(dp[v][j - a], dp[u][j] + b)
        for i in range(6000):
            if i + co[v][0] < 6000:
                dp[v][i + co[v][0]] = min(dp[v][i + co[v][0]], dp[v][i] + co[v][1])

        for j in range(a, 6000):
            dp[u][j - a] = min(dp[u][j - a], dp[v][j] + b)
        for i in range(6000):
            if i + co[u][0] < 6000:
                dp[u][i + co[u][0]] = min(dp[u]
                                          [i + co[u][0]], dp[u][i] + co[u][1])

for i in range(1, n):
    print(min(dp[i]))

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

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

    int n, k;
    cin >> n >> k;

    int a[n+1] = {};

    set<int> s;
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
        s.insert(x);
        a[x]++;
    }
    sort(a, a+n+1);

    int ans = 0;
    if(k < s.size()){
        int f = s.size() - k;
        for(int i = 0; i < n+1 && f != 0; i++){
            if(a[i] != 0){
                ans += a[i];
                f--;
            }
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>

using namespace std;
int main(){
	long long a,b;
	cin >> a >> b;
	if(a==b){
		cout << 1 << endl;
		return 0;
	}
	long long a1 = a;
	long long b1 = b;
	bool v1[100]={},v2[100]={};
	for(int i=0;i<100;i++){
		if(a1%2==1){
			v1[i]=1;
		}
		if(b1%2==1){
			v2[i]=1;
		}
		a1 = a1/2;
		b1 = b1/2;
	}
	int ma=0;
	for(int i=0;i<100;i++){
		if(v1[i]!=v2[i]){
			ma = max(ma,i);
		}
	}
	long long k=((long long)1<<ma);
	a = a%k;
	b = b%k;
	long long ans=0;
	ans += k-a;
	int bm=0;
	bool flag =0;
	for(int i=0;i<ma;i++){
		if(v2[i]==1){
			bm = max(bm,i);
			flag =1;
		}
	}
	b = ((long long)1<<(bm+1))-1;
	if(flag==0){
		b = 0;
	}
	if(a<=b){
		ans += k;
	}else{
		ans += b+1+k-a;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    char x, y;
    cin >> x >> y;
    if ((unsigned char)x == (unsigned char)y) {
        cout << '=' << endl;
    } else if ((unsigned char)x < (unsigned char)y) {
        cout << '<' << endl;
    } else {
        cout << '>' << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define llong long long
using namespace std;

llong n,a,b;

int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	if(b<=a)
	{
		printf("%lld\n",n+1);
	}
	else if(b>a)
	{
		if(a-1<=n)
		{
			llong t = (n-(a-1))/2;
			llong ans = 1ll+n-2ll*t;
			ans = ans+(b-a)*t;
			printf("%lld\n",max(n+1,ans));
		}
		else
		{
			printf("%lld\n",n+1);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int maxn=5e4+10;
ll gcd(ll a, ll b){return (b==0)?a:gcd(b, a%b);}
bool isPrime(int n) {
    if(n<=3){
        return n>1;
    }
    if(n%6!=1&&n%6!=5){
        return false;
    }
    int sqr=sqrt(n);
    for(int i=5;i<=sqr;i+=6){
        if(n%i==0||n%(i+2)==0){
            return false;
        }
    }
    return true;
}
int dis[4][2]={0,1,0,-1,1,0,-1,0};
int main()
{
	ll a,b,c;cin>>a>>b>>c;
	if(c-a-b<=0)
	cout<<"No"<<endl;
	else
	{
		ll sum=c-a-b;
		sum=sum*sum;
		ll ans=4*a*b;
		if(ans<sum)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
} 

Measured memory_bytes: 256
d = {'A':0, 'B':1, 'C':2}
ABC = 'ABC'

def main():
    N, A, B, C = map(int, input().split())
    abc_nums = [A, B, C]
    S = []
    for i in range(N):
        s = input()
        flgs = []
        for j in range(2):
            flgs.append(d[s[j]])
        S.append(flgs)

    ans = []
    for i in range(N):
        if abc_nums[S[i][0]] == abc_nums[S[i][1]] == 0:
            print('No')
            return
        elif i == N-1:  # 最後だったらどちらでも
            if abc_nums[S[i][0]] <= abc_nums[S[i][1]]:
                abc_nums[S[i][0]] += 1
                ans.append(ABC[S[i][0]])
                abc_nums[S[i][1]] -= 1
            else:
                abc_nums[S[i][0]] -= 1
                abc_nums[S[i][1]] += 1
                ans.append(ABC[S[i][1]])
        elif abc_nums[S[i][0]] == abc_nums[S[i][1]]:    # 同じだったら次に出てくる方
            if S[i][0] == S[i+1][0] or S[i][0] == S[i+1][1]:
                abc_nums[S[i][0]] += 1
                ans.append(ABC[S[i][0]])
                abc_nums[S[i][1]] -= 1
            else:
                abc_nums[S[i][0]] -= 1
                abc_nums[S[i][1]] += 1
                ans.append(ABC[S[i][1]])
        elif abc_nums[S[i][0]] <= abc_nums[S[i][1]]:
            abc_nums[S[i][0]] += 1
            ans.append(ABC[S[i][0]])
            abc_nums[S[i][1]] -= 1
        else:
            abc_nums[S[i][0]] -= 1
            abc_nums[S[i][1]] += 1
            ans.append(ABC[S[i][1]])
    print('Yes')
    for i in range(N):
        print(ans[i])
    return
main()


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

struct edge{
    int to;
    long double dist;
    edge(int to,long double dist):to(to),dist(dist){}
};

void solve(){
    while(true){
        int n,m,p,a,b;
        cin >> n >> m >> p >> a >> b;
        if(n==0 and m==0 and p==0 and a==0 and b==0) break;
        --a;
        --b;

        vector<long double> t(n);
        vector<vector<edge>> graph(m);
        for(auto& in:t) cin >> in;
        rep(i,0,p){
            int x,y;
            long double z;
            cin >> x >> y >> z;
            --x;
            --y;
            graph[x].emplace_back(edge(y,z));
            graph[y].emplace_back(edge(x,z));
        }

        typedef tuple<long double,int,int> triple;
        vector<vector<long double>> dist(m,vector<long double>(1<<n,inf));
        priority_queue<triple,vector<triple>,greater<triple>> que;
        dist[a][0]=0;
        que.push(make_tuple(0,a,0));
        while(!que.empty()){
            const triple tri=que.top();
            que.pop();
            const long double d=get<0>(tri);
            const int v=get<1>(tri),s=get<2>(tri);
            if(d>dist[v][s]) continue;
            for(const auto& e:graph[v]){
                rep(i,0,n){
                    if((s>>i)&1) continue;
                    const long double tmp_d=d+e.dist/t[i];
                    if(tmp_d>=dist[e.to][s|(1<<i)]) continue;
                    dist[e.to][s|(1<<i)]=tmp_d;
                    que.push(make_tuple(tmp_d,e.to,s|(1<<i)));
                }
            }
        }
        long double ans=inf;
        rep(i,0,1<<n) ans=min(ans,dist[b][i]);
        if(ans==inf) cout << "Impossible" << endl;
        else cout << ans << endl;
    }
}

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

Measured memory_bytes: 6356
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

bool check(vector<vector<int>> a) {
	int n = a.size();
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < n; ++j) {
			if(i != j && a[i][j] == 0) {
				a[i][j] = 1 << 29;
			}
		}
	}
	
	for(int k = 0; k < n; ++k) {
		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < n; ++j) {
				a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
			}
		}	
	}
	
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < n; ++j) {
			if(a[i][j] == (1 << 29)) {
				return true;
			}
		}
	}
	
	return false;
}

int main() {
	int n, m;
	cin >> n >> m;
	
	vector<vector<int>> a(n, vector<int>(n));
	
	for(int i = 0; i < m; ++i) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		
		a[x][y] = a[y][x] = 1;
	}
	
	int ans = 0;
	
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			if(!a[i][j]) {
				continue;
			}
			
			a[i][j] = 0;
			
			if(check(a)) {
				ans++;
			}
			
			a[i][j] = 1;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>

using namespace std;
typedef long long ll;

int main(){
	ll N,M,K;
	cin >> N >> M >> K;
	bool ok = false;
	for(int yoko=0;yoko<=N;yoko++)
		for(int tate=0;tate<=M;tate++)
			if(K == yoko*(M-tate)+tate*(N-yoko))
				ok=true;
	if(ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
use std::collections::HashSet;

fn main() {
    let s: String = read();
    let map_s : HashSet<char> = s.chars().collect();

    if map_s.len() == 2 {
        println!("Yes");
    }else {
        println!("No");
    }
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
l=[]
for i in range(3):
  a1,a2,a3=map(int,input().split())
  l.append(a1)
  l.append(a2)
  l.append(a3)
n=int(input())
for i in range(n):
  try:
    ind=l.index(int(input()))
    l[ind]=0
  except:
    pass
for i in range(0,9,3):
  if l[i+0]==l[i+1]==l[i+2]==0:
    print('Yes')
    exit(0)
for i in range(3):
  if l[i]==l[i+3]==l[i+6]==0:
    print('Yes')
    exit(0)
if l[0]==l[4]==l[8]==0:
  print('Yes')
  exit(0)
if l[2]==l[4]==l[6]==0:
  print('Yes')
  exit(0)
print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int H, W, D, Q;

int main()
{
    cin >> H >> W >> D;
    map<int, pair<int, int>> mp;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            int a;
            scanf("%d", &a);
            a--;
            mp[a] = make_pair(i + 1, j + 1);
        }
    }

    vector<vector<int>> calc(D);

    for (int i = 0; i < D; i++)
    {
        int L = i;
        auto p = mp[L];
        pair<int, int> q;
        for (int j = i; j <= H * W; j += D)
        {
            q = mp[j];
            calc[i].push_back(abs(p.first - q.first) + abs(p.second - q.second));
            p = q;
        }
        for (int j = 0; j + 1 < calc[i].size(); j++)
        {
            calc[i][j + 1] += calc[i][j];
        }
    }

    cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        int L, R, sum = 0;
        scanf("%d%d", &L, &R);
        L--, R--;
        sum = calc[L % D][R / D] - calc[L % D][L / D];
        printf("%d\n", sum);
    }
}

Measured memory_bytes: 11008
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string S; cin >> S;
    lint res = 0;
    range(len, 1, S.size() / 2) {
        if (S.substr(0, len) == S.substr(len, len)) res = len * 2;
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	int ans = 0;
	rep(i, 6) {
		if (s[i] == '1') {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
	
}





Measured memory_bytes: 256
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29

def main():
    n,l = map(int,input().split())
    s = []
    for i in range(n):
        s.append(input())
    s.sort()
    print(''.join(s))
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 64364
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<set>
#include<stack>
using namespace std;

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

int main(){
    int N,K; cin >> N >> K;
    ll t[N],d[N];
    
    vector<P> res(N);

    for(int i=0;i<N;i++){
        cin >> t[i] >> d[i];
        res[i]=make_pair(d[i],t[i]);
    }

    sort(res.begin(),res.end(),greater<P>());

    set<int> set;
    stack<int> st;
    ll ans=0;
    for(int i=0;i<K;i++){
        if(set.count(res[i].second)){
            st.push(res[i].first); //ダブりを追加
        }
        set.insert(res[i].second);
        ans+=res[i].first;
    }
    ll sum=ans;
    ans=sum+set.size()*set.size();
    for(int i=K;i<N;i++){
        if(st.empty()) break; //種類を増やせなくなったらループを抜ける
        if(set.count(res[i].second)) continue; //種類が増えない場合は最大値が更新されない
        set.insert(res[i].second);
        sum-=st.top(); st.pop();
        sum+=res[i].first;
        ans=max(ans,sum+(ll)(set.size()*set.size()));
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 6528
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};


int main(void){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    int t = 0;
    int ind = -1;
    for(int i = 0; i < N; i++){
        if(abs(a[i]) >= t){
            t = abs(a[i]);
            ind = i;
        }
    }
    vector<pair<int, int>> ANS;
    int ans = 0;
    if(a[ind] > 0){
        for(int i = 0; i < N; i++){
            if(a[i] < 0){
                a[i] += a[ind];
                ans++;
                ANS.push_back({i, ind});
            }
        }
        for(int i = 1; i < N; i++){
            if(a[i-1] > a[i]){
                int maxa = -1;
                int index = -1;
                for(int k = 0; k < N; k++){
                    if(a[k] > maxa){
                        maxa = a[k];
                        index = k;
                    }
                }
                a[i] += a[index];
                ans++;
                ANS.push_back({i, index});
            }
        }
        
    }else{
        for(int i = 0; i < N; i++){
            if(a[i] > 0){
                a[i] += a[ind];
                ans++;
                ANS.push_back({i, ind});
            }
        }
        
        for(int i = N-1; i >= 1; i--){
            if(a[i-1] > a[i]){
                int mini = 1;
                int index = -1;
                for(int k = 0; k < N; k++){
                    if(a[k] < mini){
                        mini = a[k];
                        index = k;
                    }
                }
                
                a[i-1] += a[index];
                ans++;
                ANS.push_back({i-1, index});
            }
        }
    }
    cout << ans << endl;
    for(int i = 0; i < ANS.size(); i++){
        cout << ANS[i].second + 1 << " " << ANS[i].first + 1 << endl;
    }
    
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        Reader sc = new Reader();
        PrintWriter pw = new PrintWriter(System.out);
        
        try {
            int n = sc.nextInt();
            int[] a = new int[n];
            long sum = 0;
            int max = 0;
            for(int i=0 ; i<n ; i++) {
                a[i] = sc.nextInt();
                if(a[i] < max) {
                    sum += max-a[i];
                }
                max = Math.max(max, a[i]);
            }

            pw.println(sum);
        }
        finally {
            pw.flush();
            pw.close();
        }
    }
    
    static class Reader {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while(!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException io) {
                    io.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 55096
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1005,ha=1e9+7;

int n,ans=1,now;
bool v[N];

int main(){
	scanf("%d",&n);
	for(int i=2;i<=n;i++) if(!v[i]){
		for(int j=i*i;j<=n;j+=i) v[j]=1;
		now=1;
		for(int j=i;j<=n;j*=i) now+=n/j;
		ans=ans*(ll)now%ha;
	} 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256