akhauriyash/Code-Regression huggingface dataset:
import copy
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
A = [[0 for i in range(26)]]
B1 = []
B2 = []
AA = []
ans = 0
for i in range(D):
  K = []
  for k in range(26):
    c = 0
    for j in range(26):
      if j != k:
        c += C[j] * (i+1-A[-1][j])
    an = S[i][k]-c
    K.append([an, k+1])
  K.sort()
  a = K[-1][1]
  B = copy.copy(A[-1])
  B[a-1] = i+1
  A.append(B)
  ans += K[-1][0]
  AA.append(ans)
  B1.append(a)
  B2.append(K[-2][1])
c = 0
k = B2[-1] - 1
for j in range(26):
  if j != k:
    c += C[j] * (D-A[-2][j])
an = S[D-1][k]-c
if AA[-2] + an > AA[-1]:
  B1[-1] = k + 1
for i in range(D):
  print(B1[i])

Measured memory_bytes: 9752
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e18;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);

  loop(i, 1, n + 1) cin >> a[i];
  rep(i, n) a[i + 1] += a[i];
  vector<int> b;

  loop(i, 1, n + 1) loop(j, i, n + 1) b.push_back(a[j] - a[i - 1]);

  int ans = 0;
  for (int t = 40; t >= 0; t--) {
    vector<int> res;
    rep(i, b.size()) {
      if (b[i] & (1LL << t)) res.push_back(b[i]);
    }
    if (k <= res.size()) {
      ans |= (1LL << t);
      b = res;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6128
reverse_S = input()[::-1]
n = len(reverse_S)
count = 0
mod = 0
mods = [0] * 2019
mods[0] = 1
x = 1
for s in reverse_S:
    mod = (mod + (int(s) * x)) % 2019
    mods[mod] = mods[mod] + 1
    x = x * 10
    x = x % 2019

for v in mods:
    count = count + v*(v-1)//2

print(count)


Measured memory_bytes: 68620
x1,y1 = [int(i) for i in input().split()]
x2,y2 = [int(i) for i in input().split()]
x3,y3 = [int(i) for i in input().split()]

A = ((x1-x2)**2+(y1-y2)**2)**(1/2)
B = ((x2-x3)**2+(y2-y3)**2)**(1/2)
C = ((x3-x1)**2+(y3-y1)**2)**(1/2)
S = A+B+C
A, C = max(A, B, C), min(A, B, C)
B = S-A-C

cosb = (A**2+C**2-B**2)/2/A/C
cosc = (A**2+B**2-C**2)/2/A/B

R = A/(2 + ( (1+cosb) / (1-cosb) )**(1/2) + ( (1+cosc) / (1-cosc) )**(1/2) )
print(R)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

const int MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    ll power = 1;
    for (int i = 1; i <= n; i++) {
        power *= i;
        power %= MOD;
    }
    cout << power << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void)
{
char card[201];
char copy[201];
int n;
int m;
int i,r;

while(scanf("%s\n",card),strcmp(card,"-")){
	scanf("%d",&m);
	
	n = strlen(card);
	
	
	for(i = 0;i < m;i++){
		scanf("%d",&r);
		strcpy(copy,&card[r]);
		strncat(copy,card,r);
		
		card[n] = '\0';
		
		strcpy(card,copy);
		
		
		}
	printf("%s\n",card);
	}
return 0;
}



Measured memory_bytes: 2092
import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main {
	private static void solve(){
		//Implement solution here.
		long K = ni();
		long tmp = 7;
		int result = -1;
		for(int i = 1; i <= K + 1; i++) {
			if(tmp % K == 0) {
				result = i;
				break;
			}
			tmp *= 10;
			tmp += 7;
			tmp %= K;			
		}
		System.out.println(result);
	}


	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 25732
N,Y = map(int, input().split())
#10000a + 5000b + 1000c = 1000m = Y
#10a + 5b + c = m (1 <= m <= 2*10^4)
#a+b+c = N
m = Y / 1000
for a in range(N+1):
    z = m - 10*a
    if z < 0:
        break
    for b in range(N-a+1):
        y = z - 5*b
        if y < 0:
            break
        if y == N-a-b:
            print(a,b,N-a-b)
            exit()
print(-1,-1,-1)

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

using namespace std;

bool isYY(int i) {
    if (0 <= i && i <= 99) return true;
    else return false;
}

bool isMM(int i) {
    if (1 <= i && i <= 12) return true;
    else return false;
}

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

    string s1 = S.substr(0,2);
    string s2 = S.substr(2,2);

    int i1 = atoi(s1.c_str());
    int i2 = atoi(s2.c_str());

    // cout << i1 << endl;
    // cout << i2 << endl;

    string ans;
    
    if (!(isYY(i1) && isMM(i2)) && !(isYY(i2) && isMM(i1))) {
        ans = "NA";
    } else if ((isYY(i1) && isMM(i2)) && (isYY(i2) && isMM(i1))) {
        ans = "AMBIGUOUS";
    } else if (isYY(i1) && isMM(i2)) {
        ans = "YYMM";
    } else if (isMM(i1) && isYY(i2)) {
        ans = "MMYY";
    }

    cout << ans << endl;

    return 0;
}

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

int N, M, Q;

vector<vector<int>> sum;
int buildSumTable(vector<int> L, vector<int> R) {
	sum = vector<vector<int>>(N + 1, vector<int>(N + 1, 0));
	for (int i = 0; i < M; i++)
	{
		sum[L[i]][R[i]]++;
	}

	for (int i = 1; i <= N; i++)
	{
		for (int j = 1; j <= N; j++)
		{
			sum[i][j] += sum[i - 1][j];
			sum[i][j] += sum[i][j - 1];
			sum[i][j] -= sum[i - 1][j - 1];
		}
	}
}

int getSumRange(int L, int R) {
	int ans = sum[R][R] - sum[R][L - 1] - sum[L - 1][R] + sum[L - 1][L - 1];
	return ans;
}

int main() {
	cin >> N >> M >> Q;
	vector<int> L(M);
	vector<int> R(M);
	for (int i = 0; i < M; i++)
	{
		scanf("%d %d", &L[i], &R[i]);
		//cin >> L[i] >> R[i];
	}
	vector<int> p(Q);
	vector<int> q(Q);
	for (int i = 0; i < Q; i++)
	{
		scanf("%d %d", &p[i], &q[i]);
		//cin >> p[i] >> q[i];
	}
	buildSumTable(L, R);

	for (int i = 0; i < Q; i++)
	{
		int ans = getSumRange(p[i], q[i]);
		//cout << ans << endl;
		printf("%d\n", ans);
	}
}


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


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

  for(int i=0;i< s.length()-1;i++){
    if(s[i] != s[i+1]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
  
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int r,c,i,j,x=0;
	int hyou[100][100], sum_r[100] = { 0 }, sum_c[100] = { 0 };
	scanf("%d %d", &r, &c);
	for (i = 0; i < r; i++)
	{
		for (j = 0; j < c; j++)
		{
			scanf("%d", &hyou[i][j]);
		}
	}
	for (i = 0; i < r; i++)
	{
		for (j = 0; j < c; j++)
		{
			sum_r[i] = sum_r[i] + hyou[i][j];
			x = x + hyou[i][j];
		}
	}
	for (i = 0; i < r; i++)
	{
		for (j = 0; j < c; j++)
		{
			sum_c[j] = sum_c[j] + hyou[i][j];
		}
	}
	for (i = 0; i < r; i++)
	{
		for (j = 0; j < c; j++)
		{
			printf("%d ", hyou[i][j]);
		}
		printf("%d\n", sum_r[i]);
	}
	for (i = 0; i < c; i++)
	{
		printf("%d ", sum_c[i]);
	}
	printf("%d\n", x);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;
pll arr[MAXN];
pll ls[MAXN];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n;
    ll l = 1, r = (ll) 1e9;
    ll mn = INF, mx = 0;
    for(int i = 0; i < n; i++){
        ll a, b;
        cin>>a>>b;
        mn = min(mn, b);
        mx = max(mx, a);
        arr[i].ff = a;
        arr[i].ss = b;
    }

    for(ll i = 0; i < n; i++){
        ll art = max(arr[i].ss - mx + 1, 0LL);
        ll az = max(mn - arr[i].ff + 1, 0LL); 
        ls[i] = make_pair(art, -az);
    }
    sort(ls,ls + n);
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        ans = max(ans, max(mn - mx + 1, 0LL) + arr[i].ss - arr[i].ff + 1);
    }
    ll dig = INF;
    for(int i = 0; i < n; i++){
        ls[i].ss = -ls[i].ss;
        if(i)
            ans = max(ans, dig + ls[i].ff);
        dig = min(dig, ls[i].ss);
    }
    cout<<ans<<endl;


    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 5888
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
inline int read()
{
	int x = 0 , f = 1; char ch = getchar();
	while(ch < '0' || ch > '9')	{if(ch == '-')	f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
int main()
{
	int n = read() , m = log2(n);
	if((1 << m) == n) puts("No");
	else
	{
		puts("Yes");
		printf("%d %d\n",1,2);
		printf("%d %d\n",2,3);
		printf("%d %d\n",3,n + 1);
		printf("%d %d\n",n + 1,n + 2);
		printf("%d %d\n",n + 2,n + 3);
		for(int i = 4;i < n;i += 2)
		{
			int j = i + 1;
			printf("%d %d\n",1,i);
			printf("%d %d\n",1,j);
			printf("%d %d\n",i,n + j);
			printf("%d %d\n",j,n + i);
		}
		if(!(n & 1))
		{
			for(int x = 2;x < n;x ++)
			{
				int y = n ^ 1 ^ x;
				if(y > 1 && y < n)
				{
					printf("%d %d\n",n + n,x);
					printf("%d %d\n",n,y);
					break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2304
N = int(input())
A = list(map(int, input().split()))
A.sort()

A_max = max(A)
dp = [True] * (A_max + 1)
count = 0
A_f = {a: 0 for a in A}
for a in A:
    A_f[a] += 1

for a in A:
    if dp[a]:
        for i in range(1, A_max + 1):
            if a * i > A_max:
                break
            dp[a * i] = False
        if A_f[a] == 1:
            count += 1

print(count)

Measured memory_bytes: 43452
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int h,w;
	bool ans1[510][510] = {},ans2[510][510] = {};
	cin >> h >> w;
	string a[510];
	for(int i = 0;i < h;i++){
		cin >> a[i];
	}
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(j < ((i % 2) ? w - 1 : 1)){
				ans1[i][j] = true;
			}else{
				ans2[i][j] = true;
			}
		}
	}
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(a[i][j] == '#'){
				ans1[i][j] = ans2[i][j] = true;
			}
		}
	}
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++) cout << (ans1[i][j] ? '#' : '.');
		cout << endl;
	}
	cout << endl;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++) cout << (ans2[i][j] ? '#' : '.');
		cout << endl;
	}
}


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

int main(){
  int n, d;
  cin >> n >> d;
 
  int m;
  m = 2*d + 1;
  
  int p = 0;
  for(int i=1; i<=n; i++){
    if(n <= m*i){
      p = i;
      break;
    }
  }
  
  cout << p << endl;
  return 0;
}

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

I n;I dp[1024][100001],v[323456],w[323456];
I c1,c2;

void dfs(I i){
    I j=i/2;
    if(i>1){
        for(I k=c2;k+1;k--){
            if(dp[j-1][k]or!k){
                I ne=k+w[i-1];
                if(ne<=c2)dp[i-1][ne]=max(dp[j-1][k]+v[i-1],dp[i-1][ne]);
            }
            dp[i-1][k]=dp[j-1][k];
        }
    }
    if(i*2<=min(c1,n))dfs(i*2);
    if(i*2+1<=min(c1,n))dfs(i*2+1);
}

signed main(){
    cin>>n;
    REP(i,n){I x,y;cin>>v[i]>>w[i];}
    c1=1024;c2=100000;
    dp[0][w[0]]=v[0];
    dfs(1);
    REP(i,c1)REP(j,c2)dp[i][j+1]=max(dp[i][j],dp[i][j+1]);
    I q;cin>>q;
    REP(i,q){
        I u,l;cin>>u>>l;
        vector<I> cand;
        while(u>c1){
            cand.push_back(u);
            u=u/2;
        }
        I r=cand.size();
        I ans=0;
        REP(j,1<<r){
            I v_sub=0;I w_sub=0;
            REP(k,r){
                if(j>>k&1){
                    v_sub+=v[cand[k]-1];
                    w_sub+=w[cand[k]-1];
                }
            }
            if(w_sub<=l)ans=max(ans,dp[u-1][l-w_sub]+v_sub);
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 405676
#include <cstdio>
using namespace std;
inline int ceill(int x,int y)
{
	if (x%y==0) return x/y;
	else return x/y+1;
}
int main()
{
	int n;
	scanf("%d",&n);
	int t=n,len=0;
	while (t)
	{
		t/=10;
		len++;
	}
	len-=2;
	if (len<=0)
	{
		printf("0\n");
		return 0;
	}
	int sumH=(int)(n/100);
	int gs=(n%100);
	// printf("%d %d %d\n",gs,sumH,ceill(gs,5));
	if (ceill(gs,5)>sumH) printf("0\n");
	else printf("1\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

template <typename T>
struct lazysegtree {

  struct node {
    int l, r; // range [l, r] koji obuhvaca taj node
    T val; // agregirajuca vrijednost

    // tu dodaj varijable za lazy propagaciju

    int lenght() { return r - l + 1; }
  };


  int n;
  vector <node> seg;
  vector <T> arr; // baza segtreea

  lazysegtree(int _n, vector<T> _arr) : seg(4 * _n + 1) {
    n = _n;
    arr = _arr;
    Build(1, 0, n - 1);
  }

  // obnovi rjesenje za segment od node-a seg[ind]
  void Recalculate(int ind) {
    assert(ind * 2 < (int) seg.size());
    node& leftChild = seg[ind * 2];
    assert(ind * 2 + 1 < (int) seg.size());
    node& rightChild = seg[ind * 2 + 1];
    seg[ind].val = max(leftChild.val, rightChild.val);
  }

  // pushaj informacije sa seg[ind] na djecu
  void Push(int ind) {
    assert(ind * 2 < (int) seg.size());
    node& leftChild = seg[ind * 2];
    assert(ind * 2 + 1 < (int) seg.size());
    node& rightChild = seg[ind * 2 + 1];
    // ne zaboravi resetat varijable propagacije od seg[ind] na kraju
  }

  void Build(int ind, int l, int r) {
    seg[ind].l = l;
    seg[ind].r = r;
    if(l == r) {
      seg[ind].val = arr[l];
      return;
    }
    int mid = (l + r) / 2;
    Build(ind * 2, l, mid);
    Build(ind * 2 + 1, mid + 1, r);
    Recalculate(ind);
  }

  void Upd(int l, int r, T val) {
    assert(r < n); // 0-indeksirano
    Upd(l, r, val, 0, n - 1, 1);
  }

  // updateaj [l, r] (0-indeksirano) sa vrijednoscu val 
  void Upd(int l, int r, T val, int cl, int cr, int ind) {
    if(cl > r || cr < l) return;
    if(cl >= l && cr <= r) {
      // implementiraj sam
      seg[ind].val = val;
      return;
    }
    //Push(ind);
    int mid = (cl + cr) / 2;
    Upd(l, r, val, cl, mid, ind * 2);
    Upd(l, r, val, mid + 1, cr, ind * 2 + 1);
    Recalculate(ind);
  }

  T Get(int l, int r) {
    assert(r < n); // mora bit 0-indeksirano
    return Get(l, r, 0, n - 1, 1);
  }

  // rjesenje za [l, r] (0-indeksirano)
  T Get(int l, int r, int cl, int cr, int ind) {
    if(cl > r || cr < l) return 0;
    if(cl >= l && cr <= r) {
      // implementiraj sam 
      return seg[ind].val;
    }
    //Push(ind);
    int mid = (cl + cr) / 2;
    T L = Get(l, r, cl, mid, ind * 2);
    T R = Get(l, r, mid + 1, cr, ind * 2 + 1);
    Recalculate(ind);
    return max(L, R);
  } 
};

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int n, k;
  cin >> n >> k;
  vi a(n);
  const int mx = 3e5;
  vi tmp(mx + 2);
  lazysegtree<int> seg(mx + 2, tmp);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    int d = max(0, a[i] - k);
    int u = min(mx, a[i] + k);
    //cout << a[i] << " -> " << d << " " << u << "    ";
    auto l = seg.Get(d, u);
    //cout << a[i] << " -> " << max(l, r) + 1 << endl;
    seg.Upd(a[i], a[i], l + 1);
  }
  cout << seg.Get(0, mx);
}

Measured memory_bytes: 21920
package main

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

func main() {
	N := readint()
	S := readstr()
	S = strings.TrimRight(S, "W")
	Rcnt := strings.Count(S, "R")
	N = len(S)
	if N == 0 || N == Rcnt {
		fmt.Println(0)
		return
	}
	SrhW := S[Rcnt:]
	RcntInSrhW := strings.Count(SrhW, "R")
	fmt.Println(RcntInSrhW)
}

const (
	iobufsize = 1 * 1024 * 1024 // 1 MB
)

var stdinsc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, iobufsize), iobufsize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func readint() int {
	stdinsc.Scan()
	v, err := strconv.Atoi(stdinsc.Text())
	if err != nil {
		panic(err)
	}
	return v
}

func readstr() string {
	stdinsc.Scan()
	return stdinsc.Text()
}

func pow(x, y int) int {
	if y < 1 {
		return 1
	}
	return x * pow(x, y-1)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


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

int main(){
	int x,y;
	while(1){
		cin>>x>>y;
	if(x<y){
		cout<<x<<" "<<y<<endl;
		}
	else if(x>y){
		cout<<y<<" "<<x<<endl;
		}
	else if(x==y&&x!=0)	{
		cout<<x<<" "<<y<<endl;
	}
	else if(x==0&&y==0)
		{break;}
	}
	return 0;
}

Measured memory_bytes: 1160
/**
 *      AGC 21 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-12 02:53:00
**/

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

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string N; cin >> N;
    int sizeN = N.size();

    if (sizeN == 1){
        int n = stoi(N);
        cout << n << '\n'; return 0;
    }

    char top = N[0];
    int n = ctoi(top);

    for (int i = 1; i < sizeN; ++i) {
        if (N[i] != '9'){
            cout << n + (sizeN - 1) * 9 - 1 << '\n'; return 0;
        }
    }
    cout << n + (sizeN - 1) * 9 << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define N 131072
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
int main(){
    int n;
    scanf("%d",&n);
    printf("%d\n",(n-2)*180);
}
/*
1 4 2 3
1 3 6 12
k(a+b) = a*b;
k*a+k*b = a*b;
b= (k*a)/(a-k);

k*(k+i)/i
*/

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

int main() {
	string S;
	cin >> S;
	int size = S.size(), out;
	for (int i = 0; i < size / 2; i++) {
		if (S.substr(0, i) == S.substr(i, i)) out = i;
	}
	cout << out * 2 << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int maxn = 15;

int n,m,a[maxn];

int main() {
  //freopen("in.cpp","r",stdin);
  cin>>n>>m;
  for(int i=0; i<n; i++)cin>>a[i];
  ll ret=-1;
  for(int i=1; i<(1<<n); i++) {
    int cnt=0;
    for(int j=0; j<n; j++)if(i&(1<<j))cnt++;
    if(cnt!=m)continue;
    ll ans=0;
    int pre=0;
    for(int j=0; j<n; j++) {
      if(i&(1<<j)) {
        if(a[j]>pre) {
          pre=a[j];
        } else {
          ans+=pre+1-a[j];
          pre++;
        }
      } else {
        if(a[j]>pre) {
          pre=a[j];
        }
      }
    }
    if(ret==-1||ret>ans)ret=ans;
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n;cin>>n;
  int tmp = n % 1000;
  if(tmp == 0){
    print(0);
    return 0;
  }
  print(1000 - (tmp));
  return 0;
}

Measured memory_bytes: 3640
from operator import itemgetter

N, M = map(int, input().split())
A = []
B = []

for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

# 安い店から順にドリンクを買い占めていけばよい
AB = zip(A,B)
AB = sorted(AB, key=itemgetter(0))

n_rest_drink = M
idx = 0
spent_money = 0

while n_rest_drink > 0:
    n_purchase = min(n_rest_drink, AB[idx][1])
    spent_money += AB[idx][0] * n_purchase
    n_rest_drink -= n_purchase
    idx += 1

print(spent_money)

Measured memory_bytes: 19752
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  int n;
  cin >> n;
  vector<int> a(n);
  int minA = INT_MAX;
  int maxA = -1;
  REP(i, n) {
    cin >> a[i];
    minA = min(minA, a[i]);
    maxA = max(maxA, a[i]);
  }

  int ans = INT_MAX;

  for(int i=minA; i <= maxA; i++) {
    int costs = 0;
    REP(j, n) {
      if(i != a[j]) {
        costs += (a[j] - i) * (a[j] - i);
      }
    }

    ans = min(ans, costs);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

bool binarySearch(int row[],int n,int key){
    int left = 0;
    int right = n;
    
    while(left < right){
        int center = (left + right) / 2;
        if(row[center] == key){
            return true;
        }
        else if(row[center] < key){
            left  = center + 1;
        }
        else{
             right = center;
        }
    }
    return false;
}

int main(){
    int n,row[100000 + 1],q,key,sum = 0;
    // 一つ目
    scanf("%d",&n);
    for(int i = 0;i < n;++i){
        scanf("%d",&row[i]);
    }

    // 探索する数
    scanf("%d",&q);
    for(int i = 0;i < q;++i){
        scanf("%d",&key);
        if(binarySearch(row, n, key)){
            ++sum;
        }
    }
    printf("%d\n",sum);
    return 0;
}



Measured memory_bytes: 3104
import bisect

n, m = map(int, input().split())
py = [tuple(map(int, input().split())) for _ in range(m)]

t = [[] for _ in range(n)]

for p, y in py:
  t[p-1].append(y)

for ti in t:
  ti.sort()
  
for p, y in py:
  kami = p
  shimo = bisect.bisect_left(t[p-1], y) + 1
  print('{0:06d}{1:06d}'.format(kami, shimo))

Measured memory_bytes: 29592
#include<stdio.h>
int main(void){
    long  min=1000000,max=-1000000,goukei=0;
    int n;
    long scan;
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%ld",&scan);
        if(min>scan){
            min=scan;
        }
        if(max<scan){
            max=scan;
        }
        goukei=goukei+scan;
    }
    
    printf("%ld %ld %ld\n",min,max,goukei);
    
    return 0;
}


Measured memory_bytes: 2056
def gcd(x, y): 
    while(y): 
        x, y = y, x % y 
    return x 

sum = 0
n = int(input())
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            sum += gcd(gcd(i,j),k)

print(sum)


Measured memory_bytes: 68844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");
		int n = Integer.parseInt(tmpArray[0]);
		int m = Integer.parseInt(tmpArray[1]);
		int l = Integer.parseInt(tmpArray[2]);

		long[][] a = new long[n][m];
		long[][] b = new long[m][l];
		long[][] c = new long[n][l];

		for(int i = 0; i < n; i ++){
			tmpArray = br.readLine().split(" ");
			for(int j = 0; j < m; j++){
				a[i][j] = Long.parseLong(tmpArray[j]);
			}
		}

		for(int i = 0; i < m; i ++){
			tmpArray = br.readLine().split(" ");
			for(int j = 0; j < l; j++){
				b[i][j] = Integer.parseInt(tmpArray[j]);
			}
		}

		for(int i = 0; i < n; i++){
			for(int j = 0; j < l; j++){
				for(int k = 0; k < m; k++){
					c[i][j] += a[i][k]*b[k][j];
				}

				if(j != 0 ){
					System.out.print(" ");
				}
				System.out.print(c[i][j]);
			}
			System.out.println();
		}


	}

}

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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N)  cin >> A.at(i);

  int g=0;
  rep(i,N)  g=gcd(g,A.at(i));
  if(g!=1){
    cout << "not coprime" << endl;
    return 0;
  }

  int MA=1000001;
  vector<int> cnt(MA,0);
  rep(i,N){
    int a=A.at(i);
    for(int j=2;j*j<=a;j++){
      if(a%j!=0)  continue;
      while(a%j==0){
        a/=j;
      }
      cnt.at(j)++;
    }
    if(a!=1)  cnt.at(a)++;
  }
  rep(i,MA){
    if(cnt.at(i)>1){
      cout << "setwise coprime" << endl;
      return 0;
    }
  }
  cout << "pairwise coprime" << endl;

  return 0;
}

Measured memory_bytes: 11056
#include "bits/stdc++.h"
#include <atcoder/dsu>
using namespace std;
// clang-format off
using i64 = int64_t;
using i32 = int32_t;
#define all(x) x.begin(), x.end()
#define int i64
template <class T, typename U> constexpr inline bool exist(const T &s, const U &e) { return s.find(e) != s.end(); }
template <class T> constexpr inline i32 SZ(const T &x) { return x.size(); }
template <class T> constexpr inline bool rmn(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> constexpr inline bool rmx(T &a, T b) { return a < b ? (a = b, true) : false; }
const char el = '\n'; const i32 MOD = 1e9 + 7, INF = 0x3f3f3f3f; const i64 INFLL = ((i64)INF << 32) | INF;

#ifdef LOCAL // debugging swiss knife
template <typename Ostream, typename Cont> enable_if_t<is_same<Ostream, ostream>::value, Ostream &> operator<<(Ostream &os, const Cont &v) { os << "{"; for (const auto &x : v) os << x << ", "; return os << "}"; }
template <typename Ostream, typename... Ts> Ostream &operator<<(Ostream &os, const pair<Ts...> &p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class... Args> void dbg_out(Args... args) { ((std::cerr << "\033[32m" << args << "\033[37m, "), ...); }
#define dbg(...) cerr << "\033[1;31m" << __LINE__ << ": [" << #__VA_ARGS__ << "]\033[37m  = ", dbg_out(__VA_ARGS__), cerr << "\033[0m" << endl;
#else
#define dbg(...) ;
#endif
// clang-format on
////////////////////////////////// TEMPLATE ENDS /////////////////////////////////
vector<vector<i32>> adj;
vector<i32> vis, color;

int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(13), cerr << fixed << setprecision(3);

    int n, q;
    cin >> n >> q;
    atcoder::dsu d(n);
    while (q--) {
        char ch;
        int u, v;
        cin >> ch >> u >> v;
        if (ch == '0')
            d.merge(u, v);
        else
            cout << d.same(u, v) << el;
    }

    return 0;
}

Measured memory_bytes: 3920
#include <stdio.h>

int main() {
  int H, W;
  int h, w;
  while(1) {
    scanf("%d%d", &H, &W);
    if(H==0 && W==0) break;
    for (h = 0; h < H; h++) {
      for (w = 0; w < W; w++) {
        if(w % 2 == 0) {
          if(h % 2 != 0) {
            printf(".");
          } else {
            printf("#");
          }
        } else {
          if(h % 2 != 0) {
            printf("#");
          }
          else
          {
            printf(".");
          }
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	set<int> s;
	for(int i=0,val;i<3;i++)
		cin >> val , s.insert(val);
	if((int)s.size() == 2)
		cout << "Yes" << endl;
	else		
		cout << "No" << endl;
	return 0;
}


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

typedef long long ll;
const ll INF = 1LL << 60;

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


int main(void){
    int N;
    cin >> N;
    ll h[100010];
    ll dp[100010];
    
    for(int i = 1 ; i <= N ; i++){
        cin >> h[i];
    }
    for(int i = 1 ; i <= N ; i++){
        dp[i] = INF;
    }
    
    dp[1] = 0;
    for(int i = 1 ; i <= N ; i++){
        chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }
    
    cout << dp[N] << endl;
}


Measured memory_bytes: 5184
def solve(lst):
  count_5 = 2
  count_7 = 1
  for i in lst:
    if i == 5:
      count_5 -= 1
    elif i == 7:
      count_7 -= 1
    else:
      return False
  return count_5 == 0 and count_7 == 0

if __name__ == "__main__":
  l = list(map(int,input().split()))
  if solve(l):
    print('YES')
  else:
    print('NO')


Measured memory_bytes: 3060
#include <stdio.h> 

int main(void){    

int a,b,c,x,y,z;    

scanf("%d%d%d",&a,&b,&c);    

if(a > b){ 

x = a; a = b; b = x; 

}    

if(b > c){ 

y = b; b = c; c = y; 

}    

if(a > b){ 

z = a; a = b; b = z; 

}    

printf("%d %d %d\n",a,b,c);    

return 0; 

} 

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

ll pow(ll x,ll y){
  if(y==0){
    return 1;
  }else if(y==1){
    return x%MOD;
  }else if(y%2==0){
    return pow(x,y/2)*pow(x,y/2)%MOD;
  }else{
    return x*pow(x,y-1)%MOD;
  }
}

int main(){
  int N;cin >>N;
  cout << (N-1)/2 + 1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define X 11
#define Y 11
#define R 1
#define L 2
#define U 3
#define D 4

int main(void)
{
	char brd[X][Y];/*パネル*/
	char in[X][Y];/*パネル*/
	int x = 0, y = 0;
	int i = 0, j = 0;
	int flag[100];
	char ans[4][2];
	int k = 1, t = 1;
	int r = 0;/*righet*/
	int l = 0;/*left*/
	int u = 0;/*under*/
	int o = 0;/*on*/
	for(i = 0; i < 100; i++)
	{
		flag[i] = 0;
	}


	for(i = 0; i < X; i++)
	{
		for(j = 0;j <= Y; j++)
		{
			in[i][j] = '0';
			brd[i][j] = '0';
		}
	}
	for(i = 0; i <  9; i++)
	{
		scanf("%s", in[i]);
	}
	for(i = 1; i < 10; i++)
	{
		for(j = k+1; j < 10; j += 2 )
		{
			brd[i][j] = in[x][y];
			y++;
		}
		y = 0;
		x++;
		t++;
		k = t % 2;
	}
/*
	for(i =  0; i <  X; i++)
	{
		for(j = 0; j < Y; j ++)
		{
			printf("i=%d j=%d    brd=%c\n",i,j,brd[i][j]);
		}
		printf(" %d\n",j);
	}
*/
	x = 2;/*j*/
	y = 1;/*i*/
	i = 0;
	flag[i] = R;
	
	while(1)
	{
		if(flag[i] == R)
		{
			i++;
			if(brd[y-1][x + 1] == '1')
			{
				x = x + 1; 
				y = y - 1;
				flag[i] = U;
			}
			else if(brd[y][x + 2] == '1')
			{
				x = x + 2;
				y = y;
				flag[i] = R;
			}
			else if(brd[y+1][x+1] == '1')
			{
				x = x + 1; 
				y = y + 1;
				flag[i] = D;
			}
			else
			{
				flag[i] = L;
			}
		}
		else if(flag[i] == L)
		{
			i++;
			if(brd[y+1][x-1] == '1')
			{
				x = x - 1; 
				y = y + 1;
				flag[i] = D;
			}
			else if(brd[y][x-2] == '1')
			{
				x = x - 2;
				y = y; 
				flag[i] = L;
			}
			else if(brd[y-1][x-1] == '1')
			{
				x = x - 1; 
				y = y - 1;
				flag[i] = U;
			}
			else
			{
				flag[i] = R;
			}
		}
		else if(flag[i] == U)
		{
			i++;
			if(brd[y-1][x-1] == '1')
			{
				x = x - 1; 
				y = y - 1;
				flag[i] = L;
			}
			else if(brd[y-2][x] == '1')
			{
				x = x;
				y = y-2;
				flag[i] = U;
			}
			else if(brd[y-1][x+1] == '1')
			{
				x = x + 1; 
				y = y - 1;
				flag[i] = R;
			}
			else
			{
				flag[i] = D;
			}
		}
		else if(flag[i] == D)
		{
			i++;
			if(brd[y+1][x + 1] == '1')
			{
				x = x + 1; 
				y = y + 1;
				flag[i] = R;
			}
			else if(brd[y+2][x] == '1')
			{
				x = x;
				y = y+2;
				flag[i] = D;
			}
			else if(brd[y+1][x-1] == '1')
			{
				x = x - 1; 
				y = y + 1;
				flag[i] = L;
			}
			else
			{
				flag[i] = U;
			}
		}
		if(x == 2 && y == 1)
		{
			break;
		}
	}

	for(j = 0;j <= i;j++)
	{
		if(flag[j] == R)
		{
			printf("R");
		}
		if(flag[j] == L)
		{
			printf("L");
		}
		if(flag[j] == D)
		{
			printf("D");
		}
		if(flag[j] == U)
		{
			printf("U");
		}
	}
	printf("\n");

	return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int m,d;cin>>m>>d;
  int res=0;
  for(int i=4;i<=m;i++){
    for(int j=2;j<=9;j++){
      for(int k=2;k<=9;k++){
        if(j*10+k>d)break;
        if(j*k==i)res++;
      }
    }
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<set>
#include<iostream>
#include<cassert>
#include<complex>
#include<vector>
#include<cmath>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const double eps = 1e-10;
typedef complex<double> P;
typedef vector<P> Polygon;
#define N 4002


double cross(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

bool isp(P a,P b,P c){
  return abs(a-c)+abs(b-c)<abs(a-b)+eps;
}

bool is_intersected_ls(P a1,P a2,P b1,P b2){
  if ( isp(a1,a2,b1)||isp(a1,a2,b2)||isp(b1,b2,a1)||isp(b1,b2,a2))return true;
  if ( cross(a2-a1,b1-a1)*cross(a2-a1,b2-a1)<0 &&
       cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1)<0)return true;
  return false;
}

P intersection_ls(P a1,P a2,P b1,P b2){
  P b=b2-b1;
  double d1=abs(cross(b,a1-b1));
  double d2=abs(cross(b,a2-b1));
  double t =d1/(d1+d2);
  return a1+(a2-a1)*t;
}

P tmp[4],a1,a2,b1,b2;

int make_data(Polygon &a,int y){
  int n = a.size();
  vector<pair<int,int> > block;

  rep(i,n){
    a1=a[i],a2=a[(i+1)%n];
    tmp[4];
    tmp[0].real()=-2001;
    tmp[0].imag()=y+1;
    tmp[1].real()=2001;
    tmp[1].imag()=y+1;
    tmp[2].real()=-2001;
    tmp[2].imag()=y;
    tmp[3].real()=2001;
    tmp[3].imag()=y;
    if (is_intersected_ls(a1,a2,tmp[0],tmp[1]) &&is_intersected_ls(a1,a2,tmp[2],tmp[3])){
      b1=intersection_ls(a1,a2,tmp[0],tmp[1]);
      b2=intersection_ls(a1,a2,tmp[2],tmp[3]);
      pair<int,int> ins=make_pair((int)floor(min(b1.real(),b2.real())),(int)ceil(max(b1.real(),b2.real())));
      block.push_back(ins);
    }

  }

  int ret=0;
  sort(block.begin(),block.end());

  if ( block.size()!=0){
    int prev=-10000;
    for(int i=0;i<block.size();i+=2){
      ret+=block[i+1].second-max(prev,block[i].first);
      prev=block[i+1].second;
    }
    //cout <<"end"<<endl;
  }
  return ret;
}


int solve(Polygon & a){
  int ret=0;
  int mini=10000,maxi=-10000;
  rep(i,a.size())mini=min(mini,(int)a[i].imag()),maxi=max(maxi,(int)a[i].imag());
  REP(i,mini,maxi+1)ret+=make_data(a,i);


  return ret;
}


main(){
  int n;
  while(cin>>n && n){
    Polygon a;
    P tst;
    rep(i,n){
      cin>>tst.real()>>tst.imag();
      a.push_back(tst);
    }
    cout << solve(a)<<endl;
  }
}

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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)(n); i++)
#define Loop1(i, n) for(int i = 1; i <= (int)(n); i++)
#define Loopr(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
bool nearlyeq(double x, double y) { return abs(x - y) < 1e-9; }
bool inrange(int x, int t) { return x >= 0 && x < t; }
bool inrange(vi xs, int t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

/*******************************************************/

int main() {
	string s; cin >> s;
	int x = 0, y = 0;
	int en = 0, ew = 0, es = 0, ee = 0;
	Loop(i, s.length()) {
		if (s[i] == 'N') {
			y++;
			en = 1;
		}
		if (s[i] == 'W') {
			x--;
			ew = 1;
		}
		if (s[i] == 'S') {
			y--;
			es = 1;
		}
		if (s[i] == 'E') {
			x++;
			ee = 1;
		}
	}
	if (x > 0) {
		if (ew) x = 0;
	}
	if (x < 0) {
		if (ee) x = 0;
	}
	if (y > 0) {
		if (es) y = 0;
	}
	if (y < 0) {
		if (en) y = 0;
	}
	if (x == 0 && y == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    ll n; cin >> n;
    set<ll> s;
    rep(i, n){
        ll a; cin >> a;
        if(s.count(a)) s.erase(a);
        else s.insert(a);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 8160
#include<stdio.h>

int main(void)
{
	int W, H;
	int x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if (x + r > W || x - r < 0 || y + r > H || y - r < 0){
		printf("No");
	}else{
		printf("Yes");
	}
	putchar('\n');

	return 0;
}

Measured memory_bytes: 588
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

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

  cin >> N >> K;

  vector<unsigned long long> A(N);

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

  for (size_t i = 0; i < N - K; i++) {
    if (A.at(i) < A.at(i + K)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 4744
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int D = scan.nextInt();
        int L = A + B;
        int R = C + D;
        if (L == R) {
            System.out.println("Balanced");
        } else if (L > R) {
            System.out.println("Left");
        } else {
            System.out.println("Right");
        }
    }
}


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

int main() {
    int x, y;
    cin >> x >> y;
    vector<int> m(206, 0);
    m[0] = 300000;
    m[1] = 200000;
    m[2] = 100000;
    cout << m[x - 1] + m[y - 1] + (x == 1 && y == 1 ? 400000 : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n,a,b = map(int,input().split())
    a,b = sorted([a,b])
    if (a-b)%2==1:
        x = min([n-b,a-1])
        y = n-a
        if x == a-1:
            y = b-1
        print(abs(x+y+1)//2)
    else:
        print(abs(a-b)//2)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int n; cin>>n;
    bool f=false;
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
            if(n==i*j) f=true;
        }
    }
    if(f) cout<<"Yes"<<endl;
    if(!f) cout<<"No"<<endl;
}


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

int main()
{
  int n, b[111];
  cin >> n;
  for (int i = 1; i < n; i++)
    cin >> b[i];
  b[n] = 1 << 20;

  int ans = b[1];
  for (int i = 2; i <= n; i++)
    ans += min(b[i], b[i - 1]);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb          push_back
#define endl        '\n'
#define pll         pair<int,int>
#define vll          vector<int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define int	    int64_t
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
int n,i,j,k,l,sum=0,flag=0,t,dp[200005],ans=0,a[200005];
void solve(){
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>a[i];
    }
    dp[1]=0;
    for(int i=2;i<=n;i++){
    	dp[i] =dp[i-1]+abs(a[i]-a[i-1]);
    	if(i-2>=1){
    		dp[i] = min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
    	}
    }
    cout<<dp[n]<<endl;
}
signed main()
{
    ios
    int test = 1;
    //cin>>test;
    while(test--){
    	solve();
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int len,i,cur,maks;
string s;

int main(){
	cin >> s;
	len = s.length();
	for(i=0;i<len; i++){
		if(s[i]=='R'){
			cur++;
		}else {
			cur = 0;
		}
		if(cur>maks){
			maks=cur;
		}
	}
	cout << maks << endl;
}

Measured memory_bytes: 3624