akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N; int lo = N+1;
    int ans = 0;
    F0R(i, N)  {
        int cur; cin >> cur;
        if (cur < lo) {
            ans++; lo = cur;
        }
    }
    cout << ans << endl;

	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
//https://atcoder.jp/contests/abc072/tasks/arc082_b
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N; cin>>N;
    vector<ll> pn(N+1);
    FOR(i,1,N+1){
        cin>>pn.at(i);
    }
    ll ans=0;
    FOR(i,1,N){
        if(pn.at(i) == i) {
            swap(pn.at(i),pn.at(i+1));
            ++ans;
        }
    }
    //last
    if (pn.at(N) == N) ++ans;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define lb long double
#define N 100010
#define eps 1e-11
#define INF 1e18
using namespace std;
struct Po{lb x,y;}x;
vector<Po> no;
int n;
Po operator -(Po x,Po y){return (Po){x.x-y.x,x.y-y.y};}
void get(Po &x){scanf("%Lf %Lf",&x.x,&x.y);}
bool c1(const Po &x,const Po &y){if (fabs(x.x-y.x)<eps)return x.y<y.y;return x.x<y.x;}
bool c2(const Po &x,const Po &y){return x.y<y.y;}
lb dis(Po x){return sqrtl(x.x*x.x+x.y*x.y);}
lb que(vector<Po> x){
	if (x.size()==1) return INF;
	if (x.size()==2) return dis(x[0]-x[1]);
	int mid=x.size()/2;
	vector<Po> s1,s2;
	s1.clear();s2.clear();
	for (int i=0;i<x.size();i++)if (i<mid) s1.push_back(x[i]);else s2.push_back(x[i]);
	lb an=min(que(s1),que(s2));
	reverse(s1.begin(),s1.end());
	while (s1.size()&&fabs(x[mid].x-s1[s1.size()-1].x)>an-eps)s1.pop_back();
	while (s2.size()&&fabs(s2[s2.size()-1].x-x[mid-1].x)>an-eps)s2.pop_back();
	sort(s1.begin(),s1.end(),c2);
	sort(s2.begin(),s2.end(),c2);
	int l=0,r=-1;
	for (int i=0;i<s1.size();i++){
		while (r+1<s2.size()&&s2[r+1].y-s1[i].y<an+eps) r++;
		while (l+1<=s2.size()&&s1[i].y-s2[l].y>an+eps)l++;
		for (int j=l;j<=r;j++) an=min(an,dis(s2[j]-s1[i]));
	}
	return an;
}
int main(){
	scanf("%d",&n);
	while(n--){get(x);no.push_back(x);}
	sort(no.begin(),no.end(),c1);
	printf("%.10Lf",que(no));
	lb ansn=INF;
	return 0;
}


Measured memory_bytes: 22252
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    vector<int> sum(100,0);
    int sumcount = 0;
    for (int i = 0; i < N; i++){
        int count = 0;
        int A = a[i];
        while(true){
            sum[count] = ((A % 2) + sum[count]) % 2;
            if((A /= 2) == 0){
                break;
            }
            count++;
        }
        sumcount = max(sumcount, count);
    }
    for (int i = 0; i < N; i++){
        int count = 0;
        int A = a[i];
        a[i] = 0;
        while (true)
        {
            a[i] += int(pow(2,count))*(((A % 2) + sum[count]) % 2);
            if (count >= sumcount)
            {
                break;
            }
            A /= 2;
            count++;
        }
    }
    for (int i = 0; i < N; i++){
        cout << a[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4036
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rrep(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef pair<int,int> P;
const int INF = 1000000000;

int main(){
	int n,q,a;
	char s[50],e[50];
	scanf("%d%d",&n,&q);
	strcpy(e,"kogakubu10gokan");
	rep(i,n){
		scanf("%d%s",&a,s);
		if(q>=a)strcpy(e,s);
	} 
	printf("%s\n",e);
	return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

string s = "";
int n,k;
int main() {
    cin >> n;
    cin >> s;
    cin >> k;

    REP(i,s.size())
    {
        if (s[i] != s[k-1])
            s[i] = '*';
    }
    
    cout << s << endl;
    return 0;
}

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

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> p){
    vector<long long> c(p.size());
    copy(p.begin(), p.end(), c.begin());
    sort(c.begin(), c.end());
    int count = 0;
    REP(i, N)
        if (p[i] != c[i]) count++;
    if (count == 2 || count == 0) cout << YES << '\n';
    else cout << NO << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, std::move(p));
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)

MOD = 10**9 + 7


def GCD(a, b):
    return a if b == 0 else GCD(b, a % b)


n, k = map(int, input().split())

d = {}


def func1(kk):
    # 1-kをn個並べる時、gcdが1となる通り数
    if kk == 1:
        return 1
    if kk in d:
        return d[kk]

    cnt = 0
    for x in range(2, kk + 1):
        y = kk // x
        cnt += func1(y)

    d[kk] = (MOD + pow(kk, n, MOD) - cnt) % MOD
    return d[kk]


ans2 = 0
cnt = 0
for x in range(2, k + 1):
    y = k // x
    if y > 1:
        cnt = func1(y)
        ans2 += cnt * x % MOD
        ans2 %= MOD
    else:
        ans2 += x
        ans2 %= MOD

ans1 = func1(k)
ans = ans1 + ans2
ans %= MOD
# print(ans1, ans2)
print(ans)


Measured memory_bytes: 68576
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <queue>
#include <string>
#include <map>
#include <vector>

using namespace std;

int p[10][10];

void drop(int x, int y) {
  if (0 <= x && x < 10 && 0 <= y && y < 10)
    p[x][y]++;
}

int main() {
  int x, y, s;
  while (scanf("%d,%d,%d", &x, &y, &s) == 3)
    switch (s) {
    case 3:
      drop(x-2, y);
      drop(x+2, y);
      drop(x, y-2);
      drop(x, y+2);
    case 2:
      drop(x-1, y-1);
      drop(x-1, y+1);
      drop(x+1, y-1);
      drop(x+1, y+1);
    case 1:
      drop(x-1, y);
      drop(x+1, y);
      drop(x, y);
      drop(x, y-1);
      drop(x, y+1);
      break;
    default:
      break;
    }
  int c = 0, d = 0;
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++) {
      if (!p[i][j]) c++;
      d = max(d, p[i][j]);
    }
  printf("%d\n%d\n", c, d);
  return 0;
}

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

long long a,b,c,d;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>b>>c>>d;
	cout<<max(max(a*c,a*d),max(b*c,b*d))<<endl;
}


Measured memory_bytes: 3556
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
typedef long long LL;
using namespace std;

char u;
void scan(int &x){
	int f=1;
    while(u = getchar(), u < '0' || u > '9'){if(u=='-') f=-1;};
    x = u-'0';
    while(u = getchar(), u >= '0' && u <= '9') x = x * 10 + u -'0';
    x*=f;
}

int main(){
	string s;
	cin >>s;
	string sev="SUN";
	string one="MON"; 
	string tow="TUE";
	string tre="WED";
	string four="THU";
	string five="FRI"; 
	string six="SAT";
	if(s==sev) { printf("7\n");return 0;}
	if(s==one) { printf("6\n");return 0;}
	if(s==tow) { printf("5\n");return 0;}
	if(s==tre) { printf("4\n");return 0;}
	if(s==four) { printf("3\n");return 0;}
	if(s==five) { printf("2\n");return 0;}
	if(s==six) { printf("1\n");return 0;}
	return 0;
}


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

int main() {
	unsigned long long n,syou;
	int mod;
	char c;
	string ans;
	cin >> n;
	while(n!=0){
		n=n-1;
		syou=n/26;
		mod=n%26;
		c='a'+mod;
		ans=c+ans;
		n=syou;
	}
	cout << ans <<endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#define MAX 10000

void setDepth(int,int);
int setHeight(int);
void print(int);
int getSibling(int);

typedef struct node{int parent,left,right;}Node;

Node T[MAX];
int n,D[MAX],H[MAX];

int main(){
  int v,l,r,root=0,i;
  scanf("%d",&n);

  for(i=0;i<n;i++) T[i].parent=-1;

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l!=-1) T[l].parent=v;
    if(r!=-1) T[r].parent=v;
  }

  for(i=0;i<n;i++){
    if(T[i].parent==-1) root=i;
  }

  setDepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++){
    print(i);
  }

  return 0;
}

void setDepth(int u,int d){
  if(u==-1) return;
  D[u]=d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].left!=-1) h1=setHeight(T[u].left)+1;
  if(T[u].right!=-1) h2=setHeight(T[u].right)+1;
  if(h1>h2) return H[u]=h1;
  else return H[u]=h2;
}

void print(int u){
  int deg;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  deg=0;
  if(T[u].left!=-1) deg++;
  if(T[u].right!=-1) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent==-1){
    printf("root\n");
  }
  else if(T[u].left==-1 && T[u].right==-1){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}

int getSibling(int u){
  if(T[u].parent==-1)return -1;
  if(T[T[u].parent].left !=u && T[T[u].parent].left!=-1){
    return T[T[u].parent].left;
  }
  if(T[T[u].parent].right!=u && T[T[u].parent].right!=-1){
    return T[T[u].parent].right;
  }
  return -1;
}

Measured memory_bytes: 624
n = int(input())
s = [input() for i in range(n)]


sharp_cnt = 0
for i in range(n):
    sharp_cnt += s[i].count("#")
if sharp_cnt == 0:
    print(-1)
    exit()

ans = n
for j in range(n):
    tate_all_sharp = all([s[i][j] == "#" for i in range(n)])
    if tate_all_sharp:
        ans -= 1

# 横一列#をつくる
need_cnt = n
for j in range(n):
    tate_any_sharp = any([s[i][j] == "#" for i in range(n)])
    if not tate_any_sharp:
        continue
    tmp = 0
    for i in range(n):
        if s[j][i] == ".":
            tmp += 1
    need_cnt = min(tmp, need_cnt)
    
for i in range(n):
    tmp = 0
    for j in range(n):
        if s[i][j] == ".":
            tmp += 1
    need_cnt = min(tmp + 1, need_cnt)

ans += need_cnt
print(ans)

Measured memory_bytes: 74404
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int>>
#define fin(ar,k,n) for(int i=k;i<n;i++) cin>>ar[i]
#define fout(ar,k,n) for(int i=k;i<n;i++) cout<<ar[i]<<' '
#define all(z) z.begin(),z.end()
#define mcc ((int)1e9+7)
#define mcf 998244353
#define mi map<int,int>
#define mem(a,n) memset(a,n,sizeof(a))
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> fst;

const int N=1e5+7;
ll dp[101][N],n,w;
ll maxl(ll a,ll b) {return (a>b)? a:b;}

void solve()
{
    cin>>n>>w;
	for(int i=1;i<=n;i++)
	{
		int wt,val;
		cin>>wt>>val;
		for(int j=1;j<=w;j++)
		{
			if(j>=wt) dp[i][j]=maxl(dp[i-1][j-wt]+val,dp[i-1][j]);
			else dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][w]<<endl;
	
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 78336
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>

using namespace std;

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  int c0 = 0;
  for (int i = 0; i < N; ++i) {
    if (i % 2 == 0) {
      if (S[i] != '0') ++c0;
    }
    else {
      if (S[i] != '1') ++c0;
    }
  }
  int c1 = 0;
  for (int i = 0; i < N; ++i) {
    if (i % 2 == 0) {
      if (S[i] != '1') ++c1;
    }
    else {
      if (S[i] != '0') ++c1;
    }
  }
  cout << min(c0, c1) << endl;
  return 0;
}


Measured memory_bytes: 512
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

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

		int min = 1 << 29;
		long limit = (long) Math.sqrt(N);
		for (long i = 1; i <= limit; i++) {
			if (N % i == 0) {
				int left = Long.toString(N / i).length();
				int right = Long.toString(i).length();
				int tmp = Math.max(left, right);
				if (tmp < min) {
					debug(left, right, tmp);
					min = tmp;
				}
			}
		}

		System.out.println(min);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
#define ALL(V) V.begin(), V.end()
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};



int Main(int N, int K)
{
    combination c(N);
    mint ans(0);
    REP(i, N) {
        ans += c(N, i)*c(N-1,i);
        if (i == K) return ans.x;
    }
    return ans.x;
}

int main(void){
    int N, K;
    cin >> N >> K;
    cout << Main(N, K) << endl;
    return 0;
}

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

int main(){
  int t;
  cin >> t;
  for(int i=0;i<t;i++){
    int n,k;
    int sum=0;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> b(n-1);
    for(int j=0;j<n;j++){
      cin >>  a.at(j);
    }
    for(int m=0;m<n-1;m++){
      b.at(m)=a.at(m+1)-a.at(m);
    }
    sort(b.begin(),b.end());
    int c=n-k;
      for(int l=0;l<c;l++){
	sum+=b.at(l);
      }	cout << sum << endl;
      }
}
 


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;i++)
#define dec(i,j,k) for(re int i=j;i>=k;i--)
#define ll long long 
using namespace std;
const int N=5e5+5;
const int mod=998244353;
inline int read(){
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,m;
ll fac[N],inv[N];
ll qp(ll x,ll k){ 
	ll res=1;
	while(k){
		if(k&1) res=res*x%mod;
		k>>=1,x=x*x%mod;
	}
	return res;
}
ll c(int n,int m){
	if(n<m||n<0||m<0) return 0;
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
	n=read(),m=read();
	fac[0]=inv[0]=inv[1]=1;
	inc(i,1,max(n,m)) fac[i]=fac[i-1]*i%mod;
	inc(i,2,max(n,m)) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	inc(i,3,max(n,m)) inv[i]=inv[i-1]*inv[i]%mod; 
	ll ans=0;
	inc(i,0,min(n,m)){
		if(i&1) (ans+=mod-c(n,i)*c(m,i)%mod*fac[i]%mod*qp(m+1,n-i)%mod*qp(n+1,m-i)%mod)%=mod;
		else (ans+=c(n,i)*c(m,i)%mod*fac[i]%mod*qp(m+1,n-i)%mod*qp(n+1,m-i)%mod)%=mod;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 11440
import Control.Monad

main = do
  s <- getLine
  let [x,y] = map (read ::String->Int) $ words s in
    if x /= 0 && y /= 0 then do
      putStr $ join . replicate x $ replicate y '#' ++ "\n"
      putStr "\n"
      main
    else
      return ()

Measured memory_bytes: 4096
#include<stdio.h>


int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else if(a==b){
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
K,N=map(int, input().split())
A=list(map(int, input().split()))
C=[]
for i in range(N):
  if i==N-1:
    C.append((K-A[i])+A[0])
  else:
    C.append(A[i+1]-A[i])

print(K-max(C))

Measured memory_bytes: 26060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,C;
  cin>>A>>B>>C;
  int k;
  cin>>k;
  while(B<=A && k>0)
  {
    B= B*2;
    k--;
  }
  while(C<=B && k>0)
  {
    C= C*2;
    k--;
  }
  if(B>A && C>B)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}

      

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  int n; cin >> n;
  if(n%1000 == 0) puts("0");
  else cout << 1000 - n%1000 << endl;
}


Measured memory_bytes: 3652
/*
ID: zhaowei10
TASK:
LANG: C++
*/
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define pb push_back
#define MOD 1000000007
#define NDIG(x) floor(log10(x)) + 1
#define FOR(i, j, k, l) for (s32 i = j; i < k; i += l)
#define RFOR(i, j, k, l) for (s32 i = j; i >= k; i -= l)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(x) x.begin(), x.end()
#define MEAN(a, b) min(a, b) + (abs(b - a) >> 1)
#define FASTIO()    \
  cin.tie(nullptr); \
  ios::sync_with_stdio(false);

typedef long long ll;
typedef int64_t s64;
typedef uint64_t u64;
typedef int32_t s32;
typedef uint32_t u32;
typedef float f32;
typedef double f64;
typedef pair<s32, s32> II;
typedef pair<s64, s64> LL;
typedef vector<s32> VI;
typedef vector<II> VII;
typedef vector<char> VC;
typedef vector<VII> VVII;
typedef priority_queue<s32> PQI;
typedef priority_queue<s32, VI, greater<s32>> PQIA;
typedef priority_queue<s64> PQL;
typedef priority_queue<II> PQII;
typedef priority_queue<II, VII, greater<II>> PQIIA;
typedef priority_queue<LL> PQLL;
typedef unordered_set<s32> USI;
typedef unordered_set<s64> USL;
typedef set<II> SII;
typedef multiset<s32> MSI;

template <typename T, typename U>
inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y) {
  if (x < y) x = y;
}

template <typename T>
inline s32 ndigits(T x, T b) {
  s32 r = 0;
  while (x) {
    x /= b;
    ++r;
  }
  return r;
}

int main() {
  FASTIO();

  int m, n;
  cin >> n >> m;
  cout << (n == m ? "Yes" : "No");
}

Measured memory_bytes: 888
#include<stdio.h>
#include<math.h>
int main(void)
{
	double x1,x2,y1,y2;
	
	double sum;
	
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	
	sum=pow(x2-x1,2)+pow(y2-y1,2);
	
	printf("%lf",sqrt(sum));
	
	return 0;
}


Measured memory_bytes: 2056
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int w,a,b;
	cin>>w>>a>>b;
	int a1=a+w;
	int b1=b+w;
	if(b>=a1)
	{
		cout<<b-a1<<endl;
		return 0;
	}
	else if(a>=b1)
	{
		cout<<a-b1<<endl;
	}
	else
		cout<<0<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>
 
const int MAX_N = 100;
long long X, Y;
bool can_win[MAX_N][MAX_N];
 
int main(int argc, char **argv) {
    std::cin >> X >> Y;
    if (2 <= labs(X- Y)) {
        std::cout << "Alice" << std::endl;
    } else {
        std::cout << "Brown" << std::endl;
    }
    /*
    can_win[0][0] = false;
    can_win[0][1] = false;
    can_win[1][0] = false;
    can_win[1][1] = false;

    for (int total = 2; total <= 20; total++) {
        std::cout << "total:" << total << std::endl;
        for (int k = 0; k <= total; k++) {
            can_win[total - k][k] = false;
            for (int i = 2; i <= total - k; i += 2) {
                if (!can_win[total - k - i][k + i/2]) {
                    can_win[total - k][k] = true;
                }
            }
            for (int i = 2; i <= k; i += 2) {
                if (!can_win[total - k + i/2][k - i]) {
                    can_win[total - k][k] = true;
                }
            }
            std::cout << total - k << " " << k << " " << (int)can_win[total - k][k] << std::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 repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                                \
  ifstream in("atcoder-problems/code_festival_2017_qualb_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, M;
  cin >> N;

  map<int, int> m;
  rep(i, N) {
    int d;
    cin >> d;
    m[d] += 1;
  }

  ll ans = 0;
  cin >> M;
  bool ok = true;
  rep(i, M) {
    int t;
    cin >> t;
    if (m[t])
      m[t]--;
    else {
      ok = false;
      break;
    }
  }

  cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
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; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    int p[57];
    cin >> N;
    int Ans=0;
    REP(i,N){
        cin >> p[i];
    }
    REP(i,N-2){
        if(p[i+1]!=max({p[i],p[i+1],p[i+2]})&&p[i+1]!=min({p[i],p[i+1],p[i+2]})){
            Ans++;
        }
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
//#define ss second
#define se set<ll>
#define vec vector<ll>
#define inf 10000000000000000
bool mark[100005];
vec adj[100005];
ll counter;
vec cnt;
vector<string> forsubs;




int main()
{    
 

	#ifdef APNA_IO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

   
   string s;
   cin>>s;
   ll b=0;

   ll a[4];

   for(int i=0;i<4;i++)
   {
   	a[i]=(int)s[i]-'0';
   	//cout<<a[i]<<endl;
   }

if(a[0]==0 && a[1]>=1 && ((a[2]==0 && a[3]>=1) || (a[2]==1 && a[3]<=2)))
{
	cout<<"AMBIGUOUS";
	b++;
}

if(a[0]==1 && a[1]<=2 && ((a[2]==0 && a[3]>=1) || (a[2]==1 && a[3]<=2)))
{
	cout<<"AMBIGUOUS";
	b++;
}

if(((a[2]>=2) || (a[2]==0 && a[3]==0)) && ((a[0]==0 && a[1]>=1) || (a[0]==1 && a[1]<=2) ))
{
	cout<<"MMYY";
	b++;
}

if(((a[0]>=2) || (a[0]==0 && a[1]==0) || (a[0]==1 && a[1]>=3)) && ((a[2]==0 && a[3]>=1) || (a[2]==1 && a[3]<=2) ))
{
	cout<<"YYMM";
	b++;
}

	if(b==0)
	{
		cout<<"NA";
	}
}
	




Measured memory_bytes: 2560
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
int n,m,dp[3001][3001]={},x,y,z;
string s,t,ans;
int main(){
    cin>>s;
    cin>>t;
    n=s.size();
    m=t.size();
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
            if(s[i]==t[j]){
                dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
            }
        }
    }
    x=n;
    y=m;
    z=dp[n][m];
    for(int i=x;i>=1;i--){
        for(int j=y;j>0;j--){
            if(i<1){
                break;
            }
            if(dp[i][j]==z&&dp[i][j]>max(dp[i-1][j],dp[i][j-1])){
                ans.push_back(t[j-1]);
                y=j-1;
                z--;
                break;
            }
        }
    }
    for(int i=ans.size()-1;i>=0;i--){
        cout<<ans[i];
    }
    cout<<endl;
}

Measured memory_bytes: 35456
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]

a,b = map(int, input().split())

if((a in A and b in A) or (a in B and b in B) or (a in C and b in C)):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
typedef unsigned long long  ull;

ull power(ull m, ull n, ull r){
    ull tmp = 1;
    if(n > 0){
        tmp = power(m, n/2, r);
        if(n % 2 ==0) tmp =(tmp*tmp)%r;
        else tmp = (((tmp*tmp)%r)*m)%r;
      }
      return tmp;
}


int main(){
	int m, n;
	cin >> m >> n;
    cout << power(m,n, 1000000007) << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N*3);
    REP(i,N*3) cin>>a[i];

    sort(ALL(a),greater<int>());

    int ans=0;
    REP(i,N) ans+=a[2*i+1];
    cout<<ans<<endl;

}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define loop(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ll long long

int main() {
    int n,l;
    string s;
    cin>>n>>l;
    vector<string>v(n);
    loop(i,n){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(int i=0; i<v.size(); i++){
        cout<<v[i];
    }cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define inf 1e17
#define MAX_SIZE 1000005 

void pr(int arr[], int size) 
{ for (ll i=0; i < size; i++) {printf("%d ", arr[i]); }cout << endl;}

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  ll n;
  cin >> n;
  ll a[n+1] ;
  ll cnt = 0;
  unordered_map <ll , ll> ans;
  for(ll i = 1;i <= n;i++){
      cin >> a[i];
      cnt += ans[a[i] - i];
      ans[-a[i] - i]++;
  }
  
  cout << cnt << endl;
  return 0;
}


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

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

    vector<int> v;
    int n;

    cin >> n;
    int i, t;

    while (i < n && cin >> t)
    {
        v.push_back(t);
        ++i;
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    cout << v.size() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int i, x;
  i = 1;
  
  while(1)
    {
      scanf("%d", &x);

      if(x == 0)
	{
	  break;
	}
      else
	{
	  printf("Case %d: %d\n", i, x);
	  i++;
	}
    }
}



Measured memory_bytes: 2056
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		
		double argA = (double) (60 * h + m) / 2;
		double argB = 6 * m;
		double ax = 0;
		double ay = 0;
		double bx = 0;
		double by = 0;
		
		if (argA >= 0 && argA <= 90) {
		    ax = a * Math.cos(Math.toRadians(90 - argA));
		    ay = a * Math.sin(Math.toRadians(90 - argA));
		} else if (argA > 90 && argA <= 180) {
		    ax = a * Math.cos(Math.toRadians(argA - 90));
		    ay = -a * Math.sin(Math.toRadians(argA - 90));
		} else if (argA > 180 && argA <= 270) {
		    ax = -a * Math.cos(Math.toRadians(270 - argA));
		    ay = -a * Math.sin(Math.toRadians(270 - argA));
		} else if (argA > 270 && argA <= 360) {
		    ax = -a * Math.cos(Math.toRadians(argA - 270));
		    ay = a * Math.sin(Math.toRadians(argA - 270));
		}
		
		if (argB >= 0 && argB <= 90) {
		    bx = b * Math.cos(Math.toRadians(90 - argB));
		    by = b * Math.sin(Math.toRadians(90 - argB));
		} else if (argB > 90 && argB <= 180) {
		    bx = b * Math.cos(Math.toRadians(argB - 90));
		    by = -b * Math.sin(Math.toRadians(argB - 90));
		} else if (argB > 180 && argB <= 270) {
		    bx = -b * Math.cos(Math.toRadians(270 - argB));
		    by = -b * Math.sin(Math.toRadians(270 - argB));
		} else if (argB > 270 && argB <= 360) {
		    bx = -b * Math.cos(Math.toRadians(argB - 270));
		    by = b * Math.sin(Math.toRadians(argB - 270));
		}
		
		double result = (double) Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
		
		System.out.println(result);
	}
}

Measured memory_bytes: 35816
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf (1ll << 62)
typedef vector<int> vi;
typedef pair<int, int> pii;

int h, w, k;
int x1, Y1, x2, y2;
vector<string> grid;

signed main()
{
    cin >> h >> w >> k;
    cin >> x1 >> Y1 >> x2 >> y2;
    --x1, --x2, --Y1, y2--;
    grid = vector<string>(h);
    for (int i = 0; i < h; i++)
        cin >> grid[i];
    queue<pii> q;
    vector<vi> d(h, vi(w, inf));
    vector<vi> vis(h, vi(w, 0));
    d[x1][Y1] = 0;
    q.push({x1, Y1});
    vi dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};
    while (!q.empty())
    {
        pii c = q.front();
        q.pop();
        if (vis[c.first][c.second])
            continue;
        vis[c.first][c.second] = 1;
        for (int i = 0; i < 4; i++)
        {
            for (int len = 1; len <= k; len++)
            {
                int newx = c.first + dx[i] * len;
                int newy = c.second + dy[i] * len;
                if (newx >= h or newy >= w or newx < 0 or newy < 0 or grid[newx][newy] == '@')
                    break;
                if (d[c.first][c.second] + 1 > d[newx][newy])
                    break;
                d[newx][newy] = d[c.first][c.second] + 1;
                q.push({newx, newy});
            }
        }
    }
    cout << (d[x2][y2] == inf ? -1 : d[x2][y2]);
}

Measured memory_bytes: 27640
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> v[505];
bool can[505];
int main(){
    int n,m,q;
    scanf("%d %d %d",&n,&m,&q);
    //cin>>n>>m>>q;
    int t1,t2;
    for(int i=0;i<m;i++){
        scanf("%d %d",&t1,&t2);
        v[t1].push_back(t2);
    }
    for (int j = 0; j < 505; ++j) {
        sort(v[j].begin(),v[j].end());
    }


    for(int i=0;i<q;i++){
        scanf("%d %d",&t1,&t2);
        int sum=0;
        for(int k=t1;k<=t2;k++){
            //int l=ma[k].size();
            if(!can[k]){
                sort(v[k].begin(),v[k].end());
                can[k]=1;
            }
            vector<int>::iterator up=upper_bound (v[k].begin(), v[k].end(), t2);
            sum+=(up- v[k].begin());
        }
        printf("%d\n",sum);

    }
}


Measured memory_bytes: 2176
n = int(input())
l = list(input().split())
sum = 0
min_sum = 10**10
num = 0
for i in range(-100,101):
    for j in range(len(l)):
        sum += (int(l[j]) - i)**2
    if min_sum > sum:
        min_sum = sum
        num = i
    sum = 0

print(min_sum)

Measured memory_bytes: 9116
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int m = new java.util.Scanner(System.in).nextInt();
		int sum = 0;
		for(int i=1;i<=m;i++) {
			sum += i;
		}
		System.out.println(sum);
		}

	}


Measured memory_bytes: 21716
{
  const lines = [];
  const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
  });

  reader.on('line', function (line) {
    lines.push(line);
  });
  reader.on('close', function () {
    const number = lines[0];
    const res = lines[0] >= 30 ? 'Yes' : 'No';
    console.log(res);
  });
}


Measured memory_bytes: 30132
# coding:utf-8
# Round-robin scheduling

def main():
    n, q = map(int, input().split())
    process = []
    finished = []
    counter = 0
    for _ in range(n):
        name, time = input().split()
        process.append((name, int(time)))

    while len(process)  > 0:
        name, time = process.pop(0)
        temp_q = q

        while True:
            
            if time <= 0:
                finished.append((name, counter))
                break

            # q????????§??????????¶????????????£???????????????
            # time?????´??°??????process???????°?????§???? 
            if temp_q <= 0:
                process.append((name, time))
                break
            
            time -= 1
            temp_q -= 1
            counter += 1
    
    for name, time in finished:
        print(name, time)

if __name__ == "__main__":
    main()

Measured memory_bytes: 16004
n=gets.to_i
ary=[]
n.times do |i|
  ary<<gets.split.map(&:to_i)
end
ary.sort_by! {|x| x[1]}
result=0
ss=''
ary.each { |i,j|
  result +=i
  if result <=j
    next
  else
    ss = :No
  end
}
puts ss == :No ? ss : :Yes

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

int main(){
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<6;i++){
        if(s[i]=='1')cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1ll << 62)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};

struct pos{
  int x,y,h;
};

int main(){
  
  int n;
  cin >> n;
  vector<pos> v(n);
  REP(i,n){
    int x,y,h;cin >> x >> y >> h;
    v[i] = {x,y,h};
  }
  P res;
  REP(x,101){
    REP(y,101){
      REP(j,n){
        if(v[j].h > 0){
          int h = abs(v[j].x-x)+abs(v[j].y-y)+v[j].h;
          bool is = true;
          for(int i = 1;i < n;i++){
            if(max(h - abs(v[(i+j)%n].x-x) - abs(v[(i+j)%n].y-y),0ll) != v[(i+j)%n].h)is = false;
          }
          if(is){
            cout << x << " " << y << " " << h << endl;
            return 0;
          }
          break;
        }
      }
    }
  }
  


  

  return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;

int count1=0;

void odd(int x){
    while(!(x & 1)){
        x/=2;
        count1++;
    }
}


int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

    cin>>n;

    f(i,0,n-1){
        cin>>ara[i];
    }

	vi v;

	for(i=0;i<n;i++){
        if(!(ara[i] & 1)) v.pb(ara[i]);
	}

	if(!v.size()) cout<<0<<endl;
	else{
        for(i=0;i<v.size();i++){
            odd(v[i]);
        }
        cout<<count1<<endl;
	}

}


Measured memory_bytes: 3792
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 998244353


def debug(*x):
    print(*x, file=sys.stderr)


def solve(N, K, SS):
    count = [0] * (N + 10)
    count[0] = 1
    accum = [0] * (N + 10)
    accum[0] = 1

    for pos in range(1, N):
        ret = 0
        for left, right in SS:
            # for i in range(left, right + 1):
            #     j = pos - i
            #     if j < 0:
            #         continue
            #     ret += count[j]
            #     ret %= MOD
            start = max(-1, pos - right - 1)
            end = max(-1, pos - left)
            # debug("end, start", end, start)
            ret += (accum[end] - accum[start])
            ret %= MOD
        # debug("pos, ret", pos, ret)
        count[pos] = ret
        accum[pos] = accum[pos - 1] + ret

    # ret = f(N - 1)
    ret = count[N - 1]
    return ret % MOD


def main():
    # parse input
    N, K = map(int, input().split())
    SS = []
    for i in range(K):
        SS.append(tuple(map(int, input().split())))
    print(solve(N, K, SS))


# tests
T1 = """
5 2
1 1
3 4
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
4
"""

T2 = """
5 2
3 3
5 5
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
0
"""

T3 = """
5 1
1 2
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
5
"""

T4 = """
60 3
5 8
1 3
10 15
"""
TEST_T4 = """
>>> as_input(T4)
>>> main()
221823067
"""

T5 = """
10 1
1 2
"""
TEST_T5 = """
>>> as_input(T5)
>>> main()
55
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


Measured memory_bytes: 76800
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  int n,l;
  cin>>n>>l;
  vector<string> s;
  rep(i,n){
    string t;
    cin>>t;
    s.pb(t);
  }
  sort(s.begin(),s.end());
  rep(i,n)cout<<s[i];
  cout<<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 b = sc.next();

		if (b.equals("A")) {
			System.out.print("T");
		} else if (b.equals("T")) {
			System.out.print("A");
		} else if (b.equals("C")) {
			System.out.print("G");
		} else {
			System.out.print("C");
		}
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define ll long long
#define maxn 100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
int h, w, a, b;
int main() {
	cin >> h >> w >> a >> b;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			int ns = 0;
			if (i <= b) ns ^= 1;
			if (j <= a) ns ^= 1;
			printf("%d", ns);
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define mod 1000000007
#define pai acos(-1)
#define N 200005

int node[N];
vector<int>G[N];



int main ()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
//    freopen("in.txt","r",stdin);
//   freopen("out.txt","w",stdout);
    int n,m,u;
    cin>>n;
    for(int i=2;i<=n;i++){
        cin>>u;
        G[u].pb(i);
    }
    //dfs(1,1);
    for(int i=1;i<=n;i++) cout<<G[i].size()<<endl;
    return 0;
}



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

const int N = 105;

int n;
int a[3][N], c[3][N];

int main() {
	cin >> n;
	for(int i = 1; i <= 2; ++i) {
		for(int j = 1; j <= n; ++j) {
			cin >> a[i][j];
		}
	}
	for(int i = 1; i <= 2; ++i) {
		for(int j = 1; j <= n; ++j) {
			c[i][j] = max(c[i - 1][j], c[i][j - 1]) + a[i][j];
		}
	}
	cout << c[2][n];
}

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

int main(){
	int q,h,s,d;
	long long n;
	while(~scanf("%d%d%d%d",&q,&h,&s,&d)){
		scanf("%lld",&n);
		h=min(h,q*2);
		s=min(s,h*2);
		d=min(d,s*2);
		long long ans=0;
		while(n>=2) ans+=n/2*d,n%=2;
		ans+=n*s;
		cout << ans << endl;
	}
}

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Tree;

#define dbg(x) cout<<#x<<"="<<x<<'\n'
#define ll long long
#define pr pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define For(i,n) for(int i=0;i<(n);++i)
#define Forr(i,n) for(int i=n-1;i>=0;i--)
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#define fin ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define sz(a) (int)a.size()
#define Fill(a,b) memset(a,b,sizeof(a));
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
const int INF=1e9;
#define vvi vector<vi>



void solve(){
    string s;
    cin>>s;
    ll ans=0LL;
    for(char c:s){
        ans+=(ll)(c-'0');
    }
    if(ans%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



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

Measured memory_bytes: 3776