akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> l(n);
	rep(i,n){
		cin>>l[i];
	}
	sort(begin(l),end(l));
	ll ans=0;
	rep(i,n)FOR(j,i+1,n)FOR(k,j+1,n){
		if(l[i]==l[j] || l[j]==l[k] || l[k]==l[i]) continue;
		if(l[j]+l[i]>l[k]) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3660
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;
const int maxn = 1e5 + 5;
char s[maxn];

int main(){
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    bool flag = false;
    for(int i = 1;i < n;i++){
        if(s[i] == s[i + 1]){
            flag = true;
            cout << i << " " << i + 1 << endl;
            break;
        }
    } 
    for(int i = 1;i < n - 1;i++){
        if(s[i] == s[i + 2]){
            if(!flag){
                flag = true;
                cout << i << " " << i + 2 << endl;
                break;
            }
        }
    }
    if(!flag){
        cout << -1 << " " << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 384
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;
typedef long long ll;

void solve(string s) {
  rep (i, s.size() - 1) {
    if (s[i] == s[i+1]) {
      cout << i+1 << " " << i+2 << endl;
      return ;
    }
  }

  rep (i, s.size() - 2) {
    if (s[i] == s[i+2]) {
      cout << i+1 << " " << i+3 << endl;
      return ;
    }
  }

  cout << "-1 -1" << endl;
}

int main() {
  string s;
  cin >> s;

  solve(s);
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>

using namespace std;

int main() {
   int X, Y, Z;
   cin >> X >> Y >> Z;

   swap(X, Y);
   swap(X, Z);

   cout << X << " " << Y << " " << Z << endl;
    return 0;
}


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

using namespace std;

bool sugar[3001], water[3001];
vector<int> S, W;

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    for (int i = 0; i*c <= f; i++) {
        for (int j = 0; i*c+j*d <= f; j++) {
            sugar[i*c+j*d] = true;
        }
    }

    for (int i = 0; 100*i*a <= f; i++) {
        for (int j = 0; 100*j*b+100*i*a <= f; j++) {
            water[100*i*a+100*j*b] = true;
        }
    }

    for (int i = 0; i <= f; i++) {
        if (sugar[i])
            S.push_back(i);
        if (water[i])
            W.push_back(i);
    }

    double max = -1.0;
    int s, w;
    for (int i = 0; i < S.size(); i++) {
        for (int j = 0; j < W.size(); j++) {
            if (S[i] + W[j] == 0)
                continue;
            if (S[i] + W[j] <= f && \
                    (double)W[j] / 100.0 * (double)e >= (double)S[i] && \
                    (double)(S[i]*100.0) / (double)(S[i]+W[j]) > max) {
                max = (double)(S[i]*100.0) / (double)(S[i]+W[j]);
                s = S[i];
                w = W[j];
            }
        }
    }

    cout << w+s << " " << s << endl;

    return 0;
}

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

int main(){
  int Num, MP;
  long sum = 0;
  cin >> Num >> MP ;
  vector<int> HP(Num);
  
  
  int count = 0;
  int i = Num;
  while(i--){
    cin >> HP.at(i);
    //cout << HP.at(i) << endl;;
  }
  
  std::sort(HP.begin(), HP.end());
  
  i = Num-1;
  while(MP--){
    HP.at(i) = 0;
    i--;
    if(i<0) break;
  }
  
  i = Num;
  while(i--){
    sum += HP.at(i);
  }
  cout << sum;
 
}

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

int main() {
    long long n, m, k;
    cin >> n >> m >> k;
    for(int i = 0; i < k; i++) {
        if(i % 2 == 0) {
            n -= n % 2;
            m += n / 2;
            n -= n / 2;
        }
        else {
            m -= m % 2;
            n += m / 2;
            m -= m / 2;
        }
    }
    cout << n << ' ' << m;
}


Measured memory_bytes: 256
#include<stdio.h>
int b[10000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%d",b+i);
		int now=0;
		int n=a;
		while(1){
			bool ok=true;
			for(int i=0;i<n;i++)if(b[i]!=i+1)ok=false;
			if(ok){
				printf("%d\n",now);
				break;
			}else if(now==10000){
				printf("-1\n");
				break;
			}
			now++;
			for(int i=0;i<n;i++){
				b[i]--;
			}
			int at=0;
			for(int i=0;i<n;i++)if(b[i])b[at++]=b[i];
			b[at++]=n;
			n=at;
		}
	}
}

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

a.sort(reverse = True)
# aがあるべきパターンになってるかチェック
if n % 2 == 1:
  del(a[-1])
r = 1
turn = 0
start = n - 1
check = True

for i in range(0, len(a)):
  turn += 1  
  if a[i] != start:
    r = 0
  if turn > 1:    
    turn = 0
    start -= 2

if not r:
  print(0)
else:
  # aがあるべきパターンならありうる組み合わせの数を計算
  r = 2**(n//2) % (10**9 + 7)
  print(r)

  


Measured memory_bytes: 13880
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#include<map>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;


long long  X,Y,x[100],y[100],xm,ym,now, num, N, K, M, ans;
string S, T;
bool h,w[10], k[100],con[300];
char cc;
map<int, char>msp,mtp;
map<int, bool>mmsp,mmtp;
int main() {
	cin >> S >> T;

	for (int i = 0; i < S.size(); i++) {
		if (mmsp[S[i]] == false) {
			msp[S[i]] = T[i];
			mmsp[S[i]] = true;
		}
		else {
			if (msp[S[i]] != T[i]) {
				cout << "No" << endl;
				return 0;
			}
		}
		if (mmtp[T[i]] == false) {
			mmtp[T[i]] = true;
			mtp[T[i]] = S[i];
		}
		else {
			if (mtp[T[i]] != S[i]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;

}

Measured memory_bytes: 776
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

const int N = 1234567;
int a[123][123];


int main() {
    int n,m,x;
    cin>>n>>m>>x;
    for (int i=1;i<=n;i++)
    for (int j=1;j<=m+1;j++) cin>>a[i][j];

    int ans=(1<<30);
    for (int i=0;i<(1<<n);i++) {

        int b[124]={0};
        for (int j=1;j<=n;j++)
            if (i&(1<<(j-1))) b[j]=1;

        int c[123]={0};
        int tmp=0;
        for (int j=1;j<=n;j++)
        if (b[j]) {
        tmp+=a[j][1];
        for (int k=2;k<=m+1;k++)
            c[k]+=a[j][k];
        }
        bool flag=false;
        for (int k=2;k<=m+1;k++)
        if (c[k]<x) {
            flag=true;
            break;
        }
        if (!flag) ans=min(ans, tmp);
    }
    if (ans>(1<<25)) ans=-1;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3648
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Sun, 19th Jan 2020                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(int i = a; i < (int)b; i++)
#define req(i,a,b)  for(int i = (int)b - 1; i >= a; i--)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << x << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;

int gcd(int a, int b) {return b?gcd(b,a%b):a;}

#ifdef LOCAL
	#define wa(x)       cerr << (#x) << " --- " << (x) << endl
	#define pvi(v)      {for(auto it:v) cerr << it << " "; cerr << endl;}
	#define line1	    cerr << "---------------------------" << endl;
#else
	#define wa //
	#define line1 //
	#define pvi //
	#define printf //
#endif

void solve();
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout << fixed << setprecision(10);

	int t=1; 
	// cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

void solve() {

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

	int p;
	if(s < 1e9) p = 1e9;
	else p = 1;

	vi a;
	while(sz(a) < k) a.pb(s);
	while(sz(a) < n) a.pb(p);
	
	for(auto e:a) cout << e << " ";
	cout << endl;
}


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

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = (long) 1e9 + 7;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static int maxn = 100005;

    static class sort implements Comparator<String> {
        public int compare(String a, String b) {
            return a.length() - b.length();
        }
    }

    static void solve() {
        int k = ni();
        int a = ni();
        int b = ni();
        int f = 0;
        for (int i = a; i <= b; i++) {
            if (i % k == 0) {
                f = 1;
                out.println("OK");
                break;
            }
        }
        if (f == 0) {
            out.println("NG");
        }
    }
}

Measured memory_bytes: 32560
if __name__ == '__main__':
    a, b, c, x, y = map(int, input().split())
    AB_sum = min(a + b, c * 2)  # AB1枚ずつの最小値
    ans = 0
    ans += min(x, y) * AB_sum
    if x < y:
        if b < c * 2:
            ans += b * (y - x)
        else:
            ans += (c * 2) * (y - x)
    else:
        if a < c * 2:
            ans += a * (x - y)
        else:
            ans += (c * 2) * (x - y)
    print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        if ((n & 1) == 1) {
            System.out.println("No");
            sc.close();
            return;
        }
        String h = s.substring(0, n >> 1);
        if ((h + h).equals(s)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}


Measured memory_bytes: 20820
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=a;i<b;i++)

int main() {
	ll N, A, B;
	cin >> N >> A >> B;
	vector<ll> his;
	rep(i, 0, N) {
		ll hi;
		cin >> hi;
		his.push_back(hi);
	}
	ll hp_sum = accumulate(his.begin(), his.end(), (ll)0);
	ll bad = 0;
	ll good = hp_sum / B + (hp_sum % B != 0);
	while (good - bad >= 2) {
		ll half = (good + bad) / 2;
		ll cnt = 0;
		rep(i, 0, N) {
			ll hi = his[i];
			hi -= B * half;
			if (hi > 0) {
				cnt += hi / (A - B) + (hi % (A - B) != 0);
			}
		}
		if (cnt <= half) {
			good = half;
		} else {
			bad = half;
		}
	}
	cout << good << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    rep(i, len(s)) {
        reps(ii, i, len(s)) {
            string tmp = "";
            tmp += s.substr(0, i);
            tmp += s.substr(ii);
            if (tmp == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
  N = int(input())
  if N % 2 == 1:
    print(0)
    return 0
  
  num = int(N/2)
  D = list(map(lambda d: int(d), input().split(" ")))
  D.sort()
  
  difficultABC = D[int(N/2) - 1]
  easyARC = D[int(N/2)]
# difficultABC < K <= easyARC
  print(easyARC - difficultABC)

main()

Measured memory_bytes: 20640
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(){
    int n;
    cin >> n;
    
    if(n < 10){
        cout << n << endl;
    }
    else if (n < std::pow(10,2)){
        cout << 9 << endl;
    }
    else if (n < std::pow(10,3)){
        cout << n - 100 + 1 + 9 << endl;
    }
    else if (n < std::pow(10,4)){
        cout << 900 + 9 << endl;
    }
    else if (n < std::pow(10,5)){
        cout << n - 10000 + 1 + 900 + 9 << endl;
    }
    else if (n == std::pow(10,5)){
        cout << n - 10000 + 900 + 9 << endl;
    }
   
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	ans := a * 100 + b * 10 + c
	if ans % 4 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sst stringstream
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int T,M;
string s;

int main(){
	cin>>T;
    getline(cin,s);
    rep(tc,T){
        getline(cin,s);
        cin>>M;
        string t;
        getline(cin,t);
        int cur=0;
        rep(h,M){
            getline(cin,t);
            
            if(t[0]=='f' && t[8]=='c'){
                cur=min(cur+1,(int)s.sz);
            }
            if(t[0]=='f' && t[8]=='w'){
                int mode=0;
                rep2(i,cur,s.sz+1){
                    if(i==s.sz)cur=s.sz;
                    if(s[i]==' '){
                        if(mode==1){
                            cur=i;break;
                        }
                    }else mode=1;
                }
            }
            
            if(t[0]=='b' && t[9]=='c'){
                cur=max(cur-1,0);
            }
            if(t[0]=='b' && t[9]=='w'){
                int mode=0;
                for(int i=cur-1;i>=-1;i--){
                    if(i==-1)cur=0;
                    if(s[i]==' '){
                        if(mode==1){
                            cur=i+1;break;
                        }
                    }else mode=1;
                }
            }
            
            if(t[0]=='i'){
                string u=t.substr(8,t.sz-9);
                string s1=s.substr(0,cur);
                string s2=s.substr(cur);
                s=s1+u+s2;
                cur+=u.sz;
            }
            
            if(t[0]=='d' && t[7]=='c')if(cur<s.sz){
                string s1=s.substr(0,cur);
                string s2=s.substr(cur+1);
                s=s1+s2;
            }
            if(t[0]=='d' && t[7]=='w'){
                int mode=0;
                rep2(i,cur,s.sz+1){
                    if(s[i]==' ' || i==s.sz){
                        if(mode==1){
                            string s1=s.substr(0,cur);
                            string s2=s.substr(i);
                            s=s1+s2;
                            break;
                        }
                    }else mode=1;
                }
            }
            
            //cout<<cur<<"/"<<s.sz<<endl<<s<<endl;
        }
        cout<<s.substr(0,cur)<<"^"<<s.substr(cur)<<endl;
    }
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	int ans = 0;
	int maxi = 0;
	for (int i = 0; i < n; ++i)
	{
		int a,b;
		cin >> a >> b;
		if (a==b){
			ans += 1;
			maxi = max(maxi, ans);
		} else{
			ans = 0;
		}
	}
	if (maxi>=3) 
	{
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

Measured memory_bytes: 3592
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:i64 = read();
    let l:i64 = read();
    let left = l;
    let right = l + n - 1;

    let eat = if right <= 0 {
        right
    } else if left >= 0 {
        left
    } else {
        0
    };
    let ans = (right+left) * (right - left + 1) / 2 - eat;
    println!("{}", ans);
}

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

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    if(a >= b){
        cout << "delicious" << endl;
    }
    else if(b-a <= x){
        cout << "safe" << endl;
    }
    else{
        cout << "dangerous" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
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 (a>b) { a=b; return true; } return false; }

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    VL a(n), b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    VL sumA(n+1), sumB(m+1);
    rep(i,n) sumA[i+1] = sumA[i] + a[i];
    rep(i,m) sumB[i+1] = sumB[i] + b[i];


    int ans = 0, right = m;
    for(int i = 0; i <= n; i++){
        if (sumA[i] > k) break;
        while(right >= 0){
            if (sumA[i] + sumB[right] <= k) break;
            right--;
        }
        ans = max(ans, i + right);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9564
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int q, dp[1007][1007]; string s, t;
int main() {
	cin >> q;
	while(q--) {
		cin >> s >> t;
		for(int i = 0; i < s.size(); i++) {
			for(int j = 0; j < t.size(); j++) {
				dp[i + 1][j + 1] = (s[i] == t[j] ? dp[i][j] + 1 : max(dp[i][j + 1], dp[i + 1][j]));
			}
		}
		cout << dp[s.size()][t.size()] << endl;
	}
}

Measured memory_bytes: 7104
#include "bits/stdc++.h"
using namespace std;
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
#ifdef LOCAL
mt19937 rng(unsigned(70));
#else
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#endif
#define rand rng


int main() {
	// fios;
	ll a , b, n;
	cin >> a >> b >> n;\
	if(n < b) {
		cout << floor((double)a * 1.0 * n / b) << endl;
		return 0;
	}
	cout << floor((double)a*(b-1) * 1.0 / b) << endl;

}

Measured memory_bytes: 3820
program main
    character :: c*(10**5)
    character(10**5) :: ch
    character :: anser(26)
    integer :: word(26) = 0
    integer :: max_array, a
    do i = 1, 26
        anser(i) = achar(iachar('a')+i-1)
    end do

    read(5, '(a)') c
    max_array = len(trim(c))
    ch = trim(c)
    do i=1,max_array
        a = iachar(ch(i:i)) - iachar('a') + 1
        word(a) = 1
    end do

    do i=1,26
        if (word(i) == 0) then
            print *, anser(i)
            exit
        end if
        if (i == 26) then
            print *, "None"
        end if
    end do
end program main

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 1e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
// #define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
 
ll mod = 998244353;
// ll mod = 1000000007;
  
ll mypow(ll number1,ll number2, ll mod){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
bool multicase = false;

ll n,m,num,sum,a,b,c,d,e,h,q,p;
ll w, ans;
ll k;
ll x[500005], y[500005], z[500005];
string s, t;

void solve(){
    cin >> s;
    Yes(s[2] == s[3] && s[4] == s[5]);
    return;
}

int main(){
    // init();
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);
    ll q;
    if(multicase){
        cin >> q;
    }else{
        q = 1;
    }
    while(q--){
        solve();
    }
    return 0;

}


















Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()
#define mp(a, b) make_pair(a, b)
const int inf = 1 << 28;

int N;
vector<string> in;
vector<pair<int, bool> > var;

int dfs(int used, int sum){
    int k = __builtin_popcount(used);
    if((int)var.size() <= k)return sum == 0;
    int res = 0;
    rep(i, 10){
        if(used >> i & 1 || (!i && var[k].second))continue;
        res += dfs(used | 1 << i, sum + i * var[k].first);
    }
    return res;
}

void add(pair<int, bool>& t, pair<int, bool> f){
    t = mp(t.first + f.first, t.second | f.second);
}

int solve(){
    var.assign(26, mp(inf, false));
    rep(i, N)for(int j=(int)in[i].size()-1, d=1; j>=0; --j, d*=10){
        if(var[in[i][j] - 'A'].first == inf)var[in[i][j] - 'A'].first = 0;
        add(var[in[i][j] - 'A'], mp(i != N-1? d: -d, !j & (int)in[i].size() != 1));
    }
    var.erase(remove_if(all(var), [](pair<int, bool> p){return p.first == inf;}), var.end());
    if(10 < (int)var.size())return 0;
    return dfs(0, 0);
}

int main(){
    while(cin >> N, N){
        in.assign(N, "");
        rep(i, N)cin >> in[i];
        cout << solve() << '\n';
    }
    return 0;
}

Measured memory_bytes: 1216
import sys
sys.setrecursionlimit(10 ** 6)

from math import factorial
def comb(n, r):
  if r < 0 or r > n:
    return 0
  else:
    return factorial(n) // (factorial(n - r) * factorial(r))

# 左から i 桁目以降について、0 以外の値を残り K 個使用可能
# smaller: i 桁目までが 一致している時=False, 小さい時=True  
def solve(i, k, smaller):
  if i == n:
    if k == 0:
      return 1
    else:
      return 0
  if k == 0:
    return 1
  if smaller:
    return comb(n - i, k) * 9 ** k
  else:
    if S[i] == "0":
      return solve(i + 1, k, False)
    else:
      zero = solve(i + 1, k, True)
      aida = solve(i + 1, k - 1, True) * (int(S[i]) - 1)
      icchi = solve(i + 1, k - 1, False)
      return zero + aida + icchi

S = input()  
n = len(S)
k = int(input())
print(solve(0, k, False))

Measured memory_bytes: 3064
#include <iostream>
#include <assert.h>
#include <vector>

#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <climits>

#define N 4
#define N2 16

using namespace std;

// const int N = 4;
// const int N2 = 16;

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'}; 


struct Node
{
	int puzzle[N2];
	int space;
	int md;
};

class Npuzzle
{
private:
	Node s_node;
	int limit;
	int md[N2][N2];
	// vector<int> path;
	int ans;
public:
	Npuzzle() {
		s_node = Node();
		int in[N2];
		for (int i = 0; i < N2; ++i)
		{
			int tmp;
			cin >> tmp;
			if(tmp == 0) {
				tmp = N2;
				s_node.space = i;
			}
			s_node.puzzle[i] = tmp;
		}
		set_md();
		s_node.md = get_md_sum(s_node.puzzle);
	}

	int get_md_sum(int *puzzle) {
		int sum = 0;
		for (int i = 0; i < N2; ++i)
		{
			if(puzzle[i] == N2) continue;
			sum += md[i][puzzle[i]-1];
		}
		return sum;
	}

	void set_md() {
		for (int i = 0; i < N2; ++i)
		{
			for (int j = 0; j < N2; ++j)
			{
				md[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
			}
		}
	}

	bool dfs(Node cur_n, int depth, int pre) {
		if(cur_n.md == 0 ) {
			ans = depth;
			return true;
		}
		if(depth + cur_n.md > limit) return false;
		int s_x = cur_n.space / N;
		int s_y = cur_n.space % N;
		for (int i = 0; i < 4; ++i)
		{
			Node new_n = cur_n;
			int new_x = s_x + dx[i];
			int new_y = s_y + dy[i];
			if(new_x < 0  || new_y < 0 || new_x >= N || new_y >= N) continue; 
			if(max(pre, i) - min(pre, i) == 2) continue;

			new_n.md -= md[new_x * N + new_y][new_n.puzzle[new_x * N + new_y] - 1];
			new_n.md += md[s_x * N + s_y][new_n.puzzle[new_x * N + new_y] - 1];
			swap(new_n.puzzle[new_x * N + new_y], new_n.puzzle[s_x * N + s_y]);
			new_n.space = new_x * N + new_y;
			// assert(get_md_sum(new_n.puzzle) == new_n.md);
			// return dfs(new_n, depth+1, i);
			if(dfs(new_n, depth + 1, i)){
				// path[depth] = i;
				return true;
			}
		}
		return false;
	}

	void ida_star() {
		for (limit = s_node.md; limit < 1000; ++limit)
		{
			// path.resize(limit);
			if(dfs(s_node, 0, -10)) {
				cout << limit << endl;
				// string str = "";
				// for (int i = 0; i < limit; ++i)
				// {
				// 	str += dir[path[i]];
				// }
				// cout << str << endl;
				return;
			}
		}
	}

	void exec() {
		ida_star();
	}
};


int main() {
	Npuzzle np = Npuzzle();
	np.exec(); 
}

Measured memory_bytes: 3100
function Main(input){

input=input.split("");

answer = 0;

for (i = 0; i < 4; i++) {
    if (input[i] == "+") {
        answer = answer + 1;
    }
    if (input[i] == "-") {
        answer = answer - 1;
    }
}

console.log(answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    rep(i,s.size())
    {
        if(s[i] == '1') ans++;
    }
    cout << ans << endl;
}


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

int main() {
  int H, W,a;  
  a=0;
  cin >> H >> W;
  vector<char> vec(H*W);
  for (int m=0; m<H*W; m++) {
    cin >> vec.at(m) ;
  }
  for (int i=0; i<W+2; i++) {
    cout << "#";
  }
  cout << endl;
  for (int j=0; j<H; j++) {
  cout << "#" ;
  for (int k=W*j+0;k<(1+a)*W; k++) {
    cout << vec.at(k) ;

  }
a++;
    cout << "#" << endl;
  }
  for (int l=0; l<W+2; l++) {
    cout << "#";
  }
  
}

Measured memory_bytes: 256
from math import ceil,floor
A,B,C,D = map(int,input().split())

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
def lcm(a,b):
    return a*b//gcd(a,b)

def keisan(s,e,d):
    if s%d == 0:
        return e//d - s//d + 1
    else:
        return e//d - s//d

if B == A:
    if A%C == 0 or A%D == 0:
        print(0)
    else:
        print(1)
else:
    print(B-A+1-(keisan(A,B,C)+keisan(A,B,D)-keisan(A,B,lcm(C,D))))


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

int main(){
	double v, y;
	while(cin >> v){
		y = 4.9 * pow(v / 9.8, 2);
		int n = 0;
		for(n;;n++)if(y <= 5*n-5)break;
		cout << n << endl;
	}
	return 0; 
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  if (n <= 6) {
    cout << 1 << endl;
  } else {
    if (n % 11 == 0) {
      cout << 2 * (n / 11) << endl;
    } else if (n % 11 <= 6) {
      cout << 2 * (n / 11) + 1 << endl;
    } else {
      cout << 2 * (n / 11) + 2 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int a,b; cin >> a >> b;
	cout << (b-1+a-2)/(a-1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

int mod = 1000000007;
int pow2[64];
int pow3[64];
map<Pii, bool> calced;
map<Pii, int> res;

signed main(){

    int N; cin >> N;
    //2^D<=N,2^(D+1)>N
    int D;
    REP(i, 64) if(N < (1LL << i)){
        D = i - 1;
        break;
    }
    
    mat dp(D + 2, vec(3, 0));
    dp[0][0] = 1;
    FOR(d, 1, D + 2){
        FOR(k, 0, 3){
            int N0 = (k << (D + 2 - d)) + (N % (1LL << (D + 2 - d)));
            FOR(a, 0, 3){
                int k2 = N0 - (1LL << (D + 1 - d)) * a;
                if(k2 < 0) continue;
                k2 = min(2LL, k2 >> (D + 1 - d));
                dp[d][k2] += dp[d - 1][k];
                dp[d][k2] %= mod;
            }
        }
    }
    int ans = 0;
    REP(k, 3) ans = (ans + dp[D + 1][k]) % mod;
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(100), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
const Int MOD = 998244353;
const Int MAX = 10000;
Int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
Int COM(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
Int memo[3010][6010];
Int f(int n, int sum) {
    if (sum > 2 * n || sum < 0) return 0;
    if (n == 0) return sum == 0;
    if (memo[n][sum] != -1) return memo[n][sum];
    Int ans = f(n - 1, sum) + f(n - 1, sum - 1) + f(n - 1, sum - 2);
    ans %= MOD;
    return memo[n][sum] = ans;
}
Int memo2[3010][3010];
Int g(int k, int n, int m) {
#if 0
    if (n <= 0) return 0;
    if (k == 0) return f(n, m);
    if (memo2[k][n] != -1) return memo2[k][n];
    Int ans = g(k - 1, n - 1, m) + g(k, n - 1, m);
    ans %= MOD;
    return memo2[k][n] = ans;
#else
    Int ans = 0;
    for (int a = 1; a <= n - k; a++) {
        ans += COM(n - a - 1, k - 1) * f(a, m);
        ans %= MOD;
    }
    return ans;
#endif
}
int main() {
    COMinit();
    memset(memo, -1, sizeof(memo));
    int N, X; cin >> N >> X;
    Int ans = 0;
    for (int t = 0; t <= N * 2; t++) {
        if (t < X) {
            ans += f(N, t);
            ans %= MOD;
        } else if (t == X) {
            // zero
        } else {
            if (t % 2 == 0 && X % 2 == 1) {
                int k = (t - X + 1) / 2;
                int m = t - k * 4;
                if (m <= 0) {
                    ans += COM(N, t / 2);
                } else {
                    ans += g(k * 2, N, m);
                }
                ans %= MOD;
            }
            if (t % 2 == 1 && X % 2 == 0) {
                int k = (t - X + 1) / 2;
                int m = t - k * 4;
                if (m > 0) {
                    ans += g(k * 2, N, m);
                }
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 143104
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const int INF = 2000000000;
    ll N,M,K;
    ll A[100010],B,C,X;
    bool F=true;
    ll ans=0;
    string S;
    priority_queue<ll,vector<ll>,greater<ll>> Q,W;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>M;
    ans=N;
    REP(i,M){
        cin>>A[i];
        ans-=A[i];
    }
    if(ans<0)cout<<"-1";
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3736
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<cfloat>
using namespace std;
int mod = 1e9+7;

int main() {
  long long int n, x;
  cin >> n >> x;
  vector<long long int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }

  vector<long long int> b = a;
  long long int ans = 1e18;
  for(int i=0; i<n; i++){
    long long int tmp = i*x;
    for(int j=0; j<n; j++){
      b[j] = min(b[j], a[(j-i+n)%n]);
    }
    for(int j=0; j<n; j++) tmp += b[j];
    ans = min(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}

//


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


void solve() {
    int m, n;
    cin >> m >> n;
    vector<vector<int> > a(m, vector<int>(n));
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> a[i][j];
        }
    }
    vector<pii> fr, to;
    for (int i = 0; i < m; ++i) {
        if (i & 1) {
            for (int j = n - 1; j > 0; --j) {
                if (a[i][j] & 1) {
                    fr.emplace_back(i, j);
                    to.emplace_back(i, j - 1);
                    --a[i][j];
                    ++a[i][j - 1];
                }
            }
            if ((i + 1 < m) && (a[i][0] & 1)) {
                fr.emplace_back(i, 0);
                to.emplace_back(i + 1, 0);
                --a[i][0];
                ++a[i + 1][0];
            }
        } else {
            for (int j = 0; j + 1 < n; ++j) {
                if (a[i][j] & 1) {
                    fr.emplace_back(i, j);
                    to.emplace_back(i, j + 1);
                    --a[i][j];
                    ++a[i][j + 1];
                }
            }
            if ((i + 1 < m) && (a[i][n - 1] & 1)) {
                fr.emplace_back(i, n - 1);
                to.emplace_back(i + 1, n - 1);
                --a[i][n - 1];
                ++a[i + 1][n - 1];
            }
        }
    }
    cout << fr.size() << endl;
    for (int i = 0; i < fr.size(); ++i) {
        cout << fr[i].first + 1 << " " << fr[i].second + 1 << " " << to[i].first + 1 << " " << to[i].second + 1 << "\n";
    }
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 5356
#include <iostream>

int main()
{
  int N, rate[9] = {0};
  std::cin >> N;
  
  int score;
  for(int i = 0; i < N; i++)
  {
    std::cin >> score;
    if(score < 3200)
    {
      rate[score / 400]++;
    }
    else
    {
      rate[8]++;
    }
  }
  
  int type_min = 0, type_max = 0;
  for(int i = 0; i < 8; i++)
  {
    if(rate[i] > 0)
    {
      type_min++;
    }
  }
  
  if(type_min == 0 && rate[8] > 0)
  {
    type_min = 1;
    type_max = type_min + rate[8] - 1;
  }
  else
  {
    type_max = type_min + rate[8];  
  }
  
  std::cout << type_min << " " << type_max;  
  return 0;
}

Measured memory_bytes: 3176
import sys
import re
from decimal import *

l = sys.stdin.readline()
#l = l.split(' ')
#l = [int(str) for str in l]
n = int(l)

for i in range(1,10):
  for j in range(1,10):
    if(i*j == n):
      print("Yes")
      exit(0)

print("No")

sys.stdout.flush()


Measured memory_bytes: 5400
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("Impossible"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

// Union find
struct uf {
  vi d;
  uf(){}
  uf(int mx):d(mx,-1){}
  int root(int x) {
    if(d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x,y);
    d[x] += d[y]; d[y] = x;
    return true;
  }
  int size(int x) { return -d[root(x)];}
};
//



int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  vi x(n);
  cin>>x;
  uf t(n);
  rep(i,m) {
    int a,b;
    scanf("%d%d",&a,&b);
    t.unite(a,b);
  }
  vvi d(n);
  rep(i,n) {
    d[t.root(i)].pb(x[i]);
  }
  int cnt = 0;
  rep(i,n) {
    sort(rng(d[i]));
    if (sz(d[i])) cnt++;
  }
  --cnt; cnt *= 2;
  vi p;
  ll ans = 0;
  // cerr<<cnt<<endl;
  int z = cnt/2;
  rep(i,n) {
    if (!sz(d[i])) continue;
    rep(j,min(z,sz(d[i]))) {
      if (j == 0) {
        ans += d[i][j];
        --cnt;
      } else p.pb(d[i][j]);
    }
  }
  // cerr<<sz(p)<<endl;
  // cerr<<cnt<<endl;
  sort(rng(p));
  if (sz(p) < cnt) dame;
  rep(i,cnt) ans += p[i];
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 6528
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;

#define REP(i, n) for(ll i = 0; i < n; i++)






















int main(){
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
}


Measured memory_bytes: 3600