akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T>
inline bool dpmin(T& a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool dpmax(T& a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}

void solve(long long N, string S) {
    int ans = 0;
    for (int i = 0; i < N; i++) {
        set<char> X, Y;
        for (int x = 0; x < i; x++) {
            X.insert(S[x]);
        }
        for (int y = i; y < N; y++) {
            Y.insert(S[y]);
        }

        // set and operation
        set<char> XY;
        set_intersection(X.begin(), X.end(), Y.begin(), Y.end(), inserter(XY, XY.end()));

        dpmax(ans, (int)XY.size());
    }

    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use
// the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    cin >> N;
    string S;
    cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int n;
  cin>>n;
  int f=0;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    if(a[i]%2==0)
    {
     if(a[i]%3==0 || a[i]%5==0)
     {
       f=1; 
     }
      else
      {
       f=-1; 
       break;
      }
    }
  }
  if(f==0 || f==1)
    cout<<"APPROVED"<<endl;
  else
    cout<<"DENIED"<<endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef complex<double> point;

double cross(point p1,point p2)
{
	return imag(conj(p1)*p2);
}

int main()
{
	vector<point> p;
	for(double x,y;scanf("%lf,%lf",&x,&y)==2;)
		p.push_back(point(x,y));
	
	double res=0;
	repi(i,2,p.size())
		res+=cross(p[i-1]-p[0],p[i]-p[0]);
	printf("%f\n",abs(res/2));
	
	return 0;
}

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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int k;
    cin >> k;
    string s;
    cin >> s;

    if(s.size() <= k){
        cout << s << endl;
    }
    else{
        for(int i=0; i<k; i++){
            cout << s[i];
        }
        cout << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define watch(x) cerr << (#x) << " is " << (x) << " ";

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	string s; cin >> s;
	int n = s.size();
	if (s[n - 1] == '1'){
		cout << "-1" << endl;
		return 0;
	}
	if (s[0] == '0' or s[n - 2] == '0'){
		cout << -1 << endl;
		return 0;
	}
	for (int i = 0; i <= n / 2 - 1; i++){
		if (s[i] != s[n-2-i]){
			cout << -1 << endl;
			return 0;
		}
	}
	vector<int> ones;
	vector<pair<int, int>> edges;
	
	for (int i = 0; i < n; i++){
		if (s[i] == '1'){
			ones.push_back(i + 1);
		}
	}
	int current_vertex = 1;
	for (int i = 0; i < ones.size(); i++){
		edges.push_back(make_pair(current_vertex, current_vertex + 1));
		current_vertex++;
	}
	current_vertex++;
	
	for (int i = 2; i <= ones.size(); i++){
		int number_to_attach = ones[i - 1] - ones[i - 2] - 1;
		for (int j = 0; j < number_to_attach; j++){
			edges.push_back(make_pair(i, current_vertex));
			current_vertex++;
		}
	}
	
	for (auto edge : edges){
		cout << edge.first << ' ' << edge.second << '\n';
	}
	return 0;
}

Measured memory_bytes: 2756
#include <stdio.h>
#include <algorithm>
int main()
{
	int n, k,s=0;
	int ar[55] = { 0 };
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++)
		scanf("%d", &ar[i]);
	std::sort(ar, ar + n);
	for (int i = 0; i < k; i++)
		s += ar[n-i-1];
	printf("%d\n", s);
}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							 \
			cout.tie(0);
#define PI 3.141592654
#define all(v) v.begin(), v.end()
using namespace std;

using ll = long long;
const int MOD = 1e9 + 7;
const ll INF = 1e18 + 9;

ll powmod(ll base, ll exp, const ll MOD) { ll ans = 1; while (exp) { if (exp & 1)	ans = (ans * base) % MOD; base = (base * base) % MOD; exp >>= 1; } return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
void add(ll& x, ll v) { x = (x + v) % MOD; if (x < 0) x += MOD; }
//ll f[500005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }

void test_case() {

}

const int mxN = 1e5 + 1;


int main() {
	fastio;
	ll n;
	cin >> n;
	string ans;


	while (n > 0) {
		int d = n % 26;
		ans += d == 0 ? 'z' : char('a' + d - 1);
		n -= d == 0 ? 26 : d;
		n /= 26;
	}

	reverse(all(ans));
	cout << ans;

	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int k, a, b;
    cin >> k >> a >> b;
    for(int i = a; i <= b; ++i) {
        if(i % k == 0) {
            cout << "OK" << endl;
            return 0;

        }
    }
    cout << "NG" << endl;
    return 0;
}



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

const ll INF = 1LL<<60;

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<vector<ll>> dp(n+5, vector<ll>(n+5,-INF));
  rep(i,n+5) dp[i][i] = 0;
  for (int w = 1; w <= n; ++w) { //区間幅
    for (int l = 0; l <= n-w; ++l) {
      int r = l + w;
      if (w == 1) dp[l][r] = a[l];
      else {
        //a[l]を取る場合
        if (a[l+1] < a[r-1]) dp[l][r] = max((a[l]) - dp[l+1][r], dp[l][r]);
        else dp[l][r] = max((a[l]) - dp[l+1][r], dp[l][r]);
        //a[r-1]を取る場合
        if (a[l] > a[r-2]) dp[l][r] = max((a[r-1]) - dp[l][r-1], dp[l][r]);
        else dp[l][r] = max((a[r-1]) - dp[l][r-1], dp[l][r]);
      }
    }
  }
  cout << dp[0][n] << endl;
  return 0;
}

Measured memory_bytes: 70912
ch = input()
area_idx = []
area = []
for i, c in enumerate(ch):
    if c == '\\':
        area_idx.append(i)
    elif c == '/' and area_idx:
        j = area_idx.pop() 
        v = i-j
        while area and j < area[-1][0]:
            v += area.pop()[1]
        area.append((j, v))
n = len(area)
a = [v[1] for v in area]
print(sum(a))
print(n, *a)


Measured memory_bytes: 6508
#include<bits/stdc++.h>
using namespace std;
int main()
{
  double a,b,x;

  cin>>a>>b>>x;
  if ( (x/(a*a)) >= b/2 ) {
    printf("%.16lf\n", atan2(b-(x/(a*a)), a/2) * 180 / acos(-1));
  }
  else {
    printf("%.16lf\n", atan2(b, x*2/(a*b)) * 180 / acos(-1));
  }
  return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<pair<int64_t, int>> R(0);
	vector<int64_t> L(0), length(0);
	for (int i = 0; i < N; i++)
	{
		int64_t r, l;
		cin >> l >> r;
		L.push_back(l);
		R.push_back(pair<int64_t, int>(r, i));
		length.push_back(r - l + 1);
	}
	sort(length.begin(), length.end());
	sort(R.begin(), R.end());

	//ilu[n]はR[n]までを一方に入れたときのありうるLの一番大きい(範囲が狭くなる)値
	vector<int64_t> ilu(N);
	int64_t M = L[0];
	ilu[0] = L[R[0].second];
	for (int i = 1; i < N; i++)
	{
		M = min(M, L[i]);
		ilu[i] = max(ilu[i - 1], L[R[i].second]);
	}
	//iln[n]はR[n]までを一方に入れたときの残りのLの一番大きい(範囲が狭くなる)値
	vector<int64_t> iln(N - 2);
	if (N >= 3)
		iln[N - 3] = L[R[N - 1].second];
	for (int i = N - 4; i >= 0; i--)
	{
		iln[i] = max(iln[i + 1], L[R[i + 2].second]);
	}
	//vector<int64_t> fun(N);
	int64_t fun = 0;
	for (int i = 0; i < N - 1; i++)
	{
		int64_t f;

		if (i == N - 2)
		{
			f = max(R[0].first - ilu[i] + 1, (int64_t)0) + R[i + 1].first - L[R[i + 1].second] + 1;
		}
		else {
			long damage = max(R[0].first - iln[i], (int64_t)0) - max(R[0].first - ilu[i], (int64_t)0);
			long damage2 = max(R[i + 1].first - iln[i], (int64_t)0) - max(R[i + 1].first - L[R[i + 1].second], (int64_t)0);
			if (damage > damage2)
			{
				f = max(R[0].first - max(iln[i], ilu[i]) + 1, (int64_t)0) + (R[i + 1].first - L[R[i + 1].second] + 1);
			}
			else {
				f = max(R[0].first - ilu[i] + 1, (int64_t)0) + max(R[i + 1].first - max(iln[i], L[R[i + 1].second]) + 1, (int64_t)0);
			}
		}
		fun = max(fun, f);
	}
	cout << fun << endl;
	//cout << length[N-1] << " " << M << " " << R[N - 1].first - M;
	return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const ll mod = 1e9 + 7;


int main(){

  ll n;cin>>n;
  ll ans=1;
  rep(i,1,n+1){
    ans*=i;
    ans%=mod;
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	a, b := r.nextInt(), r.nextInt()

	fmt.Fprintln(stdout, a*b)
}


Measured memory_bytes: 1728
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=300100,P=1e9+7;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
char s[N];
int p[N],f[N][3][3];
inline void rw(int&a,int b){(a+=b)%=P;}
int main(){
 	int n,i,j,k,ans=0;
   	scanf("%s",s+1);
	n=strlen(s+1);
   	for(p[n+1]=1,i=n;i;--i)
		p[i]=(p[i+1]<<(s[i]=='?'))%P;
	f[0][0][0]=1;
   	for(i=1;i<=n;++i)
	for(j=0;j<3;++j)
	for(k=0;k<3;++k){
   		if(s[i]!='0'){
   			if(k)rw(f[i][j][k-1],f[i-1][j][k]);
   			else if(j<2)rw(f[i][j+1][k],f[i-1][j][k]);
   			else rw(ans,1LL*f[i-1][j][k]*p[i+1]%P);
		}
   		if(s[i]!='1')rw(f[i][j][k<2?k+1:1],f[i-1][j][k]);
   	}
   	rw(ans,f[n][1][0]);
   	rw(ans,f[n][2][1]);
   	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define N 1000500
using namespace std;
inline int rd() {
	int x=0,f=1;char ch=getchar();
	while (ch>'9'||ch<'0') {if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
long long a[N],b[N],n,x,y;
int main() {
	x = rd(), y = rd();
	long long ans = x * y - x;
	if (ans % y == 0)
		puts("-1");
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = inp()
f = [inpl() for _ in range(n)]
p = [inpl() for _ in range(n)]
ans = -10**9

for flag in itertools.product([0,1], repeat=10):
    tmp = 0
    if not any(flag):
        continue
    for _ in range(n):
        cnt = 0
        for i,j in enumerate(flag):
            if j and f[_][i]:
                cnt += 1
        tmp += p[_][cnt]
    ans = max(ans, tmp)
print(ans)



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

#define STRING(str) #str

template <typename T >
void print_vec_1d(vector<T> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << x[i];
		if (i != x.size()-1) cout << ", ";
		else cout << " ]" << endl;
	}
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<long long> a(N), b(M);
	for (int i=0;i<N;i++) {
		cin >> a[i];
	}
	for (int i=0;i<M;i++) {
		cin >> b[i];
	}
	vector<long long> ans = convolution<998244353>(a, b);
	for (int i=0;i<N+M-1;i++) {
		cout << ans[i];
		if (i != N+M-2) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
}

Measured memory_bytes: 27248
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N,T;
    cin >> N >> T;
    ll A[N];
    cin >> A[0];
    ll minv = A[0];
    ll maxv = -1;
    REPP(i,1,N){
        cin >> A[i];
        maxv = max(maxv,A[i]-minv);
        minv = min(minv,A[i]);
    }

    ll minv1 = A[0];
    ll maxv1 = -1;
    ll cnt = 0;
    REPP(i,1,N){
        maxv1 = max(maxv1,A[i]-minv1);
        if(maxv == maxv1 && maxv1 == A[i]-minv1) cnt++;
        minv1 = min(minv1,A[i]);
      //cout << A[i] << ' ' << minv1 << endl;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        for(int i=1; i*(i+1)/2 <= n; i++) {
            if( i*(i+1)/2 == n) {
                System.out.println("Yes");
                System.out.println(i+1);
                sub(i);
                return;
            }
        }
        System.out.println("No");
    }

    private static void sub(int m) {
        int[][] a = new int[m][];
        a[0] = new int[m];
        System.out.print(m);
        for(int i =0; i<m ;i++) {
            a[0][i] = i;
            System.out.print(" ");
            System.out.print(i + 1);
        }
        System.out.println();
        int next = m;
        int ai = 1;
        for(int i=0; i<m; i++) {
            System.out.print(m);
            int rem = m - ai;
            for(int j=0; j<ai; j++) {
                System.out.print(" ");
                System.out.print(a[j][ai-j-1] + 1);
            }
            if(rem > 0) {
                a[ai] = new int[rem];
                for (int j = 0; j < rem; j++) {
                    a[ai][j] = next++;
                    System.out.print(" ");
                    System.out.print(a[ai][j] + 1);
                }
                ai++;
            }
            System.out.println();
        }


    }
}


Measured memory_bytes: 47524
from collections import deque

v,e = map(int,input().split())
L = []
ins = [0]*v
DAG = [[] for i in range(v)]
ans = []
for i in range(e):
    a,b = map(int,input().split())
    DAG[a].append(b)
    ins[b] += 1
start = 0
S = deque([])
for i in range(v):
    if ins[i] == 0:
        S.append(i)
while len(S) > 0:
    cur = S.popleft()
    ans.append(cur)
    for e in DAG[cur]:
        ins[e] -= 1
        if ins[e] == 0:
            S.append(e)
for i in range(v):
  print(ans[i])


Measured memory_bytes: 9184
#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define ALL(c) (c).begin(), (c).end()
#define dump(a) cerr << #a << "=" << (a) << endl

using namespace std;

int cards[52];

int main() {
	int N,R; 
	int P,C;

	while(cin >> N >> R) {
		if (N == 0 && R == 0) break;
		//初期化
		rep(i,52) {
			cards[i] = 0;			
		}
		rep(i,N) {
			cards[i] = i+1;
		}


		//シャッフル
		vector<int> cards_p,cards_c;
		int center=0;
		rep(r,R) {
			cin >> P >> C;

			//コピー
			center = N-(P-1);
			REP(c,center-C,center) {
				cards_c.push_back(cards[c]);
			}
			REP(p,center,N) {
				cards_p.push_back(cards[p]);
			}
			
			//ペースト
			center = N-C;
			REP(p,center-(P-1),center) {
				cards[p] = cards_p.front();
				cards_p.erase(cards_p.begin());
			}
			REP(c,center,N) {
				cards[c] = cards_c.front();
				cards_c.erase(cards_c.begin());
			}
		}

		cout << cards[N-1] << endl;			
		
	}

	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
int main(void){
    char w[6];
    scanf("%s",w);
    if (strcmp(w,"Sunny")==0){
        printf("Cloudy");
    }
    else if (strcmp(w,"Cloudy")==0){
        printf("Rainy");
    }
    else if (strcmp(w,"Rainy")==0){
        printf("Sunny");
    }
}

Measured memory_bytes: 128
rooms = [[[0]*10 for _ in range(3)] for _ in range(4)]

N = int(input())
for n in range(N):
    b, f, r, v = map(int, input().split())
    rooms[b-1][f-1][r-1] += v

for building in range(len(rooms)):
    for floor in rooms[building]:
        str_f = map(lambda s: str(s), floor)
        str_f = " ".join(str_f)
        print("", end = " ")
        print(str_f)
    if building != 3:
        print("####################")



Measured memory_bytes: 5600
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

class FC{
   public:
      int p[31];
      int n;
   bool is_over(){
      return p[1]==p[2]&&p[2]==p[3]&&p[3]==p[4]&&p[4]==p[5]&&p[5]==p[6]&&p[6]==p[7]&&p[7]==p[8]&&p[8]==p[9]
&&p[10]==p[11]&&p[11]==p[12]
&&p[13]==p[14]&&p[14]==p[15]
&&p[16]==p[17]&&p[17]==p[18]
&&p[19]==p[20]&&p[20]==p[21]
&&p[22]==p[23]&&p[23]==p[24]&&p[24]==p[25]&&p[25]==p[26]&&p[26]==p[27]&&p[27]==p[28]&&p[28]==p[29]&&p[29]==p[30];
   }
   void rot1(){
      swap(p[7],p[22]);
      swap(p[8],p[23]);
      swap(p[9],p[24]);
      swap(p[13],p[18]);
      swap(p[10],p[12]);
   }
   void rot2(){
      swap(p[1],p[28]);
      swap(p[2],p[29]);
      swap(p[3],p[30]);
      swap(p[15],p[16]);
      swap(p[21],p[19]);
   }
   void rot3(){
      swap(p[1],p[24]);
      swap(p[4],p[27]);
      swap(p[7],p[30]);
      swap(p[21],p[10]);
      swap(p[16],p[18]);
   }
   void rot4(){
      swap(p[3],p[22]);
      swap(p[6],p[25]);
      swap(p[9],p[28]);
      swap(p[13],p[15]);
      swap(p[19],p[12]);
   }
};

int main(){
   int N;
   cin >> N;
   for(int i=0;i<N;i++){
      FC now;
      for(int j=1;j<=30;j++)
         cin >> now.p[j];
      now.n=0;
      queue<FC> que;
      que.push(now);
      while(!que.empty()){
         now=que.front();
         que.pop();
         if(now.is_over()){
            cout << now.n << endl;
            break;
         }
         FC nex1=now;
         nex1.rot1();
         nex1.n++;
         que.push(nex1);
         FC nex2=now;
         nex2.rot2();
         nex2.n++;
         que.push(nex2);
         FC nex3=now;
         nex3.rot3();
         nex3.n++;
         que.push(nex3);
         FC nex4=now;
         nex4.rot4();
         nex4.n++;
         que.push(nex4);
      }
   }
   return 0;
}       

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

using namespace std;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1,i,j;
    //cin>>t;
    while(t--)
    {
        long long int n,k,count=0,sum=0,flag=0,maxi=0,mod=1e9+7;
        cin>>n>>k;
        long long a[n+1]={0};
        for(i=1;i<=n;i++) 
        {
            a[i]=i;
            a[i]+=a[i-1];
           // cout<<a[i]<<" ";
        }
        if(k==n+1)
        {
            cout<<"1";
            continue;
        }
        
        for(i=k-1;i<=n;i++)
        {
            if(i==n)
            {
                sum=(sum+1)%mod;
            }
            else
            {
                long long c=a[i];
                long long d=a[n]-a[n-i-1];
                
                sum+=(d-c+1)%mod;
            }
        }
        
       cout<<sum%mod;
            
        
    }
}

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

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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky....."<<endl;
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(8);
#define sp cout << " "
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';              


typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vpii;
typedef vector<pll > vpll;
long long MOD = (long long) 1e9 + 7LL;

int main()
{
	int i,j,n,m,k,s=0;
	cin>>n>>m;
	j=1000;
	for(i=m;i<n+m;i++)
	{
		if(abs(i)<j)
		{
			j=abs(i);
			k=i;
		}
		s=s+i;
	}
	cout<<s-k<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll f(vector<pair<int,int> >a){
    ll ans=0;
    sort(a.begin(),a.end());
    priority_queue<int,vector<int>,greater<> >q;
    for(auto i:a){
        q.emplace(i.second);
        ans+=i.second;
        while(q.size()>i.first) ans-=q.top(),q.pop();
    }
    return ans;
}

int main(){
    int t,n,k,l,r;
    cin>>t;
    while(t--){
        cin>>n;
        ll sum=0;
        vector<pair<int,int> >L,R;
        for(int i=0;i<n;i++){
            cin>>k>>l>>r;
            if(l>r) L.emplace_back(k,l-r),sum+=r;
            else if(r>l) R.emplace_back(n-k,r-l),sum+=l;
            else sum+=l;
        }
        cout<<sum+f(L)+f(R)<<endl;
    }
	return 0;
}

Measured memory_bytes: 7152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main() {
    int a,b;
    cin>>a>>b;
    if(a==b)
        cout<<"Draw"<<endl;
    else if(a==1)
        cout<<"Alice"<<endl;
    else if(b==1)
        cout<<"Bob"<<endl;
    else if(a>b)
        cout<<"Alice"<<endl;
    else
        cout<<"Bob"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;


int main() {
    int n; cin >> n;
    ll ans = 0;
    vector<int> fs(n+1, 1);
    for (int k=2; k <= n; ++k) {
        for(int j = k; j <= n; j+=k) fs[j]++;
    }
    for (ll k=1; k <= n; ++k) {
        //cout << k << "," << fs[k]  << endl;
        ans += k*fs[k];
    } 
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int a[22], c[1 << 21], d[1 << 21] = { 1 };
int main() {
	int n, p = 1e9 + 7;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t;
		for (int j = 0; j < n; j++)
			cin >> t, a[i] |= t << j;
	}
	for (int i = 1; i < 1 << n; i++) {
		c[i] = c[i&i - 1] + 1;
		int k = i & a[c[i] - 1];
		for (int j = k; j; j &= j - 1)
			(d[i] += d[i^~j + 1 & k]) %= p;
	}
	cout << d[(1 << n) - 1] << endl;
	return 0;
}


Measured memory_bytes: 16640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<pair<string,int> > v;
    for(int i = 0;i < n;i++)
    {
        string s;
        int t;
        cin >> s >> t;
        v.push_back(make_pair(s,t));
    }
    string x;
    cin >> x;
    int ans = 0;
    bool flag = false;
    for(int i = 0;i < v.size();i++)
    {
        if(flag)
        {
            ans += v[i].second;
        }
        if(v[i].first == x)
        {
            flag = true;
        }
    }
    cout << ans << "\n";
    
    return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> p(n), q(n);
    rep(i, n) cin >> p.at(i);
    rep(i, n) cin >> q.at(i);

    vector<int> v;
    rep(i, n){
        v.push_back(i+1);
    }

    int cntp = 0;
    bool ok = false;
    do{
        cntp++;
        for(int i=0; i<n; i++){
            if(p.at(i)!=v.at(i)) break;
            if(i==n-1) ok = true;
        }
        if(ok) break;
    }while(next_permutation(v.begin(),v.end())); 

    sort(v.begin(), v.end());
    int cntq = 0;
    ok = false;
    do{
        cntq++;
        for(int i=0; i<n; i++){
            if(q.at(i)!=v.at(i)) break;
            if(i==n-1) ok = true;
        }
        if(ok) break;
    }while(next_permutation(v.begin(),v.end())); 

    cout << abs(cntp-cntq) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long dp[100010][4];
int main()
{
    string s,a="ABC";
    while(cin>>s)
    {
        memset(dp,0,sizeof(dp));
        dp[s.size()][3]=1;
        for(int i=s.size()-1;i>=0;i--)
           for(int j=3;j>=0;j--)
           {
               dp[i][j]=dp[i+1][j]*(s[i]=='?'?3:1);
               if(j<3&&(s[i]=='?'||s[i]==a[j]))
               dp[i][j]+=dp[i+1][j+1];
               dp[i][j]=dp[i][j]%mod;
           }
        cout<<dp[0][0]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3584
s = int(input())

appear = {s:0,}
i = 0
while True:
    i += 1
    if s%2 == 0:
        s //= 2
    else:
        s = 3*s + 1
    if s in appear:
        break
    else:
        appear[s] = i

print(i+1)

Measured memory_bytes: 3060
def solve():
    N, Ma, Mb = map(int, input().split())
    a = [0]*N
    b = [0]*N
    c = [0]*N
    for i in range(N):
        a[i], b[i], c[i] = map(int, input().split())

    INF = sum(c)
    dp = [[[INF]*(10*N+1) for _ in range(10*N+1)] for _ in range(N+1)]
    
    dp[0][0][0] = 0
    for i in range(N):
        for j in range(10*N+1-a[i]):
            for k in range(10*N+1-b[i]):
                if dp[i][j][k]==INF:
                    continue
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])
                dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i])

    ans = INF
    for i in range(1, 10*N+1):
        if i*Ma>10*N or i*Mb>10*N:
            break
        ans = min(ans, dp[N][i*Ma][i*Mb])
    if ans==INF:
        ans = -1

    print(ans)


solve()

Measured memory_bytes: 60112
program main
	implicit none
	integer :: N, K, counter, i, m, N_const
	real(8) :: Right, Left, ans
	read(*, *) N, K
	ans = 0.0d0
	counter = 0
	N_const = N
	if(N >= K) then
		ans = ans + dble(N-K+1)  / dble(N_const)
		N   = K
	end if
	do m = 1, 20
		Right = dble(K)*(0.50d0)**(m-1)
		Left  = dble(K)*(0.50d0)**m
		counter = 0
		do i = N, 1, -1
			if(Left <= i .AND. i < Right)then
				counter = counter + 1
			end if
		end do
		ans = ans + (dble(counter)/dble(N_const))*(0.50d0)**m
		N = N - counter
!		write(*, *) Left, Right, ans, N
		if(Left <= 1) then
			exit
		end if
	end do
	write(*, *) ans
end program main

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

int S(int n)
{
  int ret = 0;
  while (0 < n)
  {
    ret += n % 10;
    n /= 10;
  }
  return ret;
}

int main()
{
  int N;
  cin >> N;
  string ans = "No";
  if (N % S(N) == 0)
    ans = "Yes";
  cout << ans << endl;
  return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換

int main() {
vv(int) G(51);
int n,m;
cin>>n>>m;
rep(i,m){
    int a,b;
    cin>>a>>b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
}

rep(i,n){
    cout<<G[i].size()<<endl;

}


   return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define OKawaiiKoto ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    OKawaiiKoto
    string s,t;
    ll ans=0;
    cin>>s>>t;
    rep(i,s.size()) if(s[i]!=t[i]) ans++;
    cout<<ans;
}


Measured memory_bytes: 3720
#include <stack>
#include <queue>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <tuple>
#include <cmath>
#include <random>
#include <algorithm>
#include <vector>
#include <iostream>
#include <fstream>
#include <chrono>
#include <numeric>

#define fio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define rng mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count())

#define ri(...) i64 __VA_ARGS__; rx(__VA_ARGS__)
#define rc(...) char __VA_ARGS__; rx(__VA_ARGS__)
#define rs(...) string __VA_ARGS__; rx(__VA_ARGS__)
#define rvi(x, n) vi x(n); cin >> x
#define rvvi(x, n, m) vvi x(n, vi(m)); cin >> x

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << '[' << #__VA_ARGS__ << "]: "; dbg_log(__VA_ARGS__)
#else
#define dbg(...) ;;
#endif

#define fa(i, v) for (auto &i : v)
#define fi(i, n) for (i32 i = 0; i < n; i++)
#define fp(i, n) for (i32 i = 1; i < n; i++)
#define fr(i, n) for (i32 i = n - 1; i >= 0; i--)
#define fu(i) ri(_i); fi(i, _i)

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

typedef uint32_t u32;
typedef int32_t i32;
typedef uint64_t u64;
typedef int64_t i64;
#ifdef __SIZEOF_INT128__
typedef __uint128_t u128;
typedef __int128_t i128;
#endif
typedef vector<i64> vi;
typedef vector<vi> vvi;

template<typename T>
inline istream &operator>>(istream &in, vector<T> &v) {
    fa(x, v) in >> x;
    return in;
}

template<typename T>
inline ostream &operator<<(ostream &out, const vector<T> &v) {
    fa(x, v) out << x << ' ';
    return out;
}

template<typename T>
inline void rx(T &x) {
    cin >> x;
}

template<typename T, typename... R>
inline void rx(T &x, R &... l) {
    cin >> x;
    rx(l...);
}

template<typename T>
inline void dbg_log(const T &x) {
    cerr << x << '\n';
}

template<typename T, typename... R>
inline void dbg_log(const T &x, const R &... l) {
    cerr << x << ", ";
    dbg_log(l...);
}

template<typename T>
inline void wl(const T &x) {
    cout << x << '\n';
}

template<typename T, typename... R>
inline void wl(const T &x, const R &... l) {
    cout << x << ' ';
    wl<R...>(l...);
}

int main() {
    fio;

    ri(n);
    rvi(a, n);
    u32 ttl = 0;
    fa(x, a) ttl ^= (u32) x;
    vi b(n);
    fi(i, n) b[i] = ttl ^ (u32) a[i];
    wl(b);

    return 0;
}


Measured memory_bytes: 6344
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>

using namespace std;

int main() {
  long N, K;
  cin >> N >> K;
  if (K == 0) {
    cout << N*N << endl;
    return 0;
  }
  long ans = 0;
  for (long b=1; b<=N; b++) {
    long bk = max(0L, b-K);
    ans += bk*(N/b);
    if (N%b > 0) {
      ans += max(0L, N%b-K+1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  if(N==1){
    cout <<"Hello World"<<endl;
  }
  else{
    int a,b;
    cin>>a>>b;
    cout <<a+b<< endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
#define INF 1000000000
int n,m;
int c[2000],d[2000];
int dp[2000][2000];
void solve(){
    cin >> n >> m;
    FOR(i,1,n + 1)
        cin >> d[i];
    FOR(i,1,m + 1)
        cin >> c[i];

    REP(i,n + 1)
        dp[0][i] = INF ;
    REP(i,m + 1)
        dp[i][0] = 0;

    FOR(i,1,m + 1){
        FOR(j,1,n + 1){
            dp[i][j] = min(dp[i - 1][j],dp[i - 1][j - 1] + c[i] * d[j]);
        }
    }
    printf("%d\n", dp[m][n]);
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 10248
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

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

#define endl '\n'
#define int long long

const int inf = 1e18 + 5;
const int MOD = 1e9 + 7;

const int N = 2e5 + 5;
vector<int> adj[N];
bool vis[N];
int cnt;

void dfs(int node)
{
    vis[node] = 1;
    cnt++;
    for(auto x : adj[node])
    {
        if(!vis[x])
            dfs(x);
    }
}

void solve()
{
    int n, m;
    cin >> n >> m;
    set<int> st;
    for(int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        st.insert(a); 
        st.insert(b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    memset(vis, 0, sizeof(vis));
    int ans = 1;
    for(auto x : st)
    {
        cnt = 0;
        if(!vis[x])
        {
            dfs(x);
            ans = max(ans, cnt);
        }
        // ans = max(ans, cnt);
    }   
    cout << ans << endl;
}

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

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


Measured memory_bytes: 30320
import java.util.Scanner;

// m_solutions2020_a
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();

		int rating = 0;
		if (400 <= X && X <= 599) {
			rating = 8;
		} else if (600 <= X && X <= 799) {
			rating = 7;
		} else if (800 <= X && X <= 999) {
			rating = 6;
		} else if (1000 <= X && X <= 1199) {
			rating = 5;
		} else if (1200 <= X && X <= 1399) {
			rating = 4;
		} else if (1400 <= X && X <= 1599) {
			rating = 3;
		} else if (1600 <= X && X <= 1799) {
			rating = 2;
		} else if (1800 <= X && X <= 1999) {
			rating = 1;
		}

		System.out.println(rating);
		sc.close();
	}
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int h, w;
    cin >> h >> w;
    int a[600][600];
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> a[i][j];
        }
    }
    vector<int> ans;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if((i == h) && (j == w)){
                break;
            }
            if((a[i][j] % 2) == 0){
                continue;
            }
            if(j < w){
                a[i][j + 1]++;
                ans.push_back(i);
                ans.push_back(j);
                ans.push_back(i);
                ans.push_back(j + 1);
                continue;
            }
            a[i + 1][j]++;
            ans.push_back(i);
            ans.push_back(j);
            ans.push_back(i + 1);
            ans.push_back(j);
        }
    }
    cout << ans.size() / 4 << endl;
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i];
        if((i % 4) == 3){
            cout << endl;
        } else {
            cout << " ";
        }
    }
    return 0;
}

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

using namespace std;

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

	int char_num[26] = { 0 };
	for (int i = 0; i < S.length(); i++){
		char_num[S[i] - 'a'] += 1;
	}

	for (int i = 0; i < 26; i++){
		if (char_num[i] % 2 != 0){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll N;
    cin >> N;
    cout << N * N * N;

    return 0;
}

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


int main() {
	int n;
	cin >> n;
	vector<vector<int>> C(9, vector<int>(9, 0));
	
	string tmp;
	for (int i = 1; i <= n; i++)
	{
		tmp = to_string(i);
		if (i % 10 != 0)  C[int(tmp[0]-'0')-1][i%10-1]++;
	}
	
	int ans = 0;
	
	for (int j = 0; j < 9; j++) 
	{
		for (int i = 0; i < 9; i++)
		{
			ans += C[i][j] * C[j][i];
		
		}
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
int main()
{
	int i,h,w;
	cin>>h>>w;
	string a[h];
	for(i=0;i<h;i++)
	{
		cin>>a[i];
		a[i]='#'+a[i]+'#';	
	}	
	
	for(i=0;i<w+2;i++)
	{
		cout<<'#';
	}
	cout<<endl;
	for(i=0;i<h;i++)
	{
		cout<<a[i]<<endl;
	}
	for(i=0;i<w+2;i++)
	{
		cout<<'#';
	}
	
	
}

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

int main(void){
    long long n, a, b;
    cin >> n >> a >> b;
    
    long long ans = 0;
    long long last = 0, now;
    long long i;
    for(i = 1; i <= n; i++){
        cin >> now;
        if(i != 1){
            if(a * (now - last) <= b){
                ans += a * (now - last);
            }else{
                ans += b;
            }
        }
        last = now;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  bool hitachi = true;
  for (int i=0; i<s.length(); i+=2) {
	if (!(s[i] == 'h' && s[i+1] == 'i')) hitachi = false;
  } if (hitachi) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
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;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long A, long long B, long long N){
  cout<<A*min(N,B-1)/B<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    solve(A, B, N);
    return 0;
}


Measured memory_bytes: 3764
# -*- coding: utf-8 -*-
#入力

N,K,Q=map(int,input().split())
a=[int(input()) for _ in range(Q)]
b=[0]*N
for i in a:
    b[i-1]+=1
for l in range(0,N,1):
    if(K+b[l]-Q>0):print("Yes")
    else:print("No")


Measured memory_bytes: 8672
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long k = scan.nextLong();
        int[] a = new int[n];
        int[] b = new int[n];
        int x = Math.abs(1-9);
        for(int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
            b[i] = scan.nextInt();
        }
        long[] buget = new long[114514];
        Arrays.fill(buget, 0);
        for(int i = 0; i < n; i++) {
            buget[a[i]] += b[i];
        }
        long num = 0;
        for(int i = 0; i < 114514; i++) {
            num += buget[i];
            if (num >= k) {
                System.out.println(i);
                return;
            }
        }
    }
}

Measured memory_bytes: 85792
#include<iostream>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define ll long long

int main()
{
	ll N, A, B;
	cin >> N >> A >> B;

	if (A > B) cout << 0 << endl;
	else if (N == 1 && A!=B) cout << 0 << endl;
	else if (N == 1) cout << 1 << endl;
	else {
		ll ans = (B - A)*(N - 2) + 1;
		cout << ans << endl;
		//ll min = A + B + (N - 2)*A, max = A + B + (N - 2)*B;
		//cout << max - min + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      int res = 700;
      for (char c: s.toCharArray()) {
      	if (c =='o') { res += 100; }
      }
      System.out.println(res);
    }
}

Measured memory_bytes: 21844