akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#pragma region Macros
typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};
#define LOCAL

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a; cin >> a;
    cout << a+a*a+a*a*a << '\n';
}

Measured memory_bytes: 3612
t = input()
if (abs(len(t))<=3) and (t in 'S' or 'R'):
    if t[0]=='R' and t[1]=='R' and t[2]=='R':
        print(3)
    elif (t[0]=='R' and t[1]=='R' and t[2]!='R') or (t[0]!='R' and t[1]=='R' and t[2]=='R'):
        print(2)
    elif t[0]!='R' and t[1]!='R' and t[2]!='R':
        print(0)
    else:
        print(1)
else:
    print('false')

Measured memory_bytes: 9012
N, K = map(int, input().split())
h = sorted(list(int(input()) for _ in range(N)))
fin = h[K-1] - h[0]
for i in range(1, N-K+1):
  t = h[i+K-1] - h[i]
  if fin > t :
    fin = t
print(fin)


Measured memory_bytes: 8292
def get_max(aa):
    mi = None
    for i,v in aa.items():
        if mi is None or v > mv:
            mi = i
            mv = v
    return mi

def main():
    k,t=map(int,input().split())
    aa={i:v for i,v in enumerate(map(int,input().split()),1)}
    mi = None
    while len(aa) > 1:
        mi = get_max({i:v for i,v in aa.items() if i != mi})
        if aa[mi] > 1:
            aa[mi]-=1
        else:
            del aa[mi]
    print(list(aa.values())[0]-1)

main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define f first
#define s second
using namespace std;
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef queue<int> qi;
typedef queue<pii> qpii;


void test_case() {
	vi a(5);
	for (int i = 0; i < 5; i ++) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << i+1 << '\n';
			return;
		}
	}
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int q = 1; 
	//cin >> q;
	while (q--) {
		test_case();
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	string s;
	cin >> s;

	--a, --b, --c, --d;

	bool ok = s[a]=='.' && s[b]=='.' && s[c]=='.' && s[d]=='.';

	string t = s.substr(a, c-a+1);
	for (int i = 1; i < t.length(); ++i)
		ok &= t[i] == '.' || t[i-1] == '.';

	t = s.substr(b, d-b+1);
	for (int i = 1; i < t.length(); ++i)
		ok &= t[i] == '.' || t[i-1] == '.';

	if (d < c)
	{
		bool ok2 = false;
		t = s.substr(b-1, d-b+3);
		for (int i = 2; i < t.length(); ++i)
			ok2 |= t[i] == '.' && t[i-1] == '.' && t[i-2] == '.';

		ok &= ok2;
	}

	if (ok)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}


Measured memory_bytes: 720
#include <iostream>

int main() {
    int i, j, k;
    std::cin >> i >> j >> k;
    if ((i == 5 || i == 7) && (j == 5 || j == 7) && (k == 5 || k == 7) && (i + j + k == 17)) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
X,Y = map(int,input().split(' '))

count_sum = 0

def count_money(X,count_sum):
    if X == 1:
        count_sum += 300000
    elif X ==2:
        count_sum += 200000
    elif X ==3:
        count_sum += 100000
    return count_sum

count_sum = count_money(X,count_sum)
count_sum = count_money(Y,count_sum)
if X == 1 and Y ==1:
    count_sum += 400000
print(count_sum)

Measured memory_bytes: 3064
N = int(input())
f = 0
ans = 'No'
for i in range(N):
    x,y = map(int,input().split())
    if x == y:
        f += 1
    else:
        f = 0
    if f == 3:
        ans = 'Yes'
        print(ans)
        quit()
print(ans)

Measured memory_bytes: 9184
//#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1e9 + 7;
const ll infll = 1e18 + 9;
const int infint = 1e9 + 7;
const int MAXN = 3e5 + 7;
const double eps = 1e-9;
const long double pi = 3.1415926535897932384626433832795;
const long double e = 2.71828182845904523536028747135266;
inline ll read()
{
    ll kr = 1, xs = 0;char ls;ls = getchar();
    while (!isdigit(ls)){
        if (!(ls ^ 45)) kr = -1;
        ls = getchar();
    }
    while (isdigit(ls)){
        xs = (xs << 1) + (xs << 3) + (ls ^ 48);ls = getchar();
    }return xs * kr;
}
// inline __int128 read128()
// {
//     __int128 kr=1,xs=0;char ls;ls=getchar();
//     while(!isdigit(ls)){
//         if(!(ls^45)) kr=-1;ls=getchar();
//     }
//     while(isdigit(ls)){
//         xs=(xs<<1)+(xs<<3)+(ls^48);ls=getchar();
//     }
//     return xs*kr;
// }
inline ull readull()
{
    ull xs = 0;char ls;ls = getchar();
    while (!isdigit(ls))ls = getchar();
    while (isdigit(ls)){
        xs = (xs << 1) + (xs << 3) + (ls ^ 48);ls = getchar();
    }return xs;
}
inline void writeull(ull x)
{
    if (x < 0){
        x *= -1;putchar('-');
    }
    if (x >= 10) writeull(x / 10);
    putchar('0' + x % 10);
}
inline void write(ll x)
{
    if (x < 0){
        x *= -1;putchar('-');
    }
    if (x >= 10) write(x / 10);
    putchar('0' + x % 10);
}
// inline void write(__int128 x){
//     if(x<0){x*=-1;putchar('-');}
//     if(x>=10) write(x/10);
//     putchar('0'+x%10);
// }
///////////////////////////////////////////////////////////////////////////////////////
int main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(0),cout.tie(0);
    int t = 1;
    // t = read();
    while (t--)
    {
        int n=read();
        n^=1;
        cout << n << endl;
    }
    return 0;
}


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

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 61; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

long long find_value(long long a, long long b, long long m) {
	if (a == 0) return 1;
	while ((m%a) != 0) {
		long long cnt = 1;
		while (true) {
			long long G = (cnt * m) / a + 1; cnt++;
			if (gcd(G, m) != 1 || (a*G) % m == a) continue;

			a *= G; a %= m; b *= G; b %= m;
			break;
		}
	}
	return b / a;
}

long long period(long long cc) {
	long long r = 1, c = cc; vector<long long>A;
	for (long long i = 2; i*i <= c; i++) {
		if (c%i != 0) continue;
		A.push_back(i);
		while (c%i == 0) c /= i;
	}
	if (c >= 2) A.push_back(c);

	for (int i = 0; i < A.size(); i++) {
		long long cx = cc, t = A[i] - 1;
		while (cx%A[i] == 0) { if (cx != cc) t *= A[i]; cx /= A[i]; }
		r *= t;
	}
	return r;
}

long long solve(long long x, long long y) {
	if (y == 1) return 1;
	x %= y;

	long long G = period(y);
	if (x == 0) return y;

	long long E = solve(x, G);
	long long L = modpow(x, E, y);
	
	long long LIM = ((1LL << 62) / y) * y;
	long long X = find_value(G, ((L - E + LIM) % y), y);
	X *= G; X += E;
	return X;
}

int main() {
	long long Q; cin >> Q;
	for (int i = 1; i <= Q; i++) {
		long long A, M; cin >> A >> M;
		long long Z = solve(A, M);
		cout << Z << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#from pprint import pprint
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from copy import deepcopy
#from itertools
#from bisect import bisect_right #二分探索用のモジュール bisect_right(a_list,value)

#import sys 
#sys.setrecursionlimit(N) #N回まで再起を許可する。

# = map(int,input().split())

# = list(map(int,input().split()))

# = [list(map(int,input().split())) for _ in range(XXXX)]


x = list(map(int,input().split()))


for i in range(len(x)):
    if x[i] == 0:
        print(i+1)
        exit()



Measured memory_bytes: 61864
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

void solve(){
    int n,k;
    cin>>n>>k;
    double ans=0;
    for(int i=1;i<=n;i++){
        double temp=1.0/n;
        int now=i;
        while(now<k){
            now*=2;
            temp/=2;
        }
        ans+=temp;
    }
    cout.precision(12);
    out(ans);

}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
typedef long long ll;

using namespace std;
using Graph = vector<vector<int>>;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;

const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

const double PI=3.14159265358979323846; // or M_PI


void Main() {
    ll n, m, in_h, in_a, in_b, count;
    int flag;
    vector<ll> h;
    vector<ll> top;

    cin >> n >> m;
    vector<vector<ll>> g(n);
    // COUT("IN");
    REP(i, n) {
        cin >> in_h;
        h.push_back(in_h);
    }
    // COUT("IN");
    REP(i, m) {
        cin >> in_a >> in_b;
        g[in_a - 1].push_back(in_b - 1);
        g[in_b - 1].push_back(in_a - 1);
    }
    // COUT("IN");

    count = 0;
    REP(i, n) {
        flag = 0;
        REP(j, g[i].size()) {
            if (h[i] <= h[g[i][j]]){
                flag = 1;
                break;
            }
        }
        if (flag == 0) {
            count++;
        }
    }
    COUT(count);
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*
4 3
1 2 3 4
1 3
2 3
2 4
*/

Measured memory_bytes: 9796
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    int N, M;
    while(cin >> N >> M){
        vector<int> cntWA(N+1, 0);
        vector<int> solve(N+1, 0);
        int wa = 0, ac = 0;
        for(int i=0;i<M;i++){
            int p; string S;
            cin >> p >> S;
            if(S == "WA") ++cntWA[p];
            else {
                if(!solve[p]){
                    solve[p] = 1;
                    ac++;
                    wa += cntWA[p];
                }
            }
        }
        cout << ac << " " << wa << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    string s, t;

    cin >> s;
    cin >> t;
    long counter = 0;
    for (long i = 0; i < s.size(); i++)
    {
        if (s[i] != t[i])
        {
            counter++;
        }
    }
    cout << counter << endl;

    return 0;
}


Measured memory_bytes: 3856
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(int i=p;i<n;++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

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

    vector<int> ws(N);
    rep (i, N) { cin >> ws[i]; }

    int sum = 0;
    rep (i, N) { sum += ws[i]; }

    int lhs = 0;
    int rhs = sum;

    int ans = sum;

    rep (i, N)
    {
        lhs += ws[i];
        rhs -= ws[i];

        ans = min(ans, abs(rhs - lhs));
    }

    cout << ans << endl;

    return 0;
}


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

#define INF 2000000000

int main(){

  int N;
  cin >> N;

  vector<int> dp(N,INF);
  vector<int> h(N);
  for(int i=0;i<N;i++){
    cin >> h[i];
  }

  dp[0]=0;

  for(int i=0;i<N;i++){
    if(i==N-1){
      cout << dp[N-1] << endl;
    }else if(i==N-2){
      //i+1
      dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
    }else{
      //i+1
      dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
      //i+2
      dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
    }
  }
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
		int nokori = c - (a - b);
		
		
		if (nokori < 0) {
			System.out.println(0);
		}
		
		else {
			System.out.println(nokori);
		}
	}		
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int x,y,z;cin>>x>>y>>z;
  cout<<z<<' '<<x<<' '<<y<<endl;
}


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

int main() {
  int a;
  double b;
  cin >> a;
  if (a%2==0)
    b=a/2;
  if(a%2==1)
    b=a/2+1;
  double c;
  c=b/a;
  
  cout << c << endl;
}

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

using namespace std;

int main()
{
	stack <int> s;
	int n;
	while (cin >> n)
	if (n == 0){
		cout << s.top()<<endl;
		s.pop();
	}
	else{
		s.push(n);
	}
	return 0;
}

Measured memory_bytes: 1200
n,k=map(int,input().split())
B=[[0]*2 for i in range(k)]
for i in range(k):
  B[i]=list(map(int,input().split()))
mod=998244353
A=[0]*(n+1)
A[0]=1
a=1
for i in range(n):
  for j in range(k):
    A[min(n,i+B[j][0])]=(A[min(n,i+B[j][0])]+a)%mod
    A[min(n,i+B[j][1]+1)]=(A[min(n,i+B[j][1]+1)]-a)%mod
  a=a+A[i+1]
print(A[-2]%mod)

Measured memory_bytes: 75640
open System

let n, m, x =
    let l = Console.ReadLine().Split(' ') |> Array.map int
    l.[0], l.[1], l.[2]

let lines =
    [ for i in 0 .. n - 1 do
        yield Console.ReadLine().Split(' ') |> Array.map int ]

let a = Array2D.init n m (fun i j -> lines.[i].[j + 1])
let c = Array.init n (fun i -> lines.[i].[0])

let ans =
    let mutable ans = Int32.MaxValue

    let rec dfs is k =
        if k = n then
            let ok =
                [ for j in 0 .. m - 1 do
                    let mutable sum = 0
                    for i in is do
                        sum <- sum + a.[i, j]
                    yield sum ]
                |> List.forall (fun sum -> sum >= x)

            if ok then
                let cost =
                    let mutable cost = 0
                    for i in is do
                        cost <- cost + c.[i]
                    cost
                cost
            else
                -1
        else
            let a, b = dfs is (k + 1), dfs (k :: is) (k + 1)
            match a, b with
            | a, -1 -> a
            | -1, b -> b
            | _ -> min a b
    dfs [] 0

ans |> Console.WriteLine


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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

const int MAX = 1000000000;

int main() {
    int N, K, S;
    cin >> N >> K >> S;

    vector<int> v;
    if (S != MAX) {
        for (int i=0; i<N; ++i) {
            if (i < K) v.push_back(S);
            else v.push_back(S+1);
        }
    } else {
        for (int i=0; i<N; ++i) {
            if (i < K) v.push_back(S);
            else v.push_back(1);
        }
    }

    for (int i=0; i<(int)v.size(); ++i) {
        cout << (i == 0 ? "" : " ") << v[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    char c[3][3];
    REP(i, 3){
        REP(j, 3){
            cin >> c[i][j];
        }
    }

    cout << c[0][0] << c[1][1] << c[2][2] << endl;
    return 0;
}

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

int main(){
  int n, k;
  vector<int> A;
  cin >> n >> k;
  A = vector<int>(n);
  for(int i = 0; i < n; i++) cin >> A[i];
  
  for(int i = 0; i < k; i++){
    vector<int> B(n,0);
    vector<int> C(n,0);
    for(int j = 0; j < n; j++){
      int s = max(0, j-A[j]);
      int e = min(j+A[j], n-1);
      B[s]++;
      if(e+1 < n) B[e+1]--;
    }
    C.at(0) = B.at(0);
    for(int j = 1; j < n; j++) C[j] = C[j-1] + B[j];
   
    if(A == C){
      for(int j = 0; j < n; j++){
        if(j) cout << " ";
        cout << A[j];
      }
      cout << endl;
      return 0;
    }
    
    for(int j = 0; j < n; j++) A[j] = C[j];
  }
  
  for(int i = 0; i < n; i++){
    if(i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 5628
n=gets.to_i

k = 0
1.upto(1000) do |i|
    if i * (i-1) / 2 == n
        k = i
        break
    elsif i * (i-1) / 2 > n
        break
    end
end

if k == 0
    puts "No"
    exit
else
    puts "Yes"
end

s = 1
ans = []
1.upto(k-1) do |i|
    (i+1).upto(k) do |j|
        ans[i] = [] if ans[i] == nil
        ans[j] = [] if ans[j] == nil
        ans[i] << s
        ans[j] << s
        s += 1
    end
end
puts k
1.upto(k) do |i|
    printf("%d ", ans[i].size)
    puts ans[i].join(" ")
end

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

// 2つの整数の場合
long long GetGreatestCommonDivisor(long long a, long long b)
{
    long long m = a;
    long long n = b;
    long long temp;
    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }
    return n;
}

int main() {

    ll k; cin >> k;
    ll ans = 0;
    for (ll i = 1; i <= k; i++) {
        for (ll j = 1; j <= k; j++) {
            for (ll x = 1; x <= k; x++) {
                vector<ll> c;
                c.push_back(i);
                c.push_back(j);
                c.push_back(x);
                // 3つ以上の整数の場合
                long long gcd = c[0];
                for (int z = 0; z < c.size(); z++) {
                    gcd = GetGreatestCommonDivisor(gcd, c[z]);
                }
                ans += gcd;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
#define MAX 1000007
#define INF 0x3f3f3f3f
#define NINF 0xc0c0c0c0 

using namespace std;
typedef long long ll;
ll arr[MAX],sum[MAX],dp[MAX];

int main(){
    ll n;
    scanf("%lld",&n);
    for(int i =1;i<=n;i++){
        scanf("%lld",&arr[i]);
        if(i>=2)sum[i]=sum[i-2]+arr[i];
        else sum[i]=arr[i];
    }
    for(int i = 2;i<=n;i++){
        if(i&1){
            dp[i] = max(dp[i-1],dp[i-2]+arr[i]);
        }else{
            dp[i] = max(sum[i-1],dp[i-2]+arr[i]);
        }
    }
    printf("%lld",dp[n]);
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull t;cin>>t;while(t--)
#define pll pair<ll,ll>
#define puu pair<ull,ull>
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define Vint vector<int>
#define Vll vector<ll>
#define Vull vector<ull>
#define nl cout<<endl
#define sp cout<<" "
#define MOD 1000000007
#define all(x) x.begin(),x.end()

int main() 
{
	 // #ifndef ONLINE_JUDGE
  //       freopen("input.txt", "r", stdin);
  //       freopen("output.txt", "w", stdout);
  //   #endif
  //   fastio();
    ll n,w;
    cin>>n>>w;
    vector<pll> v(n,{0,0});
    loop(i,0,n)
    {
    	cin>>v[i].f>>v[i].s;
    }

    ll sum_val = 0;

    loop(i,0,n)
    	sum_val+= v[i].s;

    vector<ll> dp(sum_val+1,INT_MAX);
    
    dp[0] = 0;

    for(ll items = 0;items<n;items++)
    {
    	for(ll val_alr = sum_val-v[items].s;val_alr>=0;val_alr--)
    	{
    		dp[val_alr + v[items].s] = min(dp[val_alr + v[items].s],dp[val_alr] + v[items].f);
    	}
    }

    ll ans = 0;

    loop(i,0,sum_val+1)
    {
    	if(dp[i]<=w)
    		ans = i;
    	// else
    	// 	break;
    }

    cout<<ans;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define M 998244353
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

ll power(ll a,ll b){
    ll t=1;
    while(b){
        if(b&1) t=(t*a)%M;
        a=(a*a)%M;b>>=1;
    }
    return t;
}

int main(){
    cs
    ll n,m,k,t=0,x=1,y=1,g,ans=0;
    cin>>n>>m>>k;
    if(m==1) {
        if(k==n-1) bye(1)
        bye(0)
    }
    t=power(m-1,n-1);
    t*=m;t%=M;ans=t;
    g=power(m-1,M-2);
    for(ll i=1;i<=k;i++){
        x*=n-i;x%=M;
        y*=i;y%=M;
        t*=g;t%=M;
        ans+=(((t*x)%M)*power(y,M-2))%M;
        ans%=M;
    }
    cout<<ans;
}

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

using namespace std;
using ll = long long;

#define MOD 1000000007

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

int main() {
    int n; cin >> n;
    ll a[n];
    ll cnt[64];
    memset(cnt, 0, sizeof cnt);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        for (int j = 0; j < 61; j++) {
            if (a[i] & (1ll << j)) cnt[j]++;
        }
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 61; j++) {
            if (a[i] & (1ll << j)) {
                ans = modAdd(ans, modMul(n - cnt[j], 1ll << j));
            } else {
                ans = modAdd(ans, modMul(cnt[j], 1ll << j));
            }
        }
    }

    cout << modDiv(ans, 2) << endl;
}


Measured memory_bytes: 2560
n=int(input())
from collections import defaultdict 
d=defaultdict(list)
for i in range(n-1):
    a,b,c=map(int,input().split())
    a-=1 
    b-=1 
    d[a].append([b,c])
    d[b].append([a,c])
qry,k=map(int,input().split())
k-=1 
dist=[0]*n 
dist[k]=-0 
vis=[0]*n 
vis[k]=1 
from collections import deque
q=deque() 
q.append(k)
while q: 
    t=q.popleft() 
    for node,weight in d[t]: 
        if not vis[node]:
            vis[node]=1 
            q.append(node)
            dist[node]=dist[t]+weight
while qry:
    qry-=1 
    a,b=map(int,input().split())
    a-=1 
    b-=1 
    print(dist[a]+dist[b])

Measured memory_bytes: 103512
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

#define N 200005

ll powa(ll a, ll b, ll c)
{
    a%=c;
    ll res = 1;
    while(b>0)
    {
        if(b&1)
            res*=a, res%=c;
        a*=a, a%=c;
        b>>=1;
    }
    return res;
}

ll fact[N];
ll ifact[N];
ll ncr(ll n, ll r)
{
    if(r>n)
        return 0;
    ll ans = fact[n];
    ans*=ifact[r];
    ans%=mod;
    ans*=ifact[n-r];
    ans%=mod;
    return ans;
}


int main()
{
   FAST/**/
   
    fact[0] = 1;
   for(ll i=1;i<N;i++)
        fact[i] = fact[i-1]*i, fact[i]%=mod;
   for(ll i=0;i<N;i++)
        ifact[i] = powa(fact[i],mod-2,mod);
   
   ll powa2[64];
   powa2[0] = 1;
   for(ll i=1;i<64;i++)
        powa2[i] = powa2[i-1]*2, powa2[i]%=mod;
   
   ll n;
   cin>>n;
   
   ll arr[n];
   rep(n)
        cin>>arr[i];
   
   if(n == 1)
   {
       cout<<(2*arr[0])%mod;
       return 0;
   }
   sort(arr,arr+n);
   //ll moi2 = powa(2,mod-2,mod);
   ll ans = 0;
   
   for(ll i=1;i<=n;i++)
   {
       ll ar = arr[i-1];
       ll temp = powa(4,n-1,mod);
       temp*=ar;
       temp%=mod;
       temp*=(n-i+2);
       temp%=mod;
       //cout<<"at "<<i<<" = "<<temp<<"\n";
       
       ans+=temp;
       ans%=mod;
   }
   
   cout<<ans;
    
   return 0;        
}  
   

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;





int main() {
    int n; cin >> n;
    vector<ll> A(n);
    rp(i, 0, n) scanf("%lld", &A.at(i));
    ll res1 = 0ll;
    ll res2 = 0ll;
    vector<ll> sum1(n);
    vector<ll> sum2(n);
    if(A.at(0) == 0) {
        sum1.at(0) = 1ll;
        sum2.at(0) = -1ll;
        res1 ++; res2++;
    }
    else if(A.at(0) > 0) {
        sum1.at(0) = A.at(0);
        sum2.at(0) = -1ll;
        res2 += A.at(0) + 1ll;
    }
    else {
        sum1.at(0) = A.at(0);
        sum2.at(0) = 1ll;
        res2 += -A.at(0) + 1ll;
    }

    rp(i, 1, n) {
        sum1.at(i) = sum1.at(i-1) + A.at(i);
        if(sum1.at(i) == 0) {
            if(sum1.at(i-1) < 0) sum1.at(i) = 1ll;
            else sum1.at(i) = -1ll;
            res1 ++;
        }
        if(sum1.at(i) * sum1.at(i-1) > 0) {
            if(sum1.at(i) < 0) {
                res1 += -sum1.at(i) + 1ll;
                sum1.at(i) = 1ll;
                
            }
            else {
                res1 += sum1.at(i) + 1ll;
                sum1.at(i) = -1ll;
            }
        }

        sum2.at(i) = sum2.at(i-1) + A.at(i);
        if(sum2.at(i) == 0) {
            if(sum2.at(i-1) < 0) sum2.at(i) = 1ll;
            else sum2.at(i) = -1ll;
            res2 ++;
        }
        if(sum2.at(i) * sum2.at(i-1) > 0) {
            if(sum2.at(i) < 0) {
                res2 += -sum2.at(i) + 1ll;
                sum2.at(i) = 1ll;
            }
            else {
                res2 += sum2.at(i) + 1ll;
                sum2.at(i) = -1ll;
            }
        }
    }
    ll res = min(res1, res2);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> p;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9

void StoI(string S, int T[]) {
	for (int i = 0; i < S.size(); i++) T[i] = S[i] - '0';
}

int main() {
	int T[10];
	string S; cin >> S;
	StoI(S, T);

	ll ans = 0;
	int n = S.size() - 1;

	for (int i = 0; i < (1 << n); i++) { // i<<j = 1 : j+1個目が＋
		ll tmp = 0;
		for (int j = 0; j < n; j++) {
			tmp = 10 * tmp + T[j];
			if (i&(1 << j)) {
				ans += tmp;
				tmp = 0;
			}
		}
		ans += tmp * 10 + T[n];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
WV = [tuple(map(int, input().split())) for _ in range(N)]
R = 3 * N + 10
INF = 10**18

w0 = WV[0][0]

dp = [[-INF] * R for _ in range(N + 1)]
dp[0][0] = 0

for w, v in WV:
    k = w - w0
    for n in range(N)[::-1]:
        for r in range(R)[::-1]:
            if r + k < R and dp[n + 1][r + k] < dp[n][r] + v:
                dp[n + 1][r + k] = dp[n][r] + v

ans = 0
for n in range(N + 1):
    for r in range(R):
        w = n * w0 + r
        if w <= W and dp[n][r] > ans:
            ans = dp[n][r]
print(ans)


Measured memory_bytes: 4200
#include <stdio.h>

int min(int x, int y)
{
  return (x < y ? x : y);
}

int main(void)
{
  int n, m;
  int c[20];
  int dp[50010];
  int i, j;

  scanf("%d %d", &n, &m);
  for (i = 0; i < m; i++){
    scanf("%d", &c[i]);
  }

  dp[0] = 0;
  for (i = 1; i <= n; i++){
    dp[i] = 1 << 28;
  }

  for (i = 0; i < m; i++){
    for (j = 0; j + c[i] <= n; j++){
      dp[j + c[i]] = min(dp[j + c[i]], dp[j] + 1);
    }
  }

  printf("%d\n", dp[n]);

  return (0);
}

Measured memory_bytes: 792
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))
def inpl_str():
    '''
    一行に複数の文字
    '''
    return list(input().split())

n = inp()
s=set()
for i in range(n):
    st=input()
    s.add(st)
print(len(s))

Measured memory_bytes: 88244
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        x: isize,
        k: isize,
        d: isize,
    }

    if d >= x.abs() {
        if k % 2 == 0 {
            println!("{}", x.abs())
        } else {
            println!("{}", (x.abs() - d).abs())
        }
    } else {
        // 引ける回数
        let f = x.abs() / d;
        if f >= k {
            println!("{}", ((x.abs() - k * d).abs()))
        } else {
            let l_cnt = k - f;
            let l_dist = (x.abs() - f * d).abs();

            if l_cnt % 2 == 0 {
                println!("{}", l_dist.abs())
            } else {
                println!("{}", (l_dist.abs() - d).abs())
            }
        }
    }
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 2204
program main
  implicit none
  integer(16) dp(0:300,0:300),a(0:300,0:300)
  integer(16) N
  integer(16) r,ret,i,j,k
  integer(16) pw(0:300)
  integer(16)::mo=1000000007
  read*,N
  pw(0)=1_16
  do i=1,n+1
    pw(i)=mod(pw(i-1)*2_16,mo)
  end do
  dp=0_16
  dp(0,0)=1_16
  do j=0,n-1 
    do k=0,j
  	  dp(j+1,k+1)=mod(dp(j+1,k+1)+mod(dp(j,k)*(pw(n)-pw(k)),mo),mo)
  	  dp(j+1,k)=mod(dp(j+1,k)+mod(dp(j,k)*pw(k),mo),mo)
	end do
  end do
  a=0
  do i=0,n-1
    read*,a(i,0:N-1)
  end do
  r=gauss(a,N)
  ret=0
  do i= r,n
    ret=mod(ret+mod(dp(n,i)*dp(i,r),mo)*powmod(2_16,n*n-i*n,mo),mo)
  end do
  ret=mod(ret*powmod(dp(n,r),mo-2_16,mo),mo)
  
  if(ret<=0)ret=ret+mo
  print"(i0)",ret
  
contains
function powmod(aa,b,mo)
  implicit none
  integer(16) aa,b,mo,ak,bk
  integer(16) powmod
  powmod=1_16
  bk=b
  ak=mod(aa,mo)
  do while(bk/=0_16)
    if(mod(bk,2)==1)then
      powmod=mod(powmod*ak,mo)
    endif
    ak=mod(ak*ak,mo)
    bk=bk/2_16
  end do
end function

function gauss(a,N)
  implicit none
  integer(16) N,a(0:300,0:300)
  integer(16) gauss
  integer(16) p,i,j,k
  integer(16) fg
  p=0
  do i=0,n-1
	fg=0
	do j=p,n-1 
      if (a(j,i)>0)then	
        do k=0,n-1 
          call swap(a(p,k),a(j,k))
        end do
        fg=1
		exit
      endif
    end do
	if (fg==0) cycle
    do j=p+1,n-1 
      if (a(j,i)>0)then
	    do k=0,n-1 
          a(j,k) = xor(a(j,k),a(p,k))
        end do
	  endif
    end do
	p=p+1
  end do
  gauss=p
end function

subroutine swap(a,b)
  implicit none
  integer(16) a,b
  a=xor(a,b)
  b=xor(a,b)
  a=xor(a,b)
end subroutine
end

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B,C;
    cin >>A>>B>>C;
    if(A+B>=C) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;



}


Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		switch (S) {
		case "SUN":
			System.out.println("7");
			break;
		case "MON":
			System.out.println("6");
			break;
		case "TUE":
			System.out.println("5");
			break;
		case "WED":
			System.out.println("4");
			break;
		case "THU":
			System.out.println("3");
			break;
		case "FRI":
			System.out.println("2");
			break;
		case "SAT":
			System.out.println("1");
			break;
		}
	}
}

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

int main(void)
{
  int n, a, b;
  int a2 = 0;
  int b2 = 0;
  char s[100001];
  cin >> n >> a >> b;
  int sum = a + b;
  cin >> s;
  
  for ( int i=0; i<n; i++ ) {
    if ( a2 + b2 >= sum ) {
      cout << "No" << endl;
      continue;
    }
    if ( s[i] == 'a' ) {
        cout << "Yes" << endl;
        a2++;
    } else if ( s[i] == 'b' ) {
      if ( b2 >= b ) {
        cout << "No" << endl;
      } else {
        cout << "Yes" << endl;
        b2++;
      }
    } else {
      cout << "No" << endl;
    }
  }
  
  return 0;
}

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

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		Scanner cin = new Scanner(System.in);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String  NN =br.readLine();
			int N = Integer.parseInt(NN);
			if(N==0){
				break;
			}
			String[] s= {"@"};
			for(int i =0;i<N;i++){
				String strr = br.readLine();
				String[] tmp = strr.split(" ");
				String[] tmp2=s.clone();
				s=new String[tmp.length+tmp2.length];
				for(int j = 0;j<tmp.length;j++){
					s[j]=tmp[j].toString();
				}
				for(int j = tmp.length;j<s.length;j++){
					s[j]=tmp2[j-tmp.length].toString();
				}
			}
			
			Arrays.sort(s);
			for(int i = 0;i<s.length;i++){
				//System.out.println(s[i]);
			}
			Candid[] candid = new Candid[s.length-1];
			int cnt=0;
			for(int i = 1;i<s.length;i++){
				if(s[i].equals(s[i-1])){
					candid[cnt-1].count++;
				}
				else{
					candid[cnt++]=new Candid(s[i]);
				}
			}
			Candid[] tmp = candid.clone();
			candid = new Candid[cnt];
			for(int i = 0;i<cnt;i++){
				candid[i]=tmp[i];
			}
			Arrays.sort(candid);
			for(int i = 0;i<cnt;i++){
				//System.out.println(candid[i]);
			}
			String key =br.readLine();
			cnt=0;
			for(int j = 0;j<candid.length;j++){
				if(key.charAt(0)==candid[j].word.charAt(0)){
					if(cnt==0){
						System.out.print(candid[j].word);
					}
					else{
						System.out.print(" "+candid[j].word);
					}
					
					cnt++;
				}
				if(cnt==5){
					break;
				}
			}
			if(cnt==0){
				System.out.print("NA");
			}
			System.out.println();
		}
	}

}
class Candid implements Comparable{
	String word;
	int count;
	Candid(String s){
		word=s;
		count=1;
	}
	public int compareTo(Object o) {
		Candid c = (Candid)o;
		if(this.count!=c.count){
			return c.count-this.count;
		}
		else{
			return this.word.compareTo(c.word);
		}
	}
	public String toString(){
		return word+" "+count;
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){
    string s;

    cin >> s;

    int cnt =0;
    rep(i,3){
        if(s[i] == '1') cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.06.22 20:56:50
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

int main() {
    int n, l;
    scanf("%d%d", &n, &l);
    int ret = 0;
    if (l >= 1) {
        rep1(i, n - 1) {
            ret += l + i;
        }
    } else if (l + n - 1 < 0) {
        rep1(i, n - 1) {
            ret += l + i - 1;
        }
    } else {
        rep1(i, n) {
            ret += l + i - 1;
        }
    }
    printf("%d\n", ret);

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int ma[10][10];
void fil(int i,int j)
{
    if(ma[i+1][j]==1)
    {
        ma[i+1][j]=0;
        fil(i+1,j);
    }
    else
    {
        if(ma[i][j+1]==1)
        {
            ma[i][j+1]=0;
            fil(i,j+1);
        }
    }
}
int main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    int n,m,i,j;
    char c;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            scanf(" %c ",&c);
            if(c=='#')
            {
                ma[i][j]=1;
            }
        }
    }
    if(ma[1][1]==1)
    {
        ma[1][1]=0;
        fil(1,1);
    }
    int p=0;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(ma[i][j]==1)
                p=1;
        }
    }
    if(p==0)
    {
        printf("Possible");
    }
    else
    {
        printf("Impossible");
    }
    return 0;
}


Measured memory_bytes: 128
def choco(m,n):
	if m%2==0:
		return [m*n//2,m*n//2]
	else:
		if m==1: return [(n-n%2)//2,(n+n%2)//2]
		else: return [(m-1)*n//2,(m+1)*n//2]

h,w = (int(i) for i in input().split())
answer = h*w
for i in range(1,h):
	x,y = [],[]
	x.append(i*w)
	y.append(i*w)
	x += choco(h-i,w)
	y += choco(w,h-i)
	num = min(max(x)-min(x),max(y)-min(y))
	if num<answer:
		answer = num
for j in range(1,w):
	x,y = [],[]
	x.append(j*h)
	y.append(j*h)
	x += choco(w-j,h)
	y += choco(h,w-j)
	num = min(max(x)-min(x),max(y)-min(y))
	if num<answer:
		answer = num
print(answer)


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

int main(){
  int D;cin >> D;
  ll G;cin >> G;
  G = G / 100;
  vector<int> P(D);
  vector<ll> C(D);
  for(int i=0;i<D;i++){
    cin >> P[i] >> C[i];
    C[i] = C[i]/100;
  }
  int ans=10000;
  for(int bit=0;bit<(1<<D);bit++){
    ll tmp=0;
    int num=0;
    bool valid = true;
    for(int i=0;i<D;i++){
      if(bit&(1<<i)){
        tmp += (C[i]+P[i]*(i+1));
        num += P[i];
      }
    }
    for(int i=D-1;i>=0;i--){
      if(tmp>=G){
        break;
      }
      if(bit&(1<<i)){
      }else{
        if(tmp+(P[i]-1)*(i+1)>=G){
          int k = (G-tmp-1)/(i+1)+1;
          num += k;
          break;
        }else{
          valid = false;
          break;
        }
      }
    }
    //cout << bit << " " << num << " " << valid << endl;
    if(valid){
      ans = min(ans,num);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N,M=map(int,input().split())

class UnionFind:
    def __init__(self,n):
        self.par=[i for i in range(n)]
        self.siz=[1]*n
        
    def root(self,x):
        while self.par[x]!=x:
            self.par[x]=self.par[self.par[x]]
            x=self.par[x]
        return x
    
    def unite(self,x,y):
        x=self.root(x)
        y=self.root(y)
        if x==y:
            return False
        if self.siz[x]<self.siz[y]:
            x,y=y,x
        self.siz[x]+=self.siz[y]
        self.par[y]=x
        return True
    
    def is_same(self,x,y):
        return self.root(x)==self.root(y)
    
    def size(self,x):
        return self.siz[self.root(x)]

u=UnionFind(N)
for _ in range(M):
    a,b=map(int1,input().split())
    u.unite(a,b)
ans=0
s=set()
for i in range(N):
    s.add(u.root(i))
print(len(s)-1)

Measured memory_bytes: 81528
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	int a[200001],i;
	cin>>n;
	int c=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(i=0;i<n;i++)
	{
		if(a[i]==a[i+1])
		{
		c=1;
		break;
	}
	}
	if(c==1)
	cout<<"NO";
	else
	cout<<"YES";


}

Measured memory_bytes: 1024
N = int(input())
pn = [ int(item) for item in input().split()]
ANS = list(range(1,N+1))

import copy

if pn == ANS:
  print('YES')
else:
  flag=False
  for i in range(len(pn)):
    pi = pn[i]
    for j in range(len(pn)):
      pj = pn[j]
      pnc = copy.deepcopy(pn)
      pnc[j] = pi
      pnc[i] = pj
      if pnc == ANS:
        print('YES')
        flag=True
        break
    if flag==True:
      break
  if flag == False:
    print('NO')

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N,K,U,L;
double cnt,V,T;
bool mp[10010];

int main(){
  cin>>N>>K>>T>>U>>V>>L;
  for(int i=0,a,A;i<N;i++){
    cin>>a;
    A=a;
    while(mp[a]&&(a-A)/V/T<K)a++;
    for(int j=a;j<L&&j<a+T*V;j++)cnt+=!mp[j],mp[j]=1;
  }

  printf("%.8f\n",cnt/V+(L-cnt)/U);
  return 0;
}

Measured memory_bytes: 1256
import sys
sys.setrecursionlimit(100000)

def set_enable_goal(cur_node, back_paths, enable_goal):
    if cur_node in back_paths:
        for next_node in back_paths[cur_node]:
            if enable_goal[next_node - 1] == 0:
                enable_goal[next_node - 1] = 1
                set_enable_goal(next_node, back_paths, enable_goal)


N, M = map(int, input().split())
MIN = float('-inf')
INF_LIMIT = -MIN

back_paths = {}
all_paths = {}
for i in range(M):
    a, b, c = map(int, input().split())
    if a in all_paths:
        all_paths[a].append((b, c))
    else:
        all_paths[a] = [(b, c)]

    if b in back_paths:
        back_paths[b].append(a)
    else:
        back_paths[b] = [a]


# path cut
enable_goal= [0 for i in range(N)]
enable_goal[N - 1] = 1
set_enable_goal(N, back_paths, enable_goal)

scores = [MIN for i in range(N)]
scores[0] = 0

is_inf = False
for n in range(N):
    for a in all_paths.keys():
        if not enable_goal[a - 1]:
            continue
        for b, c in all_paths[a]:
            if not enable_goal[b - 1]:
                continue
            scores[b - 1] = max(scores[b - 1], scores[a - 1] + c)

# loop check
if not is_inf:
    prev_score = scores[N - 1]
    for a in all_paths.keys():
        if not enable_goal[a - 1]:
            continue
        for b, c in all_paths[a]:
            if not enable_goal[b - 1]:
                continue
            scores[b - 1] = max(scores[b - 1], scores[a - 1] + c)
    if prev_score != scores[N - 1]:
        is_inf = True


if is_inf:
    print('inf')
else:
    print(scores[N - 1])

Measured memory_bytes: 4300