akhauriyash/Code-Regression huggingface dataset:
// finish date: 2018/01/20
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int N, x;
    cin >> N >> x;
    int left = 0, right;
    ll count = 0;
    rep(i, N) {
        cin >> right;
        if (left + right > x) {
            count += left + right - x;
            left = x - left;
        } else {
            left = right;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import product

N = int(input())
s = input()

swap = {'S': 'W', 'W': 'S'}
for a, b in product('SW', repeat=2):
    t = [None] * N
    t[0] = a
    t[1] = b
    for i in range(1, N - 1):
        if t[i] == 'S':
            if s[i] == 'o':
                t[i + 1] = t[i - 1]
            elif s[i] == 'x':
                t[i + 1] = swap[t[i - 1]]
        elif t[i] == 'W':
            if s[i] == 'o':
                t[i + 1] = swap[t[i - 1]]
            elif s[i] == 'x':
                t[i + 1] = t[i - 1]
    if t[N - 1] == 'S':
        if s[N - 1] == 'o' and t[N - 2] != t[0]:
            continue
        elif s[N - 1] == 'x' and t[N - 2] == t[0]:
            continue
    elif t[N - 1] == 'W':
        if s[N - 1] == 'o' and t[N - 2] == t[0]:
            continue
        elif s[N - 1] == 'x' and t[N - 2] != t[0]:
            continue
    if t[0] == 'S':
        if s[0] == 'o' and t[N - 1] != t[1]:
            continue
        elif s[0] == 'x' and t[N - 1] == t[1]:
            continue
    elif t[0] == 'W':
        if s[0] == 'o' and t[N - 1] == t[1]:
            continue
        elif s[0] == 'x' and t[N - 1] != t[1]:
            continue
    print(''.join(t))
    exit()
print(-1)


Measured memory_bytes: 4852
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
using namespace std;

static const int MAX_N = 100;

class comp
{
    public:
    bool operator() (pair<int, int> a, pair<int, int> b)
    {
        return a.second < b.second ? false : true;
    }
};

void dijkstra(vector<vector<pair<int, int> > > way)
{
    priority_queue<pair<int, int>, vector<pair<int, int> >, comp> PQ;
    pair<int, int> edge;
    int d[way.size()];    // array to store the cost to respective nodes
    bool on[way.size()];  // flags to indicate the minimum cost to its node has been calculated

    // initialize
    for (int i = 0; i < way.size(); i++) {
        d[i] = 0;
        on[i] = false;
    }
    PQ.push(make_pair(0, 0));

    while (!PQ.empty()) {
        edge = PQ.top();
        PQ.pop();
        // if flag is up, continue
        if (on[edge.first]) continue;
        on[edge.first] = true;
        d[edge.first] = edge.second;
        for (auto itr = way.at(edge.first).begin(); itr != way.at(edge.first).end(); ++itr) {
            if (!on[itr->first]) PQ.push(make_pair(itr->first, d[edge.first] + itr->second));
        }
    }
    // print costs
    for (int i = 0; i < way.size(); i++) {
        cout << i << " " << d[i] << endl;
    }
}

int main()
{
    int n;
    cin >> n;
    vector<vector<pair<int, int> > > way(n);
    int k, c, u, v;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            way.at(u).push_back(make_pair(v, c));
        }
    }
    dijkstra(way);
    return 0;
}

Measured memory_bytes: 13636
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

void trace (vector<int> const & a) {
    int n = a.size();
    for(int i=0; i<n; ++i) {
        if(i) cout << " ";
        cout << a[i];
    }
    cout << endl;
}

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

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

    trace(a);
    for(int i=1; i<n; ++i) {
        int j = i-1;
        int v = a[i];
        while(j>=0 && a[j] > v) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        trace(a);
        
    }


    return 0;
}



Measured memory_bytes: 3224
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int H,W;
        String work[] = new String[2];
 
        while(true){
 
            try {
                work = br.readLine().split("[\\s]+");
 
                if(work[0].equals("0") && work[1].equals("0"))break;
 
                H = Integer.parseInt(work[0]);
                W = Integer.parseInt(work[1]);
 
                for(int col = 0; col < W; col++){
                    System.out.printf("#");
                }
                System.out.printf("\n");
 
                for(int row = 1; row <= H-2; row++){
                    System.out.printf("#");
                    for(int col = 1; col <= W-2; col++){
                        System.out.printf(".");
                    }
                    System.out.printf("#\n");
                }
 
                for(int col = 0; col < W; col++){
                    System.out.printf("#");
                }
                System.out.printf("\n\n");
 
 
            } catch (IOException e) {
 
                e.printStackTrace();
            }
        }
    }
}


Measured memory_bytes: 56168
import sys
n = int(input())
h = list(map(int, input().split()))

max = 0
max_i = 0
count = 0
for i in range(n - 1):
    if h[i] >= h[i + 1]:
        count += 1
        if count > max:
            max = count
    else:
        count = 0

print(max)


Measured memory_bytes: 63984
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>

ll llmax = pow(10,18);
int main(void)
{
    ll n;
    cin>>n;

    vector<ll> a(n);

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

        if(a[i]==0)
        {
            cout<<0<<endl;
            return 0;
        }
    }

    ll ans =1;


    for(int j=0;j<n;j++)
    {


        if(a[j]>llmax/ans)
        {
            cout<<-1<<endl;
            return 0;
        }


        else ans *=a[j];
    }

    if(ans>llmax) cout<<-1<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 3568
// @Author :- Gaurav Bharti
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define empb emplace_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define mapii map<int,int> 
#define mapll map<ll,ll>
#define all(a) a.begin(),a.end()
#define test ll t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define ItsFUN ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007

ll binpow(ll a, ll b) {
	ll res = 1;
	while(b) {
		if(b&1) res = res * a ; 
		a = a * a ;
		b = b >> 1;
	}

	return res;
}

int main(){
	ItsFUN;

	int n ;cin >> n;

	vector<int> p(n);
	for(int i = 0; i < n; i++) cin >> p[i];
	int ans = 0;

	for(int i = 1; i < n - 1; i++) { 
		if((p[i - 1] < p[i]) && (p[i] < p[i + 1])) ans++; 
		else if((p[i - 1] > p[i]) && (p[i] > p[i + 1])) ans++;
 	}
	cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int result = INF;
	REP(i, 26) {
		int count = 0;
		int prev = -1;
		int j;
		for(j = 0; j < n; j++) {
			if(s[j] == i + 'a') {
				chmax(count, j - prev - 1);
				prev = j;
			}
		}
		chmax(count, j - prev - 1);
		chmin(result, count);
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 3632
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    str t; cin>>t;
    if(t[0]=='S') cout<<"Cloudy";
    else if(t[0]=='C') cout<<"Rainy";
    else cout<<"Sunny";
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int64 n;
  cin >> n;
  int64 ans = n - 1;
  for (int64 x = 1; x * x <= n; x++) {
    if (n % x == 0) {
      int64 y = n / x;
      UpdateMin(ans, x + y - 2);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int n,i,a[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=n-1;i>=0;i--){
		printf("%d",a[i]);
		if(i>0){
			printf(" ");
		}
		else{
			printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2036
#include<cstdio>
using namespace std;
#define inf 0x3f3f3f
typedef long long ll;
const int maxn = 2e4+5;
int n,m;
int main(){
	scanf("%d%d",&n,&m);
	int ans = n*(n-1)/2 + m*(m-1)/2;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 888
from sys import stdin, setrecursionlimit


def main():
    INF = float('inf')
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    dp = [[INF] * (1 << n) for _ in range(m)]

    for i in range(m):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))

        dp[i][0] = 0

        tmp = 0
        for ci in c:
            tmp |= 1 << (ci - 1)

        if i == 0:
            dp[i][tmp] = a
        else:
            for j in range(1 << n):
                dp[i][j] = min(dp[i][j], dp[i - 1][j])
                dp[i][j | tmp] = min(dp[i][j | tmp], dp[i - 1][j] + a)

    ans = dp[m - 1][-1]
    if ans == INF:
        print(-1)
    else:
        print(dp[m - 1][-1])


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 137052
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
 
#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
 
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
        if(N%2==0) {
            cout << N;
        }else{
            cout << N*2;
        }
    
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    private static final int SIZE = 10000000;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        ArrayList<Integer> primeList = new ArrayList<Integer>(SIZE);
        createPrime(primeList);
        int n = Integer.parseInt(br.readLine());
        int count = 0;
        for (int i = 0; i < n; i++) {
            int p = Integer.parseInt(br.readLine());
            if (prime(p, primeList)) {
                count++;
            }
        }
        System.out.println(count);
    }

    static boolean prime(int n, ArrayList<Integer> primeList) {
        if (n <= 1000000) {
            for (int i = 0; primeList.get(i) * primeList.get(i) <= n; i++) {
                // ????±??????°??????????????\????????¨???????´???°??§????????????
                if (0 == n % primeList.get(i)) { //???????????????????´???°??§?????????
                    return false;
                }
            }
            return true;
        } else {
            for (int i = 0; primeList.get(i) * primeList.get(i) <= 1000000; i++) {
                // ????±??????°??????????????\????????¨???????´???°??§????????????
                if (0 == n % primeList.get(i)) { //???????????????????´???°??§?????????
                    return false;
                }
            }
            for (int i = 3; i * i <= n; i += 2) {
                if (n % i == 0) {
                    return false;
                }
            }
            return true;
        }
    }

    public static void createPrime(ArrayList<Integer> primeList) {
        int n = 1000000;
        primeList.add(2);
        primeList.add(3);
        for (int i = 5; i <= n; i += 2) { //????±?????\???°??????
            boolean wflag = false; //???????????????????????????
            for (int j = 1; primeList.get(j) * primeList.get(j) <= i; j++) {
                // ????±??????°??????????????\????????¨???????´???°??§????????????
                if (0 == i % primeList.get(j)) { //???????????????????´???°??§?????????
                    wflag = true;
                    break;
                }
            }
            if (!wflag) { //???????????§????????????????????£??????
                primeList.add(i); //?´???°??¨????????°????????????
            }
        }
    }
}

Measured memory_bytes: 70632
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>

#include <sstream>
#include <algorithm>
#include <cmath>

#include <string>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>

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

#include<cassert>//assert();
#include <fstream>
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
#ifdef getchar_unlocked
#define mygc(c) (c)=getchar_unlocked()
#else
#define mygc(c) (c)=getchar()
#endif
#ifdef putchar_unlocked
#define mypc(c) putchar_unlocked(c)
#else
#define mypc(c) putchar(c)
#endif
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
/////////
using namespace::std;
/////////
#ifdef _DEBUG
#define DEBUG_BOOL(b) assert(b)
#else
#define DEBUG_BOOL(b) 
#endif
/////数値読み込み
#define ENABLE_READER_ON(T)	\
inline void reader(T &x){\
	int k;x = 0;bool flag = true;\
	while(true){\
		mygc(k);\
		if( k == '-'){\
			flag = false;break;\
		}\
		if('0' <= k && k <= '9'){\
			x = k - '0';break;\
		}\
	}\
	if( flag ){\
		while(true){\
			mygc(k);\
			if( k<'0' || '9'<k)break;\
			x = x * 10 + (k - '0');\
		}\
	}else{\
		while(true){\
			mygc(k);\
			if( k<'0' || '9'<k)break;\
			x = x * 10 - (k-'0');\
		}\
	}\
}
//整数
ENABLE_READER_ON(int)
ENABLE_READER_ON(long)
ENABLE_READER_ON(long long)
ENABLE_READER_ON(unsigned int)
ENABLE_READER_ON(unsigned long)
ENABLE_READER_ON(unsigned long long)

//////
//文字読み込み
inline int reader(char c[]){int i,s=0;
for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}
c[s++]=i;
for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}
c[s]='\0';return s;
}

inline int reader(string& c,int size=100){int i;c.reserve(size);
for(;;){mygc(i);if(i != ' '&&i != '\n'&&i != '\r'&&i != '\t'&&i != EOF)break;}
c.push_back(i);
for(;;){mygc(i);if(i == ' ' || i == '\n' || i == '\r' || i == '\t' || i == EOF)break;c.push_back(i);}
return c.size();}

/////////
//数値出力
#define ENABLE_WRITER_ON(T)	\
inline void writer(T x){char f[20];int s = 0;\
if (x<0){mypc('-');while(x){f[s++] = ~(x%10)+1,x /= 10;}}\
else{while(x){f[s++] = (x % 10), x /= 10;}}\
if (!s)f[s++] = 0;while (s--)mypc(f[s] + '0');}

ENABLE_WRITER_ON(int)
ENABLE_WRITER_ON(long)
ENABLE_WRITER_ON(long long)
ENABLE_WRITER_ON(unsigned int)
ENABLE_WRITER_ON(unsigned long)
ENABLE_WRITER_ON(unsigned long long)
/////////
inline void writer(const char c[]){for (int i = 0; c[i] != '\0'; i++)mypc(c[i]); }
inline void writer(const string str){writer( str.c_str() );}

inline void solve(){
	string str1,str2;
	LL A,B,C,D;
	
	cin>>A>>B>>C>>D;
	cout << max(A*B,C*D) << endl;


}

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//小数を10進数表示
    //cout << setprecision(16);//小数をいっぱい表示する。16?

	solve();

	return 0;
}


Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sec second
#define fir first
#define pb push_back



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
//const int inf = pow(2, 62);
//const int mod = 1e9 + 7;
const int mod = 100000;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};



/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




/* main */
int ceil(int a, int b){
    if(a % b == 0) return a /b;
    else return a /b + 1;
}


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    
    string ans = "";

    rep(i,0,3) ans += toupper(raw_input()[0]);

    print(ans);




    
    



    
    

    







   




    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000; //
const ll LINF = (ll) 4000000000000000000; //
const ll MOD = (ll) 1000000007; //
const double PI = acos(-1.0); //

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())

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

int main() {
    string s;
    cin >> s;
    set<char> st;
    for (auto c : s) {
        st.insert(c);
    }

    if (s.length() <= 25) {

        rep(i, 26) {

            if (!st.count((char) ('a' + i))) {
                cout << s << (char) ('a' + i) << endl;
                return 0;
            }
        }
    } else {
        if (s == "zyxwvutsrqponmlkjihgfedcba") {
            cout << -1 << endl;
            return 0;
        } else {
            vector<char> v;
            for (auto c : s) v.push_back(c);
            NP(v);
            string t = "";

            rep(i, s.length()) {
                if (s[i] == v[i]) t.push_back(s[i]);
                else {
                    t.push_back(v[i]);
                    cout << t << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}


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

int N;
void resistors(){
    cin >> N;
    int A[N]={};
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    double sum=0;
    for(int i=0;i<N;i++){
        sum += (double)1/(double)A[i];
    }
    cout.precision(10);
    cout << (double)1/sum << endl;
}

int main(){
    resistors();
    return 0;
}

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

int main() {
  int h, w;
  std::cin >> h >> w;
  bool s[50][50];

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c;
      std::cin >> c;
      if (c == '#') {
        s[i][j] = true;
      } else {
        s[i][j] = false;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j]) {
        if (i != 0 && s[i - 1][j]) {
        } else if (i != h - 1 && s[i + 1][j]) {
        } else if (j != 0 && s[i][j - 1]) {
        } else if (j != w - 1 && s[i][j + 1]){
        } else {
          std::cout << "No" << std::endl;
          return 0;
        }
      }
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
 
#define MOD 1000000007
 
int dp[100010][13] = {};
 
int main() {
	string s; cin >> s;
 
	dp[s.size()][0] = 1;
	long long dig = 1;
	for (int i = s.size() - 1; i >= 0; --i) {
		if (s[i] == '?') {
			for (int j = 0; j < 10; ++j) {
				for (int k = 0; k < 13; ++k) {
					dp[i][(j * dig + k) % 13] += dp[i + 1][k];
					dp[i][(j * dig + k) % 13] %= MOD;
				}
			}
		} else {
			int x = s[i] - '0';
			for (int k = 0; k < 13; ++k) {
				dp[i][(x * dig + k) % 13] += dp[i + 1][k];
				dp[i][(x * dig + k) % 13] %= MOD;
			}
		}
		dig *= 10; dig %= 13;
	}
	cout << dp[0][5] << endl;
 
	return 0;
}

Measured memory_bytes: 5504
n,k=map(int,input().split())
if k>((n-1)*(n-2))//2:
  print(-1)
else:
  print(n-1+((n-1)*(n-2))//2-k)
  for i in range(n-1):
    print(i+1)
    print(n)
  j=1
  l=2
  for i in range(((n-1)*(n-2))//2-k):
    print(j)
    print(l)
    l+=1
    if l==n:
      j+=1
      l=j+1



Measured memory_bytes: 44392
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();

		System.out.println(Math.min(b, n*a));
	}

}


Measured memory_bytes: 22996
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    N,K=map(int,input().split())

    cntlist=[0]*(N+1)
    for i in range(1,N+1):
        cnt=0
        j=i
        while j<K:
            j=j*2
            cnt+=1
        else:
            cntlist[i]=cnt
    for i in range(N+1):
        cntlist[i]=0.5**cntlist[i]

    print((1/N)*sum(cntlist[1:]))

resolve()

Measured memory_bytes: 44400
#解説参照
l=int(input())
r=0
while 2**(r+1)<=l:
    r+=1
n=r+1
ans=[]
for i in range(r):
    ans.append((i+1,i+2,0))
    ans.append((i+1,i+2,2**i))

for t in range(n-1,0,-1):
    if l-2**(t-1)>=2**r:
        ans.append((t,n,l-2**(t-1)))
        l-=2**(t-1)
print(n,len(ans))
for a in ans:
    print(*a)

Measured memory_bytes: 38384
a,b=map(int,input().split())

# 1/1,2/2,3/3,4/4,5/5,6/6,7/7,8/8,9/9,10/10,11/11,12/12

ans = a-1
if b>=a:
	print(ans+1)
else:
	print(ans)
	

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

int main(void) {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> v(n);
    FOR(i, n) cin>>v[i];
    sort(v.begin(), v.end());
    int ans = 0;
    for(int i=n-1;i>=2;i--){
        for(int j=0;j<i;j++){
            for(int k=j+1;k<i;k++){
                if(v[i]<v[j]+v[k])
                    ans++;
            }
        }
    }
    cout<<ans;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 1e6 + 5;

char c[MAXN];

void solve(){
	int n, q, k;
	scanf("%d%s%d", &n, &c[0], &q);
	while(q--) {
		scanf("%d", &k);
		ll ans = 0ll;
		ll cnt_m = 0ll, cnt_c = 0ll, cnt = 0ll;
		for(int i = n - 1; i >= 0; i--) {
			if (i + k < n) {
				if (c[i + k] == 'C') {
					cnt -= cnt_m;
					cnt_c--;
				} else if (c[i + k] == 'M') {
					cnt_m--;
				}
			}
			if (c[i] == 'C') {
				cnt_c++;
			} else if (c[i] == 'M') {
				cnt += cnt_c;
				cnt_m++;
			} else if (c[i] == 'D') {
				ans += cnt;
			}
			//printf("%lld %lld %lld %lld\n", cnt_m, cnt_c, cnt, ans);
		}
		printf("%lld\n", ans);
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 1280
/*
Problem

Category
全探索・全列挙

URL
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_B&lang=ja

Date: 2020/03/24
*/

#include <bits/stdc++.h>
// #include "../utils.cpp"
using namespace std;

/* ==== declarations ====== */
// functions
void solve();

// global variables
int n; // 最大値
int x; // 合計

/* ======================== */

void solve() {
    int ans = 0;
    for (int i=1; i<=n; ++i) {
        for (int j=i+1; j<=n; ++j) {
            for (int k=j+1; k<=n; ++k) {
                if (i + j + k == x) {
                    ans++;
                    // cout<<i<<", "<<j<<", "<<k<<endl;
                }
            }
        }
    }
    cout<<ans<<endl;
}

int main() {
    bool co = true;
    while(co) {
        cin>>n>>x;
        co = n || x;
        if (co) solve();
    }

}


Measured memory_bytes: 3104
n=int(input())
s=input()
cnt=0
for i in range(1000):
    num=str(i).zfill(3)
    x=s.find(num[0])
    y=s.find(num[1],x+1)
    z=s.find(num[2],y+1)
    if x!=-1 and y!=-1 and z!=-1:
        cnt +=1
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
#define SIZE 200005
vector<ll> graph[SIZE];
ll ans[SIZE];
bool assign[SIZE];
set<ll> A;
set<ll> B;
void bipartite(ll u,ll p,ll color){
	if(color) B.insert(u);
	else A.insert(u);
	// cout<<u<<endl;
	for(auto v:graph[u]){
		if(v!=p)
			bipartite(v,u,1-color);
	}
}
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll N;
	cin>>N;
	for(ll i=1;i<=N;++i){
		graph[i].clear();
		assign[i]==false;
	}
	for(ll i=0;i<N-1;++i){
		ll u,v;
		cin>>u>>v;
		graph[u].pb(v);
		graph[v].pb(u);
	}
	A.clear();
	B.clear();
	bipartite(1,0,0);
	if(A.size()>B.size()){
		swap(A,B);
	}
	// for(auto e:A){
	// 	cout<<e<<" ";
	// }
	// cout<<endl;
	// for(auto e:B){
	// 	cout<<e<<" ";
	// }
	// cout<<endl;
	if(A.size()<=(N/3)){
		ll first=3;
		for(auto e:A){
			ans[e]=first;
			assign[first]=true;
			first=first+3;
		}
		first=1;
		for(auto e:B){
			if(assign[first]==true){
				first++;
			}
			ans[e]=first;
			first++;
		}
		for(ll i=0;i<N;++i){
			cout<<ans[i+1]<<" ";
		}
	}
	else{
		ll first=1;
		for(auto e:A){
			if(first>N) break;
			ans[e]=first;
			assign[e]=true;
			first+=3;
		}
		first=2;	
		for(auto e:B){
			if(first>N) break;
			ans[e]=first;
			assign[e]=true;
			first+=3;
		}
		first=3;
		for(auto e:A){
			if(assign[e]==true) continue;
			if(first>N) break;
			ans[e]=first;
			assign[e]=true;
			first+=3;
		}
		for(auto e:B){
			if(assign[e]==true) continue;
			if(first>N) break;
			ans[e]=first;
			assign[e]=true;
			first+=3;
		}
		for(ll i=0;i<N;++i){
			cout<<ans[i+1]<<" ";
		}
	}
}

Measured memory_bytes: 28800
N = int(input())
s = 0
front_b = 0
tail_a = 0
has_a_b = 0
for i in range(N):
    t = input()
    s += t.count('AB')
    if t[0] == 'B' and t[len(t) -1] == 'A':
        has_a_b += 1
    elif t[0] == 'B':
        front_b += 1
    elif t[len(t) -1] == 'A':
        tail_a += 1

res = s
if has_a_b > 0:
    if front_b > 0 and tail_a > 0:
        res += has_a_b + 1 + min(front_b-1, tail_a-1)
    elif front_b > 0 or tail_a > 0:
        res += has_a_b
    else:
        res += has_a_b - 1
else:
    res += min(front_b, tail_a)

print(res)



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

#define rep(i, first, to) for(ll i = first; i < to; ++i)

using namespace std;
typedef long long ll;

void solve() {
	int n, r, g, b;
	cin >> r >> g >> b;
	n = 100 * r + 10 * g + b;
	cout << ( n % 4 == 0 ? "YES" : "NO") << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,i,l,m;
    cin>>a>>b;
    if(a==1||b==1){
       
    if(a==1&&b==1){
          cout<<"Draw"<<endl;
    }
     if(b!=1&&a==1){
        cout<<"Alice"<<endl;

    }
     if(a!=1&&b==1){
        cout<<"Bob"<<endl;

    }
    }
    else{
        if(a!=1&&a>b){
        cout<<"Alice"<<endl;

    }
     if(b!=1&&a<b){
        cout<<"Bob"<<endl;

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

    }
    }



}


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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

ll cur = 1, cnt = 0, residue1 = 0, residue0 = 0;
vector<vector<ll>> v;
int n; string x;
ll calc(ll cur, ll MOD){
    ll steps = 0; cur = (cur%MOD + MOD)%MOD;
    while(cur > 0){
        steps++;
        cur %= __builtin_popcount(cur);
    }
    return steps;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> x;
    v.assign(2, vector<ll>(n, 0));
    for(auto i : x) cnt += i == '1';
    cnt++;
    for(int i = n - 1; i >= 0; --i){
        residue1 += cur * (x[i] - '0');
        v[1][i] = cur;
        cur *= 2;
        cur %= cnt, residue1 %= cnt;
    }
    cnt -= 2, cur = 1;
    if(cnt > 0){
        for(int i = n - 1; i >= 0; --i){
            residue0 += cur * (x[i] - '0');
            v[0][i] = cur;
            cur *= 2;
            cur %= cnt, residue0 %= cnt;
        }
    }
    cnt++;
    // cout << "HERE";
    //now residue has residue mod 
    for(int i = 0; i < n; ++i){
        if(x[i] == '1'){
            if(cnt - 1 == 0) cout << 0 << "\n";
            else cout << calc(residue0 - v[0][i] + (cnt - 1), cnt - 1) + 1 << "\n";
        }
        else{
            cout << calc(residue1 + v[1][i], cnt + 1) + 1 << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 8360
#include <stdio.h>
#include <string.h>
int main(void){
    int N, M, b_fase=0;
    char A[50][50], B[50][50];
    scanf("%d%d", &N, &M);
    for (int i=0; i<N; i++) scanf("%s", A[i]);
    for (int i=0; i<M; i++) scanf("%s", B[i]);

    for(int i=0; i<N; i++){
        for(int j=0; j<=N-M; j++){
            if(strncmp(A[i]+j, B[0], M)==0){
                for(int k=0; k<M; k++){
                    if(strncmp(A[i+k]+j, B[k], M)!=0) break;
                    if(k==M-1){
                        printf("Yes");
                        return 0;
                    }
                }
            }
        }
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 1752
readint()=parse.(Int,readline())


N=readint()
S=Vector{String}(undef,N)
for i in 1:N
    S[i]=readline()
end
println("AC x ",sum(S.=="AC"))
println("WA x ",sum(S.=="WA"))
println("TLE x ",sum(S.=="TLE"))
print("RE x ",sum(S.=="RE"))

Measured memory_bytes: 192448
N, W = map(int, input().split())
Data = [list(map(int, input().split())) for _ in range(N)]

dp = [[None for _ in range(W+1)] for _ in range(N+1)]
dp[0] = [0]*(W+1)

for i in range(1, N+1):
    for j in range(W+1):
        if Data[i-1][0] <= j:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-Data[i-1][0]] + Data[i-1][1])
        else:
            dp[i][j] = dp[i-1][j]

print(max(dp[-1]))


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

int main() {
  int A,B;
  cin>> A>>B ;
  
  if ( A-1 >= B )
  {
    cout << A + ( A - 1 )<< endl;
  }
  else if ( A <= B - 1)
  {
    cout << B + ( B - 1 )<< endl;
  }
  else if ( A > B && A-1 <= B)
  {
   cout <<  A + B << endl; 
  }
  else if ( A < B && B-1 <= A)
  {
    cout << B + A << endl;
  }
  else if ( A = B )
  {
    cout << A + B << endl;
  }
  
}

Measured memory_bytes: 256
while True:
    sum=0
    N,x = map(int,input().split())
    if N==x==0:break
    sum=0
    for i in range(1,N-1):
        for j in range(i+1,N):
            for k in range(j+1,N+1):
                if i+j+k==x:
                    sum+=1
                    break
    print(sum)


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

int main(){
	while(1){
		int x,y;
		cin>>x>>y;
		int a[10],b[10];
		for(int i=0;i<10;i++){
			a[i]=0;
			b[i]=0;
		}
		int ans=0;
		if(x==0&& y==0) break;
		for(int i=0;i<x;i++){
			cin>>a[i];
			ans+=a[i];
		}
		for(int i=0;i<y;i++){
			int z;
			cin>>z;
			int check=0;
			for(int j=0;j<x;j++){
				if(a[j]==z && b[j]==0){
					b[j]=1;
					check=1;
					break;
				}
			}
			if(check==1) 1;
			else ans+=z;
		}
		cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 3060
import java.util.Scanner;

class Main {
    public static void main(String []args){
        Scanner in = new Scanner (System.in);
        int n = in.nextInt ();
        int[] arr = new int[n];
        int[] brr = new int[n];
        for(int i=0;i<n;i++){
            arr[i] = in.nextInt();
        }
        for(int i=0;i<n;i++){
            brr[i] = in.nextInt();
        }
        int max=0;
        for(int i=0;i<n;i++){
            if(arr[i]>brr[i])
                max+= arr[i]-brr[i];
        }
        System.out.println(max);

    }
}

Measured memory_bytes: 23764
import sys

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


def main():
    n = int(readline())

    if n % 2 == 0:
        m = n * (n - 1) // 2 - n // 2
        print(m)
        for i in range(1, n + 1):
            k = n - i + 1
            for j in range(i + 1, n + 1):
                if j == i or j == k:
                    continue
                print(i, j)
    else:
        m = n * (n - 1) // 2 - n // 2
        print(m)
        for i in range(1, n + 1):
            k = n - i
            for j in range(i + 1, n + 1):
                if j == i or j == k:
                    continue
                print(i, j)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74632
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const int N = 1005;
vi adj[N];
int visited[N], nxt[N];
int start = -1;

bool dfs(int u) {
	visited[u] = 1;
	for (int v : adj[u]) {
		if (visited[v] == 1) {
			nxt[u] = v;
			start = v;
			return true;
		}
		else if (visited[v] == 0) {
			if (dfs(v)) {
				nxt[u] = v;
				return true;
			}
		}
	}
	visited[u] = 2;
	return false;
}

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

	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		adj[a].push_back(b);
	}

	for (int i = 1; i <= n; i++) {
		if (!visited[i]) {
			if (dfs(i)) break;
		}
	}

	if (start == -1) {
		puts("-1");
		return 0;
	}

	while (true) {
		bool changed = false;
		set<int> s{start};
		for (int u = nxt[start]; u != start; u = nxt[u])
			s.insert(u);

		int u = start;
		do {
			for (int v : adj[u]) {
				if (v != nxt[u] && s.count(v)) {
					nxt[u] = v;
					start = v;
					changed = true;
					break;
				}
			}
			if (changed) break;
			u = nxt[u];
		} while (u != start);

		if (!changed) break;
	}

	vi answer{start};
	for (int u = nxt[start]; u != start; u = nxt[u])
		answer.push_back(u);
	printf("%lu\n", answer.size());
	for (int u : answer) printf("%d\n", u);
}


Measured memory_bytes: 384
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    x = kwargs["x"]
    n = int(x ** 0.25) + 1
    R = [[0 for i in range(n)] for i in range(n)]
    done = False

    for i in range(n):
        R[0][i] = i ** 5
        R[i][0] = i ** 5

    for i in range(0, n):
        for j in range(i + 1, n):
            R[i][j] = R[0][j] - R[0][i]

            if R[i][j] == x:
                res = '{} {}'.format(j, i)
                done = True
                break

        for j in range(1, i):
            R[i][j] = R[i][0] + R[j][0]

            if R[i][j] == x:
                res = '{} {}'.format(i, -j)
                done = True
                break

        if done:
            break

    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    #kwargs["n"] = cin[0]
    #kwargs["n"], kwargs["k"] = cin
    kwargs["x"] = [int(i) for i in cin][0]
    #kwargs["n"], kwargs["k"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Measured memory_bytes: 31360
#include <stdio.h>

int main(){
  char str[3][3];
  for(int i=0;i<3;i++){
      scanf("%c%c%c\n",&str[i][0],&str[i][1],&str[i][2]);
  }
  
  printf("%c%c%c\n",str[0][0],str[1][1],str[2][2]);
}


Measured memory_bytes: 128
n,a = map(int,input().split())
x = list(map(int,input().split()))

#dp[j][k][s] = (x0...xj からk枚選んでxiの合計をsにするような選び方の総数)
dp = [[[0 for s in range(a*n+1) ] for k in range(n+1) ] for j in range(n)]

for j in range(n):
    dp[j][0][0]=1
    if x[0]<= a*n:
        dp[j][1][x[0]] = 1

for j in range(n-1):
    for k in range(n+1):
        for s in range(a*n+1):
            if k>j+2:
                dp[j+1][k][s]=0
            elif s>=x[j+1] and k>= 1:
                dp[j+1][k][s]=dp[j][k][s] + dp[j][k-1][s-x[j+1]]
            else:
                dp[j+1][k][s]=dp[j][k][s]

res = 0
for i in range(1,n+1):
    res += dp[n-1][i][a*i]

print(res)

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

int main(){
  int N;
  cin>>N;
  int V[N],C[N];
  for(int i = 0;i < N;i++) cin>>V[i];
  for(int i = 0;i < N;i++) cin>>C[i];
  int Max = 0;
  int a[N];
  int dp[N] = {};
  for(int i = 0;i < N;i++){
     a[i] = V[i] - C[i];
  }
  for(int i = 0;i < N;i++){
      dp[i+1] = max(dp[i],dp[i]+a[i]);
  }
  cout<<dp[N];
}

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

typedef pair<int,int> P; //500, -totalcost

P dp[101][50000];

int main(){
    int n;
    while(cin>>n,n){
        fill(dp[0],dp[101],P(0,-5000000));
        dp[0][0]=P(0,0);
        for(int i=0;i<n;i++){
            int price;
            cin>>price;
            for(int c=0;c<50000;c++){
                if(dp[i][c].second<=-5000000) continue;
                dp[i+1][c]=max(dp[i+1][c],dp[i][c]); //????????????
                if(price%1000==0){
                    if(c>=500){
                        dp[i+1][c-500]=max(dp[i+1][c-500],P(dp[i][c].first+1,dp[i][c].second-price));
                    }
                    continue;
                }else{
                    if(price%1000<=500){//500????????¨?????£???????¢???????
                        int cc= c + 1000 - price%1000 - 500;
                        dp[i+1][cc]=max(dp[i+1][cc],P(dp[i][c].first+1,dp[i][c].second-price));
                    }else{
                        if(price%1000-500<=c){
                            int cc = c - (price%1000-500);
                            //?°???????????????????500??????????¢???????
                            dp[i+1][cc]=max(dp[i+1][cc],P(dp[i][c].first+1,dp[i][c].second-price));
                        }
                        //500??????????¢??????????????°???????????¢???????
                        int cc = c + (1000-price%1000);
                        dp[i+1][cc]=max(dp[i+1][cc],P(dp[i][c].first,dp[i][c].second-price));
                    }
                }
            }
        }
        P ans = P(0,-5000000);
        for(int c=0;c<50000;c++) if(dp[n][c].second>-5000000) ans = max(dp[n][c],ans);
        cout<<ans.first<<' '<<-ans.second<<endl;
    }


    return 0;
}

Measured memory_bytes: 42436
#include <bits/stdc++.h>
#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;
int dp[3005][3005];

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

  cin >> N >> T;
  vector<pair<int, int>> cooking;

  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    cooking.push_back(make_pair(A, B));
  }
  cooking.push_back(make_pair(0, 0));

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

  int ans = 0;
  dp[0][0] = 0;

  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < T; j++) {
      dp[i][j] = dp[i - 1][j];
      ans = max(ans, cooking[i].second + dp[i - 1][j]);
      if (j - cooking[i].first >= 0) {
        dp[i][j] =
            max(dp[i][j], dp[i - 1][j - cooking[i].first] + cooking[i].second);
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 35584
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        var hash = new HashSet<char>();
        foreach(var c in s) {
            if(!hash.Contains(c)) hash.Add(c);
        }

        for(char c = 'a'; c<='z'; c++) {
            if(!hash.Contains(c)) return c.ToString();
        }

        return "None";
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }

}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int n; cin >> n;

    int dp[100010];

    for (int i = 0; i < 100010; ++i) {
        dp[i] = INF;
    }

    dp[0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int pow6 = 1; i + pow6 <= n; pow6 *= 6) {
            dp[i + pow6] = min(dp[i + pow6], dp[i] + 1);
        }

        for (int pow9 = 1; i + pow9 <= n; pow9 *= 9) {
            dp[i + pow9] = min(dp[i + pow9], dp[i] + 1);
        }
    }

    cout << dp[n] << endl;
}

Measured memory_bytes: 640