akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int h, w;
    
    while (1) {
        scanf("%d %d", &h, &w);
        
        if (h == 0 && w == 0) {
            break;
        }
        
        for (int i=0; i<w; i++) {
            printf("#");
        }
        printf("\n");
        
        for(int i=2; i<h; i++) {
            printf("#");
            for (int j=2; j<w; j++) {
                printf(".");
            }
            printf("#");
            printf("\n");
        }
        
        for (int i=0; i<w; i++) {
            printf("#");
        }
        printf("\n");
        
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2036
/// In the name of ALLAH
/// I'm THEOVE46
#include<bits/stdc++.h>
using namespace std;

#define gap             " "
#define nn              "\n"
#define pi              2*acos(0.0)
#define db              double
#define ft              float
#define ll              long long
#define ull             unsigned long long
#define pf              printf
#define sf              scanf
#define ff              first
#define ss              second
#define sc(n)           sf("%d",&n)
#define sc2(n, m)       sf("%d%d",&n,&m);
#define scl(n)          sf("%lld",&n)
#define scl2(n, m)      sf("%lld%lld",&n,&m);
#define pc(n)           pf("%d",n)
#define scf(f)          sf("%f",&f)
#define pcf(f)          pf("%f",f)
#define bfs             cin.get()
#define bfc             getchar()
#define gl(s)           getline(cin, s);
#define loop(a,n)       for(ll i=a; i<n; i++)
#define rloop(a,n)      for(ll i=a; i>n; i--)
#define tloop(test)     for(ll tl=1; tl<=test; tl++)
#define case1(z)        cout<<"Case "<<z<<": "
#define case2(z)        printf("Case %d: ",z)
#define vi              vector<int>
#define vl              vector<ll>
#define vld(vc,rw)      vector<vector<ll> >vc(rw)
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define pis             pair<int,string>
#define psi             pair<string,int>
#define mls             map <ll,string>
#define msl             map <string,ll>
#define mll             map <ll,ll>
#define mp              make_pair
#define pb              push_back
#define itr             vector<int> :: iterator
#define sz(s)           s.size()
#define sl(s)           s.length()
#define Sort(s)         sort(s.begin(), s.end());
#define SortR(s)        sort(s.rbegin(), s.rend());
#define all(x)          x.begin(),x.end()
#define rall(x)         x.end(), x.begin()
#define MEM(ar,val)     memset(ar, (val), sizeof(ar))
#define IN(A,B,C)       assert(B<=A && A<=C)
#define EPS             1e-9
#define bug1            "**1**"
#define bug2            "****2****"
#define artri(b,h)      0.5*b*h
#define artrap(b1,b2,h) (b1+b2)/2*h
#define arcrl(r)        pi*r*r
#define vlsyl(r,h)      pi*r*r*h
#define vlcone(r,h)     pi*r*r*(h/3)
#define vlsph(r)        (4/3)*pi*r*r*r
#define flush           fflush(stdout);
#define pcn(dg,val)     fixed << setprecision(dg) << val
#define fap(x)          cout << __LINE__ << " says: " << #x << " = " << x << "\n"
#define FastIO          ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define showsort(n, a)  for(int i=0; i<n; i++) cout << a[i] << gap; cout << endl;

///THEOVE46

int main()
{
    FastIO;
    string s;
    cin >> s;
    cout << s[0]<<s[1]<<s[2] << endl;
    return 0;
}

///   check for integer overflow, array bounds
///   check for n=1
///   - - - The Ove 46



Measured memory_bytes: 3532
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line = br.readLine();

        System.out.println(line.toUpperCase());
    }
}

Measured memory_bytes: 24160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int N, A;
int x[111];
ll coudp[111][111][5555];

int main() 
{
	string A, B, C;
	
	cin >> A>> B>> C;

	int ia = 0;
	int ib = 0;
	int ic = 0;

	char next = 'a';

	while (1)
	{
		if (next == 'a')
		{
			if (A.length() == ia)
			{
				cout << 'A' << endl;
				break;
			}
			
			next = A[ia];
			ia++;
		}
		else if (next == 'b')
		{
			if (B.length() == ib)
			{
				cout << 'B' << endl;
				break;
			}
			
			next = B[ib];
			ib++;
		}
		else if (next == 'c')
		{
			if (C.length() == ic)
			{
				cout << 'C' << endl;
				break;
			}
			
			next = C[ic];
			ic++;
		}
	}


	return 0;
	
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, W;
int A[10001];
int dp[202][10001];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> W;
  rep(i, N) cin >> A[i];
  sort(A, A+N, greater<int>());

  dp[0][0] = 1;
  rep(i, N) {
    rep(w, W+1) dp[i+1][w] = dp[i][w];
    for (int w=W; w>=A[i]; w--) {
      dp[i+1][w] += dp[i][w-A[i]];
      dp[i+1][w] %= MOD;
    }
  }
  rep(a, N+1) {
    int b = N-a;
    if (a>=b) break;
    swap(dp[a], dp[b]);
  }
  dp[N+1][0] = 1;
  reverse(A, A+N);
  A[N] = INF;
  // all[0, i) | some[i+1, N)
  int sum = 0, s = 0;
  rep(i, N+1) {
    if (i>0) sum += A[i-1];
    if (sum > W) break;

    for (int w=W-sum; w>=0; w--) {
      if (w+sum+A[i] <= W) break;
      s += dp[i+1][w];
      if (s >= MOD) s -= MOD;
    }
  }
  cout << s << "\n";
  return 0;
}

Measured memory_bytes: 10980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
int main()
{
	int n,i,j,k,a,b;
	cin>>n>>a>>b;
	int p[n];
	int ca=0,cb=0,cc=0;
	for (i=0;i<n;i++)
	{
		cin>>p[i];
		if (p[i]<=a)
		ca++;
		else if (p[i]>b)
		cc++;
		else
		cb++;
	}
	cout<<min(ca,min(cb,cc));	
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n;cin >>n;
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    sort(all(a));
    reverse(all(a));
    ll key=a[0];
    cout <<key<<" ";
    ll ans;
    if(key%2==0){
        ll m=key/2;
        ll d=INF;
        for (int i = 0; i < n; ++i) {
            if(abs(a[i]-m)<=d){
                ans=a[i];
                d=abs(a[i]-m);
            }
        }
    }
    else {
        ll m=key/2;
        ll d=INF;
        for (int i = 0; i < n; ++i) {
            ll now=min(abs(a[i]-m),abs(a[i]-(m+1)));
            if(now<=d){
                ans=a[i];
                d=now;
            }
        }
    }
    cout <<ans <<endl;
    return 0;
}


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

bool y =false;

bool judge(string &s,char &x){
  int count=0;
  for (int i =0;i<s.size();i++){
    if (s.at(i)==x){
      count++;
    }
  }
  if (count%2==1){
    y=true;
  }
  return y;
}

int main(){
  string s;
  cin >>s;
  for (int j=0;j<s.size();j++){
    if(judge(s,s.at(j))){
      cout<< "No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

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

#define sz(x) (int)(x.size())
#define FOR(x,y,z) for(int x = y; x <= z; x++)
#define int long long

const int N = 1e5 + 2, inf = 1e18;

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);  

    string s;
    cin >> s;
    cout << s.substr(0,3);
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int N = scanner.nextInt();
		    String[] s = new String[N];
		    int truefalse = 0;
		    
		    for(int i = 0; i < N; i++) 
		    {
		    	s[i] = scanner.next();
		    	if( s[i].equals("Y") ) 
		    	{
		    		System.out.println("Four");
		    		truefalse++;
		    		break;
		    	}
		    }
		    if( truefalse == 0 ) 
		    {
		    	System.out.println("Three");
		    }
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int n, p = 1000000007;
string s;
long long f[5020][5020];
int main() {
	f[0][0] = 1;
	cin >> n >> s;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			f[i][j] = (f[i - 1][max(j - 1, 0)] + f[i - 1][j + 1] * 2) % p;
		}
	}
	cout << f[n][s.size()] << endl;
	return 0;
}

Measured memory_bytes: 196864
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int maxNum = sc.nextInt();
    int minSum = sc.nextInt();
    int maxSum = sc.nextInt();

    int[] nums = new int[maxNum + 1];
    for (int i = 0; i <= maxNum; i++) {
      char[] chars = Integer.toString(i).toCharArray();
      int sums = 0;
      for (int j = 0; j < chars.length; j++) {
        sums += Character.getNumericValue(chars[j]);
      }
      if (sums >= minSum && sums <= maxSum) {
        nums[i] = i;
      }
    }
    List<Integer> list = Arrays.stream(nums)
        .boxed()
        .collect(Collectors.toList());
    int result = list.stream().mapToInt(Integer::intValue).sum();
    System.out.println(result);
  }
}

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

const int MAX = 1e6 + 3;

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n; cin >> n;

    vector<int> a(n);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    vector<int> dp(MAX, 0);

    for (auto x : a) {
        if (dp[x] != 0) {
            dp[x] = 2;
            continue ;
        }
        for (int i = x; i < MAX; i += x) dp[i]++;
    }

    int cnt = 0;
    for (auto x : a)
        if (dp[x] == 1) cnt++;

    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 7924
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n, m, k, x, y = 0, z = 0, h, ans=0, w, sum = 0, Max = -1, Min = 1e9+1;
  string u;
  bool ok=true;
  cin >> x;
  rep2(i,1,x+1){
    n = i*(i+1)/2;
    if(n>=x){
      pri(i); return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp(a,b) make_pair(a,b)
const long long mod = 1000000007;
const long long inf = 1ll<<61;
typedef pair<int, int> P;
typedef pair<int ,P> PP;
struct edge { int to; int to2; int cost; };
int a[100006];
int isb[100006];
int dp[100006];
signed main() {
	int n, m; cin >> n >> m;
	rep(i, m) {
		cin >> a[i];
		isb[a[i]]++;
	}
	dp[0] = 1;
	rep(i, n) {
		if (isb[i + 1] == 0)dp[i + 1] += dp[i];
		if (isb[i + 2] == 0)dp[i + 2] += dp[i];
		dp[i + 1] %= mod;
		dp[i + 2] %= mod;

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

Measured memory_bytes: 2560
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>

using ll = long long;
ll M = 10010;
ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
using namespace std;
int main()
{
	ll a, b;
	int c, d;
	cin >> a >> b >> c >> d;
	ll zg = max(a, b);
	ll zk = min(a, b);
	ll kb = lcm(c, d);
	ll c1 = zg / c;
	ll c2 = (zk - 1) / c;
	ll d1 = zg / d;
	ll d2 = (zk - 1) / d;
	ll k1 = zg / kb;
	ll k2 = (zk - 1) / kb;
	cout << b - a + 1 - (c1 + d1 - k1) + (c2 + d2 - k2);
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String... args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[] L = new int[N];
    
    for(int i=0; i<N; i++) {
      L[i] = scan.nextInt();
    }
    Arrays.sort(L);
    
    int ans = 0;
    for(int start=0; start<N; start++) {
      for(int end=N-1; start<end; end--) {
        for(int target = end-1; target>start; target--) {
          if(L[start]+L[target] > L[end]) {
            ans++;
          } else {
            break;
          }
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 25164
def main():
    A = [[int(a) for a in input().split()] for i in range(3)]
    N = int(input())
    b = [int(input()) for i in range(N)]
    for k in b:
        for i in range(3):
            for j in range(3):
                if A[i][j] == k:
                    A[i][j] = "x"
    bingo = False
    if A[0][0] == A[0][1] == A[0][2] == "x" or \
       A[1][0] == A[1][1] == A[1][2] == "x" or \
       A[2][0] == A[2][1] == A[2][2] == "x" or \
       A[0][0] == A[1][0] == A[2][0] == "x" or \
       A[0][1] == A[1][1] == A[2][1] == "x" or \
       A[0][2] == A[1][2] == A[2][2] == "x" or \
       A[0][0] == A[1][1] == A[2][2] == "x" or \
       A[0][2] == A[1][1] == A[2][0] == "x":
       bingo = True
       
    if bingo:
        print("Yes")
    else:
        print("No")
main()

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    string s;
    cin >> s;
    ll n = s.size();
    vi tmp;
    REP(i, 0, n-1)
        if(s[i] == 'R' && s[i+1] == 'L')
            tmp.pb(i);
    vi ans(n, 0);
    REP(i, 0, n) {
        if (s[i] == 'R') {
            auto p = lower_bound(all(tmp), i) - tmp.begin();
            ll d = tmp[p]-i;
            if (d%2)
                ans[tmp[p]+1]++;
            else
                ans[tmp[p]]++;
        }
        else if (s[i] == 'L') {
            auto p = upper_bound(all(tmp), i) - tmp.begin() - 1;
            ll d = i-(tmp[p] + 1);
            if (d%2)
                ans[tmp[p]]++;
            else
                ans[tmp[p]+1]++;
        }
    }
    print(ans);
    cout << endl;
    return 0;
}


Measured memory_bytes: 1864
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
 
int main() {
  int n,t;
  while(cin>>n>>t&&n) {
    vector<P> v[n];
    int c[n],d=0;
    memset(c,0,sizeof(c));
    priority_queue<P,vector<P>,greater<P> > que;
    for(int i=0; i<n; i++) {
      int x,y;
      while(cin>>x&&x) {
        cin>>y;
        v[i].push_back(P(x,y));
      }
      if(v[i].size()) que.push(P(v[i][0].F,i));
    }
    int ans=0;
    for(int i=0; i<t; i++) {
      if(que.top().F<=i&&!d) {
        P p=que.top();que.pop();
        ans+=max(0,i-p.F);
        int k=p.S;
        d+=v[k][c[k]].S;
        c[k]=(c[k]+1)%v[k].size();
        que.push(P(i+v[k][c[k]].F+d,k));
      }
      if(d) d--;
    }
    while(!que.empty()) {
      P p=que.top();que.pop();
      ans+=max(0,t-p.F);
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3124
N = int(input())
A = list(map(int, input().split()))

D = {}
for a in A:
    if a not in D:
        D[a] = 1
    else:
        D[a] += 1

pattern = 0
for d in D.values():
    pattern += d * (d - 1) // 2

for i in range(N):
    print(pattern - D[A[i]] + 1)

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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector< pair<int, int> > a;
  for(int i=0;i<n;i++){
    int tmp=0;
    cin >> tmp;
    a.push_back( make_pair(tmp, i+1) );
  }
  sort(a.begin(), a.end());
  for(int i=0;i<n;i++){
    cout << a.at(i).second << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1780
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 5005
const ll INF = 1e9 + 7;


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

const ll MOD = 1e9 + 7;



//約数の列挙
template<typename T>
vector<T> divisor(T n) {
	vector<T> res;
	for (T i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			res.push_back(i);
			if (i != n / i) {
				res.push_back(n / i);
			}
		}
	}
	return res;
}

int main() {

	ll n;
	cin >> n;
	vector<ll> a = divisor(n);
	sort(a.begin(), a.end());

	ll ans = 0;
	
	for (int i = 0; i < a.size(); i++)
	{
		if (n / a[i] < a[i] - 1)
		{
			//cout << a[i] << endl;
			ans += a[i] - 1;
		}
	}
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 384
import java.util.*;
public class Main{
	public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
    	String s = sc.nextLine();
      String s1 = sc.nextLine();
      
      int count =0;
      for(int i=0;i<s.length();i++){
      	if(s.charAt(i)!=s1.charAt(i)){
          
          count++;
        }
        
      }
      System.out.println(count);
      
    }
}

Measured memory_bytes: 42728
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=998244353;



int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n),b(m),pa(n),pb(m);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    for(ll i=0;i<m;i++)
        cin>>b[i];
    pa[0]=a[0];
    for(ll i=1;i<n;i++)
        pa[i]=a[i]+pa[i-1];
    pb[0]=b[0];
    for(ll i=1;i<m;i++)
        pb[i]=b[i]+pb[i-1];
    ll ans=0;
    for(ll i=0;i<n;i++){
        if(pa[i]>k) break;
        ll d=k-pa[i];
        ll c=lower_bound(pb.begin(),pb.end(),d)-pb.begin();
        if(d==*lower_bound(pb.begin(),pb.end(),d)) c++;
        ans=max(ans,i+c+1);
    }
    for(ll i=0;i<m;i++){
        if(pb[i]>k) break;
        ll d=k-pb[i];
        ll c=lower_bound(pa.begin(),pa.end(),d)-pa.begin();
        if(d==*lower_bound(pa.begin(),pa.end(),d)) c++;
        ans=max(ans,i+c+1);
    }
    cout<<ans;

    
    return 0;
}

Measured memory_bytes: 9528
#include<stdio.h>

int main(void)
{
	int i, flag[3] = { 0, 0, 0 };
	char next,winner='z',S[3][101];

	scanf("%s", S[0]);
	scanf("%s", S[1]);
	scanf("%s", S[2]);

	next = 'a';

	do
	{
		switch (next)
		{
		case 'a':
			next = S[0][flag[0]];

			if (S[0][flag[0]] == '\0')
				winner = 'A';

			flag[0]++;

			break;

		case 'b':
			next = S[1][flag[1]];

			if (S[1][flag[1]] == '\0')
				winner ='B';

			flag[1]++;

			break;

		case 'c':
			next = S[2][flag[2]];

			if (S[2][flag[2]] == '\0')
				winner = 'C';

			flag[2]++;

			break;
		}

	} while (winner == 'z');

	printf("%c\n", winner);

	return 0;
}

Measured memory_bytes: 128
N=int(input())
S=input()
ans=""

abc="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"

L=len(S)

for i in range(L):
    idx=abc.index(S[i])
    ans=ans+abc[idx+N]

print(ans)

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

#define fs first
#define sc second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }
/*
#include <bits/stdc++.h>
using namespace std;
 */
struct BIT {
	vector<int> v;
	int n;

	BIT() { init(); }
	BIT(int size) :n(size){ init(); }

	void init() {
		v.clear();
		v.resize(n + 1, 0);
	}

	int sum(int i, int idx = 1) {
		idx--; idx *= -1; i += idx;
		int ret = 0;
		while (i) {
			ret += v[i];
			i -= i & -i;
		}
		return ret;
	}

	void add(int i, int x, int idx = 1) {
		idx--; idx *= -1; i += idx;
		while (i <= n) {
			v[i] += x;
			i += i & -i;
		}
	}
};

int main() {
	int n = in(), q = in();
	BIT beet(n);

	rep(_, q) {
		int a = in(), b = in(), c = in();
		//print(beet.v);
		if (a)
			cout << beet.sum(c) - beet.sum(b - 1) << endl;
		else 
			beet.add(b, c);
	}
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N + 2);
  int total = 0;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    total += abs(A[i] - A[i - 1]);
  }
  total += abs(A[N]);
  for (int i = 1; i <= N; i++) {
    int a = total - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]);
    cout << a << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */

Measured memory_bytes: 1664
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<String> set = new HashSet<>();
		for(int i =0; i < n ; i++){
			set.add(sc.next());
		}
		System.out.println(set.size() == 3 ? "Three" : "Four");
	}
}

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

int main(){
	int k, a, b;
	cin >> k >> a >> b;
	k = b/k*k;
	if(a <= k)
		cout << "OK" << endl;
	else
		cout << "NG" << endl;
}

Measured memory_bytes: 3584
n,k = map(int, input().split())
ans = 0
if k%2 == 1:
    if k>n:
        print(0)
    elif k==n:
        print(1)
    else:
        a = n//k
        ans += a
        if a>1:
            ans += a*(a-1)*3
            if a>2:
                ans+=a*(a-1)*(a-2)
        print(ans)

else:
    k2 = k//2
    if k>n:
        if k2>n:
            print(0)
        elif k2==n:
            print(1)
    elif k==n:
        print(2)

    else:
        a = n//k
        a2 = n//k2 - a
        ans += a
        ans += a2
        if a>1:
            ans += a*(a-1)*3
            if a>2:
                ans+=a*(a-1)*(a-2)
        if a2>1:
            ans += a2*(a2-1)*3
            if a>2:
                ans+=a2*(a2-1)*(a2-2)
        print(ans)


Measured memory_bytes: 3064
s = int(input())
dp =[0]*2001
dp[0] = dp[1] = dp[2] = 0
dp[3] = dp[4] = dp[5] = 1
dp[6] = dp[3]+1
for i in range(7,s+1):
    dp[i] = dp[i-1]+dp[i-3]
print(dp[s] % (10**9+7))


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

int main() {
	int n, a[100], i, j;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long dp[100][21] = {};
	dp[0][a[0]] = 1;
	for (i = 1; i < n - 1; i++) {
		for (j = 0; j < 21; j++) {
			if (j - a[i] >= 0)
				dp[i][j] += dp[i - 1][j - a[i]];
			if (j + a[i] < 21)
				dp[i][j] += dp[i - 1][j + a[i]];
		}
	}
	cout << dp[n-2][a[n-1]] << endl;
}

Measured memory_bytes: 1180
mod = 1000000007
n = int(input())
als = list(map(int, input().split()))

sumlist = [0 for _ in range(n)]
sumlist[0] = als[0]

for i in range(1, n-1):
    sumlist[i] = sumlist[i-1] + als[i]

ans = 0

for i in range(n-1):
    ans += als[n-1-i] * sumlist[n-2-i]
    ans = ans%mod

print(ans)

Measured memory_bytes: 31624
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(a>0 and b>0) {
		c-=b;
		if(c<=0) {
			cout<<"Yes"<<endl;
			return 0;
		}
		a-=d;
		if(a<=0) {
			cout<<"No"<<endl;
			return 0;
		}
	}



	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define INF LLONG_MAX/3
#define int long long
using namespace std;

int dp[20001];
int d[20000];
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	dp[0] = 0;
	fill(dp + 1, dp + a + 1, INF);
	for (int e = 0; e < a; e++)scanf("%lld", &d[e]);
	for (int f = 0; f <a; f++) {
		int MIN = INF, MAX = 0;
		for (int g = f + 1,sum=0; g <=a&&sum<b; g++,sum++) {
			MIN = min(MIN, d[g-1]);
			MAX = max(MAX, d[g-1]);
			dp[g] = min(dp[g], dp[f] + c + (g - f)*(MAX - MIN));
		}
	}
	cout << dp[a] << endl;
}

Measured memory_bytes: 3476
#include "iostream"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;

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

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

template <typename T>
void drop(const T& x) {
  cout << x << endl;
  exit(0);
}

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

  string N;
  ll K;
  cin >> N >> K;

  V<V<V<ll>>> dp(N.size() + 1, V<V<ll>>(K + 1, V<ll>(2)));
  dp[0][0][1] = 1;

  rep(i, N.size()) {
    ll va = N[i] - '0';

    rep(k, K + 1) {
      if (va == 0) {
        dp[i + 1][k][1] += dp[i][k][1];
        dp[i + 1][k][0] += dp[i][k][0];
        if (k == K) continue;
        dp[i + 1][k + 1][0] += 9 * dp[i][k][0];
      } else {
        dp[i + 1][k][0] += dp[i][k][0] + dp[i][k][1];
        if (k == K) continue;
        dp[i + 1][k + 1][1] += dp[i][k][1];
        dp[i + 1][k + 1][0] += dp[i][k][0] * 9 + dp[i][k][1] * (va - 1);
      }
    }
  }

  cout << dp[N.size()][K][1] + dp[N.size()][K][0] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    std::string S;
    std::cin >> S;

    int length = S.size();
//    std::cout << S[length-1] << std::endl;

    int last = S[length-1] - '0';
    switch(last)
    {
        case 3:
            std::cout << "bon" << std::endl;
            break;

        case 0:
        case 1:
        case 6:
        case 8:
            std::cout << "pon" << std::endl;
            break;

        default:
            std::cout << "hon" << std::endl;
            break;
    }

    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int BEET=-1001001001;

int H,W;
string S[222];

int dp[2][1<<16];
int pc[1<<16];
signed main(){
    cin.tie(0);ios_base::sync_with_stdio(0);

    for(int i=0;i<1<<16;i++)pc[i]=__builtin_popcount(i);
    cin>>H>>W;
    S[0]="";
    rep(i,H)cin>>S[i+1];

    fill_n(*dp,2*(1<<16),BEET);
    dp[0][0]=0;
    int mask=(1<<W)-1;
    for(int t=0;t<H*W;t++){
            const int i=t/W,j=t%W,p=t&1,q=(t+1)&1;
            const int beet=(1<<(W-1));
            const int ei=(1<<W);
            const int mask2=(1<<j)-1;
            const int len=S[i].size();
            const int len2=S[i+1].size();

            for(int k=0;k<beet;k++){
                if(dp[p][k]==BEET)continue;
                chmax(dp[q][(k<<1)&mask],dp[p][k]);

                int l=pc[k&mask2];
                if(l<len2){
                    int po=0;
                    if(j&&(k&1)&&S[i+1][l]==S[i+1][l-1])po++;
                    chmax(dp[q][((k<<1)&mask)+1],dp[p][k]+po*2);
                }
                dp[p][k]=BEET;
            }

            for(int k=beet;k<ei;k++){
                if(dp[p][k]==BEET)continue;
                chmax(dp[q][(k<<1)&mask],dp[p][k]);

                int l=pc[k&mask2];
                if(l<len2){
                    int po=0;
                    if(j&&(k&1)&&S[i+1][l]==S[i+1][l-1])po++;
                    if(S[i][len-pc[k]+l]==S[i+1][l])po++;
                    chmax(dp[q][((k<<1)&mask)+1],dp[p][k]+po*2);
                }
                dp[p][k]=BEET;
            }

        if(j==W-1)for(int k=0;k<ei;k++)if(pc[k]!=len2)dp[q][k]=BEET;
    }

    int ans=BEET;
    rep(i,1<<W)chmax(ans,dp[(H*W)&1][i]);
    cout<<ans<<endl;
    return 0;
}

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

#define int long long

auto main() -> signed {
    int n;
    cin >> n;
    if(n==1) {
        cout << 1 << endl;
        return 0;
    }
    int ans = 2;
    int c = 2;
    while(true) {
        if(pow(2,c)>n) break;
        ans = pow(2,c);
        c++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
int main(){
    ll n;cin>>n;
    out((n+1)/2);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int main()
{
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)
			printf("%dx%d=%d\n",i,j,i*j);
	return 0;
}

Measured memory_bytes: 0
import sys
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  H, N = map(int, readline().split())
  total = 0
  for a in map(int, readline().split()):
    total += a
  if total>=H:
    print('Yes')
  else:
    print('No')
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 8472
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        int c = 0;
        if (s.charAt(0) == '1') c++;
        if (s.charAt(1) == '1') c++;
        if (s.charAt(2) == '1') c++;
        System.out.println(c);
    }
}

Measured memory_bytes: 21716
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
using namespace std;
#define long long long
const long MOD = 1e9+7, LINF = 1e18 + 1e16;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};

class TaskD {

	long k, n, a[51];

public:
	void solve(istream &cin, ostream &cout) {
		cin >> k;
		n = 50;
		long f = k / n;
		for(int i = 0; i < n; i++) a[i] = n-1 + f;
		for(int i = 0; i < k % n; i++) {
			a[i] += n;
			for(int j = 0; j < n; j++) if(j != i) --a[j];
		}
		cout << n << endl;
		for(int i = 0; i < n; i++) cout << a[i] << ' ';
	}
};

class Solver {
public:
	void solve(std::istream& in, std::ostream& out) {
	    TaskD *obj = new TaskD();
		obj->solve(in, out);
		delete obj;
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	Solver solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

using namespace std;

const int N_MAX = 202;

int n;

bool ma[N_MAX][N_MAX];

queue <int> q;
int color[N_MAX];

int bfs (int node)
{
    memset(color, 0, sizeof(color));
    while(!q.empty())
        q.pop();
    q.push(node);
    color[node] = 1;
    int answer = 0;
    while(!q.empty())
    {
        int f = q.front();
        answer = color[f];
        q.pop();
        for(int i = 1; i <= n; i++)
            if(ma[f][i] == true)
            {
                if(color[i] != 0 && color[i] != color[f] - 1 && color[i] != color[f] + 1)
                    return -1;
                if(color[i] == 0)
                {
                    color[i] = color[f] + 1;
                    q.push(i);
                }
            }
    }
    return answer;
}

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        string s;
        cin >> s;
        for(int j = 1; j <= n; j++)
            ma[i][j] = (s[j - 1] == '1');
    }
    int k = -1;
    for(int i = 1; i <= n; i++)
        k = max(k, bfs(i));
    cout << k << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define INFTY 10000000
#define N 100

int main(){
  int n, o[N], m[N][N];
  int i, j, k, l;
 
  scanf("%d",&n);
 
  for(i = 1; i <= n; i++)
    scanf("%d %d", &o[i-1], &o[i]);
 
  for(i = 1 ;i <= n; i++)
    m[i][i]=0;
    
  for(l = 2; l <= n; l++){
    for( i=1 ; i <= n-l+1; i++){
      j = i + l - 1;
      m[i][j] = INFTY;
      for(k=i; k <= j - 1; k++){
        if (m[i][j] > m[i][k] + m[k+1][j] + o[i-1] * o[k] * o[j])
          m[i][j] = m[i][k] + m[k+1][j] + o[i-1] * o[k] * o[j];
      }
    }
  }
 
  printf("%d\n",m[1][n]);
 
  return 0;
}

Measured memory_bytes: 1892
n, m = list(map(int, input().split()))
aa = list(map(int, input().split()))
 
# aa = sorted(aa)
mn = (1/(4*m)) * sum(aa)
count = 0
 
for a in aa: 
  if (a >= mn): 
    count += 1
    
print("Yes" if count >= m else "No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    long[] s = new long[N];
    for (int i = 0; i < N; i++) s[i] = scanner.nextInt();

    long max = 0;
    long[] dp = new long[N + 1];
    for (int d = 1; d < N; d++) {
      int maxn = N - d;
      if ((N - 1) % d == 0) maxn = N / 2;
      for (int k = 1; k * d < maxn; k++) {
        dp[k] = dp[k - 1] + s[k * d] + s[N - 1 - k * d];
        max = Math.max(max, dp[k]);
      }
    }
    System.out.println(max);
  }
}


Measured memory_bytes: 51888
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int a[100005],b[100005];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int A,B,M;
    cin >> A >> B >> M;
    int amn = 1e9+7,bmn = 1e9+7;
    rep(i,A){
        cin >> a[i];
        chmin(amn,a[i]);
    }
    rep(i,B){
        cin >> b[i];
        chmin(bmn,b[i]);
    }
    int ans = amn + bmn;
    rep(i,M){
        int x,y,c;
        cin >> x >> y >> c;
        chmin(ans,a[x-1]+b[y-1]-c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main(){
    double n;
    cin>>n;
    if((int)n%2==0){
        cout<<n/2/n<<endl;
    }else{
        cout<<(n/2+0.5)/n<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h> 
int main(){long long a,b,c;scanf("%lld%lld%lld",&a,&b,&c);if((c-a-b)<=0){printf("No");return 0;}if(4*a*b<(c-a-b)*(c-a-b))printf("Yes");else printf("No");
          }


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

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



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    string s; cin >> s;
    if(s.at(s.size()-1) == 's') s += "es";
    else s += 's';

    cout << s << endl;
}

Measured memory_bytes: 3660
//ABC 043-A
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;

int main() {
	int N, candy = 0;
	cin >> N;
	for(int i = 1; i <= N; i++) candy += i;
	cout << candy << endl;
}


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

int main(){
	long long x,y;
	while(~scanf("%lld%lld",&x,&y)){
		int ans=1;
		while(x*2<=y){
			x=x*2;
			ans++;
		}
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 256
class BellmanFord():
    """ ベルマンフォード法
    重み付き有向グラフにおける単一始点最短路アルゴリズム
    
    * 使用条件
        - DAG（有向グラフで閉路を持たない）であること
        - 負のコストがあってもOK
    
    * 負の閉路がある場合、最短路は求まらないが、負の閉路の検出はできる
    
    * 計算量はO(V*E)
    """
    class Edge():
        """ 重み付き有向辺 """
        def __init__(self, _from, _to, _cost):
            self.from_ = _from
            self.to = _to
            self.cost = _cost
        
    def __init__(self):
        self.edges = []  # 辺
        self.v_set = set()  # 頂点の集合
    
    @property
    def E(self):
        """ 辺数 """
        return len(self.edges)
    
    @property
    def V(self):
        """ 頂点数 """
        return len(self.v_set)
    
    def add(self, _from, _to, _cost):
        """ 2頂点と、辺のコストを追加する """
        self.edges.append(self.Edge(_from, _to, _cost))
        self.v_set.add(_from)
        self.v_set.add(_to)
    
    def shortest_path(self, s):
        """ 始点sから頂点iまでの最短路を格納したリストを返す 
        Args:
            s(int): 始点s
        Returns:
            d(list): d[i] := 始点sから頂点iまでの最短路
        """
        d = [float("inf")] * self.V
        d[s] = 0
    
        while True:
            do_update = False
            for i in range(self.E):
                e = self.edges[i]
                if d[e.from_] != float("inf") and d[e.to] > d[e.from_]+e.cost:
                    d[e.to] = d[e.from_] + e.cost
                    do_update = True
            
            if not do_update: break
        
        return d
    
    def exist_negative_loop(self):
        """ 負の閉路が存在するか否か
        Returns:
            (bool): 負の閉路が存在する(True)/しない(False)
        """
        d = [0] * self.V
        for i in range(self.V):
            for j in range(self.E):
                e = self.edges[j]
                if d[e.to] > d[e.from_] + e.cost:
                    d[e.to] = d[e.from_] + e.cost
                    # n回目にも更新があるなら負の閉路が存在する
                    if i == self.V-1: return True
        return False
    
if __name__ == "__main__":
    V, E, s = list(map(int, input().split()))
    bf = BellmanFord()
    if V == 1:
        print(0)
        exit()
        
    if E == 0:
        for i in range(V-1):
            bf.add(i, i+1, float("INF"))
    else:
        for i in range(E):
            _from, to, cost = list(map(int, input().split()))
            bf.add(_from, to, cost)
        
        for i in range(V):
            # 存在しない頂点があるとき、適当にINFの辺を作成する
            if not i in bf.v_set:
                bf.add(i, 0, float("inf"))

    d = bf.shortest_path(s)
    
    for i in range(V):
        if i >= len(d):
            print("INF")
            continue

        cost = d[i]
        if cost == float("inf"):
            print("INF")
        else:
            print(cost)



Measured memory_bytes: 145488
n,m,l=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
b=[list(map(int,input().split())) for i in range(m)]
c= [[0]*l for i in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k]*b[k][j]

for i in c:
  print(*i)
           
          
       
     





Measured memory_bytes: 7048
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Bits (popCount, (.&.))
import Data.Maybe (fromJust)
import Data.Char (digitToInt)

readBin :: String -> Int
readBin = foldl' (\a x -> a * 2 + digitToInt x) 0

main :: IO ()
main = do
    n <- fst . fromJust . B.readInt <$> B.getLine
    fs <- replicateM n $ readBin . filter (/= ' ') <$> getLine
    ps <- replicateM n $ map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    ans <- forM [1..1023 :: Int] $ \b ->
        return $ foldl (\x i -> x + (ps !! i) !! popCount ((fs !! i) .&. b)) 0 [0..n - 1]
    print $ maximum ans


Measured memory_bytes: 1148
import math

n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort(reverse=True)
B.sort(reverse=True)

cnt = 0
cnt_num = 0
for i in range(n):
    if B[i] < A[0]:
        break
    cnt += B[i]
    cnt_num += 1
    if cnt >= h:
        print(i + 1)
        exit()
        
left = h - cnt
print(math.ceil(left / A[0]) + cnt_num)


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  c_fac();
  ll T; cin >> T;
  rep(_,T) {
    ll N; cin >> N;
    ll result = 0;
    if (N>=5) {
      N-=5;
      rep(i,12) {
        if (N>=i&&(N-i)%2==0) {
          ll c1 = 1; rep(j,15) c1 = c1 * (((N-i)/2+15-j)*inv(j+1)%MOD) % MOD;
          result = (result+c1*nck(11,i)) % MOD;
        }
      }
    }
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 10972
/* Created:2017/06/06                                     */
/**/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_CNT ( 10 )


int main() {
    char  cIn[MAX_CNT+1]="";
    int   iLen=0,i;

    char* pcIn1=NULL;
    char* pcIn2=NULL;

    int   iLenIn1=0;
    int   iLenIn2=0;

    int    iInA=0;
    int    iInB=0;
    int    iOut=0;



    /* 入力 */
    fgets(cIn, sizeof(cIn), stdin);
    iLen = strlen(cIn);


    /*改行コードは読み飛ばす*/
    iLen = iLen-1;


    /* 要素1 */
    pcIn1   = strtok(cIn, " ");
    iLenIn1 = strlen(pcIn1);

    iInA=atoi(pcIn1);


    /* 要素2 */
    pcIn2   = strtok(NULL, " ");
    iLenIn2 = strlen(pcIn2);

    iInB=atoi(pcIn2);


    iOut=iInA+iInB;

    if( iOut >= 10 )
        printf("error\n");
    else
        printf("%d\n", iOut);


    return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
inf = 10**18
sushi = [[-inf] for _ in range(N)]
for i in range(N):
    t, d = map(int, input().split())
    sushi[t-1].append(d)
for i in range(N):
    sushi[i].sort(reverse = True)
sushi.sort(key = lambda x:x[0], reverse = True)
que = []
res = 0
for i in range(K):
    res+=sushi[i][0]
    for j in sushi[i][1:]:
        que.append(j)
que.sort()
cur = res
res+=K**2
for var in range(1, K)[::-1]:
    a = que.pop()
    b = sushi[var][0]
    cur+=a-b
    res = max(res, cur+var**2)
print(res)




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

typedef long long ll;

int main() {
  int n; 
  ll dp[31];
  dp[1] = 1;
  dp[2] = 2;
  dp[3] = 4;
  for ( int i = 4; i <= 30; i++ ) dp[i] = dp[i-1] + dp[i-2] + dp[i-3];

  while ( cin >> n, n ) cout << dp[n]/365/10 + 1 << endl;
  
  return 0;
}

Measured memory_bytes: 1156