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

using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u)
{
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u)
{
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main()
{
    int n, i, x;
    string com;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 26752
using System;

namespace AOJ.Volume1
{
    public class DayCount
    {
        public static void Main()
        {
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                if (input[0] == "-1") { break; }

                int y1 = int.Parse(input[0]);
                int m1 = int.Parse(input[1]);
                int d1 = int.Parse(input[2]);

                int y2 = int.Parse(input[3]);
                int m2 = int.Parse(input[4]);
                int d2 = int.Parse(input[5]);

                var date1 = new DateTime(y1, m1, d1);
                var date2 = new DateTime(y2, m2, d2);
                var span = date2 - date1;
                Console.WriteLine(span.Days);
            }
        }
    }
}

Measured memory_bytes: 9284
int(input())
s = list(input())
ans = 0
for i in range(10):
    if str(i) in s:
        ss = s[s.index(str(i))+1:]
        for j in range(10):
            if str(j) in ss:
                sss = ss[ss.index(str(j))+1:]
                for k in range(10):
                    if str(k) in sss:
                        ans += 1
print(ans)

Measured memory_bytes: 10260
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func newSplitScanner(r io.Reader) *bufio.Scanner {
	sc := bufio.NewScanner(r)
	sc.Split(bufio.ScanWords)
	return sc
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	//
	//	str := `
	//1
	//1000000000
	//`
	//	var sc = newSplitScanner(strings.NewReader(str))

	var sc = newSplitScanner(os.Stdin)
	N := nextInt(sc)
	H := make([]int, N)
	for i := 0; i < N; i++ {
		H[i] = nextInt(sc)
	}

	fmt.Println(solve(N, H))
}

func solve(N int, H []int) string {
	for i := len(H) - 1; i > 0; i-- {
		a := H[i-1] - H[i]
		if a >= 2 {
			return "No"
		} else if a == 1 {
			H[i-1]--
		}
	}
	return "Yes"
}

Measured memory_bytes: 3072
#include <iostream>

using namespace std;

int main(){
  int n;
  cin>>n;
  n=n%10;
  if(n==2 || n==4 ||n==5 ||n==7 ||n==9){cout<<"hon";}
  else if(n==0 || n==1 || n==6 || n==8){cout<<"pon";}
  else if(n==3){cout<<"bon";}
}

Measured memory_bytes: 3588
# B問題
N, L = map(int, input().split())
lst = []
for i in range(N):
    lst.append(L + i)
if L > 0:
    lst = lst[1:]
    print(sum(lst))
elif 0 in lst:
    print(sum(lst))
else:
    lst = lst[:-1]
    print(sum(lst))

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

int main() {
    int a, b, sum;
    while (cin >> a >> b) {
        int divisor = 10, digit = 1;
        sum = a + b;

        do {
            if ((sum / divisor) != 0) {
                digit++;
                divisor *= 10;
            }
            else if ((sum / divisor) == 0)
                break;
        } while (1);

        cout << digit << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
#define ioFix ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

long long madd(long long x, long long y, long long modulo) {
  return (x + y) % modulo;
}

long long mmult(long long x, long long y, long long modulo) {
  return (x * y) % modulo;
}

long long mpow(long long base, long long exponent, long long modulo) {
  long long res = 1;
  for(int i = 0; i < exponent; i++)
    res = (res * base) % modulo;
  return res;
}

long long mfac(long long n, long long modulo) {
  long long res = 1;
  for(int i = 2; i <= n; i++)
    res = (res * i) % modulo;
  return res;
}

// Slower, DP approach
// long long mcombDP(long long n, long long k, long long modulo) {
//   long long C[k+1];
//   memset(C, 0, sizeof(C));
//   C[0] = 1;

//   for(long long i = 1; i <= n; i++)
//     for(long long j = min(i, k); j > 0; j--)
//       C[j] = (C[j] + C[j - 1]) % modulo;
//   return C[k];
// }

// Lucas theorem
// long long mcomb(long long n, long long k, long long modulo) {
//   if(k == 0)
//     return 1;

//   return (
//           mcomb(n / modulo, k / modulo, modulo) *
//           mcombDP(n % modulo, k % modulo, modulo)
//           ) % modulo;
// }


#define PI (2.0 * acos(0.0))
#define INF (int)1e9
#define LINF (long long)1e18
#define EPS 1e-9

#define ll long long
#define ull unsigned long long

#define pii pair<int, int>
#define pll pair<long long, long long>
#define pdd pair<double, double>
#define pcc pair<char, char>
#define pbb pair<bool, bool>

#define vi vector<int>
#define vvi vector<vector<int>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vvs vector<vector<string>>

#define REP(n) for(int xix = 0; xix < (n); xix++)
#define FOR(i, from, to) for(int (i) = from; (i) < (to); (i)++)
#define RANGE(i, from, to) for(int (i) = from; (i) <= (to); (i)++)
#define ALL(x) x.begin(),x.end()

#define pb push_back
#define mp make_pair
#define mt make_tuple

#define fillArray(arr, val) std::fill(std::begin(arr), std::end(arr), (val))

#define pow2(x) ((x)*(x))
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))

#define watch(x) cout << (#x) << " is " << (x) << endl
#define watchVector(v) { for(int xvx = 0; xvx < (v).size(); xvx++) { cout << (v)[xvx] << " "; } cout << endl; }
#define watchArray(arr, n) { for(int xax = 0; xax < (n); xax++) { cout << (arr)[xax] << " "; } cout << endl; }
#define watchMatrix(x, rows, cols) for(int r = 0; r < (rows); r++) { for(int c = 0; c < (cols); c++) { cout << (x)[r][c] << " "; } cout << endl; }



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


int main() {
  ioFix;
  ll A, B, C;
  cin >> A >> B >> C;
  cout << B + min(C, A+B+1) << endl;
}


Measured memory_bytes: 256
//1_5A	15???
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main(void) {
	char tmp[1000];
	//????????¢???????¨?
	int height[300];
	int width[300];
	int cnt = 0;
	//????????¢???????¨??????\???????¶???????
	while (1) {
		fgets(tmp, sizeof(tmp), stdin);
		height[cnt] = atoi(strtok(tmp, " "));
		width[cnt] = atoi(strtok(NULL, " "));
		//????????¨???0????????°?????????
		if (height[cnt] == 0 && height[cnt] == 0)break;
		cnt++;
	}
	//??¨??????????§???¢???????????????
	int i, j, k;
	for (i = 0; i < cnt; i++) {
		for (j = 0; j < height[i]; j++) {
			for (k = 0; k < width[i]; k++) {
				if((k+j)%2==0)printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");

	}
	return 0;
}

Measured memory_bytes: 524
#include<iostream>
using namespace std;
int main(){
	int a=0;
	cin>>a;
	int ans=0;
	int p=1;
	for(;;){
		p=p<<1;
		if(p<=a){
			ans=p;
		}else{
			break;
		}
	}
	if(ans==0)ans=a;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N, L = list(map(int,input().split()))

n = [i for i in range(1,N+1)]

l = [abs(i) for i in range(L,N+L)]

l2 = [i for i in range(L,N+L)]

l2.pop(l2.index(l2[l.index(min(l))]))
ans = sum(l2)    

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};

int f[1000001]={};
ll a[200002]={};
ll r=1000000;

int main() {

	ll n;
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);

	ll ans=0;
	rep(i,n){
		if(f[a[i]]==1)continue;
		if(a[i]==a[i+1])ans--;

		ll t=0;
		while(t<r){
			t+=a[i];
			if(t<=r)f[t]=1;
		}
		ans++;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 8996
#include<iostream>
#include<stdio.h>
#include<cctype>
#include<string>
using namespace std;
int main() {
	int  q, a, b, sub;
	string str, str2, str3, str4, command;
	cin >> str;
	cin >> q;
	str2 = str;

	for (int x = 0; x < q; x++) {

		cin >> command;

		if (command == "print") {
			cin >> a >> b;
			sub = b - a ;
			cout << str.substr(a , sub+1) << endl;
		}
		else if (command == "reverse") {
			str3 = str;
			cin >> a >> b;

			sub = b - a ;

			for (int y = 0; y <= sub/2; y++) {
				swap(str[a+y ], str[b-y]);

			}
		
			
		}
		else if (command == "replace") {
			cin >> a >> b;
			cin >> str4;
			for (int y = 0; y<= b-a; y++) {
				str[a + y] = str4[y];
			}
			
		}



	}


	return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
const double PI = acos(-1.0);
const long mod = 1000000007;

int main() {
  int n;
  cin >> n;
  for(int i = n/1.1; i <= n; i++) {
    if((int)(i*1.08) == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int N;
    cin >> N;

    int rs = 0;
    int n = 0;
    REP(i, N) {
        int a;
        cin >> a;

        if (a >= 3200) {
            ++n;
            continue;
        }

        rs |= (1 << int(floor(a / 400)));
    }

    int result = 0;
    REP(i, 8) {
        result += (rs >> i) % 2;
    }

    cout << max(1, result) << " " << result + n << endl;

}


Measured memory_bytes: 256
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;



//#[proconio::fastout]
fn main() {
    input! {
        mut v0: Bytes,
    }

    let mut v = vec![0u8,0u8];
    v.append(&mut v0);

    // "aaaaa" は aa-a-aa
    let len = v.len();
    let mut dp1 = vec![0;len+1]; // dp1[i] : [0,i) をdp1[i]個の文字列に分割できる。その最後の文字列は v[i-1..i]
    let mut dp2 = vec![0;len+1]; // dp2[i] : [0,i) をdp2[i]個の文字列に分割できる。その最後の文字列は v[i-2..i]
    dp1[2] = 0;
    dp1[3] = 1;
    dp2[2] = 0;
    dp2[3] = 0;
    for i in 4..=len {
        if v[i-1] != v[i-2] {
            dp1[i] = max(dp1[i-1],dp2[i-1])+1;
        } else {
            dp1[i] = dp2[i-1]+1;
        }

        if v[i-2..i] != v[i-4..i-2] {
            dp2[i] = max(dp1[i-2],dp2[i-2])+1;
        } else {
            dp2[i] = dp1[i-2]+1;
        }
    }

    println!("{}", max(dp1[len],dp2[len]));
}


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

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for(int i = 0; i < h;i++){
		cin >> a[i];
	}
	
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			int cb = 0, cf = 0;
			if(a[i][j] == '.') continue;
			if(i > 0){
				if(a[i-1][j] == '#'){
					cb++;
				}
			}
			if(i < h-1){
				if(a[i+1][j] == '#'){
					cf++;
				}
			}
			if(j > 0){
				if(a[i][j-1] == '#'){
					cb++;
				}
			}
			if(j < w-1){
				if(a[i][j+1] == '#'){
					cf++;
				}
			}
			if(i == 0 && j == 0){
				cb = 1;
			}
			if(i == h - 1 && j == w - 1){
				cf = 1;
			}
			if(cb != 1 || cf != 1){
				cout << "Impossible" << endl;
				return 0;
			}
		}
	}
	
	cout << "Possible" << endl;
	
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc159/tasks/abc159_e

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 0
#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int H_MAX = 10;
const int W_MAX = 1000;
const int INF = 1e6;

int H, W, K;
vector<string> S;

vector<vector<int>> acc;

int main() {
  cin >> H >> W >> K;
  S = vector<string>(H);
  REP(i, H) cin >> S[i];

  acc = vector<vector<int>>(H + 1, vector<int>(W + 1, 0));
  REP(i, H) REP(j, W) acc[i + 1][j + 1] = (S[i][j] == '1') + acc[i + 1][j] + acc[i][j + 1] - acc[i][j];
  DUMP2D(acc);

  int ans = INF;

  int T = 1 << (H - 1);
  REP(t, T) {
    vector<int> hs;
    hs.push_back(0);
    REP(i, H - 1) if ( t  >> i & 1) hs.push_back(i + 1);
    hs.push_back(H);
    DUMP(hs);

    int div = hs.size() - 2;
    int l = 0;
    FOR(r, 1, W) {
      bool impossible = false;
      REP(i, hs.size() - 1) {
        int u = hs[i];
        int d = hs[i + 1];
        int w = acc[d][r] - acc[u][r] - acc[d][l] + acc[u][l];
        if (w > K) {
          if (r == l + 1) {
            impossible = true;
          } else {
            div++;
            l = r - 1;
          }
          break;
        }
      }
      if (impossible) {
        div = INF;
        break;
      }
    }
#if DEBUG
    cout << "div : " << div << endl;
#endif
    ans = min(ans, div);
 }

  cout << ans << endl;
}


Measured memory_bytes: 3724
#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;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) "FUCK YOU"
#endif
	

const int mod=1e9+7;
#define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);
const int N=500006;


void solve()
{
	vi a(5);
	cin>>a;
	int ans=1e9;
	sort(all(a));
	do
	{
    int cur=0;
	for(int i=0;i<5;i++)
	{
		cur+=a[i];
		if(i!=4&&a[i]%10)cur+=10-a[i]%10;
		}
		ans=min(ans,cur);
		}while(next_permutation(all(a)));
		cout<<ans;
}




signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc=1;
	//~ cin>>tc;	
	for(int i=0; i<tc; i++)
	{
		solve();
	}

}


int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}

void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	if(a<0)a+=mod;
}
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P=pair<int,int>;
int main() {
    int n;cin>>n;
    vector<int> s(n);
    int sum=0;
    vector<int> rest(0);
    rep(i,n){
        cin>>s[i];
        if(s[i]%10==0) sum+=s[i];
        else rest.push_back(s[i]);
    }
    int rest_sum=0;
    if(rest.size()==0) cout<<0<<endl;
    else{
        rep(i,rest.size()){
            rest_sum+=rest[i];
        }

        if(rest_sum%10!=0) sum+=rest_sum;
        else{
            sort(rest.begin(),rest.end());
            rest_sum-=rest[0];
            sum+=rest_sum;
        }
        cout<<sum<<endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    long long vec[a-1];
    for(int i=0;i<a;i++) cin>>vec[i];
    long long max=vec[0],min=vec[0];
    for(int i=0;i<a;i++){
        if(max<vec[i]) max=vec[i];
        if(min>vec[i]) min=vec[i];
    }
    cout<<max-min<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <string>
#include <queue>
#include <cmath>

using namespace std;

int main(){
  int n,a,b,c,i,j,k;
  string s;
  cin >> n;
  long long x[n],y[n],ret=0,ret2=0;
  for(i=0;i<n;i++){
    cin >> x[i];
    y[i]=x[i];
  }
  sort(x,x+n);
  sort(y,y+n);
  reverse(y,y+n);
  for(i=0;i<n/2;i++){
    ret+=y[i]-x[i];
    //cout << y[i]-x[i] << endl;
    if(i!=0){
      ret+=y[i]-x[i-1];
      //cout << y[i]-x[i-1] << endl;
    }
  }
  if(n%2==0){
    ret+=y[0]-x[n/2-1];
    ret-=y[n/2-1]-x[n/2-1];
  }
  else {
    long long l;
    if(y[0]-x[n/2]>y[n/2]-x[n/2-1])ret+=y[0]-x[n/2];
    else ret+=y[n/2]-x[n/2-1];
    //ret+=abs(y[0]-x[n/2]);
  }
  //2pat
  for(i=0;i<n/2;i++){
    ret2+=y[i]-x[i];
    //cout << y[i]-x[i] << endl;
    if(i!=0){
      ret2+=y[i-1]-x[i];
      //cout << y[i]-x[i-1] << endl;
    }
  }
  if(n%2==0){
    ret2+=y[n/2-1]-x[0];
    ret2-=y[n/2-1]-x[n/2-1];
  }
  else {
    long long l;
    if(y[n/2]-x[0]>y[n/2-1]-x[n/2])ret2+=y[n/2]-x[0];
    else ret2+=y[n/2-1]-x[n/2];
    //ret+=abs(y[0]-x[n/2]);
  }
  cout << max(ret,ret2) << endl;
  return 0;
}


Measured memory_bytes: 1792
# AOJ 0004 Simultaneous Equation
# Python3 2018.6.9 bal4u
 
EPS = 0.0001
while True:
    try:
        a = list(map(float, input().split()))
        dd = a[0]*a[4]-a[3]*a[1]
        d1 = a[2]*a[4]-a[5]*a[1]
        d2 = a[0]*a[5]-a[3]*a[2]
        print("{0:.3f} {1:.3f}".format(d1/dd+EPS, d2/dd+EPS))
    except EOFError:
        break


Measured memory_bytes: 5584
long gcd(a,b)long a,b;{return b?gcd(b,a%b):a;}
const long mod=1e9+7;
long pow(a,b)long a,b;{return b?pow(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
struct X{long A,B;int f}A[2<<17];
O=mod-1;
cmp(a,b)struct X*a,*b;{
	long dA=a->A-b->A,dB=a->B-b->B;
	return dA?dA<0?-1:1:dB?dB<0?-1:1:0;
}
main(N)
{
	scanf("%d",&N);
	int sz=0;
	for(int i=0;i<N;i++)
	{
		long a,b;scanf("%ld%ld",&a,&b);
		if(!a&&!b)O++;
		else
		{
			long g=gcd(a,b);
			a/=g;b/=g;
			if(a<0)
			{
				a=-a;
				b=-b;
			}
			int f=0;
			if(a==0)
			{
				a=1;
				b=0;
				f=1;
			}
			else if(b<0)
			{
				long t=a;
				a=-b;
				b=t;
				f=1;
			}
			A[sz].A=a;
			A[sz].B=b;
			A[sz].f=f;
			sz++;
		}
	}
	qsort(A,sz,sizeof(struct X),cmp);
	long ans=1;
	for(int i=0;i<sz;)
	{
		int c[2]={};
		int j=i;
		while(i<sz&&A[i].A==A[j].A&&A[i].B==A[j].B)
		{
			c[A[i++].f]++;
		}
		ans=ans*(pow(2,c[0])+pow(2,c[1])-1)%mod;
	}
	printf("%d\n",(ans+O)%mod);
}

Measured memory_bytes: 10692
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

vector<vector<int>> G;
vector<int> du,dv;
int N,u,v;
void input(){
    cin>>N>>u>>v;
    u--;v--;
    G.resize(N);du.assign(N,-1);dv.assign(N,-1);
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
}
void bfs(int start, vector<int> &d){
    d[start] = 0;
    queue<int> q;
    q.push(start);
    while(!q.empty()){
        int x = q.front();
        q.pop();
        for(int nv:G[x]){
            if(d[nv] != -1)continue;
            d[nv] = d[x] + 1;
            q.push(nv);
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    input();
    bfs(u,du);
    bfs(v,dv);
    //print(du);
    //print(dv);
    if(G[u].size() == 1){
        for(int nv:G[v]){
            if(nv == G[u][0]){
                cout<<1<<endl;
                return 0;
            }
        }
    }
    if(G[u].size() == 1 && G[u][0] == v){
        cout<<0<<endl;
        return 0;
    }
    //du[i] < dv[i]最大のdv[i]であるところで捕まるべき
    int ans = 0;
    rep(i,N){
        if(du[i] < dv[i]){
            if(du[i] % 2 == dv[i] % 2){
                chmax(ans, dv[i]-1);
            }
            else{
                chmax(ans, dv[i]-1);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6656
#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 erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  int a,b,q;
  cin >> a >> b >> q;
  vint S(a),T(b),ST;
  rep(i,0,a){
    cin >> S[i];
  }
  rep(i,0,b){
    cin >> T[i];
  }
  vint SV(a),TV(b);
  rep(i,0,a){
    if(T[b-1] < S[i]){
      SV[i] = abs(S[i] - T[b-1]);
    }
    else{
      int l = lower_bound(T.begin(),T.end(),S[i]) - T.begin();
      if(l == 0){
        SV[i] = abs(S[i] - T[l]);
      }
      else{
        SV[i] = min(abs(S[i] - T[l]),abs(S[i] - T[l-1]));
      }
    }
  }
  rep(i,0,b){
    if(S[a-1] < T[i]){
      TV[i] = abs(T[i] - S[a-1]);
    }
    else{
      int l = lower_bound(S.begin(),S.end(),T[i]) - S.begin();
      if(l == 0){
        TV[i] = abs(T[i] - S[l]);
      }
      else{
        TV[i] = min(abs(T[i] - S[l]),abs(T[i] - S[l-1]));
      }
    }
  }
  //rep(i,0,b) cout << TV[i] << endl;
  rep(i,0,q){
    int ans = INF;
    int A;
    cin >> A;
    if(S[a-1] < A){
      ans = min(ans,abs(S[a-1] - A) + SV[a-1]);
      // cout << ans << endl;
    }
    else{
      int l = lower_bound(S.begin(),S.end(),A) - S.begin();
      ans = min(ans,abs(S[l] - A) + SV[l]);
      if(l != 0){
        ans = min(ans,abs(S[l-1] - A) + SV[l-1]);
      }
      // cout << ans << endl;
    }
    if(T[b-1] < A){
      ans = min(ans,abs(T[b-1] - A) + TV[b-1]);
      // cout << ans << endl;
    }
    else{
      int l = lower_bound(T.begin(),T.end(),A) - T.begin();
      ans = min(ans,abs(T[l] - A) + TV[l]);
      if(l != 0){
        ans = min(ans,abs(T[l-1] - A) + TV[l-1]);
      }
      // cout << ans << endl;
    }
    cout << ans << endl;
  }

}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
int main(void){
  
  long long X; 	 //最大100000
  cin >> X;
  
  long long wari = X / 100;
  long long amari = X % 100;
  
  
  //cout << wari << endl;
  //cout << amari << endl;
  
  //1～5をwari回足して、amariになれば1、無理なら0を出力
  //例えば432ならamariは32であるが、これをどのように1-5でwari回足せば32になるか。
  
  //5 * wariがamariより小さければ絶対に無理である。
  if(amari == 0)
  {
    cout << 1;		//余りが0の場合　100で割り切れるということなので可能（1）
  }  
  else if(5 * wari < amari)
  {
    cout << 0;
  }
  else
  {
    cout << 1;
  } 
  
  //余りは0～99である。
  //90000の場合　
  
  //216は無理だが、20216は？どこかに可能になる分岐がある。
  //1000～1099の範囲は、1001や1002でも可能だが、1010～1050しか無理な条件式になっている。
  
      
  return 0;
}

Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mInt = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000



int main(){
	
	int N,D;
	cin>>N>>D;
	
	vector<int> X(2*N);
	rep(i,2*N)cin>>X[i];
	
	two_sat S(2*N);
	
	rep(i,N){
		S.add_clause(i*2,true,i*2+1,true);
		S.add_clause(i*2,false,i*2+1,false);
	}
	
	rep(i,2*N){
		rep(j,2*N){
			if(i<j&&abs(X[i]-X[j])<D){
				S.add_clause(i,false,j,false);
			}
		}
	}
	
	if(S.satisfiable()){
		cout<<"Yes"<<endl;
		vector<bool> ans = S.answer();
		rep(i,ans.size()){
			if(ans[i])cout<<X[i]<<endl;
		}
	}
	else{
		cout<<"No"<<endl;
	}
	
    return 0;
}

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

using namespace std;
using ll = long long int;
ll ara[100005][2],cum[100005],p[100005];

int main()
{
    ll n,m,i,j;
    scanf("%I64d %I64d",&n,&m);
    for(i=1; i<=m; i++)
    {
        scanf("%I64d %I64d",&ara[i][0],&ara[i][1]);
        cum[ara[i][0]]++;
        cum[ara[i][1]+1]--;
    }
    for(i=1; i<=n; i++)
    {
        cum[i]+=cum[i-1];
    }
    ll ans=0;
    for(i=1; i<=n; i++)
    {
        if(cum[i]==m) ans++;
    }
    printf("%I64d\n",ans);


}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int b){
    if(a%b == 0){
        return b;
    }else{
    return gcd(b, a%b);
    }
}

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(max(a*c,a*d),max(b*c,b*d)) << endl;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long H, W; cin >> W >> H;
    vector<long long> p(W);
    vector<long long> q(H);
    priority_queue<long long, vector<long long>, greater<long long>> p_pq;
    priority_queue<long long, vector<long long>, greater<long long>> q_pq;
    for (int i = 0; i < W; i++) {
        cin >> p[i];
        p_pq.push(p[i]);
    }
    for (int i = 0; i < H; i++) {
        cin >> q[i];
        q_pq.push(q[i]);
    }
    p_pq.push(100000000000);
    q_pq.push(100000000000);
    
    long long p_cnt = 0;
    long long q_cnt = 0;
    long long ans = 0;
    for (int i = 0; i < H+W; i++) {
        long long p_top = p_pq.top();
        long long q_top = q_pq.top();
        if (p_top < q_top) {
            ans += p_top * (H - q_cnt + 1);
            p_cnt++;
            p_pq.pop();
        } else {
            ans += q_top * (W - p_cnt + 1);
            q_cnt++;
            q_pq.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4084
n = int(input())
pos = [[int(i) for i in input().split()] for i in range(n)] 

x = 0
y = 0
cur = 0
ans = "Yes"
for i in pos:
  maximum = abs((i[1] - x) + (i[2] - y))
  if maximum > i[0] - cur:
    ans = "No"
    break
  elif maximum % 2 != (i[0] - cur) % 2:
    ans = "No"
    break
  x = i[1]
  y = i[2]
  cur = i[0]
print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> vec(N);
  for (int i = 0; i < N; i++) {
    string city;
    int point;
    cin >> city >> point;
    vec[i] = make_tuple(city, point, 1 + i);
  }
  sort(vec.begin(), vec.end());
  int i = 0;
  while (i < N) {
    if (i == N - 1) {
      int c1 = get<2>(vec[i]);
      cout << c1 << endl;
      break;
    } else {
      string a1 = get<0>(vec[i]);
      string a2 = get<0>(vec[i + 1]);
      if (a1 != a2) {
        cout << get<2>(vec[i]) << endl;
        i++;
      } else {
        int counter = 0;
        for (int j = i; j < N; j++) {
          string a3 = get<0>(vec[j]);
          if (a3 == a1) {
            counter++;
          } else {
            break;
          }
        }
        for (int j = 0; j < counter; j++) {
          int c3 = get<2>(vec[i + counter - 1 - j]);
          cout << c3 << endl;
        }
        i += counter;
      }
    }
  }
  
  return 0;
}

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

int main() {
    int N,M,C;cin >> N >> M >> C;
    int A[N][M] = {};int B[M] = {};
    for (int i = 0;i < M;i++){
        cin >> B[i];
    }
    for (int i = 0;i < N;i++){
        for (int j = 0;j < M;j++){
            cin >> A[i][j];
        }
    }
    int ans = 0;
    for (int i = 0;i < N;i++){
        int sum = 0;
        for (int j = 0;j < M;j++){
            sum += A[i][j] * B[j];
        }
        sum += C;
        if (sum > 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
a, b, Cdeg = map(int, input().split())
Crad = math.radians(Cdeg)
c = (a**2+b**2-2*a*b*math.cos(Crad))**0.5
h = b*math.sin(Crad)
print(0.5*a*h)
print(a+b+c)
print(h)

Measured memory_bytes: 7860
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  string s;
  cin>>s;
  int a,b;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'){
      a=i;
      break;
      }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='Z'){
      b=i;
      break;
    }
  }
    cout<<b-a+1<<endl;
  }

Measured memory_bytes: 640
N,T = map(int,input().split())
t = list(map(int,input().split()))
if N == 1:
  print(T)
  exit()
tmp = T
cnt = 0
ans = 0
for i in range(1,N):
  if tmp >=  t[i]:
    tmp = t[i] + T
  else:
    ans += tmp - cnt
    tmp = t[i] + T
    cnt = t[i]
  if i == N - 1:
    ans += tmp - cnt
print(ans)

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

int main(){

  int tab[11][11], n, low[11], colume[11], sum;

  while(cin >> n){
    if(n == 0) break;
    fill(low, low+11, 0);
    fill(colume, colume+11, 0);
    
    for(int i=0; i<=n; i++){
      sum = 0;
      if(i != n){
        for(int j=0; j<n; j++){
          cin >> tab[i][j];
          sum += tab[i][j];
          low[j] += tab[i][j];
        }
      }
      else{
        for(int j=0; j<n; j++){
          tab[i][j] = low[j];
          sum += low[j];
        }
      }

      tab[i][n] = sum;

    }
    
    for(int i=0; i<=n; i++){
      for(int j=0; j<=n; j++){
        printf("%5d", tab[i][j]);
      }
      cout << endl;
    }
    
  }

  return 0;

}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    int cnt = 0;
    for(int i=0;i<n;i++){
        while(a[i]%2==0){
            cnt++;
            a[i]/=2;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void){

    ll a,b,x; cin>>a>>b>>x;
    ll dai,syo;
    dai = b / x;
    if(a==0) syo = -1;
    else syo = (a-1) / x;
    ll ans = dai-syo;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>
typedef long long ll;
#define inf 100000000
using namespace std;
#define nmax 40
#define abmax 10
int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];


int main(int argc,char const* argv[])
{
  int n,ma,mb;
  cin >> n >> ma >> mb;
  vector<int> a(nmax,0);
  vector<int> b(nmax,0);
  vector<int> c(nmax,0);
  for(int i=0;i<n;i++)
    {
      cin >> a[i] >> b[i] >> c[i];
    }
  for(int i=0;i<=n;i++)
    {
      for(int ca=0;ca<=nmax*abmax;ca++)
	{
	  for(int cb=0;cb<=nmax*abmax;cb++)
	    {
	      dp[i][ca][cb]=inf;
	    }
	}
    }
  dp[0][0][0]=0;
  for(int i=0;i<n;i++)
    {
      for(int ca=0;ca<=nmax*abmax;ca++)
	{
	  for(int cb=0;cb<=nmax*abmax;cb++)
	    {
	      if(dp[i][ca][cb]==inf) continue;
	      dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]);
	      dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
	    }
	}
    }

  int ans=inf;
  for(int ca=1;ca<=nmax*abmax;ca++)
    {
      for(int cb=1;cb<=nmax*abmax;cb++)
	{
	  if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]);
	}
    }
  if(ans==inf) ans=-1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 25984
def read():
    X = int(input())
    return X,

def solve(X):
    if X < 600:
        return 8
    elif X < 800:
        return 7
    elif X < 1000:
        return 6
    elif X < 1200:
        return 5
    elif X < 1400:
        return 4
    elif X < 1600:
        return 3
    elif X < 1800:
        return 2
    else:
        return 1


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 9172
#include<iostream>
#include<stdio.h>
using namespace std;
 
int main(){
  double x,y,r;
  
  cin >> r;
  x = r * r * 3.141592653589;
  y = r * 2 * 3.141592653589;
  printf("%.6lf ",x);
  printf("%.6lf\n",y);

  
      

  return 0;		 
}
		   


Measured memory_bytes: 3172
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
#https://note.nkmk.me/python-union-find/

    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n
    
        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]
    
        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)
    
            if x == y:
                return
    
            if self.parents[x] > self.parents[y]:
                x, y = y, x
    
            self.parents[x] += self.parents[y]
            self.parents[y] = x
    
        def size(self, x):
            return -self.parents[self.find(x)]
    
        def same(self, x, y):
            return self.find(x) == self.find(y)
    
        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]
    
        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]
    
        def group_count(self):
            return len(self.roots())
    
        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}
    
        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    n=I()
    lisx=[]
    lisy=[]
    edge=[]
    for i in range(n):
        x,y=MI()
        lisx.append([x,i])
        lisy.append([y,i])
    lisx.sort(key=lambda x:x[0])
    lisy.sort(key=lambda x:x[0])
    for i in range(n-1):
        edge.append([lisx[i][1],lisx[i+1][1],lisx[i+1][0]-lisx[i][0]])
        edge.append([lisy[i][1],lisy[i+1][1],lisy[i+1][0]-lisy[i][0]])
    edge.sort(key=lambda x:x[2])
    #print(edge)
    ans=0
    uf=UnionFind(n)
    count=0
    for x,y,z in edge:
        if uf.same(x,y):
            continue
        else:
            uf.union(x,y)
            ans+=z
            count+=1
        if count==n-1:
            break
    print(ans)
        
        
    
if __name__=="__main__":
    main()


Measured memory_bytes: 138456
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
#include<bitset>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  cin>>N;
  string S;
  cin>>S;
  ll sum=0;
  for(ll i=1; i<N; ++i){
    if(S[i]=='E') ++sum;
  }
  ll ans = sum;
  for(ll i=1; i<N; ++i){
    if(S[i]=='E') --sum;
    if(S[i-1]=='W') ++sum;
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
  return 0;
}
  
  
  

Measured memory_bytes: 900
program main
      implicit none
      integer(4) :: n, i, j, k, l
      integer(8) :: sumR, sumB, sumG
      integer(8) :: sum
      character(4000) :: s

      read *, n
      read *, s

      sumR = 0
      sumB = 0
      sumG = 0

      do i = 1, n
        if ( s(i:i) == 'R' ) sumR = sumR + 1
        if ( s(i:i) == 'B' ) sumB = sumB + 1
        if ( s(i:i) == 'G' ) sumG = sumG + 1
      end do
      sum = sumR*sumB*sumG

      do i = 1, n-2
        do j = i+1, n-1
          k = 2*j - i
          if ( k > n ) cycle
          if (( s(i:i) /= s(j:j) ) .and. &
                ( s(j:j) /= s(k:k) ) .and. &
                ( s(i:i) /= s(k:k) ) ) then
                sum = sum - 1
          end if
        end do
      end do
      print *, sum

end program main


Measured memory_bytes: 2820
w,h,n=map(int,input().split())
g=[[1]*w for _ in range(h)]
for _ in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        for i in range(h):
            for j in range(x):
                g[i][j]=0
    elif a==2:
        for i in range(h):
            for j in range(x,w):
                g[i][j]=0
    elif a==3:
        for i in range(y):
            for j in range(w):
                g[i][j]=0
    else:
        for i in range(y,h):
            for j in range(w):
                g[i][j]=0
ans=0

for i in range(h):
    for j in range(w):
        ans+=g[i][j]

print(ans)


Measured memory_bytes: 42096
import math
S = str(input())
S=S[0:len(S)-1]
 
if len(S)%2!=0:
	S=S[0:len(S)-1]
 
for i in range (0, int(len(S)/2)):
	N = len(S)
	if S[0:int(N/2)] == S[int(N/2)::]:
		print(2*len(S[0:int(N/2)]))
		exit()	
	else:
		S=S[0:N-2]

Measured memory_bytes: 9048
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            if (S.Count(x => x.ToString() == S.Substring(0, 1)) == S.Count())
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
            Console.ReadLine();
        }
    }
}

public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    REP(i,n){
        cin >> a[i];
        b[i] = fabs(a[i]);
    }

    int minus_cnt = 0;

    REP(i,n){
        if(a[i] < 0){
            minus_cnt++;
        }
    }

    sort(all(b));
    ll ans = 0;
    FOR(i,0,n){
        ans += b[i];
    }

    if(minus_cnt % 2 == 0){
        cout << ans << endl;
    }
    else{
        cout << ans - 2*b[0] << endl;
    }


    return 0;
}

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

using namespace std;
typedef long long LL;

vector<int> ch[100010];
int dp[100010];

int go(int cur) {
    if (dp[cur]>=0) return dp[cur];
    int ret=0;
    for (int i=0;i<ch[cur].size();i++) {
        int v=ch[cur][i];
        ret=max(ret, go(v));
    }
    return dp[cur]=ret+1;
}

int main() {
    int n, m;
    cin>>n>>m;
    for (int i=0;i<100010;i++) {
        ch[i].clear();
    }
    for (int i=0;i<m;i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        ch[x-1].push_back(y-1);
    }
    memset(dp,-1,sizeof(dp));
    int ret=0;
    for (int i=0;i<n;i++) ret=max(ret, go(i));
    cout<<ret-1<<endl;
}

Measured memory_bytes: 8192
x,n = map(int,input().split())
p = list(map(int,input().split()))
if x in p:
    i = 0
    while(True):
        i +=1
        if not(x-i in p):
            print(x-i)
            break
        if not(x+i in p):
            print(x+i)
            break
else:
    print(x)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma optimize("JARU SOSISONI")

using namespace std;

#define int long long
#define fast cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define geometry cout.setf(ios::fixed); cout.precision(15);
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;

const int INF = 1e9 + 100;
const int MOD = 998244353;
const int MOD1 = 1e9 + 7;
const int N = 52;
const int nul = 0;
const int SIZE = 1e6 * 3;

int dp[N][N][N * N];

signed main() {
#ifdef parasha
    freopen("A.in", "r", stdin);
#endif // parasha
    fast;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N * N; k++) dp[i][j][k] = 0;
        }
    }
    int n, A;
    cin >> n >> A;
    vector<int> a(n);
    for (int &i : a) cin >> i;
    for (int i = 0; i < n; i++) {
        for (int sum = 0; sum < N * N; sum++) {
            if (i > 0) dp[i][1][sum] += dp[i - 1][1][sum];
            if (sum == a[i]) dp[i][1][sum]++;
        }
    }
    for (int i = 1; i < n; i++) {
        for (int len = 2; len <= n; len++) {
            for (int sum = 1; sum <= N * N; sum++) {
                dp[i][len][sum] = dp[i - 1][len][sum];
                if (sum >= a[i]) {
                    dp[i][len][sum] += dp[i - 1][len - 1][sum - a[i]];
                }
            }
        }
    }
    int ans = 0;
    for (int len = 1; len <= n; len++) {
        //cout << len << " " << dp[n - 1][len][len * A] << endl;
        ans += dp[n - 1][len][len * A];
    }
    cout << ans << endl;

}


Measured memory_bytes: 60780
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int Y = scanner.nextInt();
        int Z = scanner.nextInt();

        System.out.println(Z + " " + X + " " + Y);
    }
}

Measured memory_bytes: 23636
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Main{
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}                                              
		return ans;
	} 
	static long mod=1000000007;
	static long power(long x,long y) 
    { 
        long res = 1; 
        x = x % mod; 
        while (y > 0) { 
            if (y % 2 == 1) 
                res = (res * x) % mod; 
            y = y >> 1;
            x = (x * x) % mod; 
        } 
        return res%mod; 
    } 
    static long modInverse(long n) 
    { 
        return power(n, mod-2); 
    } 
    static int[]h;
    static int[]t;
    static int[][]dp;
    static int knapsack(int ind,int capacity)
    {
    	if(capacity<1)
    		return 0;
    	if(ind==h.length)
    		return 0;
    	if(dp[ind][capacity]!=-1)
    		return dp[ind][capacity];
    	int res=Math.max(knapsack(ind+1,capacity),h[ind]+knapsack(ind+1,capacity-t[ind]));
    	dp[ind][capacity]=res;
    	return res;
    }
    public static void main(String[] args) throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
        int[]ar=split();
        int n=ar[0];
        int k=ar[1];
        t=new int[n];
        h=new int[n];
        int[][]c=new int[n][2];
        for(int i=0;i<n;i++)
        {
        	ar=split();
        	t[i]=ar[0];
        	h[i]=ar[1];
        	c[i][0]=t[i];
        	c[i][1]=h[i];
        }
        Arrays.sort(c,new Comparator<int[]>(){
        	public int compare(int[]a,int[]b)
        	{
        		return a[0]-b[0];
        	}
        });
        for(int i=0;i<n;i++)
        {
        	t[i]=c[i][0];
        	h[i]=c[i][1];
        }
        dp=new int[n+1][k+1];
        for(int i=0;i<=n;i++)
        {
        	Arrays.fill(dp[i],-1);
        }
        System.out.println(knapsack(0,k));
    }
}

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

static const int MAX_N  = 101;
static const int MAX_NN = 21;

int main()
{

	int n, ans;
	int arr[MAX_N];
	long long table[MAX_N][MAX_NN];

	cin >> n;
	for(int i = 0; i < n - 1; i++) cin >> arr[i];

	// Initalize
	for(int i = 0; i < n - 1; i++) {
		for(int j = 0; j < 21; j++) table[i][j] = 0;
	}

	cin >> ans;

	// DP
	table[0][arr[0]] = 1;

	for(int i = 1; i < n - 1; i++) {
		for(int j = 0; j < 21; j++) {
			if(table[i - 1][j] >= 1) {
				if(j - arr[i] >= 0) {
					table[i][j - arr[i]] += table[i - 1][j];
				}
				if(j + arr[i] <= 20) {
					table[i][j + arr[i]] += table[i - 1][j];
				}
			}
		}
	}

	cout << table[n - 2][ans] << endl;

	return 0;

}

Measured memory_bytes: 3084
while True:
    x = raw_input().split()

    a = int(x[0])
    b = int(x[2])
    op = x[1]

    if op == '?':
        break
    elif op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        print(a/b)

Measured memory_bytes: 6400