akhauriyash/Code-Regression huggingface dataset:
def main():
    N, M = map(int, input().split())
    D = [tuple(map(int, input().split())) for _ in range(N)]
    D.sort()
    ans = 0
    i = 0
    while M > 0:
        a, b = D[i]
        ans += a * min(M, b)
        M -= min(M, b)
        i += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 59224
x = int(input())
a = 0

while True:
    b = 0
    b2 = 0
    while a**5 - b**5 > 0 or a**5 - b2**5 < 10**9:
        if a**5 - b**5  == x:
            print(a ,b)
            break
        b += 1
        if a**5 - b2**5 == x:
            print(a ,b2)
            break
        b2 -= 1
    else:
        a += 1
        continue
    break


Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s;
  cin >> s;
  cout << s.substr(0, 4) << " " << s.substr(4) << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	int r;
	std::cin >> r;
	std::cout << r * r << std::endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main(){
	IOS;
	int a, b;
	cin >> a >> b;
	if( a < 9 && b < 9 ){
		cout << "Yay!\n";
	}else{
		cout << ":(\n";
	}
	return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
 
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define PI acos(-1.0)
const int N=2e5 + 5;
const int M=1e5 + 5;
 

 
int main()
{
    ios_base::sync_with_stdio(false);
    int i,n;
    ll k;
    int s[N];
    int arr[N],fst[N],nxt[N],jmp[N];
    for(i=0;i<N;i++){
    	arr[i]=-1;
    	fst[i]=-1;
    } 
    cin>>n;
    cin>>k;
    for(i=0;i<n;i++){
    	cin>>s[i];
    	if(fst[s[i]]==-1){
    		fst[s[i]]=i;
    	}
    }
    for(i=n-1;i>=0;i--){
    	


    	if(arr[s[i]]==-1){
    		nxt[i]=(fst[s[i]]+1)%n;
    		arr[s[i]]=i;
    		if(fst[s[i]]<i){
    			jmp[i]=1;
    		}
    		else{
    			if(nxt[i]>i){
    				jmp[i]=1;
    			}
    			else{
    				jmp[i]=2;
    			}
    		}
    	}
    	else{
    		nxt[i]=(arr[s[i]]+1)%n;
    		arr[s[i]]=i;
    		if(nxt[i]>i){
    			jmp[i]=0;
    		}
    		else{
    			jmp[i]=1;
    		}
    	}
    	
    }
    
    ll foo;
    
    int cur =nxt[0];
    ll js = jmp[0];
    while(cur != 0){
    	js += (ll)(jmp[cur]);
    	cur = nxt[cur];
    	
    }
    //cout << jmp[0] << endl;
    k--;
    ll rem = k%js;
    cur = 0;
    js = 0;

    while(js!=rem){
    	js += jmp[cur];
    	cur = nxt[cur];
    }


    vector <int> ans;
    stack <int> st;
    multiset <int> ms;
    multiset <int> :: iterator it,it2;
    for(i=cur;i<n;i++){
    	int val = s[i];
    	it = ms.find(val);
    	if(it == ms.end()){
    		st.push(val);
    		ms.insert(val);
    	}
    	else{
    		while((it = ms.find(val)) != ms.end()){
    			it2 = ms.find(st.top());
    			ms.erase(it2);
    			st.pop();
    		}

    	}
    }
    
 	while(!st.empty()){
 		ans.pb(st.top());
 		st.pop();
 	}
 	reverse(ans.begin(),ans.end());
 	for(i=0;i<ans.size();i++) cout << ans[i] << " ";
 	cout << endl;
    return 0;
}

Measured memory_bytes: 16504
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
ll mod=1E9+7;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)

ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

int main(){
    ll N=ii();
    map<ll,ll> lmap;
    map<ll,ll> rmap;
    vector<ll> A;

    REP(i,1,N+1){
        ll a=ii();
        A.push_back(a);

        ll lidx=i+a-1;
        lmap[lidx]++;
        ll ridx=i-a+1;
        rmap[ridx]++;
    }

    ll ret=0;
    REP(i,1,N+1){
        ll a=A[i-1];

        ret+=lmap[i-a-1];
        ret+=rmap[i+a+1];
    }

    oie(ret/2);
    return 0;
}


Measured memory_bytes: 49976
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        StringBuilder sb = new StringBuilder(input);
        int length = input.length();
        String replaceStr = Integer.toString(length-2);
        sb.replace(1,length-1, replaceStr);
        System.out.println(sb);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <iostream>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;

//typedef long long int i64; // 9e18
typedef long long int i64; // 9e18

typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

//const double PI = 3.141592653589793238463;
//const int MAXN = 1000500;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;
const i64 INF = 1e18;
i64 mod = 1e9 + 7;


i64 T, n, m, k;
//vector <vector<i64>> a;
//vector <i64> b;
//vector <i64> dp;

//vector <vector<i64>> dp;

i64 norm(i64 d, i64 MOD) {
    return ((d % MOD) + MOD) % MOD;
}

i64 add_m(i64 x, i64 y, i64 MOD) {
    return norm(norm(x, MOD) + norm(y, MOD), MOD);
}

i64 sub_m(i64 x, i64 y, i64 MOD) {
    return norm(norm(x, MOD) - norm(y, MOD), MOD);
}

i64 mul_m(i64 x, i64 y, i64 MOD) {
    return norm(norm(x, MOD) * norm(y, MOD), MOD);
}

i64 fastpow(i64 a, i64 n, i64 MOD) {
    if (n == 0) return 1;
    if (n % 2 == 1) {
        return (a * fastpow(a, n - 1, MOD)) % MOD;
    }
    i64 tmp = fastpow(a, n / 2, MOD);
    return (tmp * tmp) % MOD;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(16);

    //cin >> T;
    T = 1;

    for (i64 tt = 0; tt < T; ++tt) {

        cin >> n;

        cout << sub_m(fastpow(10, n, mod), sub_m(mul_m(2, fastpow(9,n,mod), mod), fastpow(8,n,mod), mod), mod) << endl;

    }
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define LL long long
using namespace std ;
LL gcd ( LL a, LL b ) { return b?gcd(b,a%b):a ; }
int main() {
	LL x, n ;
	scanf ( "%lld%lld", &n, &x ) ;	
	printf ( "%lld\n", 3*(n-gcd(n,x)) ) ;
	return 0 ;
}

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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> s(n);
    for(int i = 0; i < n; ++i){
        std::cin >> s.at(i);
    }

    int q;
    std::cin >> q;
    std::vector<int> t(q);
    for(int i = 0; i < q; ++i){
        std::cin >> t.at(i);
    }

    int ans = 0;
    for(int i = 0; i < q; ++i){
        for(int j = 0; j < n; ++j){
            if(s.at(j) == t.at(i)){
                ++ans;
                break;
            }
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
int n;
int a[25];
int res = 0;

int main(){
  cin >> n;
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }
  for(int i = 1; i < n-1; ++i){
    if(a[i-1] < a[i]){
      if(a[i] < a[i+1]){
        res += 1;
      }
    }else{
      if(a[i] > a[i+1]){
        res += 1;
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const long long int infLL = 9000000000000000000;
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(a) (a).begin(),(a).end()
#define mx_int_prime 999999937
const int inf = 2000000000;
const double PI = acos(-1);
const double eps = 1e-9;
typedef long double ld;
#define MOD 1000000007
typedef long long ll;
const int mx=2e5+125;
ll p[mx],a[mx],b[mx];
#define PB push_back
//#define '\n' endl
#define S second
#define F first
int main()
{
    faster();
    int n,m;
    cin>>n>>m;
    if(m==n)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return  0;
}


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

bool ok(string s) {
    //奇数
    for (int i = 0; i < s.length(); i = i + 2) {
        if (s.at(i) == 'L') {
            return false;
        }
    }

    //偶数
    for (int i = 1; i < s.length(); i = i + 2) {
        if (s.at(i) == 'R') {
            return false;
        }
    }

    return true;
}

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

    cout << (ok(s) ? "Yes" : "No") << endl;

    return 0;
}

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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int) 1e5;
const int INF = (int) 1e9 + 7;

int cnt[N + 7];

int main(int argc, char *argv[])
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

	int n;
	sf("%d", &n);
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		int x;
		sf("%d", &x);
		++cnt[x];
		sum += x;
	}

	int q;
	sf("%d", &q);
	while (q--) {
		int a, b;
		sf("%d %d", &a, &b);
		cnt[b] += cnt[a];
		sum += cnt[a] * (b - a);
		cnt[a] = 0;

		printf("%lld\n", sum);
	}

	return 0;
}


Measured memory_bytes: 4108
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807/5;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n;
ll l[2010];
ll ans=0;
int main(){
	cin>>n;
	REP(i,n)cin>>l[i];
	sort(l,l+n);
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int a=l[j];
			int b=l[i];
			auto itr=lower_bound(l,l+i,a-b+1);
			if(itr==l+i)continue;
			ans+=(l+i-itr);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.trim_right();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (x, y, z) = parse_line!(usize, usize, usize);

    println!("{} {} {}", z, x, y);
}


Measured memory_bytes: 4352
#include <iostream>
#include <utility>
#include <algorithm>

using namespace std;

int main(){
  int n;
  cin>>n;
  pair<int,int> last=make_pair(-1,0),tmp;
  for(int i=0;i<n;i++){
    cin>>tmp.first>>tmp.second;
    if(tmp.first>last.first){
      last.first=tmp.first;
      last.second=tmp.second;
    
    }
  
  }

  cout<<last.first+last.second<<endl;

}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    int tn = 0;
    string pre, suf;
    REP(i, Q){
        int t;
        cin >> t;
        if(t==1){
            tn++;
        }else{
            int f;char c;
            cin >> f >> c;
            if(tn&1){
                if(f==2) pre += c;
                else suf += c;
                // if(f==2) S = c+S;
                // else S = S+c;
            }else{
                if(f==1) pre += c;
                else suf += c;
                // if(f==1) S = c+S;
                // else S = S+c;
            }
        }
    }

    if(tn&1){
        reverse(ALL(S));
        reverse(ALL(suf));
        pr(suf + S + pre);
    }else{
        reverse(ALL(pre));
        pr(pre + S + suf);
    }
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// abc124d
int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> ans;
    int pre = 1;
    if (s[0]=='0'){
        ans.push_back(0);
        ans.push_back(1);
        pre = 0;
    }else{
        ans.push_back(1);
    }
    rep(i, n){
        if (i==0) continue;
        if (pre == s[i] - '0'){
            ans[ans.size()-1] = ans[ans.size()-1]+1;
        }else{
            ans.push_back(1);
            pre = s[i]-'0';
        }
    }
    if (pre==0) ans.push_back(0);
    rep(i, ans.size()-1) ans[i+1] = ans[i]+ans[i+1];
    int ansm = 0;
    if (ans.size() == 1){
        cout << n << endl;
        return 0;
    }
    if (2*k+1>ans.size()){
        cout << n << endl;
        return 0;
    }else{
        rep(i, n){
            int l = i, r = 2*k+i;
            if (i%2==1) continue;
          	if (r >= ans.size()) break;
            if (l==0){
                chmax(ansm, ans[r]);
            }else{
                chmax(ansm, ans[r]-ans[l-1]);
            }
        }
    }
    cout << ansm << endl;
    return 0;
}


Measured memory_bytes: 1020
n = int(input())
alp = "abcdefghijklmnopqrstuvwxyz"
def solve(n):
    if n<26:
        return [alp[n]]

    ans=[alp[(n%26)]]

    ans.extend(solve((n//26)-1))
    return ans


ans=solve(n-1)
ans.reverse()
print(*ans,sep="")

Measured memory_bytes: 61880
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include <time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);


int main(){
	int n,m,p;
	while(cin>>n>>m>>p,n|m|p){
		vi x(n);
		int total=0;
		REP(i,n){
			cin>>x[i];
			total+=x[i]*100;
		}
		total=total*(100-p)/100;
		if(x[m-1]==0){
			cout<<0<<endl;
		}else{
			cout<<(int)((double)total/x[m-1])<<endl;
		}
	}
}

Measured memory_bytes: 1196
import fractions
N,M = map(int,input().split())
S = input()
T = input()
gcd = fractions.gcd(N,M)
x = N // gcd 
y = M // gcd
check = 0
for i in range(gcd):
    if S[i*x] != T[i*y]:
        check = 1
        break
if check == 1:
    ans = -1
else:   
    ans = N * M // gcd
print(ans)



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

const int MOD = 1e+9 + 7;
vector<long long> factorial(200000);

// × n!
void factorialMul()
{
    factorial[0] = 1;
    for( int i = 1; i < 2e+5; ++i ){
        factorial[i] = (long long) i * factorial[i-1];
        factorial[i] %= MOD;
    }
}

// n^p mod m
long long powMOD( int n, int p, int m )
{
    if( p == 0 ) return 1;
    if( p%2 == 1 ) return powMOD(n, p-1, m) % m * (long long) n % m; 
    long long tmp = powMOD(n, p/2, m) % m;
    return tmp*tmp % m;
}

// / n!
long long factorialDiv( int n ){ return powMOD(factorial[n], MOD-2, MOD); } 

long long comb( int n, int k ){ return factorial[n] * factorialDiv(k) % MOD * factorialDiv(n-k) % MOD; }


int main()
{
    int H, W, A, B; 
    cin >> H >> W >> A >> B;


    factorialMul();
    long long ans = 0; 
    // 中間点について足し合わせる
    for( int j = B+1; j <= W; ++j ){
        ans += comb(H-A-1+j-1, j-1) * comb(W-j+A-1, A-1);
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

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

int n, m, ans;

int main()
{
    cin >> n >> m;
    for(int i = 1;i<=n;++i)
        for(int j = 1;j<=m;++j)
        {
            char x;
            cin >> x;
            if(x=='#')
                ++ans;
        }
    if(ans != n+m-1)
        cout << "Impossible";
    else
        cout << "Possible";

    return 0;
}


Measured memory_bytes: 384
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = -float('inf')

for i in range(1, N+1):
    score = [0]
    alr = set()
    now = i
    while not now in alr:
        alr.add(now)
        now = P[now-1]
        score.append(score[-1] + C[now-1])
    if len(score)-1 >= K:
        for j in range(K):
            ans = max(ans, score[j+1])
    else:
        base = 0
        if score[-1] > 0:
            base = score[-1]*(K//(len(score)-1))
            L = K % (len(score)-1)
            for j in range(len(score)-1):
                ans = max(ans, (base-score[-1])+score[j+1])
            for j in range(L):
                ans = max(ans, base+score[j+1])
        else:
            for j in range(len(score)-1):
                ans = max(ans, base+score[j+1])

print(ans)
        


Measured memory_bytes: 164784
N, M = [int(x) for x in input().split()]
E = [[] for x in range(N+1)]
visited = set()

for i in range(M):
    A, B = [int(x) for x in input().split()]
    E[A].append(B)
    E[B].append(A)

if set(E[1]) & set(E[N]):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 48652
#include <bits/stdc++.h>//toINFandByd
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define endl "\n"
using namespace std;
typedef long long ll;

void solve(){
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
}   

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		Unit[] units = new Unit[n];
		for (int i = 0; i < n; i++) {
			units[i] = new Unit(sc.nextInt() - 1, sc.nextInt() + h - 1, sc.nextInt());
		}
		Arrays.sort(units);
		UnionFindTree uft = new UnionFindTree(h, w);
		long total = 0;
		for (Unit u : units) {
			if (uft.canSet(u.r, u.c)) {
				uft.unite(u.r, u.c);
				total += u.value;
			}
		}
		System.out.println(total);
	}
	
	static class UnionFindTree {
		int hSize;
		int[] parents;
		int[] pCount;
		int[] hCount;
		public UnionFindTree(int hSize, int wSize) {
			this.hSize = hSize;
			parents = new int[hSize + wSize];
			pCount = new int[hSize + wSize];
			hCount = new int[hSize + wSize];
			for (int i = 0; i < parents.length; i++) {
				parents[i] = i;
				pCount[i] = 1;
			}
		}
		
		private int find(int x) {
			if (x == parents[x]) {
				return x;
			}
			int ans = find(parents[x]);
			parents[x] = ans;
			return ans;
		}
		
		private boolean canSet(int x, int y) {
			int xx = find(x);
			int yy = find(y);
			if (xx == yy) {
				return pCount[xx] >= hCount[xx] + 1;
			} else {
				return pCount[xx] + pCount[yy] >= hCount[xx] + hCount[yy] + 1;
			}
		}
		
		private void unite(int x, int y) {
			int xx = find(x);
			int yy = find(y);
			if (xx == yy) {
				hCount[xx]++;
			} else {
				parents[xx] = yy;
				pCount[yy] += pCount[xx];
				hCount[yy] += hCount[xx] + 1;
			}
		}
	}
	
	static class Unit implements Comparable<Unit> {
		int r;
		int c;
		int value;
		
		public Unit(int r, int c, int value) {
			this.r = r;
			this.c = c;
			this.value = value;
		}
		
		public int compareTo(Unit u) {
			return u.value - this.value;
		}
	}
}


Measured memory_bytes: 95812
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int dp[114514];
signed main(){
	int n; cin>>n;
	vector<int> h;
	h.pb(0);
	for(int i=0;i<n;i++){
		int x; cin>>x; h.pb(x);
	}
	dp[1] = 0;
	dp[2] = abs(h[2]-h[1]);
	for(int i=3;i<=n;i++){
		dp[i] = min( dp[i-2] + abs(h[i]-h[i-2]) , dp[i-1] + abs(h[i]-h[i-1]) );
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1908
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s;
    cin >> s;
    for(char c: s) {
        if (c == '9') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
#include<ios>
#include<iomanip>

using namespace std;
typedef unsigned long long ll;
typedef pair<int,int>P;

int main()
{
	int H,W,N;
	cin>>H>>W>>N;
	vector<int>cnt(N,0);
	vector<vector<int>>G;
	for(int i=0;i<H;i++)
	{
		vector<int>r(W,0);
		G.push_back(r);
	}
	for(int i=0;i<N;i++)
	{
		cin>>cnt[i];
	}
	int np=0;
	int npc=0;
	for(int i=0;i<H;i++)
	{
		if(i%2)
		{
			for(int j=0;j<W;j++)
			{
				G[i][j]=np;
				npc++;
				if(npc==cnt[np])
				{
					np++;
					npc=0;
				}
			}
		}
		else
		{
			for(int j=W-1;j>=0;j--)
			{
				G[i][j]=np;
				npc++;
				if(npc==cnt[np])
				{
					np++;
					npc=0;
				}
			}
		}
	}
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
		{
			cout<<G[i][j]+1<<(j==W-1?'\n':' ');
		}
}

Measured memory_bytes: 384
#include <stdio.h>

#define N	300000

int min(int a, int b) { return a < b ? a : b; }

int main() {
	static int ii[N];
	static char safe[N];
	int n, i, a, b, c;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a), a--;
		ii[a] = i;
	}
	for (b = n - 1; b >= 0; b = a - 1) {
		i = ii[b], a = b;
		while (i < a)
			i = min(i, ii[--a]);
		for (c = b - 1; c >= a; c -= 2)
			if (ii[c] != c) {
				printf("No\n");
				return 0;
			}
		i = -1;
		for (c = a + (a + b) % 2; c <= b; c += 2)
			if (i < ii[c])
				i = ii[c], safe[c] = 1;
		i = n;
		for (c = b; c >= a; c -= 2) {
			if (!safe[c] && i < ii[c]) {
				printf("No\n");
				return 0;
			}
			i = min(i, ii[c]);
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll n, p[200020], q[200020];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		q[p[i] - 1] = i;
	}
	ll ans = 1, cnt = 1;
	for (int i = 0; i < n; i++) {
		if (!i)continue;
		if (q[i] > q[i - 1])cnt++;
		else cnt = 1;
		ans = max(ans, cnt);
	}
	cout << n - ans << endl;
	return 0;
}


Measured memory_bytes: 3328
/**
 *		author:  zvm
 *		created: 27.09.2020 18:35:26
**/

#include <bits/stdc++.h>

using namespace std ;

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

	int a, b ;
	cin >> a >> b ;
	cout << (a+b+1)/2 << endl ;
}


Measured memory_bytes: 3580
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int r, d, x; readV(r, d, x);

  foreach (i; 0..10) {
    x = r*x-d;
    writeln(x);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
/*
ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=2000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll nPk(ll n,ll k){
	return nCk(n,k)*F[k]%mod;
}*/

int x;

int main(){
	cin>>x;
	cout<<max(1,8-(x-400)/200)<<endl;
}

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

int main(){
  int N,i,num;
  cin >> N;
  bool B = true;
  vector<int> A(N);

  for(i=0;i<N;i++)
  cin >> A.at(i);

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

  num = A.at(0);

  for(i=1;i<N;i++){
    if(num==A.at(i)){
      B = false;
      break;
    }else if(num!=A.at(i))
    num = A.at(i);
  }
  if(B)
  cout << "YES";
  else
  cout << "NO";
}

Measured memory_bytes: 1024
def main():
    N, M = map(int, input().split())
    mr = float('INF')
    ml = 0
    for _ in range(M):
        l, r = map(int, input().split())
        ml = max(ml, l)
        mr = min(mr, r)
    if mr - ml >= 0:
        print(mr - ml + 1)
    else:
        print(0)


main()


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

int digitsum(int x) {
    int result = 0;
    while (x) {
        result += x % 10;
        x /= 10;
    }
    return result;
}

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

    int result = numeric_limits<int>::max();
    for (int A = 1, B = N-1; A <= N-1; A++, B--) {
        result = min(result, digitsum(A) + digitsum(B));
    }

    cout << result << endl;
}


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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
inline double distance(double y1, double x1, double y2, double x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, 1, 0, -1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;


void solve(vector<pair<int, int>> v, vector<int> q) {
    VV<LL> dp(v.size() + 1, V<LL>(1001, 0));
    dp[0][0] = 1;

    FOR(i, 0, v.size()) {
        FOR(j, 0, dp[0].size()) {
            if (dp[i][j] == 0) { continue; }

            FOR(k, 0, v[i].second + 1) {
                int x = v[i].first * k;
                if (j + x < dp[0].size()) {
                    dp[i + 1][j + x] += dp[i][j];
                }
            }
        }
    }

    FOE(n, q) {
        print(dp[dp.size() - 1][n]);
    }
}

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

    while (true) {
        int M;
        cin >> M;
        if (M == 0) {
            break;
        }
        vector<pair<int, int>> v;
        FOR(_, 0, M) {
            int a, b;
            cin >> a >> b;
            v.emplace_back(make_pair(a, b));
        }

        vector<int> q;
        int G;
        cin >> G;
        FOR(_, 0, G) {
            int n;
            cin >> n;
            q.emplace_back(n);
        }

        solve(v, q);
    }
    return 0;
}


Measured memory_bytes: 3264
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		sc.close();
		int count = 0;
		for(int i = 0; i < 3; i++) {
			if(S.substring(i, i + 1).equals(T.substring(i, i + 1))) {
				count++;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 23636
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  long long X;
  long long NOW = 100;
  long long ADD;
  int ans = 0;
  cin >> X;
  while(NOW<X){
    ADD = (NOW*0.01);
    NOW +=ADD;
    ans++;
  }
 
  
  
  cout << ans <<endl;

  
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	string s, t; cin >> s >> t;
	int n = s.size();
	vector<vi> next(n + 1, vi(26, inf));
	for(int i = n - 1; i >= 0; i--){
		rep(j, 26){
			if(s[i] == 'a' + j) next[i][j] = i;
			else next[i][j] = next[i + 1][j];
		}
	}
	
	int cnt = 0, pos = 0;
	for(char c : t){
		int npos = next[pos][c - 'a'];
		if(npos == inf){
			cnt++; pos = 0;
			npos = next[pos][c - 'a'];
			if(npos == inf){
				cout << -1 << endl;
				return 0;
			}
		}
		pos = npos + 1;
	}
	cout << (ll)cnt * n + pos << endl;
	return 0;
}

Measured memory_bytes: 13904
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;


int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if (a == b && b == c) cout << 1 << endl;
	else if (a != b && b != c && c != a) cout << 3 << endl;
	else cout << 2 << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

vector<ll> pw27(11,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}

//a,b x
int main(){
	rep1(i,10) pw27[i]=27*pw27[i-1];
	ll N; cin>>N;
	vector<ll> S[100000];
	rep(i,N){
		string tmp; cin>>tmp;
		rep(j,10){
			ll TMP=tmp[j]-'a'+1;
			S[i].pb(TMP);
		}
	}
	rep(i,N){
		sort(S[i].bg,S[i].ed);
	}
	//rep(i,N)rep(j,10) cout<<S[i][j];
	vector<ll> NN(N,0);
	rep(i,N)rep(j,10){
		NN[i]+=S[i][j]*pw27[9-j];
	}
	sort(NN.bg,NN.ed);
	//rep(i,N) cout<<NN[i]<<endl;;
	ll mem=NN[0],cnt=1,ans=0;
	rep1(i,N-1){
		if(NN[i]==mem) cnt++;
		else{
			ans+=cnt*(cnt-1)/2;
			mem=NN[i];
			cnt=1;
		}
	}
	ans+=cnt*(cnt-1)/2;;
	cout<<ans;
}	

Measured memory_bytes: 17408
n = int(input())
total=0
mini=101
for _ in range(n):
    s = int(input())
    total+=s
    if s%10 != 0:
        mini=min(mini,s)
if total%10==0:
    if mini==101:
        print(0)
    else:
        print(total-mini)
else:
    print(total)
    


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n; cin>>n;
    map<int, bool> mp;
    for(int i=0; i<n; i++){
        int x; cin>>x;
        mp[x] = 0;
    }
    for(int i=0; i<n; i++){
        int x; cin>>x;
        mp[x] = 1;
    }

    ll cnta=0, cntb=0;
    ll ans=1;
    for(auto i : mp){
        if(i.sc == 0) cnta++;
        else cntb++;

        if(cnta && cntb){
            ans *= cnta * cntb;
            cnta--;
            cntb--;
            ans %= MOD;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 9728
#include <iostream>
using namespace std;
 
int main() {
    int n,m,a[101],b[101],ar,br,flag;
    while(1){
        flag = ar = br = 0;
        for(int i = 0;i < 101;i++){
            a[i] = b[i] = 0;
        }
        cin >> n >> m;
        if(n+m == 0)break;
        for(int i = 0;i < n;i++){
            cin >> a[i];
            ar += a[i];
        }
        for(int i = 0;i < m;i++){
            cin >> b[i];
            br += b[i];
        }
        if(ar < br || ar > br){
            for(int i = 0;i < n;i++){
                if(flag == 1)break;
                for(int j = 0;j < m;j++){
                    if(ar - a[i] + b[j] == br + a[i] - b[j]){
                        flag = 1;
                        cout << a[i] << " " <<b[j]<<endl;
                        break;
                    }
                }
            }
        }
        else if(ar == br){
            for(int i = 0;i < n;i++){
                if(flag == 1)break;
                for(int j = 0;j < m;j++){
                    if(a[i] == b[j]){
                        flag = 1;
                        cout << a[i] <<" "<<b[j]<<endl;
                        break;
                    }
                }
            }
        }
        if(flag == 0)cout << "-1" <<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int K = int.Parse(str[1]);
		bool flag = true;
		if(K>N*(N-1)/2-(N-1)){
			flag = false;
		}
		var ans = new List<int[]>();
		if(flag){
			for(var i=2;i<=N;i++){
				ans.Add(new int[2]{1,i});
			}
			long ct = (N*(N-1)/2-(N-1))-K;
			while(ct>0){
				for(var i=2;i<=N-1;i++){
					if(ct==0){
						break;
					}
					for(var j=i+1;j<=N;j++){
						ans.Add(new int[2]{i,j});
						ct--;
						if(ct==0){
							break;
						}
					}
				}
			}
			Console.WriteLine(ans.Count);
			for(var i=0;i<ans.Count;i++){
				Console.WriteLine(ans[i][0]+" "+ans[i][1]);
			}
		} else {
			Console.WriteLine("-1");
		}
	}
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
const int MAXN=1e5+5;
vector<int> g[MAXN];
int vis[MAXN];
int dp[MAXN];
int dfs(int u)
{
     if(vis[u])
          return dp[u];
     vis[u]=1;
     int ans=0;
     for(auto v : g[u])
     {
          ans=max(ans,dfs(v)+1);
     }
     return dp[u]=ans;
}
int main()
{
     int n,m;
     cin>>n>>m;
     int ans=0,u,v;
     for(int i=0;i<m;i++)
     {
          cin>>u>>v;
          g[u].push_back(v);
     }
     for(int i=1;i<=n;i++)
     {
          ans=max(ans,dfs(i));
     }
     cout<<ans;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vvvll vector<vector<vector<ll>>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define  ones(x)  __builtin_popcount(x)
using namespace std;
int main(){
    int h1, s1 , h2, s2;
    cin >> h1 >> s1 >> h2 >> s2;
    if(h1 <= 0){cout <<"No";return 0;}
    while(1){
        h2 = h2 - s1;
        if(h2 <= 0){cout << "Yes";break;}
        h1 = h1 - s2;
        if(h1 <= 0){cout <<"No";break;}
    }
    
}

Measured memory_bytes: 3544
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (typeof((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(typeof(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



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

int w,h;
int C[100][100];
bool seen[100][100];

int res = 0;
void dfs(int x, int y) {
    seen[x][y] = true;
    
    for (int i = 0; i < 8; ++i) {
        int nx = x + dx[i], ny = y + dy[i];
        if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
        if (!seen[nx][ny] && C[nx][ny] == 1) {
            dfs(nx, ny);
        }
    }
}

int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/input.in", "r", stdin );
    
    while (cin >> w >> h) {
        if (w == 0) break;
        
        memset(C, 0, sizeof(C));
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cin >> C[i][j];
            }
        }
        
        res = 0;
        memset(seen, 0, sizeof(seen));
        
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                if (!seen[i][j] && C[i][j] == 1) {
                    dfs(i, j);
                    ++res;
                }
            }
        }
        
        cout << res << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1284
#include <iostream>

#define N 100
using namespace std;

int count;
int A[N];

void display(){
	int i,j;   // roop variable
	for(i=0;i<count;i++){
	cout << A[i];
	if(i != count-1)
		cout << " ";
	else cout << "\n";
	}
}
void insertionSort(int A[],int count){
	int i,j;   // roop variable
for(i=1;i<count;i++){
	int key = A[i];
	int j = i - 1;
	while((j>=0) && (A[j] > key)){
	A[j+1] = A[j];
	j--;
	}
A[j+1] = key;
display();
	}
}

int main(){
	int i,j;   // roop variable
	cin >> count;
 for(i=0;i<count;i++){
	cin >> A[i];
 }
// cout << "\n";
 display();
insertionSort(A, count);
return 0;
}

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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    ll n; std::cin >> n;
    if (n == 0) {
        int a; std::cin >> a;
        if (a == 1) std::cout << 1 << "\n";
        else if (a == 0) std::cout << 0 << "\n";
        else std::cout << -1 << "\n";
        return 0;
    }
    vl a(n+1); rep(i, n+1) std::cin >> a[i];
    vector<pl> mm(n+1);
    mm[n].fi = mm[n].se = a[n];
    for (ll i = n-1; i >= 0; i--) {
        mm[i].fi = (mm[i+1].fi+1)/2 + a[i];
        mm[i].se = mm[i+1].se + a[i];
    }
    ll ans = 1 + a[n], par = 1;
    for (ll i = 1; i < n; i++) {
        ll x = min(par*2, mm[i].se);
        ans += x;
        par = x-a[i];
    }
    if (mm[0].fi <= 1 && mm[0].se >= 1) std::cout << ans << "\n";
    else std::cout << -1 << "\n";
}


Measured memory_bytes: 5572
sx, sy , tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
ans = "U" * y + "R" * x + "D" * y + "L" * x
ans += "L" + "U" * (y + 1) + "R" * (x + 1) + "D"
ans += "R" + "D" * (y + 1) + "L" * (x + 1) + "U"
print(ans)

Measured memory_bytes: 3060