akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    string S;
    cin >> S;
    vector<int> f;
    int size;
  int u=(int)(S.length());
  for(int i=0;i<u;i++){
    size = (int)(f.size());
    if(S[i]=='0')  f.push_back(0);
    if(S[i]=='1')  f.push_back(1);
    if(S[i]=='B'){
      if(size!=0) f.pop_back();
    }
  }
  size = (int)(f.size());
  for(int i=0;i<size;i++){
  cout << f[i];
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
int main() {
	int n, ans;
	cin >> n;
	for (int i = 6; i >= 0; i--)if (1 << i <= n) {
		ans = 1 << i;
		break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int N=0,ans=1;
 string S;
  cin >> N >> S;
  
 for(int i=0;i<N-1;i++){
    if(S[i]!=S[i+1])
    ans = ans + 1;
 }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int number = scanner.nextInt();
		int acCount = 0;
		int waCount = 0;
		int tleCount = 0;
		int reCount = 0;
		while (scanner.hasNext()) {
			String str = scanner.next();
			if (str.equals("AC")) {
				acCount++;
			} else if (str.equals("WA")) {
				waCount++;
			} else if (str.equals("TLE")) {
				tleCount++;
			} else if (str.equals("RE")) {
				reCount++;
			}
		}
		System.out.println("AC x " + acCount);
		System.out.println("WA x " + waCount);
		System.out.println("TLE x " + tleCount);
		System.out.println("RE x " + reCount);
	}
}


Measured memory_bytes: 58732
#include<stdio.h>

int main()
{
    long long int N;
    scanf("%lld",&N);
    unsigned long long fact =1;
    int i;
    if(N>=1&&N<=20)
    for(i=N;i>0;--i)
    {
        fact = fact*i;
    }
    printf("%llu\n",fact);
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <bitset>
#include <cmath>
#include <utility>
#include <ctime>
#define Maxn 100005
#define Maxm 1000005
#define lowbit(x) x&(-x)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define PI acos(-1.0)
#define eps 1e-8
#define random(x) (rand()%x)+1
#define LL long long
#define Inf (1LL<<62)
#define inf 0x3f3f3f3f
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
using namespace std;
const int mod=1e9+7;
int main()
{
	//input;output;
	int n,x,cnt_0,cnt_1,cnt,sum;
	while(~scanf("%d",&n))
	{
		cnt_0=0;cnt_1=0,cnt=0;sum=0;
		for(int i=0;i<n;i++)
		{
			int flag=0;
			scanf("%d",&x);
			while(x%2==0)
			{
				flag++;
				x>>=1;
			}
			if(flag==0)
				cnt_0++;
			else if(flag==1)
				cnt_1++;
			else
				cnt++;
		}
		if(cnt_1&&cnt_0)
			cnt_1=1;
		sum=cnt_0+cnt_1-1;
		if(cnt_0==0&&cnt_1==1||cnt_0==1&&cnt_1==0)
			sum=1;
		if(cnt_0==0)
			sum=0;
		if(cnt>=sum)
			puts("Yes");
		else
			puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    string S;
    cin>>S;
    for(int i=0;i<3;i++){
        if(S[i]=='1')S[i]='9';
        else S[i]='1';
    }
    cout<<S<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final String s = scanner.next();
        final long count = IntStream.range(0, n).filter(i -> s.charAt(i) == 'R').count();
        final long minReplace = Math.min(count, n - count);
        if (minReplace == 0) {
            System.out.println(0);
            return;
        }

        final int wFirst = s.indexOf("W");
        final int rEnd = s.lastIndexOf("R");
        if (wFirst > rEnd) {
            System.out.println(0);
            return;
        }

        final long rangedCount = IntStream.rangeClosed(wFirst, rEnd)
            .filter(i -> s.charAt(i) == 'R')
            .count();

        final long minSwap = IntStream.range(wFirst, wFirst + (int) rangedCount)
            .filter(i -> s.charAt(i) == 'W')
            .count();

        System.out.println(Math.min(minReplace, minSwap));
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
    

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

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

    vector<string> s(N);

    for (int i = 0; i < N; i++)
    {
        cin >> s[i];
    }

    vector<int> c(N);
    for (int i = 0; i < N; i++)
    {
        c[i] = 0;
        for (int j = 0; j < N; j++)
        {
            if (j == i) continue;

            if (s[i] > s[j]) c[i]++;
        }
    }

    int count = 0;
    string ans;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            //if (count == c[j]) ans += s[j];
            if (count == c[j]) cout << s[j];
        }
        count++;
    }
    //cout << ans;
}

Measured memory_bytes: 3596
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<bits/stdc++.h>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3F3F3F3F
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int n,k;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n>>k;
	if(n%k==0){
		cout<<0; 
	}
	else
	cout<<1;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
#define MAX 50

typedef pair<int, int> P;

const int INF = 1 << 29;

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

int h, w;
string s[MAX];
int d[MAX][MAX];

void bfs() {
  queue<P> que;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      d[i][j] = INF;
    }
  }
  que.push(P(0, 0));
  d[0][0] = 0;

  while (!que.empty()) {
    P p = que.front();
    que.pop();
    for (int i = 0; i < 4; i++) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if (0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] == '.' && d[nx][ny] == INF) {
        que.push(P(nx, ny));
        d[nx][ny] = d[p.first][p.second] + 1;
      }
    }
  }
}

int black_count() {
  int count = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') count++;
    }
  }
  return count;
}

int main() {
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  bfs();
  if (d[h - 1][w - 1] == INF) cout << -1 << endl;
  else cout << h * w - d[h - 1][w - 1] - 1 - black_count() << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.Set;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            Set<Integer> hs = new HashSet<>();
            int n = in.nextInt();
            for (int i = 0; i < n; ++i) {
                int x = in.nextInt();
                if (hs.contains(x)) {
                    hs.remove(x);
                } else {
                    hs.add(x);
                }
            }
            out.println(hs.size());
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 48516
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        String[] dates = s.split("/");
        if (Integer.parseInt(dates[0]) < 2019) {
            System.out.println("Heisei");
        } else if (Integer.parseInt(dates[0]) > 2019){
            System.out.println("TBD");
        } else {
            if (Integer.parseInt(dates[1]) < 4) {
                System.out.println("Heisei");
            } else if (Integer.parseInt(dates[1]) > 4){
                System.out.println("TBD");
            } else {
                if (Integer.parseInt(dates[2]) > 30) {
                    System.out.println("TBD");
                } else {
                    System.out.println("Heisei");
                }
            }
        }
    }
}

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

d = {}

for i in a:
    d[i] = d.get(i, 0) + 1

d = sorted(d.items(), key=lambda x: x[1])

dif = len(set(a)) - k

if dif <= 0:
    print(0)
    exit()


c = 0

for i in range(dif):
    c += d[i][1]

print(c)

Measured memory_bytes: 40112
#include <iostream>

using namespace std;

typedef long long ll;
const ll MOD = 998244353;

int n, m;
int x[100000], y[100000];
int ball[100000];
bool is_red[100000];


int main(){
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }

    is_red[0] = true;

    for (int i = 0; i < n; i++){
        ball[i]++;
    }

    for (int i = 0; i < m; i++){
        // x[i] から y[i] へ移す操作をする。
        ball[x[i]]--; ball[y[i]]++;
        if (is_red[x[i]]) {
            is_red[y[i]] = true;
            if (ball[x[i]] == 0){
                is_red[x[i]] = false;
            }
        }
    }

    int sum = 0;
    for (int i = 0; i < n; i++){
        if (is_red[i]){
            sum++;
        }
    }
    cout << sum << endl;

}


Measured memory_bytes: 1536
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
const int mxn=1e5+1;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  ll t=1;
  //cin>>t;
    while(t--){
            int n,k,mn,pos=-1;
    cin>>n>>k;
    int ans=0;
    int arr[n];
    int i;
    fr(i,0,n)
    {
        cin>>arr[i];
        if(arr[i]==1)
            pos=i;
    }
   int himj=0;
   fr(i,0,n)
   {
   	himj++;
   	if(himj==k)
   	{
   		ans++;
   		himj=1;
   		continue;
   	}
   }
   if(himj>1)
   ans++;
   cout<<ans;

    }
  return 0;
  }



Measured memory_bytes: 640
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main(){
    int n;
    cin >> n;
    int num = 1;
    int ans;

    for(int i = 1; i <= n; i++){
        if(num == n){
            ans = num;
            break;
        }
        else if( num > n ){
            ans = num / 2;
            break;
        }
        num *= 2;
    }
    cout << ans << endl; 
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 10;
const int MAXM = 10;

int h, w, k, mp[MAXN][MAXM];
int row[MAXN], col[MAXM], ans;

char getch(){
	char tmps = getchar();
	while(tmps != '#' && tmps != '.') tmps = getchar();
	return tmps;
}

int main(){
	scanf("%d %d %d", &h, &w, &k); k = -k;
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++){
			mp[i][j] = getch() == '#' ? 1 : 0;
			k += mp[i][j];
		}
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			row[i] += mp[i][j];
	for(int i = 0; i < w; i++)
		for(int j = 0; j < h; j++)
			col[i] += mp[j][i];
	ans = 0;
	for(int i = 0; i < (1 << h); i++)
		for(int j = 0; j < (1 << w); j++){
			int tmps = k;
			for(int pi = 0; pi < h; pi++)
				if(i & (1 << pi)) tmps -= row[pi];
			for(int pj = 0; pj < w; pj++)
				if(j & (1 << pj)) tmps -= col[pj];
			for(int pi = 0; pi < h; pi++)
				for(int pj = 0; pj < w; pj++){
					if((i & (1 << pi)) && (j & (1 << pj)))
						tmps += mp[pi][pj];
				}
//			printf("%d %d %d\n", i, j, tmps);
			if(tmps == 0) ans++;
		}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3756
// In The Name Of Allah
// Mehrkish Makuei

#include <bits/stdc++.h>

#define pb push_back
#define debug1(x) cerr << #x << " : " << x << endl;
#define debug2(x, y ) cerr << #x << " : " << x << "  " << #y << " : " << y << endl;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef vector <ll> vll;
typedef set <char> sch;
typedef set <ll> sll;

const ll MOD = 1e9 + 7;
const ll MAXN = 1e5 + 19;

ll n, a[MAXN], dp[3][MAXN], c[MAXN], b[MAXN];

int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for ( int i = 0; i < n; i++ )
		cin >> a[i] >> b[i] >> c[i];
	dp[0][0] = a[0];
	dp[1][0] = b[0];
	dp[2][0] = c[0];
	for ( int i = 1; i < n; i++ ){
		dp[0][i] = max( dp[1][i - 1] + a[i], dp[2][i - 1] + a[i] );
		dp[1][i] = max( dp[0][i - 1] + b[i], dp[2][i - 1] + b[i] );
		dp[2][i] = max( dp[0][i - 1] + c[i], dp[1][i - 1] + c[i] );
	}
	ll ans = max( dp[1][n - 1], max( dp[0][n - 1], dp[2][n - 1] ) );
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
#include"bits/stdc++.h"
#include<iostream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
const ll inf = 1000000007;

ll mod = 1000000007;

ll modpow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

ll modcmb(int n, int r) {
	ll ans = 1;
	rep(i, r) {
		ans *= (n - i) * modpow(i + 1, mod - 2) % mod;
		ans %= mod;
	}
	return ans;
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	ll all_sum = modpow(2, n);
	ll exclusion = (modcmb(n, a) + modcmb(n, b)) % mod;
	ll ans = all_sum - exclusion;
	ans = (ans + mod) % mod;
	cout << ans - 1 << endl;
	return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
int main() {
    long n, i, sum1[111111], sum2[111111], q, a[111111], b[111111], ans[111111], x;
    scanf("%ld%ld", &n, &q);
    for (i = 1; i <= n; i++)
        scanf("%ld", &a[i]);
    sum1[0] = 0;
    sum2[n + 1] = 0;
    for (i = 1; i <= n; i++) {
        if ((n - i) % 2 == 0)
            sum1[i] = sum1[i - 1] + a[i];
        else
            sum1[i] = sum1[i - 1];
        sum2[n + 1 - i] = sum2[n + 2 - i] + a[n + 1 - i];
    }
    for (i = n - 1; i >= n / 2; i--) {
        b[i] = (a[i] + a[i * 2 - n]) / 2;
    }
    long max, min, r;
    for (i = 0; i < q; i++) {
        scanf("%ld", &x);
        max = n - 1;
        min = n / 2;
        while (max != min) {
            r = (max + min) / 2;
            if (min == r)
                r++;
            if (x <= b[r]) {
                if (max == r)
                    max--;
                else
                    max = r;
            }
            else
                min = r;
        }
        if (min * 2 - n<0)
            ans[i] = sum2[min + 1];
        else
            ans[i] = sum1[min * 2 - n] + sum2[min + 1];
    }
    for (i = 0; i < q; i++)
        printf("%ld\n", ans[i]);
    return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	ll a,b,c,ans = 0;
	cin >> a >> b >> c;	
	if(a==b&&b==c && a%2==0)cout << -1 << endl;
	else if(a==b&&b==c && a%2!=0)cout << 0 << endl;
	else{
		while(a%2==0&&b%2==0&&c%2==0){
			ll ta,tb,tc;
			ta = b/2 + c/2;
			tb = a/2 + c/2;
			tc = a/2 + b/2;
			a = ta;
			b = tb;
			c = tc;
			ans ++;
		}
		cout << ans << endl;
	}
	
}

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

using ll = long long;
// #define int long long

using P = pair<int,int>;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/

bool CompareBySecond(pair<int,int> a, pair<int, int> b) {
  return a.second < b.second;
}

signed main() {
  int n, duration, attack_p;
  cin >> n >> duration >> attack_p;
  duration *= 2;
  vector<P> pairs(n);
  
  REP(i,n) {
    int first, second;
    cin >> first >> second;
    pairs[i] = P(first,second);
  }
  SORT(pairs);
  
  ll ans = 0;
  queue<P> bombs; // 個数 距離
  ll current_p = 0;

  REP(i, n) {
    int fox_posi = pairs[i].first;
    int fox_hp = pairs[i].second;
    while(true) {
      if(bombs.empty()) break;
      P tmp_p = bombs.front();
      if(tmp_p.second >= fox_posi) break;
      current_p -= attack_p * tmp_p.first;
      bombs.pop();
    }
    int left_hp = fox_hp - current_p;
    if(left_hp <= 0) continue;
    
    int needed_bombs = ceil( (double) left_hp / (double) attack_p);
    ans += needed_bombs;
    current_p += attack_p * needed_bombs;
    bombs.push(P(needed_bombs, fox_posi+duration));
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()





int main(){

  int N, M;
  int si, ci;
  bool dup, topz = false;
  cin >> N >> M;
  vector<int>vec(N, -1);

  rep(i, 0, M){
    cin >> si >> ci;
    

    if(vec[si-1] == -1){
      vec[si-1] = ci;
    }else{
      if(vec[si-1] != ci){
        cout << -1 << endl;
        return 0;
      }
    }
  }

  if(vec[0] == 0){
    if(N == 1){
      cout << 0 << endl;
      return 0;
    }else{
      cout << -1 << endl;
      return 0;
    }
  }
  rep(i, 0, N){
    if(vec[i] == -1){
      if(i == 0){
        vec[i] = (N == 1)? 0:1;
      }else{
        vec[i] = 0;
      }
    }
    cout << vec[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int comb=(1<<k)-1;
  int ans=1LL<<50LL;
  while(comb<(1<<n)){
    int tmp=0,res=0;
    for(int i=0;i<n;i++){
      if((comb>>i)&1){
	if(tmp<a[i]){
	  tmp=a[i];
	  continue;      
	}
	res+=(tmp+1)-a[i];
	tmp++;
      }else{
	tmp=max(tmp,a[i]);
      }
    }
    //cout<<res<<endl;
    ans=min(ans,res);
    int x=comb&-comb;
    int y=comb+x;
    comb=((comb&~y)/x>>1)|y;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 764
import datetime

while True:

    year1, month1, day1, year2, month2, day2 = [int(item) for item in input().split(" ")]

    if any([item < 0 for item in [year1, month1, day1, year2, month2, day2]]):
        break

    date1 = datetime.date(year1, month1, day1)
    date2 = datetime.date(year2, month2, day2)

    subtract = date2 - date1

    print(subtract.days)



Measured memory_bytes: 6048
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <math.h>
using namespace std;
#define ll long long int

int main(void)
{
	int a, b, d, g, count = 0;
		string S, T, U;
	cin >> g;
	vector<int> vec(g);
	map<char, int> mp;
	for (int i = 0;i < g;i++)
	{
		std::cin >> vec[i];
	}

	for (int i = 1;i < g - 1;i++)
	{
		if (vec[i - 1] < vec[i] && vec[i] < vec[i + 1])
			count++;
		else if(vec[i - 1] > vec[i] && vec[i] > vec[i + 1])
			count++;
	}
		cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

void solve(void)
{
  int N;
  cin >> N;
  auto D = divisor(N);
  int ANS = 0;
  for (auto &&i : D)
  {
    if(i >= 2 && N/i < i -1)
    {
      ANS += i - 1;
    }
    // DEBUG(i);
  }
  cout<<ANS<<endl;
  
  return;

}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 384
#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 998244353;// 10^9+7
constexpr ll LIM = 400'000;

//変数
ll N, A, B, K;




//繰り返し累乗法
//in:  x,n,mod
//out: x^n(Mod mod)
template<typename T>
T mod_pow(T x, T n, T mod) {
	T res = 1;
	while (n > 0) {
		if (n & 1)res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

//
vector<ll> fact, inv;
void make_contents()
{
	ll tmp = 1;
	fact.push_back(0);
	FOR(i, 1, LIM) {
		tmp *= i;
		tmp %= MOD;
		fact.push_back(tmp);
	}

	tmp = mod_pow(tmp, MOD - 2, MOD);
	//inv.push_back(tmp);
	for (ll i = LIM - 1; i > 0; i--) {
		tmp *= i;
		tmp %= MOD;
		inv.push_back(tmp);
	}
	reverse(inv.begin(), inv.end());
	fact[0] = inv[0] = 1;
	/*正当性確認
	REP(i, LIM) {
	cerr << (fact[i] * inv[i]) % MOD << endl;
	}
	*/
}

ll comb(ll n, ll k) {
	ll res = fact[n];
	res *= inv[k]; res %= MOD;
	res *= inv[n - k]; res %= MOD;
	return res;
}





//サブ関数
//入力
void input()
{
	cin >> N >> A >> B >> K;
	make_contents();
}


//計算
void calc()
{
	ll res = 0;
	REP(numA, N + 1) {
		ll will = K - A * numA;
		if (will<0 ||  will%B != 0)continue;
		will /= B;
		if (will > N)continue;
		
		ll tmp = comb(N, numA)*comb(N, will);
		tmp %= MOD;
		res += tmp;
		res %= MOD;
	}
	cout << res << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 12396
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<list>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;
// index が条件を満たすかどうか vector<>maeに検索したいvectorを入れる keyを超える最小の要素番号を返す
bool isOK(int index, long long key, vector<long long>&mae) {
   if (mae[index] >= key) return true;
   else return false;
}

// 汎用的な二分探索のテンプレ
int binary_search(long long key, vector<long long>&mae) {
   int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
   int right = (int)mae.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

   /* どんな二分探索でもここの書き方を変えずにできる！ */
   while (right - left > 1) {
	  int mid = left + (right - left) / 2;

	  if (isOK(mid, key, mae)) right = mid;
	  else left = mid;
   }

   /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
   return right;
}


ll n;
string s;

int main() {
   cin >> n;
   VLL a(n);
   rep(i, n)cin >> a[i];
   sort(a.begin(), a.end());
   ll cnt = 0;
   for (int i = n-1; i >=2; i--)
   {
	  for (int j = i-1; j >=1; j--)
	  {
		 if (a[i] - a[j] >= a[j - 1])continue;
		 cnt += max(0,(j - binary_search(a[i] - a[j]+1, a)));
	  }
   }
   cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  cout << a*b/2 << endl;
  return 0;
}

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

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

typedef long long ll;

struct K {
  int lb, ub, x;
};
bool operator>(const K& k1, const K& k2) {
  return k1.x > k2.x;
}
bool operator<(const K& k1, const K& k2) {
  return k1.lb - k1.x < k2.lb - k2.x;
}

K ks[200000+10];

int main(void) {
  int n, nQuery;
  scanf("%d%d", &n, &nQuery);
  REP(i, n) {
    int s, t, x;
    scanf("%d%d%d", &s, &t, &x);
    ks[i].lb = s;
    ks[i].ub = t-1;
    ks[i].x = x;
  }
  sort(ks, ks + n);
  priority_queue<K, vector<K>, greater<K> > q;
  int ki = 0;
  REP(i, nQuery) {
    int t;
    scanf("%d", &t);
    for(; ki < n; ++ki) {
      // cerr << "> " << ki << " " << ks[ki].lb << " " << ks[ki].ub << " " << ks[ki].x << " " << ks[ki].lb - ks[ki].x << endl;
      if(ks[ki].lb - ks[ki].x <= t) {
        q.push(ks[ki]);
      } else {
        break;
      }
    }
    while(!q.empty()) {
      K cur = q.top();
      if(cur.ub - cur.x < t) {
        q.pop();
      } else {
        break;
      }
    }
    printf("%d\n", q.empty() ? -1 : q.top().x);
  }
  return 0;
}


Measured memory_bytes: 6900
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
graph = [[0 for i in range(n)] for j in range(2)]
for i in range(m):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    if a == 0:
        graph[a][b] = 1
    if b == n - 1:
        graph[1][a] = 1
flg = False
for i in range(n):
    if graph[0][i] & graph[1][i]:
        flg = True
if flg:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 65776
N, M = map(int, input().split())

L = []
R = []
for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

if min(R)-max(L)+1 <= 0:
    print(0)
else:
    print(min(R)-max(L)+1)

Measured memory_bytes: 10996
#include <stdio.h>

int main(void){
	int a,b,c;
  	scanf("%d %d %d",&a,&b,&c);
  for(int i=0; i<3; i++){
  	if(a == b && b == c){ 
      printf("No");
      return 0;
    }
    if(a == b && b !=c){
      printf("Yes");
      return 0;
    }
    if(a != b && b == c){
      printf("Yes");
      return 0;
    }
    if(a == c && b != c){
      printf("Yes");
      return 0;
    }
    
  }
  printf("No");
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i!=(n);++i)

typedef long long ll;

using namespace std;

int main(){

    int N,K;
    cin>>N>>K;

    int h[N];

    rep(i,N) cin>>h[i];

    sort(h,h+N);
    int Min=1000000000;
    int a;

    for(int i=0;i!=N-K+1;++i){
        a=h[i+K-1]-h[i];
        Min=(Min<=a)?Min:a;
    }

    cout<<Min<<endl;
}



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

using namespace std;

const int maxn = 110;
int a[maxn], top;
pair<int, int> sta[maxn];

int main()
{

	int n;
	scanf("%d", &n);
	int ans = 1;
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for(int i = 1; i <= n; ++i) ans = abs(a[ans]) > abs(a[i]) ? ans : i;
	if(a[ans] > 0)
	{
		sta[++top] = make_pair(ans, n); sta[++top] = make_pair(ans, n);
		for(int i = 1; i < n; ++i) sta[++top] = make_pair(n, i), sta[++top] = make_pair(n, n);
	}
	if(a[ans] < 0)
	{
		sta[++top] = make_pair(ans, 1); sta[++top] = make_pair(ans, 1);
		for(int i = n; i > 1; --i) sta[++top] = make_pair(1, i), sta[++top] = make_pair(1, 1);
	}
	cout << top << endl;
	for(int i = 1; i <= top; ++i) printf("%d %d\n", sta[i].first, sta[i].second);

	return 0;
}

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;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e5+100;
const ll  MAX=1e18+500;
const int sz=1e3+100;
struct node
{
    int first,second,cost;
};
node ara[50];
int n,a,b;
int dp[45][500][500];
bool Check(int x,int y)
{
    if(x<=0 || y<=0) return false;
    int gc=__gcd(x,y);
    x/=gc,y/=gc;
    if(x==a && b==y)  return true;
    else return false;
}
int cholo(int id,int tota,int totb)
{
    if(id>=n){
        if(Check(tota,totb)) return 0;
        else return Max;
    }
    int &ret=dp[id][tota][totb];
    if(~ret)  return ret;
    int mx=ara[id].cost+cholo(id+1,tota+ara[id].first,totb+ara[id].second);
    mx=min(mx,cholo(id+1,tota,totb));
    return (ret=mx);
}
int main()
{
    Khela
    int c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n>>a>>b)
    {
        for(i=0;i<n;i++) cin>>ara[i].first>>ara[i].second>>ara[i].cost;
        memset(dp,-1,sizeof dp);
        int ans=cholo(0,0,0);
        if(ans>=Max) cout<<"-1"<<endl;
        else cout<<ans<<endl;

    }





}

Measured memory_bytes: 44160
#include<bits/stdc++.h>
using namespace std;
int main()
{
	double a,b,x;
	cin>>a>>b>>x;
	double volume=a*a*b;
	if(x<=(volume/2))
	{
		double ans= (2*x)/(b*b*a);
		ans=atan(ans);
		ans= acos(-1)/2 - ans;
		ans= ans*180/acos(-1);
		cout<<fixed<<setprecision(10)<<ans<<"\n";
	}
	else
	{
		//cout<<"diff\n";
		double ans=2*(a*a*b-x)/(a*a*a);
		ans=atan(ans);
		ans=ans*180/acos(-1);
		cout<<fixed<<setprecision(10)<<ans<<"\n";
	}
	
}


Measured memory_bytes: 256
# coding: utf-8
# Here your code !

def func():
    try:
        line = input()
    except:
        print("input error")
        return -1
        
    marks = ("S","H","C","D")
    cards = []
    while(True):
        try:
            line = input().rstrip()
            elements = line.split(" ")
            if(elements[0] in marks):
                elements[1]=int(elements[1])
                cards.append(elements)
            else:
                print("1input error")
                return -1
        except EOFError:
            break
        except :
            print("input error")
            return -1
    
    result=""
    for mark in marks:
        for i in range(1,14):
            if([mark,i] not in cards):
                result += mark+" "+str(i)+"\n"
    if(len(result)>0):
        print(result.rstrip())
func()

Measured memory_bytes: 7632
# AGC037A - Dividing a String
def main():
    S = input().rstrip()
    ans, prev, cur = 0, "", ""
    for s in S:
        cur += s
        if cur != prev:
            ans += 1
            prev, cur = cur, ""
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3500
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define repe(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repi(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
void out(pair<int, int> a) {
	rep(i, abs(a.first)) {
		if (a.second == 'U') {
			cout << (a.first >= 0 ? "U" : "D");
		}
		else {
			cout << (a.first >= 0 ? "R" : "L");
		}
	}
}
int main() {
	int a, b;
	char c;
	cin >> a >> c >> b;
	cout << (c == '+' ? a + b : a - b);
	return 0;
}

Measured memory_bytes: 256
import itertools

N = int(input())
d = len(str(N))
choices = [7, 5, 3]

c=0
for _d in range(1, d+1):
    pats = list(itertools.product(choices, repeat=_d))
    for pat in pats:
        if not (7 in pat and 5 in pat and 3 in pat):
            continue

        n = 0
        for p in pat:
            n = 10*n + p
        if n <= N:
            c += 1
print(c)

Measured memory_bytes: 6756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <unordered_map>

using namespace std;

typedef long long ll;

ll gcd(ll m, ll n) {
	if (m == 0 || n == 0)
    return 0;

	// ユークリッドの方法
	while( m != n ) {
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}

int main(void) {
  int N; cin >> N;
  vector<ll> A(N);
  vector<bool> used(N, false);
  for (int i = 0; i < N; i++) { cin >> A[i]; }

  ll ans = gcd(A[0], A[1]);
  used[0] = used[1] = true;
  for (int i = 2; i < N; i++) {
    if (A[i] % A[0] == 0 || A[i] % A[1] == 0)
      used[i] = true;
  }

  // remove Ai s.t. Ai % A[0] == 0 or Ai % A[1] == 0
  for (int i = 2; i < N; i++) {
    if (!used[i]) {
      ans = gcd(ans, A[i]);
      used[i] = true;
      for (int k = i + 1; k < N; k++) {
        if (A[k] % ans == 0) {
          used[k] = true;
        }
      }
    }
  }
  cout << ans << endl;
}


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

int main() {

	int N, D;
	int range;
	double division;
	int man;


	cin >> N >> D;
	range = D * 2 + 1;

	division = N / range;

	man = (N + (range - 1)) / range;
	
	
	cout << man << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
X_list = list(map(int, input().split()))
tmp = X_list.copy()

tmp.sort()
a = tmp[int(N/2)-1]
b = tmp[int(N/2)]
for i in range(N):
    if(X_list[i] <= a):
        print(b)
    else:
        print(a)

Measured memory_bytes: 30776
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli unsigned long long int
#define MOD 1000000007
#define DEBUG 0
#define REP(i,n) for(int i=0;i<n;i++)
 
 
int main(){

	lli n,m;
	cin>>n>>m;
	vector<lli> x(n),y(m);
	REP(i,n)cin>>x[i];
	REP(i,m)cin>>y[i];

	lli xSum=0;
	lli ySum=0;
	lli before=0,after=0;
	/*最初*/
	REP(i,n)xSum += x[i]-x[0];
	REP(i,m)ySum += y[i]-y[0];
 	
 	/*xについて足しまくる*/
 	before = xSum;
 	if(DEBUG)cout<<"xStart"<<endl;
 	if(DEBUG)cout<<before<<endl;
 	for(lli i=1;i<n-1;i++){
 		after = before - (x[i]-x[i-1])*(n-i);
 		xSum += after;
 		xSum %=MOD;
 		if(DEBUG)cout<<after<<endl;
 		before = after;
 	}

 	before = ySum;
 	 if(DEBUG)cout<<"yStart"<<endl;
 	 if(DEBUG)cout<<before<<endl;
 	for(lli i=1;i<m-1;i++){
 		after = before -(y[i]-y[i-1])*(m-i);
 		ySum += after;
 		ySum %=MOD;
 		if(DEBUG)cout<<after<<endl;
 		before = after;
 	}
 	if(DEBUG)cout<<xSum<<" "<<ySum<<endl;
 	cout<<(xSum%MOD)*(ySum%MOD)%MOD<<endl;

	return 0;
 
}

Measured memory_bytes: 1792
import java.util.Scanner;

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

		int H = 0;
		int W = 0;
		
		while ( true ) {
		
			H = sc.nextInt ();
			W = sc.nextInt ();

			if ( H == 0 && W == 0 ) {
				break;
			}

			for ( int i = 0; i < H; i++ ) {
				for ( int j = 0; j < W; j++ ) {
					System.out.print ( "#" );
				}
				System.out.print ( "\n" );
			}
			System.out.println ();
		}
	}
}

Measured memory_bytes: 37960
#include<stdio.h>
#include<stdlib.h>
int n,m,i,f[10000][2],a;

int cmp(const void *a,const void *b)
{
	return ((int*)a)[0]-((int*)b)[0];
}

int main()
{
	for(;scanf("%d%d",&n,&m),n;)
	{
		int r[501]={0},x[501]={0};
		for(i=0;i<m;i++)
			scanf("%d%d",&f[i][0],&f[i][1]);
		qsort(f,m,sizeof(int[2]),cmp);

		for(i=a=0;f[i][0]==1;i++)
			r[f[i][1]]=1,x[f[i][1]]=1;
		for(;i<m;i++)
		{
			if(r[f[i][0]]&&!x[f[i][1]])
				x[f[i][1]]=1;
			else if(r[f[i][1]]&&!x[f[i][0]])
				x[f[i][0]]=1;
		}
		for(i=a=0;i<=n;i++)
			if(x[i])
				a++;
		printf("%d\n",a);
	}

	return 0;
}

Measured memory_bytes: 796
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

typedef pair<int, int> pii;
const int N = 102;
const int logN = 17;

template<typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}

pii p[N], cur;
int n;
ll res = 0;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    Cin(n);
    for(int i = 1; i <= n; ++i) Cin(p[i].fi, p[i].se);
    sort(p + 1, p + n + 1, [](const pii& x, const pii& y) {
            return atan2(x.fi, x.se) < atan2(y.fi, y.se);
         });
    for(int i = 1; i <= n; ++i) {
        cur = p[i]; res = max(res, 1ll * cur.fi * cur.fi + 1ll * cur.se * cur.se);
        for(int j = (i < n? i + 1: 1); j != i; j = (j < n? j + 1: 1)) {
            cur.fi += p[j].fi; cur.se += p[j].se;
            res = max(res, 1ll * cur.fi * cur.fi + 1ll * cur.se * cur.se);
        }
    }
    cout << fixed << setprecision(11);
    cout << sqrt((long double)res);
}


Measured memory_bytes: 512
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
    int N;
    char w[100][12];
    cin >> N;
    int i;
    for(i = 0; i < N; i++){
        cin >> w[i];
    }
    
    int j;
    for(i = 1; i < N; i++){
        if(w[i - 1][strlen(w[i - 1]) - 1] != w[i][0]){
            cout << "No" << endl;
            return 0;
        }
        for(j = 0; j < i; j++){
            if(!strcmp(w[j], w[i])){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yes" << endl;
    
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> data(n);
  for(int i=0; i<n; i++){
    cin >> data.at(i);
  }
  
  int count = 0;
  
  for(int i=1; i<n-1; i++){
    int a,b,c;
    a = data.at(i-1);
    b = data.at(i);
    c = data.at(i+1);
    
    if(a < b && b < c) count++;
    if(c < b && b < a) count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
void read(int &x){
	char ch;bool ok;
	for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
	for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
#define rg register
const int maxn=2e5+10;
int n,a[maxn],b[maxn];
bool check(int x){
	int sum=0;
	for(rg int i=1;i<=n;i++){
		b[i]=a[i]>=x;
		if(b[i])sum++;
		else sum--;
	}
	bool flag=0;
	for(rg int i=1;i<n;i++)if(b[i]==b[i+1])flag=1;
	if(!flag)return sum>0;
	int now=(n+1)>>1,now1=now;
	while(now1>1){
		if(b[now]==b[now+1])return b[now];
		if(b[now1]==b[now1-1])return b[now1];
		now++,now1--;
	}
}
int main(){
	read(n);n=(n<<1)-1;
	for(rg int i=1;i<=n;i++)read(a[i]);
	int l=1,r=n;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid))l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",r);
}


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

#define F first
#define S second
#define pb push_back
#define ld  double
#define ll long long
#define int long long

using namespace std;

const int MAXN = 101 * 1001 , MOD = 1e9 + 7 , sq = 333  ;


int a[MAXN] , cnt[MAXN];

int32_t main()
{
   ios::sync_with_stdio(0);cin.tie(0);
   int n ;
   cin >> n ;
   for(int i = 0  ; i < n ; i ++ )
    cin >> a[i] , cnt[a[i]] ++ ;
   int ans = 1 ;
   for(int i = 0 ; i < n / 2 ; i ++ )
    ans = ans * 2 % MOD ;
   if(cnt[0]!=(n&1))
    return cout<<0,0;
   if(n&1)
   {
       for(int i = 2 ; i < n ; i += 2 )
        if(cnt[i]!=2)
            return cout<<0,0;
   }
   else
   {
       for(int i = 1 ; i < n ; i += 2 )
        if(cnt[i]!=2)
            return cout<<0,0;
   }
   cout<<ans;


}


Measured memory_bytes: 1920
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
 
class Program
{
    static void Main(string[] args)
    {
        int N = ReadLineParseInt();
        long ans = 1;
        for (int i = 0; i < N; i++)
            ans = Lcm(ans, long.Parse(ReadLine()));
        WriteLine(ans);
    }
    static long Gcd(long n, long m)
    {
        if (n < m) return Gcd(m, n);
        while(m != 0)
        {
            long r = n % m;
            n = m;
            m = r;
        }
        return n;
    }
    static long Lcm(long n, long m)
    {
        return n / Gcd(n, m) * m;
    }
    static int ReadLineParseInt() => int.Parse(ReadLine());
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int n, k;
    cin >> n >> k;
    cout << ((n % k) ? 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	lnt n,m,k;
	std::cin >> n >> m >> k;
	std::vector<lnt> a(n),b(m);
	rep(i,n) std::cin >> a[i];
	rep(i,m) std::cin >> b[i];
	std::vector<lnt> ac(n+1,0),bc(m+1,0);
	rep(i,n) ac[i+1]=ac[i]+a[i];
	rep(i,m) bc[i+1]=bc[i]+b[i];
	lnt max=0;
	rep(i,n+1) {
		lnt count=i;
		if(k<ac[i]) continue;
		auto it = std::lower_bound(all(bc),k-ac[i]);
		if(it==bc.end()) {
			count+=m;
		} else if(*it==k-ac[i]) {
			count+=it-bc.begin();
		} else {
			count+=it-bc.begin()-1;
		}
		max=std::max(max,count);
	}
	print(max);
}


Measured memory_bytes: 9532