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

#define FOR(i, a, n) for(int i = a; i < n; ++i)
#define logarr(arr) for(auto i : arr) { cout << i << " "; } cout << "\n";
#define ll long long
#define sc(a) scanf("%d", &a);
#define scl(a) scanf("%lld", &a);

bool bsearch(vector<int> v, int n) {
    int l = 0, r = v.size() - 1;
    while(l <= r) {
        int mid = (l + ((r - l) / 2));
        if (v[mid] == n) {
            return true;
        }
        else if (v[mid] < n) {
            l = mid + 1;
        }
        else {
            r = mid - 1;
        }
    } 
    return false;
}

int lbound(vector<int> v, int n) {
    int l = 0, r = v.size() - 1;
    int ans;
	while(l <= r) {
		
		int mid = l + (r - l) / 2;
		if (v[mid] <= n) {
			ans = v[mid];
			l = mid + 1;
		}
		else {
			r = mid - 1;
		}
	}	
	return ans;
}

void solve() {

    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    vector<ll> a(n), b(m), prefA(n+1), prefB(m+1);
    FOR(i, 0, n) { scl(a[i]); }
    FOR(i, 0, m) { scl(b[i]); }
    prefA[0] = 0; prefB[0] = 0;

    FOR(i, 0, n) {
        prefA[i+1] += a[i] + prefA[i];
    }
    FOR(i, 0, m) {
        prefB[i+1] += b[i] + prefB[i];
    }

    int ans = 0;

    FOR(i, 0, n+1) {
        ll f = k - prefA[i];
        if (f < 0) 
            continue;
        int l = lower_bound(prefB.begin(), prefB.end(), f) - prefB.begin();
        if (l > m || prefB[l] > f) {
            l--;
        }
        ans = max(ans, i+l);
    } 
    cout << ans << "\n";
}


int main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input", "r", stdin);
    freopen("output", "w", stdout);
#endif

    int t = 1;
    // sc(t); 
    while(t--) {
		solve();
    }
    return 0;

}

Measured memory_bytes: 9600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999
#define int ll

vector<string> split(string s,char ch){
    vector<string> ret;
    string tmp ="";
    rep(i,s.size()){
        if(s[i]==ch){
            ret.pb(tmp);
            tmp = "";
        }else tmp+=s[i];
    }
    if(tmp.size())ret.pb(tmp);
    return ret;
}

string addString(string a,string b ){
    if(a.size()<b.size())swap(a,b);         //len(a)>len(b)???
    b = string(a.size()-b.size(),'0')+b;    //b????????????a??¨??????????????????????????????0??§?????????
    
    string ans = string(a.size()+1,'0');    //a?????????+1 ?????????0??§???????????????
    for(int i=(int)a.size()-1;i>=0;i--){    //?¶??????? & ??°????????????
        ans[i+1] += (a[i]-'0') + (b[i]-'0');
        if(ans[i+1]>='0'+10){
            ans[i] += 1;
            ans[i+1] -= 10;
        }
    }
    string ret = "";                        //??????????????°???0????¶????
    rep(i,ans.size()){
        if(ans[i]!='0'||i==ans.size()-1){
            ret = ans.substr(i,ans.size()-i);
            break;
        }
    }
    return ret;
}


bool is(string s){
    rep(i,s.size())if(s[i]=='+')s[i]='=';
    vector<string> res = split(s,'=');
    rep(i,res.size()){
        if(res[i].size()>=2&&res[i][0]=='0')return false;
    }
    if(addString(res[0],res[1])==res[2])return true;
    return false;
}



signed main(){
    string s;
    while(cin>>s){
        rep(i,10){
            string tmp = s;
            rep(j,tmp.size())if(tmp[j]=='X')tmp[j]='0'+i;
            if(is(tmp)){
                cout<<i<<endl;
                break;
            }
            if(i==9)cout<<"NA"<<endl;
        }
    }
}

Measured memory_bytes: 3132
// A - Ferris Wheel
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int a, b, r;
	cin >> a >> b;
	if (a <= 5) r = 0;
	else if (a <= 12) r = b / 2;
	else r = b;
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		for(int i=0;i<totalVertex;i++) {
			//System.out.println(""+i+" "+adjList.get(i).size());
			for(int j=0;j<totalVertex;j++) {
				adjMatrix[i][j]=0;
				
				for(int k=0;k<adjList.get(i).size();k++) {
					if(j==adjList.get(i).get(k)) {
						//System.out.println(i+" "+j);
						adjMatrix[i][j]=1;
					}
				}
				
				if(j==totalVertex-1) {
					System.out.println(adjMatrix[i][j]);
				}else {
					System.out.print(adjMatrix[i][j]+" ");
				}
				
			}
		}
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


Measured memory_bytes: 33100
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,m; cin >> n >> m;
    vector<vector<ll>> graph(n);
    rep(i,m) {
        ll a,b;cin >> a >> b;
        a--;b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }
    bool ok = false;
    for(auto to : graph[0]){
        for(auto dis : graph[to]){
            if(dis == n-1)ok = true;
        }
    }

    cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 12776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main (){
  int N ; 
  cin >> N ;
  int count = 0 ;
  vector<int> d(N);
  rep(i,N) cin >> d.at(i) ; 
  sort(d.begin(),d.end());
  //rep(i,N) cout << d.at(i) << " " ;
  //cout << endl;
  //cout << d.at( N/2 - 1 ) << " " <<  d.at( N/2 ) << endl;
  while( d.at( N/2 - 1 ) != d.at( N/2 )){
    count++;
    d.at( N/2 - 1 ) ++;
  }
  cout <<  count << endl;
}



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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, M;
	cin >> N >> M;
	if (N == 1 && M == 1)
	{
		cout << 1 << endl;
	}
	else if (N == 1)
	{
		cout << M - 2 << endl;
	}
	else if (M == 1)
	{
		cout << N - 2 << endl;
	}
	else
	{
		cout << (M - 2)*(N - 2) << endl;
	}

	return 0;
}

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

typedef long long ll;
typedef long double ld;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define ROF(i,a,n) for(int i=(a);i>(n);--i)

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
 //   freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
    int n;ld d;cin>>n>>d;
    int cnt=0;
    while(n--){
        ld x,y; cin>>x>>y;
        if(pow(x*x+y*y,0.5)<=d) cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b) a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b) a=b;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  lint n; cin >> n;
  cout << --n / 2 << '\n';
}


Measured memory_bytes: 256
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]

AB = sorted(AB,key = lambda x:x[0])

con = 0
yen = 0

flag = 0

for i in range(N):
  amount = AB[i][1]
  price = AB[i][0]
  for j in range(0,amount):
    con += 1
    yen += price
    if con == M:
      flag = 1
      break
  if flag == 1:
    break
    
print(yen)

Measured memory_bytes: 29752
dummy = list(map(int, input().split(" ")))
N = dummy[0]

P = list(map(int, input().split(" ")))

out = 0
min = N + 1
for a in range(N):
    if(P[a] <= min):
        min = P[a]
        out += 1

#print(P)
print(out)

Measured memory_bytes: 24744
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <climits>
using namespace std;
 
typedef long long ll;

#define MAX_V 1000
#define INF 100000000000LL

ll V;
ll cap[MAX_V][MAX_V];
bool used[MAX_V];

ll dfs(ll v, ll g, ll f){
  if(v == g) return f;
  used[v] = true;

  for(ll i = 0; i < V; i++){
    ll c = cap[v][i];
    if(!used[i] && c > 0){
      ll d = dfs(i, g, min(f, c));

      if(d > 0){
        cap[v][i] -= d;
        cap[i][v] += d;
        return d;
      }
    }
  }
  return 0;
}

ll mf(ll s, ll g){
  ll flow = 0;
  for(;;){
    memset(used, 0, sizeof(used));
    ll f = dfs(s, g, INF);
    if(f == 0) return flow;
    flow += f;
  }
}

void add_edge(ll from, ll to, ll c){
  cap[from][to] = c;
  cap[to][from] = 0;
}

int main(){
  ll n, w;
  map<string,int> week;
 
  week["Sunday"] = 0;
  week["Monday"] = 1;
  week["Tuesday"] = 2;
  week["Wednesday"] = 3;
  week["Thursday"] = 4;
  week["Friday"] = 5;
  week["Saturday"] = 6;
 
  while(cin >> n >> w, n || w){
    memset(cap, -1, sizeof(cap));

    for(ll i = 0; i < 7; i++){
      add_edge(0, i + 1, w);
    }
 
    ll sum = 0;
 
    for(ll i = 0; i < n; i++){
      ll tn, cn;
      cin >> tn >> cn;
      add_edge(i + 8, n + 8, tn);
      sum += tn;
 
      for(ll j = 0; j < cn; j++){
        string s;
        cin >> s;
        ll from = week[s] + 1;
        add_edge(from, i + 8, w);
      }
    }

    V = n + 9;

    ll flow = mf(0, V - 1);

    if(flow == sum){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 9032
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
V<ll>Fac,Rac;void setF(int n,int mod){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%mod;Rac[n-1]=modInv(Fac[n-1],mod);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%mod;}
ll comb(int a,int b,int m){return a<0||b<0?0:Fac[a+b]*Rac[a]%m*Rac[b]%m;}

const int IINF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 1e6+10;

int c1, c2, r1, r2;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  setF(N*2, MOD);
  cin >> r1 >> c1 >> r2 >> c2;
  int _r1=r1, _c1=c1, _r2=r1, _c2=c1;
  ll s = comb(r1, c1, MOD), ans = 0;
  while(s){
    ans += s;
    s = s*2 + comb(++_r1, _c1-1, MOD) + comb(_r2-1, ++_c2, MOD);
    if(_r1>r2) s-= comb(_r1--, _c1++, MOD);
    if(_c2>c2) s-= comb(_r2++, _c2--, MOD);
    s %= MOD;
  }
  cout << (ans%MOD+MOD)%MOD << endl;
}

Measured memory_bytes: 31488
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;

struct Node{
    int key;
    Node *right,*left,*parent;
};

Node *root,*NIL;

Node * find(Node *u,int k){
    while(u!=NIL&&k!=u->key){
        if(k<u->key) u=u->left;
        else u=u->right;
    }
    return u;
}

void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;
    
    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;
    while(x!=NIL){
        y=x;
        if(z->key<x->key) x=x->left;
        else x=x->right;
    }
    z->parent=y;
    if(y==NIL) root=z;
    else{
        if(z->key<y->key) y->left=z;
        else y->right=z;
    }
}

void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,i,x;
    string com;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }
        else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        else if(com=="find"){
            scanf("%d",&x);
            Node *t=find(root,x);
            if(t!=NIL) printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}



Measured memory_bytes: 22072
fun main(args: Array<String>) {
    val n: String = readLine()!!
    val target: String = n[n.length - 1].toString()

    if (
        target == "2"
        || target == "4"
        || target == "5"
        || target == "7"
        || target == "9"
    ) {
        println("hon")
    } else if (
        target == "0"
        || target == "1"
        || target == "6"
        || target == "8"
    ) {
        println("pon")
    } else if (
        target == "3"
            ) {
        println("bon")
    }
}

Measured memory_bytes: 34360
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void testCase();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	int n, k;
	string s;
	cin >> n >> k >> s;
	s[k - 1] = tolower(s[k - 1]);
	cout << s << "\n";
}

Measured memory_bytes: 256
S = input()
l = len(S)
ans = 100000000
count = 1
for i in range(l-1):
	if S[i+1] != S[i]:
		tmp = max([i+1,l-i-1])
		ans = min([ans,tmp])

if ans == 100000000:
	ans = l
print(ans)



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

typedef long long ll;
typedef pair<int,int> P;
const ll MOD = 998244353;

int main(){
	static int n;
	static int a[100010];
	static int b[100010];
	scanf("%d",&n);
	for(int i = 1 ; i <= n ; i ++)scanf("%d",&a[i]);
	for(int i = 1 ; i <= n ; i ++)scanf("%d",&b[i]);
	
	vector<P> A;
	for(int i = 1 ; i <= n ; i ++){
		A.push_back(P(a[i],i));
	}
	sort(A.begin(),A.end());
	vector<P> B;
	for(int i = 1 ; i <= n ; i ++){
		B.push_back(P(b[i],i));
	}
	sort(B.begin(),B.end());
	
	static int nex[100010];
	for(int i = 1 ; i <= n ; i ++){
		nex[A[i-1].second] = B[i-1].second;
	}
	for(int i = 1 ; i <= n ; i ++){
		if(A[i-1].first > B[i-1].first){
			puts("No");
			return 0;
		}
	}
	
	bool ret = false;
	for(int i = 1 ; i+1 <= n ; i ++){
		if(A[i].first <= B[i-1].first)ret = true;
	}
	int cnt = 1, loc = nex[1];
	while(loc != 1){
		cnt ++;
		loc = nex[loc];
	}
	if(cnt != n)ret = true;
	
	if(ret)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 3316
# npを使わずにリストの破壊的ソートを利用する場合

x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort()
q.sort()

p = p[::-1][:x]
q = q[::-1][:y]
a = p + q + r
a.sort(reverse=True)

print(sum(a[:x+y]))

Measured memory_bytes: 22720
#include "bits/stdc++.h"
#define rep(i,n) for(ll i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define ll long long
 
ll count(ll num1,ll num2){
  if(num1>num2)swap(num1,num2);
  ll k1;
    if((num2-num1)%3==0){
      k1=(num2-num1)/3;
    }else{
      k1=(num2-num1)/3;
      for(ll dif=-2;dif<3;dif++){
        if(num2-2*(k1+dif)<=k1+dif+num1){
          k1+=dif;
          break;
        }
      }
    }
    if(k1<0)return -1;
    ll k2;
    if(k1+num1==num2-2*k1){
      k2=2*k1-2;
    }else{
      k2=num1+num2-k1-1;
    }
    //cout<<k1<<" "<<k2<<" "<<k1+k2<<" "<<num1+num2<<endl;
    return k1+k2;
}
int main(void){
	ll k;
  cin >> k ;
  //t-2*k1<=k1 t<=3*k1
  /* 
  if(t-k1 %2==1){
    k2=t-k1-1;

  }else{
    k2=t-k1-2;
  }
  
  */
  ll ans=k+500;
  ll ans1,ans2;
  int flag2=0;
 if(k<1000000){
      rep(i,1000){
        ll c=count(0,ans-i);
        if(c<0)continue;
        if(c==k){
          ans-=i;
          //cout<<k1<<" "<<k2<<endl;
          break;
        }
        if(c<k){
          ll i2=i-1;
          flag2=1;

          rep(j,10000){
            ll num1=j;
            ll num2=ans-i-j;
            ll c2=count(num1,num2);
            if(c2==k){
              ans1=num1;
              ans2=num2;
              break;
            }
          }
          ans-=i;
          break;
        }
    }
  }else{
    ll odd =k%50;
    ll num3=k/50;
    vl a(50,num3-odd+50-1);
    rep(i,odd){
      a[i]+=51;
    }
    cout<<50<<endl;
    rep(i,50){
      cout<<a[i]<<" ";
    }
    return 0;
  }

  cout<<2<<endl;
  if(flag2==0){
    cout<<flag2<<" "<<ans<<endl;

  }else{
    cout<<ans1<<" "<<ans2<<endl;
  }
	return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {
	public static void main( String[] args ) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] ABC = br.readLine().split( " " );
		boolean flgNG = false;
		Integer cntFive = 0;
		Integer cntSeven = 0;
		for( Integer cnt = 0; cnt < 3; cnt++){
			Integer i = Integer.valueOf( ABC[cnt] );
			if( i == 5 ) {
				cntFive++;
				if( cntFive > 2 ) {
					flgNG = true;
					break;
				}
			} else if( i == 7 ) {
				cntSeven++;
				if( cntSeven > 1 ) {
					flgNG = true;
					break;
				}
			} else {
				flgNG = true;
				break;
			}
		}
		if( flgNG ) {
			System.out.println( "NO" );
		} else {
			System.out.println( "YES" );
		}
	}
}


Measured memory_bytes: 20692
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    let iroha = [5,5,7];
    input! { a: usize, b: usize, c: usize, }
    let mut abc = vec![a,b,c];
    abc.sort();
    if abc.iter().zip(iroha.iter()).fold(true, |checker, i| checker & (i.0 == i.1)) {
      println!("YES");
    }
    else{
      println!("NO");
    }
}

Measured memory_bytes: 4352
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    cnt=[Dict{Char,Int}() for i in 1:n]
    a=[chomp(readline()) for i in 1:3]
    for i in 1:n
        for j in 1:3
            if haskey(cnt[i],a[j][i])
                cnt[i][a[j][i]]+=1
            else
                cnt[i][a[j][i]]=1
            end
        end
    end
    ans=0
    for i in 1:n
        m=""
        res=0
        for j in keys(cnt[i])
            if cnt[i][j]>res
                m=j
                res=cnt[i][j]
            end
        end
        for j in 1:3
            if a[j][i]!=m
                ans+=1
            end
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 171548
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<vc> vcc;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 7;
void solve(){
    string s; cin>>s;
    mci m;
    for(char c:s) m[c]++;
    int ans=2;
    for(auto i:m){
        if(i.S!=ans){
            cout<<"No";
            return;
        }
    }
    cout<<"Yes";
}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

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

int main(){
  ll n;cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v.at(i);
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  ll tate = 0,yoko = 0;
  rep(i,n-1){
    if (v.at(i) == v.at(i+1)){
      tate=max(tate,v.at(i));
      i++;
    }
    if (tate > 0 && yoko >0){
      cout << tate * yoko << endl;
      return 0;
    }
    if (tate>0){
      yoko = tate;
      tate = 0;
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    int N,W,H,c,x,y,i,j,k,l,m,S,T;
    while(1){
        scanf("%d",&N);
        if(!N){break;}
        scanf("%d %d",&W,&H);
        int ll[H+1][W+1];
        fill(ll[0],ll[H+1],0);
        for(i=0;i<N;i++){
            scanf("%d %d",&x,&y);
            ll[y][x]=1;
        }
        scanf("%d %d",&S,&T);
        m=0;
        for(i=1;i+T-1<=H;i++){
            for(j=1;j+S-1<=W;j++){
                c=0;
                for(k=i;k<=i+T-1;k++){
                    for(l=j;l<=j+S-1;l++){
                        if(ll[k][l]){c++;}
                    }
                }
                m=max(m,c);
            }
        }
        printf("%d\n",m);
    }
    return 0;
}
    



Measured memory_bytes: 2596
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

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

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N, Q;
const ll MAX_N = 200000, MAX_Q = 200000;
ll S[MAX_N], T[MAX_N], X[MAX_N];
ll D[MAX_Q];

struct Event {
  ll time;
  int type;
  ll x;
};

bool comp(const Event& lhs, const Event& rhs) {
  if(lhs.time == rhs.time) {
    return lhs.type < rhs.type;
  } else {
    return lhs.time < rhs.time;
  }
}

int main(){
  cin >> N >> Q;
  REP(i, N) cin >> S[i] >> T[i] >> X[i];
  REP(i, Q) cin >> D[i];

  vector<Event> events;
  REP(i, N) {
    events.pb(Event{S[i] - X[i], 1, X[i]});
    events.pb(Event{T[i] - X[i], -1, X[i]});
  }

  sort(ALL(events), comp);

  set<ll> st;

  int itr = 0;
  REP(i, Q) {
    while(itr < 2 * N && events[itr].time <= D[i]) {
      Event e = events[itr];
      if(e.type == 1) {
        st.insert(e.x);
      } else {
        st.erase(e.x);
      }
      itr++;
    }
    if(st.empty()) {
      cout << -1 << endl;
    } else {
      cout << *st.begin() << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 27752
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,a[3333]={};
	LL ans=0LL;
	cin>>n;
	FOR(i,0,n){
		int t;
		cin>>t;
		ans+=t;
	}
	cout<<ans-n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    string in; cin >> in;
    int n = in.size();

    vi a(n);
    rep(i, n) a[i] = (in[i] == 'B' ? 1:0);

    ll res = 0LL;

    int r = n - 1;
    rrep(i, n){
    	if(a[i] == 1) res += r - i, r--;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1428
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

std::vector<long long> divisor(long long n) {
    // nの約数をソートして列挙。1とnも含む。計算量はO(sqrt(n))なので、long longも入り得る。
    std::vector<long long> res;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) {
                res.push_back(n / i);
            }
        }
    }
    std::sort(res.begin(), res.end());
    return res;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

const int MAX_N = 1e3 + 10;
int N;
int64_t K;
int64_t A[MAX_N], B[MAX_N];

bool solve(int64_t x) {
    std::vector<int> vec;
    rep (i, 1, N) {
        B[i] = A[i];
        vec.push_back(i);
    }
    std::sort(vec.begin(), vec.end(), [&](int i, int j){
        return B[i] % x < B[j] % x;
    });

    int sum = 0;
    for (int i : vec) {
        if (sum + B[i] % x <= K) {
            sum += B[i] % x;
            B[i] -= B[i] % x;
        } else {
            break;
        }
    }

    rep (i, 1, N) {
        if (0 < B[i] % x) {
            if (x - (B[i] % x) <= sum) {
                sum -= x - (B[i] % x);
            } else {
                return false;
            }
        }
    }

    return true;

}

int main(int argc, char **argv) {
    std::cin >> N >> K;
    int64_t sum = 0;
    rep (i, 1, N) {
        std::cin >> A[i];
        sum += A[i];
    }

    auto divi = divisor(sum);

    std::reverse(divi.begin(), divi.end());

    for (int d : divi) {
        if (solve(d)) {
            std::cout << d << std::endl;
            return 0;
        }
    }
    
    return 0;
}

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

int main() {
  int a=0,b=0,c=0;
  for(int i=0;i<3;i++){
    char s;
    cin >> s;
    if(s=='a') a++;
    if(s=='b') b++;
    if(s=='c') c++;
  }
  if(a*b*c == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    int n, m, x;
    cin>>n>>m>>x;
    vector<int> c(n);
    vector<vector<int>>v1(n,vector<int>(m));
    rep(i,n){
        cin>>c[i];
        rep(j,m) cin>>v1[i][j];
    }
    
    int ans = 10000000;
    rep(s,1<<n){
        int cost = 0;
        vector<int>v2(m);
        rep(i,n){
            if(s>>i&1){
                cost += c[i];
                rep(j,m) v2[j] += v1[i][j];
            }
        }
        bool ok = true;
        rep(i,m) if(v2[i] < x) ok = false;
        if(ok) ans = min(ans,cost);
    }
    if(ans == 10000000) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int dp[MAX_N][21]; // dp[i][j] 頂点iから2^j回移動して到達できる最大頂点

int main() {
    int N, L, Q;
    cin >> N;
    vector<int> x(N);
    for(int i=0;i<N;i++){
        cin >> x[i];
    }
    cin >> L;
    for(int i=0;i<N-1;i++){
        dp[i][0] = upper_bound(x.begin(), x.end(), x[i]+L) - x.begin() - 1;
    }
    dp[N-1][0] = N;
    dp[N][0] = N;
    // doubling
    for(int j=0;j<20;j++){
        for(int i=0;i<=N;i++){
            dp[i][j+1] = dp[dp[i][j]][j];
        }
    }

    cin >> Q;
    for(int i=0;i<Q;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(a > b) swap(a, b);
        int now = a, cnt = 0;
        while(now != b){
            for(int j=20;j>=0;j--){
                if(dp[now][j] <= b){
                    now = dp[now][j];
                    cnt += 1<<j;
                    break;
                }
                else if(j==0){
                    now = b;
                    cnt++;
                    break;
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 9472
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;

int main(){
  int c[3][3];
  bool b[3][3];
  int c2[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>c[i][j];
    }
  }
  bool flag=true;
  for(int i=0;i<3;i++){
    int next=i+1;
    if(i==2)next=0;
    for(int j=0;j<3;j++){
      int next2=j+1;
      if(j==2)next2=0;

      if(c[i][j]-c[i][next2]!=c[next][j]-c[next][next2])flag=false;
    }
  
  }
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 256
n=int(input())
s=list(input())

memo=[0]*1000

sudeni1=set() #その時点で登場した数の配列をまず用意
sudeni2=set() #その時点で作れる2桁の数を入れた配列(01とかも含む)
sudeni3=set()

sudeni1.add(str(s[0]))
sudeni1.add(str(s[1]))
sudeni2.add(str(s[0])+str(s[1]))

for i in range(2,n):
  temp1=list(sudeni1)
  temp2=list(sudeni2)
  for j in temp2: #その桁までで作れる3桁の数に追加。
    sudeni3.add(j+str(s[i]))
  for j in temp1: #その桁までで作れる2桁の数に追加。
    sudeni2.add(j+str(s[i]))
  sudeni1.add(str(s[i]))

print(len(sudeni3))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
constexpr int INF = (int)1e9;
int main()
{
    int n;
    cin >> n;
    vector<long long> r(n);
    for (int i = 0; i < n; i++)
        cin >> r[i];
    
    long long ans = -INF;
    long long minv = r[0];
    for (int i = 1; i < n; i++) {
        ans = max(ans, r[i] - minv);
        minv = min(minv, r[i]);
    }
    cout << ans << '\n';
  
    return 0;
}


Measured memory_bytes: 4428
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int, int>pii;
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	if (k + k > n + 1)
	{
		printf("-1\n");
		return 0;
	}
	vector<pii>v;
	for (int i = 0; i < n; i++)
	{
		int t;
		if (n % 2 == 0)
		{
			if (i % 2 == 0)t = k + n / 2 - 1 - i / 2;
			else t = k + n - 1 - i / 2;
		}
		else
		{
			if (i % 2 == 0)t = k + n - 1 - i / 2;
			else t = k + n / 2 - 1 - i / 2;
		}
		v.push_back(make_pair(k + n + i + t, t));
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < n; i++)printf("%d %d %d\n", v[i].second, v[i].first - v[i].second, k + n + n + i);
}

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

main(){
  int in[4];
  while(cin>>in[0]>>in[1]>>in[2]>>in[3]){
    int sum=0;
    rep(i,4)sum+=in[i];
    cout << sum/60 << endl << sum%60 << endl;
  }

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, m;
bool a[maxn];
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		a[u] ^= 1;
		a[v] ^= 1;
	}
	for(int i = 1; i <= n; ++i)
		if(a[i])
		{
			puts("NO");
			return 0;
		}
	puts("YES");
	return 0;
}

Measured memory_bytes: 3852
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int m[11],t;
	for(int i=1;i<=10;i++)
	{
		cin>>m[i];
	}
	for(int i=1;i<=10;i++)
	{
		for(int j=1;j<=10;j++)
		{
			if(m[i]<m[j])
			{
				t=m[i];
				m[i]=m[j];
				m[j]=t;
			}
		}
	}
	cout<<m[10]<<endl;
	cout<<m[9]<<endl;
	cout<<m[8]<<endl;
	return 0;
}

Measured memory_bytes: 3076
import sys
from functools import cmp_to_key
n = int(input())
data = [[int(j) for j in input().split()] for i in range(n)]
t = 0
data.sort(key = cmp_to_key(lambda x, y: x[1] - y[1]))
for d in data:
  t += d[0]
  if t > d[1]:
    print('No')
    sys.exit()
print('Yes')


Measured memory_bytes: 48320
n = list(map(int,input().split()))
p = list(map(int,input().split()))

exp = [] #期待値のリスト
exp.append(0) #０の期待値
count = 1
max = 0
tmp = 0

for i in range(1,1001):
    exp.append(count/i)
    count = count + (i+1)

#まず最初のK個の期待値を求める
for i in range(n[1]):
    tmp = tmp + exp[p[i]]
if(tmp >= max):
    max = tmp

#尺取り法でK+1個目の期待値を足して、j(0から増えていく＝先頭の期待値)を引いていく
for j in range(n[0]-n[1]):
    #print(j,tmp)
    tmp = tmp + exp[p[j+n[1]]] - exp[p[j]]
    if(tmp >= max):
        max = tmp

print(max)

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

int main()
{
    ll N;
    cin >> N;
    vector<ll> a(3*N);

    for(int i = 0; i < 3 * N; i++)
    {
        cin >> a.at(i);
    }

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    int count = 0;
    ll sum = 0;

    for(int i = 1; count < N;i += 2)
    {
        sum += a.at(i);
        count++;
    }

    cout << sum << endl;

}

Measured memory_bytes: 2560
#166_C
n, m = map(int, input().split())
h = list(map(int, input().split())) 
a = [0] * m
b = [0] * m

v = [[] for i in range(n)]
for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
    v[a[i]].append(h[b[i]])
    v[b[i]].append(h[a[i]])

ans = 0
for i in range(n):
    if v[i] == []:
        ans += 1
    else:
        v[i].sort(reverse=True)
        if h[i] > v[i][0]:
            ans += 1
            
print(ans)

Measured memory_bytes: 31088
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
int gcd(int a,int b){
    return b ? gcd(b,a%b) : a;
}
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++) cin >> a[i];
    vector<int> left(n+1,0),right(n+1,0);
    for(int i = 0;i < n;i++) left[i+1] = gcd(left[i],a[i]);
    for(int i = n-1;i >= 0;i--) right[i] = gcd(right[i+1],a[i]);
    
    int ans = 0;
    for(int i = 0;i < n;i++){
        chmax(ans,gcd(left[i],right[i+1]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
N,M,C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = []
for i in range(N):
    A.append(list(map(int, input().split())))

result = 0

for i in range(N):
    x = 0
    for j in range(M):
        x += A[i][j] * B[j]
    x += C
    if x > 0:
        result += 1
print(result)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define LL long long 
#define LD long double

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

    LL n,k;
    cin>>n>>k;
    LL a[n]; 
    for(LL i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    LL sum=0;
    for(LL i=0;i<n-k;i++){
        sum+=a[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1792
N = int(input())
T = [int(input()) for i in range(N)]

from fractions import gcd

def mygcd(a,b):
    gcd_list = []
    for i in range(1,int(min(a,b)**0.5)+1):
        if a%i == 0 and b%i == 0:
            gcd_list.append(i)
    return max(gcd_list)

number = T[0]

for i in range(1,N):
    number = number*T[i]//gcd(number,T[i])
    
print(number)

Measured memory_bytes: 5100
import java.util.Scanner;

public class Main{

	static final Scanner	s	=new Scanner(System.in);

	public static void main(String args[]){
		input();
		solve();
	}

	private static void input(){
	}

	private static void solve(){
		int n=s.nextInt();
		System.out.println(n*800-n/15*200);
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int w[110];
    for(int i=0; i<n; i++){
        cin >> w[i];
    }
    int m = 1000000;
    for(int t=1; t<n; t++){
        int s1=0, s2=0;
        for(int j=0; j<n; j++){
            if(j<=t){
                s1 += w[j];
            }else{
                s2 += w[j];
            }
        }
        m = min(m, abs(s1-s2));
    }
    cout << m << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

ll dp[100005][13];

void solve_abc_d() {
	string s;
	cin >> s;
	ll n = s.size();

	ll ans;

	reverse(ALL(s));

	rep(i, 100005)rep(j, 13) {
		dp[i][j] = 0;
	}

	rep(d, 10) {
		if (s[0] == '?' || d == s[0] - '0') {
			dp[1][d] = 1;
		}
	}

	ll x = 10;
	rep2(i, 1, n) {
		rep(d, 10) {
			if (s[i] == '?' || d == s[i] - '0') {
				rep(j, 13) {
					dp[i + 1][(j + d * x) % 13] += dp[i][j];
					dp[i + 1][(j + d * x) % 13] %= MOD;
				}
			}
		}
		x = (x * 10) % 13;
	}

	ans = dp[n][5];

	cout << ans << "\n";
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed;
	//cout << setprecision(7);

	solve_abc_d();

	return 0;
}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
#define int long long
constexpr long long mod = 1000000007;
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << x << "\n"
using namespace std;
int n, a[1234];
int ans[5];
vector<int>v;
signed main() {
	cin >> n;
	for1(i, n) {
		cin >> a[i];
		ans[i % 2] += max(a[i], (int)0);
	}
	if (ans[0] == 0 && ans[1] == 0) {
		ans[2] = -mod; for1(i, n)if (ans[2] < a[i]) { ans[2] = a[i]; ans[3] = i; }
		puts(ans[2]); puts(n - 1);
		for1(i, n)if (i < ans[3])puts(1); else if (i != ans[3])puts(n + 2 - i);
		return 0;
	}
	else {
		puts(max(ans[0], ans[1]));
		for1(i, n) {
			if (i == n)break;
			if (i == 1 && ans[0] > ans[1])v.push_back(1);
			else if (a[i] < 0) { v.push_back(1); v.push_back(1); i++; }
			else if (i + 1 == n) { v.push_back(2); break; }
			else if (a[i + 2] > 0) { v.push_back(2); i++; }
			else { v.push_back(3); if (i + 2 == n) { v.push_back(2); break; }i++; a[i + 1] = 1; }
		}
		puts(v.size()); for (int i : v)puts(i);
	}
}

Measured memory_bytes: 256