akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

bool is_prime(int a) {
  if (a == 1) return false;
  for (int i = 2; i * i <= a; i++) {
    if (a % i == 0) return false;
  }
  return true;
}

int main() {
  int N;
  cin >> N;
  set<int> s;
  for (int i = 0; i < N; i++) {
    int num;
    cin >> num;
    if (is_prime(num)) s.insert(num);
  }
  cout << s.size() << endl;
}


Measured memory_bytes: 3108
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[m];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            y[i] = sc.nextInt();
        }
        int x_max = -100;
        int y_min = 100;
        for (int i = 0; i < n; i++) {
            if (x_max < x[i])
                x_max = x[i];
        }
        for (int i = 0; i < m; i++) {
            if (y_min > y[i])
                y_min = y[i];
        }
        if (X < x_max && x_max < y_min && y_min <= Y)
            System.out.println("No War");
        else
            System.out.println("War");
    }
}

Measured memory_bytes: 22740
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

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

    static class Triangles {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] array = new int[n];

            for (int i = 0; i < n; i++) {
                array[i] = in.nextInt();
            }
            Arrays.sort(array);

            long result = 0;
            for (int i = 0; i < n - 2; i++) {
                int a = array[i];
                for (int j = i + 1; j < n - 1; j++) {
                    int b = array[j];
                    int k = j + 1;
                    while (k < n && array[k] < a + b) {
                        k++;
                    }
                    result += k - (j + 1);
                }
            }
            out.println(result);
        }

    }
}



Measured memory_bytes: 39932
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    int cnt=0;
    for(int i=1; i<=n; i++){
        cin >> a[i];
        if(i%2==1 && a[i]%2==1){
            cnt++;
        }
    }
    cout << cnt << endl;
}




Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e9

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;


int main(){
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double sh, ln;
    sh = 360.0 * h/12.0 + 30.0 * m/60.0;
    ln = 360.0 * m/60.0;
    double rid = min(abs(sh - ln), abs(ln - sh));

//    if(rid >= 180){rid = rid - 180.0;}

    const double pi=3.1415926535897932384626433832795028841971;

    double ans = pow(a, 2.0) + pow(b, 2.0) - 2.0*a*b*cos(rid*(pi/180.0)) ;

    cout << std::fixed << std::setprecision(20) << pow(ans, 0.5) << endl;

    return 0;
}


Measured memory_bytes: 4348
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
using namespace std;
int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int max = 0;
  int min = 0;
  if(b > a) max = a;
  else max = b;

  if(a + b > n) min = a + b - n;
  else min = 0;
 
  cout << max << " " << min << endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    string n;
    while(true){
        cin >> n;
        if(n == "0") break;
        int sum = 0;
        rep(i,n.size()) sum += n[i] - '0';
        cout << sum << endl;
    }
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e5+5;

vector<int> G[maxn];
int d[maxn];// distance to root.



void dfs(int v,int dis,int f){
    d[v] = dis;
    for(auto a:G[v]){
        if(a != f)
            dfs(a,dis+1,v);
    }
}


int dfs2(int v,int f){
    int ret = 0;
    for(auto a:G[v]){
        if(a != f)
            ret = max(1 + dfs2(a,v),ret);
    }
    return ret;
}

int main()
{
    int N,u,v;
    cin >> N >> u >> v;
    _for(i,0,N-1){
        int s,t;
        cin >> s >> t;
        G[s].PB(t);
        G[t].PB(s);
    }

    dfs(v,0,-1);
    int up = (d[u]-1)/2;

    int p = 0;
    if(d[u] % 2 == 0) p++;

    _for(i,0,up){
        for(auto a:G[u]){
            if(d[a] == d[u] - 1){
                u = a;
                break;
            }
        }
    }

    int fa;
    for(auto a:G[u]){
        if(d[a] == d[u] - 1){
            fa = a;
            break;
        }
    }
    int down = dfs2(u,fa);

    cout << up + down + p << endl;

    return 0;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main (void) {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (1) {
        C -= B;
        A -= D;
        if (C <= 0) {
            cout << "Yes" << endl;
            break;
        } else if (A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
}


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

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

void insert(int k){
	Node *y=NIL;//x??????
	Node *x=root;//T??????
	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){//T???????????´???
		root=z;
	}else{
		if(z->key<y->key){
			y->left=z;//z???y?????????????????????
		}else{
			y->right=z;//z???y?????????????????????
		}
	}
}

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,x;
	string com;
	scanf("%d",&n);
	for (int 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: 26740
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
using namespace std;

class dice {
public:
	int a[6];
	int b;
	void moveN() {
		b = a[0];
		a[0] = a[1];
		a[1] = a[5];
		a[5] = a[4];
		a[4] = b;
	}

	void moveS() {
		b = a[0];
		a[0] = a[4];
		a[4] = a[5];
		a[5] = a[1];
		a[1] = b;
	}

	void moveE() {
		b = a[0];
		a[0] = a[3];
		a[3] = a[5];
		a[5] = a[2];
		a[2] = b;
	}

	void moveW() {
		b = a[0];
		a[0] = a[2];
		a[2] = a[5];
		a[5] = a[3];
		a[3] = b;
	}

	void moveR() {
		b = a[1];
		a[1] = a[2];
		a[2] = a[4];
		a[4] = a[3];
		a[3] = b;
	}

	void moveL() {
		b = a[1];
		a[1] = a[3];
		a[3] = a[4];
		a[4] = a[2];
		a[2] = b;
	}
};

int main() {

	dice dice1, dice2;

	for (int i = 0; i < 6; i++) {
		cin >> dice1.a[i];
	}

	for (int i = 0; i < 6; i++) {
		cin >> dice2.a[i];
	}

	if (dice1.a[2] == dice2.a[2] && dice1.a[3] == dice2.a[3] && dice1.a[4] == dice2.a[4] && dice1.a[0] == dice2.a[0] && dice1.a[1] == dice2.a[1] && dice1.a[5] == dice2.a[5]) {
		cout << "Yes" << endl;
		return 0;
	}

	for (int i = 0; i < 4; i++) {
		dice2.moveR();
		for (int j = 0; j < 4; j++) {
			dice2.moveN();
			if (dice1.a[2] == dice2.a[2] && dice1.a[3] == dice2.a[3] && dice1.a[4] == dice2.a[4] && dice1.a[0] == dice2.a[0] && dice1.a[1] == dice2.a[1] && dice1.a[5] == dice2.a[5]) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}



	for (int i = 0; i < 4; i++) {

		dice2.moveE();

		for (int j = 0; j < 4; j++) {

			dice2.moveN();

			if (dice1.a[2] == dice2.a[2] && dice1.a[3] == dice2.a[3] && dice1.a[4] == dice2.a[4] && dice1.a[0] == dice2.a[0] && dice1.a[1] == dice2.a[1] && dice1.a[5] == dice2.a[5]) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3100
using System;

class ITP1_5_B
{
    public static void Main()
    {
        while (true)
        {
            string[] Input = Console.ReadLine().Split(' ');
            int H = int.Parse(Input[0]);
            int W = int.Parse(Input[1]);

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

            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (j == 0 || j == W - 1 || i == 0 || i == H - 1)
                        Console.Write("#");
                    else
                        Console.Write(".");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8700
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] read = stra();
        Write(read[1]);
        WriteLine(read[0]);

    
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static long rlong(){
        return long.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    static long[] longa(){
        string[] read_str_array = ReadLine().Split(' ');
        long[] return_long_array = new long[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_long_array;
    }
    static double[] doublea(){
        string[] read_str_array = ReadLine().Split(' ');
        double[] return_double_array = new double[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_double_array;
    }
    // A/B小数点以下切上
    static long divideup(long divided,long divid){
        long temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
    static long GCD(long a,long b){
        if(a < b){
            long temp = a;
            a = b;
            b = temp;
        }
        if(a % b == 0){ return b; }
        else{
            long temp = b;
            b = a%b;
            a = temp;
            return GCD(a,b);
        }
    }
    static long LCM(long a,long b){
        return a * b / GCD(a,b);
    }
}
//知見
// (string) hogestr -> (char[]) hoge
    // char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
    // string hoge = new string(hoge);
// Hashtable ×  Dictionary ○
// Dictionary hoge<string,int>
    // hoge.ContainsKey(string) -> return boolean
    // hoge[string] -> return int
    // hoge[int] -> CE
// Dictionary hoge<int1,int2>
    // hoge<int1,int2>: hoge[int1] -> return int2
    // KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー　-> 幅優先 ???
// スタック -> 深さ優先 ???


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
namespace modular_space {
	long long mod;
	struct umod {
		long long val;
		umod(): val(0ll){}
		umod(long long x){ x %= mod; if(x < 0) x += mod; val = x; }
		umod& operator += (umod oth){ val += oth.val; if(val >= mod) val -= mod; return *this; }
		umod& operator -= (umod oth){ val -= oth.val; if(val < 0) val += mod; return *this; }
		umod& operator *= (umod oth){ val = val * oth.val % mod; return *this; }
		umod& operator /= (umod oth){ return *this *= oth.inverse(); }
		umod& operator ^= (long long oth){ return *this = pwr(*this, oth); }
		umod operator + (umod oth) const { return umod(*this) += oth; }
	       	umod operator - (umod oth) const { return umod(*this) -= oth; }
		umod operator * (umod oth) const { return umod(*this) *= oth; }
		umod operator / (umod oth) const { return umod(*this) /= oth; }
		umod operator ^ (long long oth) const { return umod(*this) ^= oth; }
		bool operator < (umod oth) const { return val < oth.val; }
		bool operator > (umod oth) const { return val > oth.val; }
		bool operator <= (umod oth) const { return val <= oth.val; }
		bool operator >= (umod oth) const { return val >= oth.val; }
		bool operator == (umod oth) const { return val == oth.val; }
		bool operator != (umod oth) const { return val != oth.val; }
		umod pwr(umod a, long long b) const {
			umod r = 1;
			for(; b; a *= a, b >>= 1)
				if(b&1)
					r *= a;
			return r;
		}
		umod inverse() const {
			long long a = val, b = mod, u = 1, v = 0;
			while(b){
				long long t = a/b;
				a -= t * b; swap(a, b);
				u -= t * v; swap(u, v);
			}
			if(u < 0)
				u += mod;
			return u;
		}
		friend istream& operator >> (istream &is, umod &oth);
		friend ostream& operator << (ostream &os, const umod& oth);
	};
	ostream& operator << (ostream &os, const umod &oth){
		os << oth.val;
		return os;
	}
	istream& operator >> (istream &is, umod &oth){
		long long x; is >> x;
		oth = umod(x);
		return is;
	}
	struct binprime_kit {
		int sz;
		vector<umod> fat, ifat;
		void init(int s){
			sz = s;
			fat.resize(sz + 1);
			ifat.resize(sz + 1);
			fat[0] = 1;
			for(int i = 1; i <= sz; i++) fat[i] = fat[i - 1] * i;
			ifat[sz] = fat[sz] ^ (mod - 2);
			for(int i = sz - 1; i >= 0; i--) ifat[i] = ifat[i + 1] * (i + 1);
		}
		umod coef(int n, int r){
			if(n < r) return 0;
			return fat[n] / (ifat[r] * ifat[n - r]);
		}
	};
};
const int maxn = 1000100;
using umod = modular_space::umod;
umod sum[maxn], par[maxn];
int main(){
	modular_space::mod = 998244353;
	int n; cin >> n;
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		par[x] += sum[x] * x;
		sum[x] += x;
	}
	for(int i = 1; i < maxn; i++){
		for(int j = i + i; j < maxn; j += i){
			par[i] += par[j] + sum[i] * sum[j];
			sum[i] += sum[j];
		}
	}
	umod ans = 0;
	for(int i = maxn - 1; i >= 1; i--){
		for(int j = i + i; j < maxn; j += i){
			par[i] -= par[j];
		}
		ans += par[i] / i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  rep(i,s.size()-1){
    if(s[i]=='A' && s[i+1]=='C'){cout<<"Yes"<<endl;return 0;
    }
  }
  cout<<"No"<<endl;
  

  return 0;
}

Measured memory_bytes: 256
s=list(map(int,list(input())))
# s[0]=1,s[-1]=0,s[k]=s[n-k-1]は必要
def main(s):
  n=len(s)
  if s[0]!=1 or s[-1]!=0:return [[-1]]
  for k in range(n//2-1):
    if s[k]!=s[n-k-2]:return [[-1]]
  uv=[(1,2)]
  t=2
  i=3
  for x in s[1:-1]:
    uv.append((t,i))
    if x==1:
      t=i
    i+=1
  return uv
for x in main(s):
  print(*x,sep=' ')


Measured memory_bytes: 92472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    ll x;
    cin>>x;

    for(ll a=-1000;a<=1000;a++){
        for(ll b=-1000;b<=1000;b++){
            if(a*a*a*a*a-b*b*b*b*b==x){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(c-a)<=d){
    cout << "Yes" << endl;
    return 0;
  } else if(abs(b-a)<=d&&abs(c-b)<=d){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;

int dfs(vector <int> &dp, vector<vector<int>> &to, int node)
{
  if( dp[node] != -1)
    return dp[node];

  int tmp = 0;
  for( const auto & n:to[node] )
    {
      tmp = max(dfs(dp, to, n)+1, tmp);
    }
  dp[node] = tmp;
  return tmp;
}

int main()
{
  int N,M;
  cin >> N >> M;
  vector <vector<int> > to(N+1);

  for( int i=0;i<M;i++ )
    {
      int x,y;
      cin >> x >> y;
      to[x].push_back(y);
    }

  vector <int> dp(N+1, -1);
  int m;
  for( int i=0;i<N+1;i++ )
    m = max(dfs(dp, to, i), m);
  
  cout << m << endl;
}


Measured memory_bytes: 8832
#include<stdio.h>
#include<math.h>

int main(){
	
	double a,b,x,S,L,h;
	
	scanf("%lf %lf %lf",&a,&b,&x);
	
	S=0.5*a*b*sin(x*M_PI/180);
	L=a+b+sqrt(a*a+b*b-2*a*b*cos(x*M_PI/180));
	h=b*sin(x*M_PI/180);
	
	printf("%lf\n%lf\n%lf\n",S,L,h);
	
	return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=6e3+5;
char buf[1<<12],*p1=buf,*p2=buf,nc;int ny;
//inline char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}int n,tmp,p[MAXN],kind[MAXN],cnt,bel[MAXN];string s,F[MAXN];
int main(){
	n=read(),cin>>s,p[0]=-1;
	Rep(i,0,2*n-1){
		tmp+=s[i]=='a'?1:-1;
		if(!tmp)p[++cnt]=i,kind[cnt]=s[i]=='a';
	}bool flg=1;
	Red(i,cnt,1){
		if(kind[i]){
			int s1=0,s2=0;
			Rep(j,p[i-1]+1,p[i])if(s[j]=='a')bel[j]=++s1;else bel[j]=++s2;
			F[i]=F[i+1],flg=0;
			Rep(j,1,s1){
				string cur;
				Rep(k,p[i-1]+1,p[i])if(bel[k]>=j)cur+=s[k];
				F[i]=max(F[i],cur+F[i+1]);
			}
		}else if(flg){
			int s1=0,s2=0;
			Rep(j,p[i-1]+1,p[i])if(s[j]=='a')bel[j]=++s1;else bel[j]=++s2;
			for(int r=p[i-1]+1;;){
				for(;r<=p[i]&&s[r]=='b';r++);
				if(r>p[i])break;int t=bel[r];
				for(r++,F[i]+="ab";bel[r]!=t;r++);r++;
			}F[i]+=F[i+1];
		}else F[i]=F[i+1];
	}cout<<F[1]<<'\n';
	return 0;
}




Measured memory_bytes: 16912
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 5e3 + 5;
int x, ans;

int32_t main() 
{
	ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
	cin >> x;
	int cur = 100;
	for(int i = 1; i < M; i++)
	{
		cur = (int)(cur * 1.01);
		if(cur >= x)
			return cout << i, 0;
	}
    	return 0;
}

Measured memory_bytes: 3648
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		while(true){
			int x = in.nextInt();
			int y = in.nextInt();
			if(x+y==0)break;
			new AOJ1072().doIt(x,y);
		}
	}

	class AOJ1072{
		void doIt(int x,int y){
			if((x*y)%2==0)System.out.println("yes");
			else System.out.println("no");
		}
	}
}

Measured memory_bytes: 21068
#include <iostream>
#include <string>

using namespace std;
int main()
{
	string a;
	cin >> a;
	int p = a.at(0);
	int o = a.at(1);
	int r = a.at(2);
	int w = a.at(3);

	int x = (p * 100) + (o * 10) + r;
	int z = (o * 100) + (r * 10) + w;

	if (x % 111 == 0 || z % 111 == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 3612
n = int(input())

a = n // 100
b = (n%100) // 10
c = n % 10

if a == 1:
    a = 9
else:
    a = 1
if b == 1:
    b = 9
else:
    b = 1
if c == 1:
    c = 9
else:
    c = 1
    
print(a*100+b*10+c)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


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 n;
int main(){
	cin>>n;
	int a=n;
	int digits=0;
	do{
		digits++;
		a/=10;
	}while(a!=0);
	int ans=0;
	if(digits==1){
		cout<<n<<endl;
	}else if(digits==2){
		cout<<9<<endl;
	}else if(digits==3){
		cout<<9+(n-99)<<endl;
	}else if(digits==4){
		cout<<909<<endl;
	}else if(digits==5){
		cout<<909+(n-9999)<<endl;
	}else{
		cout<<90909<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N=int(input())
s=[]
t=[]
for i in range(N):
    s_tmp,t_tmp=map(str,input().split())
    s.append(s_tmp)
    t.append(int(t_tmp))
X=input() 

# N=3
# s=["dwango","sixth","prelims"]
# t=[ 2, 5,25]
# X="prelims"

print(sum(t[s.index(X)+1:]))



Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (i % 2 == 0 && a[i] % 2 == 1) { ++ans; }
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3620
def d(a,b):
    return ((a[0]-b[0])**2+(a[1]-b[1])**2)**(.5)
n = int(raw_input())
l = [map(int,raw_input().split()) for i in range(n)]
s = 0
for i in range(n):
    for j in range(n):
        if i !=j:
            s += d(l[i],l[j])
print s/n

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

int main() {
	int N, D;
	cin >> N >> D;
	vector<vector<int>> vec(N, vector<int>(D));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++)
			cin >> vec.at(i).at(j);
	}
	double distance = 0;
	int count, x;
	count = 0;
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			distance = 0;
			for (int k = 0; k < D; k++)
				distance += pow(vec.at(i).at(k) - vec.at(j).at(k), 2);
			x = sqrt(distance);
			if (double(sqrt(distance) - x) == 0) count++;
		}
	}
	cout << count << endl;
}

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

namespace _1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            if (a < 10 && b < 10)
            { Console.WriteLine(a * b); }
            else { Console.WriteLine(-1); }
        }
    }
}

Measured memory_bytes: 11220
#include<stdio.h>
int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main(void)
{
  int A,B,C,N,Q,num[100000]={0};static long long sum=0;
  N=IN();
  while(N--){A=IN();num[A-1]++;sum+=A;}
  Q=IN();
  while(Q--)
  {
    B=IN()-1;C=IN()-1;
    sum+=1ll*num[B]*(C-B);
    num[C]+=num[B];num[B]=0;
    printf("%lld\n",sum);
  }
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int mp[222222];
int v[222222];
int n,h;

bool check(int mid){
	REP(i,n){
		if(v[i] >= mid)mp[i] = 1;
		else mp[i] = 0;
	}
	
	DBG(SHOW1d(mp,n);)
		
	if(mp[n/2] == mp[n/2+1] || mp[n/2] == mp[n/2-1]){
		DBG(cout << "!" << endl;)
		return mp[n/2];
	}
	else {
		int ret = 0, mi;
		int L = n/2;
		int R = n/2;
		while(L > 0 && mp[L] != mp[L-1])L--;
		if(L == 0)L--;
		while(R < n && mp[R] != mp[R+1])R++;
		if(R == n)R++;
		DBG(cout << "L R " << L << " " << R << endl;)
		if(R != n+1 && abs(n/2 - L) > abs(n/2 - R)){
			DBG(cout << "!!" << endl;)
			return mp[R];
		}
		else if(L != -1 && abs(n/2 - L) <= abs(n/2 - R)){
			DBG(cout << "!!!" << endl;)
			return mp[L];
		}
		else{
			DBG(cout << "!!!!" << endl;)
			return (mp[n/2] + (h % 2) + 1) % 2;
		}
	}
}

int main(){
	
	cin >> h;
	n = 2 * h - 1;
	REP(i,n)cin >> v[i];
	
	int low_b = 1;
	int up_b = n;
	
	while(abs(up_b - low_b) > 1){
		int mid = (up_b + low_b) / 2;
		if(check(mid))low_b = mid;
		else up_b = mid;
		DBG(cout << " " << mid << endl;)
	}
	
	cout << low_b << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)));
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(typename vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int N , K;

int main(){
	scanf("%d%d" , &N , &K);
	int ans = K;
	--K;
	repp(i,1,N){
		ans *= K;
	}
	printf("%d\n" , ans);
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
const int MaxN = 1e5;
int vis[MaxN + 5];
int b[MaxN + 5];
int n,c,a;
long long ans;

int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n;i++)
	{
		scanf("%d",&a);
		if(a > MaxN) 
		{
			ans++;
			continue;
		}
		vis[a] = 1;
		b[a]++;
		if(c < a) c = a;
	}
	for(int j = 1;j <= c;j++)
	{
		if(vis[j]==0) continue;
		if(b[j] > j) ans = ans + b[j] - j;
		if(b[j] < j) ans = ans + b[j];
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  int mx = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == '#') {
        continue;
      }
      vector<pair<int, int>> que;
      vector<vector<int>> dist(n, vector<int>(m, -1));
      que.emplace_back(i, j);
      dist[i][j] = 0;
      for (int b = 0; b < (int) que.size(); b++) {
        int x = que[b].first, y = que[b].second;
        for (int dx = -1; dx <= 1; dx++) {
          for (int dy = -1; dy <= 1; dy++) {
            if (dx * dx + dy * dy == 1) {
              if (dx + x >= 0 && dx + x < n && dy + y >= 0 && dy + y < m) {
                if (dist[dx + x][dy + y] == -1 && s[dx + x][dy + y] != '#') {
                  dist[dx + x][dy + y] = dist[x][y] + 1;
                  que.emplace_back(dx + x, dy + y);
                  mx = max(mx, dist[dx + x][dy + y]);
                }
              }
            }
          }
        }
      }
    }
  }
  cout << mx << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>
#include<map>
#include <utility>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int B, C;
  map<int, int, std::greater<int>> D;
  for (int j = 0; j < M; j++) {
    cin >> B >> C;
    D[C] += B;
  }

  sort(A.begin(), A.end());
  
  long int res = 0;
  auto itr = D.begin();
  int num = itr->second;
  for (int i = 0; i < N; i++) {
    
    if(A[i] < itr->first) {
      res+=itr->first;
      num--;
      if (num==0) {
	itr++;
	num = itr->second;
      }
    } else {
      res+=A[i];
    }
  }
  
  cout<<res<<endl;
  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll memo[2][10101][101];
ll mo=1000000007;
int N,D;
string K;

ll dp(int top,int d,int m) {
	if(d==N) return m==0;
	if(memo[top][d][m]>=0) return memo[top][d][m];
	
	ll ret=0;
	int i;
	if(top) {
		FOR(i,K[d]) ret+=dp(0,d+1,(m+i)%D);
		ret+=dp(1,d+1,(m+K[d])%D);
	}
	else {
		FOR(i,10) ret+=dp(0,d+1,(m+i)%D);
	}
	return memo[top][d][m]=ret%mo;
	
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K>>D;
	N=K.size();
	FORR(c,K) c-='0';
	
	MINUS(memo);
	cout<<(dp(1,0,0)+mo-1)%mo<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 17024
package main

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

func main() {
	var n, m int
	_, _ = fmt.Scan(&n, &m)
	list := make([][]string, m)
	sc := bufio.NewScanner(os.Stdin)
	
	for i := range list {
		sc.Scan()
		list[i] = strings.Split(sc.Text(), " ")
	}
	
	problems := make([]int, n)
	ac := 0
	wa := 0
	
	for _, t := range list {
		s, _ := strconv.Atoi(t[0])
		s -= 1
		if problems[s] != -1 {
			if t[1] == "WA" {
				problems[s] = problems[s] + 1
			} else {
				ac++
				wa += problems[s]
				problems[s] = -1
			}
		}
	}
	
	fmt.Println(ac, wa)
}


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

main()
{
    int n,d;
    cin>>n>>d;
    int a[n][d];
    for(int i=0;i<n;i++)
    for(int j=0;j<d;j++)
        cin>>a[i][j];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int val=0;
            for(int k=0;k<d;k++)
            {
                val+=pow(a[i][k]-a[j][k],2);
            }
            int sqrt_val=sqrt(val);
            if(sqrt_val*sqrt_val==val){
                ans++;
            }
        }
    }
    cout<<ans<<"\n";
}



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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

int query(Vec<int> q)
{
  cout << "? ";
  for (int i = 0; i + 1 < q.size(); i++) {
    cout << q[i] << " ";
  }
  cout << q[q.size() - 1] << endl;
  int res;
  cin >> res;
  return res;
}

void answer(Vec<bool> q)
{
  cout << "! ";
  for (int i = 0; i + 1 < q.size(); i++) {
    cout << q[i] << " ";
  }
  cout << q[q.size() - 1] << endl;
}

bool check(Vec<int> info)
{
  int n = info.size(), now = !(info.size() % 2);
  for (int i = 0; i < n; i++) {
    if (info[i] != now) return false;
    if ((i % 2) != (info.size() % 2)) {
      now += 2;
    }
  }
  return true;
}

void hawawa()
{
  int n;
  cin >> n;
  Vec<int> a(n);
  for (auto&& i : a) {
    cin >> i;
  }
  sort(begin(a), end(a));
  if (check(a)) {
    int ans = 1;
    for (int i = 1; i < n; i += 2) {
      ans *= 2;
      ans %= INF;
    }
    cout << ans << "\n";
  } else {
    cout << "0\n";
  }
}

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


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

typedef long long ll;
const int maxn = 2e5 + 10;
int n, a[maxn], c[20][maxn];
ll ans;

void add(int id, int pos) {
    for (; pos <= n; pos += pos & -pos) {
        c[id][pos]++;
    }
}

int query(int id, int pos) {
    int sum = 0;
    for (; pos >= 1; pos -= pos & -pos) {
        sum += c[id][pos];
    }
    return sum;
}

bool check(int l, int r) {
    for (int bit = 0; bit < 20; bit++) {
        if (query(bit, r) - query(bit, l - 1) > 1) {
            return false;
        }
    }
    return true;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 20; j++) {
            if (a[i] & (1 << j)) {
                add(j, i);
            }
        }
        int l = 1, r = i;
        while (l < r) {
            int mid = (l + r) >> 1;
            if (check(mid, i)) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }
        ans += max(0, i - l + 1);
    }
    printf("%lld\n", ans);
    return 0;
}

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);

using namespace std;

int main(){_
    int x;
    int t1 = 1000,t2 = 5;
    cin >> x;
    int quociente = x/500;
    int resto = x%500;
    resto /= 5;
    long int resposta = (quociente*t1) + (resto*t2);
    cout << resposta << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>

using ll = long long;
using namespace std;
template<typename T, typename U>
using P = pair<T, U>;

bool comparesecond(const P<int , int>& p1, const P<int, int>& p2){
    return p1.second > p2.second;
}

int main() {
    int n, ans = 0;
    vector<P<int, int>> vr, vb;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        vr.emplace_back(a, b);
    }
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        vb.emplace_back(a, b);
    }
    sort(vb.begin(), vb.end());
    sort(vr.begin(), vr.end(), comparesecond);
    for (auto &b: vb) {
        auto r = vr.begin();
        while (r != vr.end()){
            if((*r).first < b.first && (*r).second < b.second){
                r = vr.erase(r);
                ans++;
                break;
            }else r++;
        }
    }
    cout << n-vr.size() << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 1000000010
using namespace std;
typedef long long ll;
bool A[maxn];
int main(void)
{
    int n;
    cin>>n;
    bool flg = true;
    while(n--)
    {
        int x;
        cin>>x;
        if(!A[x])
            A[x] = true;
        else
        {
            flg = false;
        }
    }
    if(flg)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 975360
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int N; cin >> N;
    map<int, int> AMAP;
    for (int i = 0; i < N; i++)
    {
        int Ai; cin >> Ai;
        AMAP[Ai] = i + 1;
    }
    for (int i = 1; i <= N; i++)
    {
        cout << AMAP.at(i);
        if (i != N)
        {
             cout << " ";
        }
    }
    cout << endl;
	return 0;
}

Measured memory_bytes: 5504
package main

import "fmt"

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	left, right := max(a, c), min(b, d)
	if left <= right {
		fmt.Println(right - left)
	} else { // left > right
		fmt.Println(0)
	}
}


Measured memory_bytes: 512
import itertools
N, M =map(int, input().split())
G  = [[[] for _ in range(N)] for __ in range(M)]
visit = [0]*N
for i in range(M):
    a,b = map(int, input().split())
    for j in range(M):
      if i != j:
        G[j][a-1].append(b)
        G[j][b-1].append(a)
    
def dfs(v,goal,G,visit):
    visit[v-1]=1 
    if visit[goal-1]:
        return True 
    for next in G[v-1]:        
        if visit[next-1]:
            continue
        if dfs(next,goal,G,visit) == True:
            return True
    return False
  
comb = list(itertools.combinations(range(1,N+1),2))
count = 0

for g in G:
  flag = False
  for c in comb:
    visit = [0]*N  
    if not dfs(c[0],c[1],g,visit):
      flag = True
  if flag:
    count += 1
  
print(count)

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

int main(void)
{
  int n;
  cin >> n;
  long long sum = 0;
  for(int i = 1; i <= n; i++)
  {
    if(!(i % 15 == 0 || i % 5 == 0 || i % 3 == 0))
      sum += i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3612
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int n; 
		n=cin.nextInt();
		for(int i=0;i<n;i++){
			int y,m,d,x=0;
			y=cin.nextInt();
			m=cin.nextInt();
			d=cin.nextInt();
			x=x+(y-1)*195+(y-1)/3*5;
			if(y%3==0){
				x=x+(m-1)*20;
			}
			else if(y%3!=0){
					x=x+(m-1)*19+(m/2);
			}
			x=x+d;
			System.out.println(196471-x);
		}
	}

}

Measured memory_bytes: 20476
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 100005
#define MOD 1000000007
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int main()
{
    int d,t,s;
    scanf("%d %d %d",&d,&t,&s);
    if(t*s>=d)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 3824
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
using namespace std;

const int maxn = 100010 * 2;

int a[maxn], b[maxn];
int father[maxn];
map<int,int> mapp;
int cnt[maxn];
multiset<int> s;
int n;
set<int> all;

bool check_same()
{
	for (int i=1;i<=n;i++) s.insert(a[i]);
	for (int i=1;i<=n;i++)
	{
		if (s.count(b[i]) == 0) return false;
		multiset<int>::iterator iter = s.lower_bound(b[i]);
		s.erase(iter);
	}
	return true;
}

int find(int x)
{
	if (father[x] != x) father[x] = find(father[x]);
	return father[x];
}

void link(int u, int v)
{
	int fx = find(u), fy = find(v);
	if (fx != fy) father[fx] = fy;
}
	
int main()
{
	//freopen("D.in","r",stdin);
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]), a[n+1] ^= a[i];
	for (int i=1;i<=n;i++) scanf("%d",&b[i]), b[n+1] ^= b[i];
	n++;
	if (!check_same())
	{
		puts("-1");
		return 0;
	}

	for (int i=1;i<=n;i++) father[i] = i;
	for (int i=1;i<=n;i++) mapp[a[i]] = i;
	int edge = 0;
	for (int i=1;i<n;i++)
	{
		if (a[i] != b[i]) 
		{
			link(mapp[a[i]],mapp[b[i]]);
			edge++;
		}
	}
	for (int i=1;i<n;i++) 
		if (a[i] != b[i]) all.insert(find(mapp[a[i]])), all.insert(find(mapp[b[i]]));
	int cc = (int)all.size();
	if (all.count(find(mapp[a[n]])) == 0) cc++;
	if (all.count(find(mapp[b[n]])) == 0 && a[n] != b[n]) cc++;
	printf("%d\n",edge + cc - 1);
	return 0;
}


Measured memory_bytes: 8448
/***************************************************************
	File name: E.cpp
	Author: huhao
	Create time: Thu 16 Jan 2020 05:17:21 PM CST
***************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=r*10+c-48;
		c=getchar();
	}
	return r*t;
}
const int N=200010;
int n,a[N],m,ans,Ans;
int main()
{
	n=read()*2; m=read();
	fr(i,1,n) a[i]=read();
	std::sort(a+1,a+n+1);
	Ans=n/2;
	fd(i,n,1) while(n-i+1<=Ans&&a[i]+a[(n-Ans)-(i-(n-Ans+1))]<m) Ans--;
	int p1=n-Ans,p2=n-Ans+1;
	fr(i,1,Ans)
	{
//		printf("%d %d\n",a[p1],a[p2]);
		ans=std::max(ans,(a[p1--]+a[p2++])%m);
	}
	p1=n/2-Ans; p2=n/2-Ans+1;
	fr(i,1,n/2-Ans)
	{
//		printf("%d %d\n",a[p1],a[p2]);
		ans=std::max(ans,(a[p1--]+a[p2++])%m);
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    int a,b;
    cin>>a>>b;
    string A,B;

    for(int i = 0;i < b; i++) A += to_string(a);
    for(int i = 0;i < a; i++) B += to_string(b);

    if(A < B)cout<<A<<endl;
    else cout<<B<<endl;
    
}

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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readP(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public void readP(String str) {
		String[] strArr = str.split("\\s+");
		int min = N + 1;
		int ans = 0;
		for (int i = 0; i < N; i++) {
			int p = Integer.parseInt(strArr[i]);
			if (min > p) {
				ans++;
				min = p;
			}
		}
		System.out.println(ans);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


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

string N;

int main()
{
    cin >> N;

    for(int i = 0; i < 3; i++)
    {
        if(N[i] == '7')
        {
            cout << "Yes" << endl;
            break;
        }
        
        if(i == 2)
        {
            cout << "No" << endl;
        }
    }
}

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

int main() {
	//初期化
	int N;
	int K;
	cin >> N >> K;
	int array[N + 1];
	for (int i = 0; i < N; i ++){
		cin >> array[i];
	}	
	std::set<int> S;
	for (int i = 0; i < K; i ++){
		S.insert(array[i]);
	}

	//計算
	int ans;
	ans = 1;
	for (int i = K; i < N; i++){
		S.insert(array[i]);
		std::set<int>::iterator m = S.begin();
		std::set<int>::iterator M = S.end();
		M--;
		if (*M != array[i] || *m != array[i - K]){
			ans ++;
		}
		S.erase(array[i - K]);
	}
	int val = 0;
	int c = 1;
	for (int i = 0; i < N - 1; i++){
		if (array[i + 1] > array[i]){
			c++;
		}
		else{
			if (c >= K){
				val ++;
			}
			c = 1;
		}
	}
	if (c >= K){
		val ++;
	}
	if (val > 1){
		cout << ans - val + 1 << endl;
	}
	else{
		cout << ans << endl;
	}
}


Measured memory_bytes: 10368