akhauriyash/Code-Regression huggingface dataset:
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 10????????? cout << setprecision(10) << double;
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (???test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// ??\??????push_back(d)???array[d]???????????????1?????§?????????
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN(){T d;cin>>d;return d;}
// ?????§??¬?´???°???Greatest Common Divisor???
LL gcd(LL a, LL b){ return (b > 0) ? gcd(b, a%b) : a; }
// ????°???¬?????°???Least Common Multiple???
LL lcm(LL a, LL b){ return a / gcd(a, b) * b; }

// ------------------- include, typedef, define END. -------------------

// return 0:aiko , 1:win g , 2:win c 3: win p
int Result(bool demashita[]){

	// aiko : 5?????¨???????????????or  3?¨??????¨??¨??????
	if( (!demashita[0] && !demashita[1]) ||
		(!demashita[1] && !demashita[2]) ||
		(!demashita[2] && !demashita[0]) ||
		(demashita[0] && demashita[1] && demashita[2]))
		return 0;

	// ????????????
	else if(!demashita[2])	return 1;
	// ?????§?????????
	else if(!demashita[1])	return 3;
	// ??°?????????
	else return 2;

	return 0;
}

void Output(int hand[], int result){
	FOR(i,0,5){
		int ans=0;
		if(result == 1){
			// ??°?????????
			if(hand[i] == 1)	ans = 1;
			else				ans = 2;
		}else if(result == 2){
			// ?????§?????????
			if(hand[i] == 2)	ans = 1;
			else				ans = 2;
		}else if(result == 3){
			// ????????????
			if(hand[i] == 3)	ans = 1;
			else				ans = 2;
		}else{
			// ?????????
			ans = 3;
		}
		cout << ans << endl;
	}
}

int main(){
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;
	
	//??????????????????????????????.
	int hand[5];
	while(cin>>hand[0],hand[0]){
		bool demashita[3] = {false,false,false};	// [0]:g [1]:c [2]:p
		demashita[ hand[0] - 1 ] = true;
		FOR(i,0,4){
			cin >> hand[i+1];
			demashita[ hand[i+1] - 1 ] = true;
		}
		// output ans
		Output(hand, Result(demashita));
	}
	return 0;
}

Measured memory_bytes: 1192
#include <cstdio>
#include <vector>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<int> h(N);
  int sum = 0;
  for (int& hi: h) {
    scanf("%d", &hi);
    sum += hi;
  }

  int res = 0;
  while (sum) {
    size_t i = 0;
    for (; i < N; ++i)
      if (h[i] > 0) break;

    for (; i < N; ++i) {
      if (h[i] == 0) break;
      --h[i];
      --sum;
    }
    ++res;
  }

  printf("%d\n", res);
}


Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
    string n;
    string m;
 
   cin >> n >> m;
  
   cout << m+n << endl;
   
  return 0;
}

Measured memory_bytes: 256
def segfunc(x, y): return max(x, y)
def update(i, x):
    i += MAX_N-1
    node[i] = x
    while i:
        i = (i-1)//2
        node[i] = segfunc(node[i*2+1], node[i*2+2])

def query(l, r):
    L = l + MAX_N
    R = r + MAX_N
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = segfunc(s, node[R - 1])
        if L & 1:
            s = segfunc(s, node[L - 1])
            L += 1
        L >>= 1
        R >>= 1
    return s

N, K = map(int, input().split())
MAX_N = 2**(300005).bit_length()
a = [int(input()) for _ in range(N)]
node = [0] * (2 * MAX_N)
INF = 0
ans = 0

#for i in range(N):
#    update(i, a[i])

for i in a:
    tmp = query(max(i - K, 0), min(300005, i + K) + 1)
    update(i, tmp + 1)
    ans = max(ans, tmp + 1)
print(ans)


Measured memory_bytes: 103304
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	string N;
	cin >> N;

	cout << "ABC" + N << '\n';
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::Reverse;

#[allow(unused_imports)]
use proconio::{fastout, input, marker::Chars};

#[allow(unused_imports)]
use itertools::Itertools;

#[fastout]
pub fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }

    let mut dp = vec![false; k + 1];
    for i in 1..=k {
        a.iter().for_each(|&a| {
            if i >= a && !dp[i - a] {
                dp[i] = true;
            }
        });
    }
    println!("{}", if dp[k] { "First" } else { "Second" });
}


Measured memory_bytes: 2256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b,c,k;
string s,t;
signed main()
{
	cin>>s>>t;
	cout<<t<<s;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>

#include <vector>
#include <algorithm>
using namespace std;

#define rep_init(i, init, n) for(int i = (init); i < n; ++i)
#define rep(i, n) rep_init(i, 0, n)

template<typename T>
constexpr T int_pow(T b, uint64_t e)
{
	if (e == 0) return 1;
	if ((e & 0x1) == 0) return int_pow(b * b, e >> 1);
	else return b * int_pow(b * b, e >> 1);
}

template<typename T>
constexpr T divide_ceil(T a, T b)
{
	T remainder = a % b;
	return remainder == 0 ? a / b : (a + (b - remainder)) / b;
}

// Modulo が素数である必要がある。
template<typename T, T Modulo>
class modulo_int
{
public:
	modulo_int(T v)
		:value(v)
	{
		value = value >= 0 ? value % Modulo : value + divide_ceil(-value, Modulo) * Modulo;
	}

	operator T() const
	{
		return value;
	}

	modulo_int<T, Modulo> operator++(int)
	{
		T retval = value;
		value = value+1 == Modulo ? 0 : value+1;
		return retval;
	}

	modulo_int<T, Modulo> operator--(int)
	{
		T retval = value;
		value = value-1 == -1 ? Modulo-1 : value-1;
		return retval;
	}

	modulo_int<T, Modulo>& operator++()
	{
		value = value+1 == Modulo ? 0 : value+1;
		return value;
	}

	modulo_int<T, Modulo>& operator--()
	{
		value = value-1 == -1 ? Modulo-1 : value-1;
		return value;
	}

	modulo_int<T, Modulo> operator+()
	{
		return value;
	}

	modulo_int<T, Modulo> operator-()
	{
		return value == 0 ? 0 : Modulo-value;
	}

	modulo_int<T, Modulo>& operator*=(const modulo_int<T, Modulo>& t)
	{
		(value *= T(t)) %= Modulo;
		return *this;
	}

	modulo_int<T, Modulo>& operator/=(const modulo_int<T, Modulo>& t)
	{
		value = int_pow(value, Modulo-2) % Modulo;
		return *this;
	}

	modulo_int<T, Modulo>& operator+=(const modulo_int<T, Modulo>& t)
	{
		(value += T(t)) %= Modulo;
		return *this;
	}

	modulo_int<T, Modulo>& operator-=(const modulo_int<T, Modulo>& t)
	{
		value -= T(t);
		if (value < 0) value += divide_ceil(-value, Modulo) * Modulo;
		value %= Modulo;
		return *this;
	}

private:
	T value;
};

template<typename T, T Modulo>
modulo_int<T, Modulo> operator*(const modulo_int<T, Modulo>& t1, const modulo_int<T, Modulo>& t2) { return modulo_int<T, Modulo>(t1) *= t2; }

template<typename T, T Modulo>
modulo_int<T, Modulo> operator/(const modulo_int<T, Modulo>& t1, const modulo_int<T, Modulo>& t2) { return modulo_int<T, Modulo>(t1) /= t2; }

template<typename T, T Modulo>
modulo_int<T, Modulo> operator+(const modulo_int<T, Modulo>& t1, const modulo_int<T, Modulo>& t2) { return modulo_int<T, Modulo>(t1) += t2; }

template<typename T, T Modulo>
modulo_int<T, Modulo> operator-(const modulo_int<T, Modulo>& t1, const modulo_int<T, Modulo>& t2) { return modulo_int<T, Modulo>(t1) -= t2; }

using mint = modulo_int<int64_t, 1000000007>;

void Main()
{
	int N;
	cin >> N;

	mint P = 1;
	rep(i, N)
	{
		P *= mint(i)+1;
	}

	cout << P << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);

	Main();
	return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;
  
public class Main{
    public static void main(String[] ss){
        int h,w,i,j;
        Scanner s = new Scanner(System.in);
        while(true){
        h = s.nextInt();
        w = s.nextInt();
        if(h*w==0)break;
        for(i=1;i<=h;i++){
            for(j=1;j<=w;j++){
                if((i+j)%2==0)System.out.print("#");
                else System.out.print(".");
            }
                System.out.println();
            }
            System.out.println();
        }
    }
}



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

const int INF = 1e9 + 7;
int m;
int g1[100][100]; //cost
int g2[100][100]; //time

void floyd()
{
  for (int k = 0; k < m; k++) {
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < m; j++) {
        g1[i][j] = min(g1[i][j], g1[i][k] + g1[k][j]);
        g2[i][j] = min(g2[i][j], g2[i][k] + g2[k][j]);
      }
    }
  } 
}

signed main()
{
  int n, k;
  int a, b, c, t;

  while (cin >> n >> m, n || m) {
    for (int i = 0; i < 100; i++) {
      for (int j = 0; j < 100; j++) {
        g1[i][j] = INF;
        g2[i][j] = INF;
      }
    }

    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c >> t;
      a--;
      b--;
      g1[a][b] = c;
      g1[b][a] = c;
      g2[a][b] = t;
      g2[b][a] = t;
    }

    floyd();

    cin >> k;
    for (int i = 0; i < k; i++) {
      int p, q, r;
      cin >> p >> q >> r;
      if (r == 0) {
        cout << g1[p - 1][q - 1] << endl;
      } else {
        cout << g2[p - 1][q - 1] << endl;
      }
    }
  }
  return (0);
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
long long w[1000000],c[1000000];
int main()
{
	long long n,k,m,i,j,x,y,p;
	x=0;
	y=0;
	string s;
	cin>>n>>m;
	for (i=0;i<m;i++)
	{
		cin>>p;
		cin>>s;
		if (c[p]!=1)
		{
			if (s[0]=='W')
			{
				w[p]++;
			}
			else
			{
				c[p]=1;
				
			}
		}
	}
	for (i=0;i<=n;i++)
	{
		if (c[i]==1)
		{
			x++;
			y=y+w[i];
		}
	}
	cout<<x<<" "<<y<<endl;
}

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

void answer1() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> a(n);
  for(int& a_i: a) {
    cin >> a_i;
  }

  long long count = 0;
  long long sum = 0;
  long long count2 = 0;
  long long sum2 = 0;
  bool is_positive = a.at(0) > 0;
  for (int i = 0; i < a.size(); i++) {
    sum += a.at(i);
    sum2 += a.at(i);

    if (is_positive) {
      if (sum <= 0) {
        // 次は1になるまでインクリメント
        long long diff = 1 - sum;
        count += diff;
        sum += diff;
      }
      if (sum2 >= 0) {
        // 次は-1になるまでデクリメント
        long long diff = 1 + sum2;
        count2 += diff;
        sum2 -= diff;
      }
    } else {
      if (sum >= 0) {
        // 次は-1になるまでデクリメント
        long long diff = 1 + sum;
        count += diff;
        sum -= diff;
      }
      if (sum2 <= 0) {
        // 次は1になるまでインクリメント
        long long diff = 1 - sum2;
        count2 += diff;
        sum2 += diff;
      }
    }
    is_positive = ! is_positive;
  }
  cout << min(count, count2) << endl;

}

void answer2() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> a(n);
  for(int& a_i: a) {
    cin >> a_i;
  }

  long long count = 0;
  long long sum = 0;
  long long count2 = 0;
  long long sum2 = 0;

  for (int i = 0; i < a.size(); i++) {
    sum += a.at(i);
    sum2 += a.at(i);
    if (i % 2 == 0) {
      // 偶数番目が正
      if (sum <= 0) {
        long long diff = 1 - sum;
        count += diff;
        sum = 1;
      }
      // 偶数番目が負
      if (sum >= 0) {
        long long diff = 1 + sum;
        count += diff;
        sum = -1;
      }
    } else {
      // 奇数番目が負
      if (sum >= 0) {
        long long diff = 1 + sum;
        count += diff;
        sum = -1;
      }
      // 奇数番目が正
      if (sum <= 0) {
        long long diff = 1 - sum;
        count += diff;
        sum = 1;
      }
    }
  }
  cout << min(count, count2) << endl;
}

int main() {
  answer1();
  //answer2();
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
ll lcm(ll a,ll b)
{
	return (a/__gcd(a,b))*b;
}
bool cmp(pair<string,ll> a,pair<string,ll> b)
{
	if(a.first<b.first)
		return 1;
	else if(a.x==b.x)
	{
		return a.y<b.y;
	}
	return 0;
}
bool cmp(ll a,ll b)
{
	return a>b;
}
ll cnt(ll a,ll b,ll x)
{
	ll lf=0,ri=0;
	if(a%x==0)
	{
		lf=a/x;
	}
	else
	{
		lf=1+(a/x);
	}
	ri=b/x;
	return ri-lf+1;
}
void solve()
{
	ll a,b,x,y;
	cin>>a>>b>>x>>y;
	ll p=cnt(a,b,x);
	ll q=cnt(a,b,y);
	ll lcm=(x*y)/__gcd(x,y);
	ll r=cnt(a,b,lcm);
	//cout<<p<<" "<<q<<" "<<r<<" ";
	cout<<b-a+1-p-q+r;
	
}	
int main()
{
	
	IOS
	ll t;
	t=1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 256
//ritik_patel05

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& STL DEBUGGER &&&&&&&&&&&&&&&&&&&&&&&&&&&

// #define _GLIBCXX_DEBUG       // Iterator safety; out-of-bounds access for Containers, etc.
// #pragma GCC optimize "trapv" // abort() on (signed) integer overflow.

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& LIBRARIES &&&&&&&&&&&&&&&&&&&&&&&&&&&

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

/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; 
*/
//find_by_order()->returns an iterator to the k-th largest element(0-based indexing)
//order_of_key()->Number of items that are strictly smaller than our item

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEFINES &&&&&&&&&&&&&&&&&&&&&&&&&&&

#define int long long int
#define all(i) i.begin(), i.end()
#define sz(a) (int)a.size()
 
// const ld PI  = 3.141592;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& DEBUG &&&&&&&&&&&&&&&&&&&&&&&&&&&
 
#define XOX
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}
 
void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
 
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CODE &&&&&&&&&&&&&&&&&&&&&&&&&&&

void solve(){
    int x, y; cin >> x >> y;
    for(int a = 0; a <= 100; ++a){
        for(int b = 0; b <= 100; ++b){
            if(a * 4 + b * 2 == y and a + b == x){
                cout << "Yes\n";
                return;
            }
        }
    }
    cout << "No\n";
}


int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    int T = 1; 
    // cin >> T;
    for(int i = 1; i <= T; ++i){
        // brute();
        solve();
    }
    return 0;
}

/*
Sample inp
*/

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

int N;
string S;

int main() {
    cin >> N >> S;
    ll ans = 1;
    REP (i, N-1) if (S[i] != S[i+1]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

string s;
cin>>s;
int N=s.size();
long long ans=0;
for(int i=0;i<N/2;i++){
    if(s[i]!=s[N-1-i])ans++;
}

cout<<ans<<endl;
 return 0;
}
/*
redcoder

1

vvvvvv

abcdabc

2
*/

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int n;
int c;
int k;
int t[100000];

int main(){
  scanf("%d%d%d",&n,&c,&k);
  for(int i=0;i<n;++i)
    scanf("%d",t+i);
  sort(t,t+n);
  int cnt = 0;
  for(int i=0;i<n;){
    int x = t[i]+k;
    ++i;
    ++cnt;
    int bus = 1;
    while(i<n && bus<c && t[i]<=x)
      ++i,++bus;
  }

  printf("%d\n",cnt);
  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long[] A;
        public long[] S;

        public void Run()
        {
            {
                N = Input.ReadInt();
                A = Input.ReadLongArray();
            }

            S = new long[N];
            for (int i = 0; i < N; i++)
            {
                S[i] = (i == 0 ? 0 : S[i - 1]) + A[i];
            }

            var D = new Dictionary<long, long>();
            D.Add(0, 1);
            for (int i = 0; i < N; i++)
            {
                if(!D.ContainsKey(S[i])) D.Add(S[i], 0);
                D[S[i]]++;
            }

            long ret = 0;
            foreach (var k in D.Keys)
            {
                ret += D[k] * (D[k] - 1) / 2;
            }

            Console.WriteLine(ret);
        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 40984
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

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

    bool flag1 = true;
    bool flag2 = true;
    bool flag3 = true;

    int n = s.size();
    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[n - i - 1]) {
            flag1 = false;
        }
    }

    int k = (n - 1) / 2;
    for (int i = 0; i < k / 2; i++) {
        if (s[i] != s[k - i - 1]) {
            flag2 = false;
        }
    }

    int l = (n + 1) / 2;
    for (int i = l; i < n; i++) {
        if (s[i] != s[n + l - i - 1]) {
            flag3 = false;
        }
    }

    if (flag1 and flag2 and flag3) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final int N = sc.nextInt();
			
			int[] array = new int[N];
			for(int i = 0; i < N; i++){
				array[i] = sc.nextInt();
			}
			
			Arrays.sort(array);
			
			int answer = 1;
			for(int i = 1; i < N; i++){
				if(array[i - 1] < array[i]){
					answer++;
				}
			}
			
			System.out.println(answer);
		}
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

/**
 * A-Z Cat
 */
public class Main {

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

		line = br.readLine();
		Deque<Character> az = new ArrayDeque<>();

		boolean a = true;
		for (char c : line.toCharArray()) {
			if (c == 'A' && a) {
				az.add(c);
				a = false;
			}
			if (c == 'Z' && !a) {
				az.add(c);
				a = true;
			}
		}
		if (!az.isEmpty() && az.peekLast() == 'A') {
			az.pollLast();
		}

		if (!az.isEmpty()) {
			StringBuilder sb = new StringBuilder();
			for (char c : az) sb.append(c);
			System.out.println(sb.toString());
		} else {
			System.out.println(-1);
		}
	}
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> p(m), y(m);
  vector<vector<ll>> yd(100001);

  rep(i, m) cin >> p[i] >> y[i], yd[p[i]].push_back(y[i]);
  rep(i, n) sort(yd[i + 1].begin(), yd[i + 1].end());
  rep(i, m) printf("%06lld", p[i]),
      printf("%06lld\n", lower_bound(yd[p[i]].begin(), yd[p[i]].end(), y[i]) -
                             yd[p[i]].begin() + 1);
}


Measured memory_bytes: 8576
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

int main(){
    int k, x;
    cin >> k >> x;
    
    int lnum = max(-1000000, x - k + 1);
    int unum = min(1000000, x + k - 1);

    for(int num = lnum; num <= unum; ++num){
        cout << num;
        
        if(num == unum){
            cout << endl;
        }else{
            cout << ' ';
        }
    }
    return 0;
}

Measured memory_bytes: 888
import java.io.*;
import java.util.*;

public class Main
{
    public static void main (String[] args) throws java.lang.Exception    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken()),
            m = Integer.parseInt(st.nextToken());
        if (Math.abs(n-m)>1) {
            System.out.println(0);
            return;
        }
        long a = 1,
            b = 1;
        int mod = 1000000007;
        for (int i=2 ; i<=n ; i++) {
            a *= i;
            a = a % mod;
        }
        for (int i=2 ; i<=m ; i++) {
            b *= i;
            b = b % mod;
        }
        
        if (Math.abs(n-m) == 1) {
            System.out.println((a*b)%mod);
            return;
        }
        
        System.out.println(2*((a*b)%mod)%mod);
        
    }
}


Measured memory_bytes: 22996
#include<stdio.h>

int main()
{
  int x, y, t, i;

  for(i = 1; i <= 10000; i++){
    scanf("%d%d", &x, &y);
    if(x == 0 && y == 0) break;

    if(x > y){
      t = x;
      x = y;
      y = t;
    }
    printf("%d %d\n", x, y);
  }

  return 0;
}

Measured memory_bytes: 600
import sys
from collections import deque

input = sys.stdin.readline


def bfs(G, v, p, counter):
    queue = deque([(v, p)])
    while queue:
        v, p = queue.popleft()
        for c in G[v]:
            if c == p:
                continue
            counter[c] += counter[v]
            queue.append((c, v))


def main():
    N, Q = map(int, input().split())

    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)

    counter = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        counter[p] += x

    bfs(G, 0, -1, counter)

    print(" ".join(map(str, counter)))


if __name__ == "__main__":
    main()


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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	string s;
    cin >> s;
    int n = s.length();
    int maxl = 0, tmp = 0;
    bool flag = false;
    REP(i, n){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
            if(!flag){  //計測開始点
                flag = true;
                tmp++;
            }else{
                tmp++;
            }
        }else{
            if(flag){
                maxl = max(maxl, tmp);
                tmp = 0;
                flag = false;
            }
        }
    }
    maxl = max(maxl, tmp);
    cout << maxl << endl;
	return 0;
}


Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

string s,t;
int k;
vector <string> v;

int main()
{
	cin>>s>>k;
	int sz=s.size();
	rep(i,sz)
	{
		t="";
		for(int j=i;j<sz&&j-i<k;j++)
		{
			t.pb(s[j]);
			v.pb(t);
		}
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	cout<<v[k-1]<<endl;
	rt0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;cin >> a >> b >> c;
    cout << min(c,b/a) << endl;
}

Measured memory_bytes: 256
def main():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))

    best_num = 0
    best_diff = 999
    for i in range(102):
        if i not in p and abs(x - i) < best_diff:
            best_num = i
            best_diff = abs(x - i)

    print(best_num)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9088
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
const int N=100000+10;
int a[N];
int main()
{
    int n,c,k;
    while(~scanf("%d%d%d",&n,&c,&k))
    {
        for(int i=0;i<n;i++) scanf("%d",&a[i]);
        sort(a,a+n);
        int ans=0,l=a[0],len,r=1;
        for(int i=1;i<n;i++)
        {
             len=a[i]-l;
             r++;
         //    if(i==n-1) cout<<l<<endl;
             if(len>k||r>c)
             {
                 ans++;
                 l=a[i];
                 r=1;
             }
             if(i==n-1) ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(args...) do { cout << "DEBUG: " << #args << " -> "; err(args); } while (0)
#else
#define dbg(...)
#endif
void err() { cout << "" << endl; }
template<template<typename...> class T, typename t, typename... Args>
void err(T<t> a, Args... args) { for (auto x: a) cout << x << ' '; err(args...); }
template<typename T, typename... Args>
void err(T a, Args... args) { cout << a << ' '; err(args...); }
// -----------------------------------------------------------------------------

const int N = 200;
LL n, x, a[N];

int main() {
    cin >> n >> x;
    FOR (i, 0, n) cin >> a[i];
    sort(a, a + n);
    LL ans = 0, now = 0;
    FOR (i, 0, n) {
        now += a[i];
        if (now == x) ans = i + 1;
        else if (now < x) {
            if (i < n - 1) ans = i + 1;
            else ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

struct Edge {
public:
	int from, to;
	Edge() {}
	Edge(int _from, int _to) {
		from = _from;
		to = _to;
	}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;



vi indeg;//各頂点の入次数を管理。
vb visited;//各頂点の訪問状態を管理

void bfsForTSort(int s, Graph G, vi &out) {
	queue<int> Q;
	Q.push(s);
	visited[s] = true;
	while (!Q.empty()) {
		int u = Q.front(); Q.pop();
		out.push_back(u);
		for (Edge e : G[u]) {
			indeg[e.to]--;
			if (indeg[e.to] == 0 && !visited[e.to]) {
				visited[e.to] = true;
				Q.push(e.to);
			}
		}
	}
}

vi topologicalSort(Graph G) {
	vi ret;//返り値
	indeg = vi(SZ(G), 0);
	visited = vb(SZ(G), false);
	REP(i, SZ(G)) {
		for (Edge e : G[i]) {
			indeg[e.to]++;
		}
	}
	REP(u, SZ(G)) {
		if (indeg[u] == 0 && !visited[u])bfsForTSort(u, G, ret);
	}
	return ret;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	Graph G(N);
	REP(i, N - 1 + M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(Edge(a, b));
	}
	vi result = topologicalSort(G);
	vi Indeg(N);
	REP(i, N) {
		for (Edge e : G[i]) {
			Indeg[e.to]++;
		}
	}
	vi ans(N, 0);
	REP(i, N) {
		int v = result[i];
		for (Edge e : G[v]) {
			Indeg[e.to]--;
			if (Indeg[e.to] == 0) {
				ans[e.to] = v + 1;
			}
		}
	}
	REP(i, N) {
		cout << ans[i] << endl;
	}
	PAU;
	return 0;
}


Measured memory_bytes: 17664
#include <stdio.h>
int main(void){
    int i,a,b,n,s,e;
    scanf("%d %d\n%d",&a,&b,&n);
    for(i=0;i<n;++i){
        scanf("%d %d",&s,&e);
        if(b>s&&a<e){
            printf("1\n");
            return 0;
        }
    }
    printf("0\n");
}


Measured memory_bytes: 2112
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

		int W = keyboard.nextInt();
		int H = keyboard.nextInt();
		int N = keyboard.nextInt();
		
		int[] menseki = new int[W*H];
		
		for(int i = N; i > 0; i--) {
			int X = keyboard.nextInt();
			int Y = keyboard.nextInt();
			int a = keyboard.nextInt();
			
			if(a == 1) {
				for(int a1 = 0; a1 < W*H; a1++) {
					if(a1 % W < X) {
						menseki[a1] = 1;	
					}
				}
			}else if(a == 2) {
				for(int a2 = 0; a2 < W*H; a2++) {
					if(a2 % W >= X) {
						menseki[a2] = 1;	
					}
				}
			}else if(a == 3) {
				for(int a3 = 0; a3 < W*H; a3++) {
					if(a3 < (Y*W)) {
						menseki[a3] = 1;	
					}
				}
			}else {
				for(int a4 = 0; a4 < W*H; a4++) {
					if(a4 >= (Y*W)) {
						menseki[a4] = 1;	
					}
				}
			}
		}
		
		int count = 0;
		for(int j = 0; j < W*H; j++){
			if(menseki[j] == 0) {
			count++;
			}
		}

		System.out.print(count);
		keyboard.close();	
	}
}


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

	using namespace std;

	long long h[100000];

	int main() {

		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);

		long long n;
		cin >> n;
		long long current, prev = 0;
		int index = 0;
		for (int i = 0; i < n; ++i) {
			cin >> current;
			if (current == prev) continue;
			prev = current;
			h[index] = current;
			index++;
		}
		for (int i = 0; i < index - 2; ++i) {
			if (h[i] - h[i + 1] >= 2) {
				cout << "No\n";
				return 0;
			}
			else if (h[i] - h[i + 1] >= 1 && h[i + 1] - h[i + 2] >= 1) {
				cout << "No\n";
				return 0;
			}
		}
		cout << "Yes\n";
		return 0;
	}

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

int main(){
    int r, c, sum;
    cin >> r >> c;
    vector<vector<int>> table(r+1, vector<int>(c+1));
    for (int i=0; i<r; i++){
        sum = 0;
        for (int j=0; j<c; j++){
            cin >> table.at(i).at(j);
            cout << table.at(i).at(j) << " ";
            sum += table.at(i).at(j);
        }
        table.at(i).at(c) = sum;
        cout << sum << endl;
    }
    for (int j=0; j<c+1; j++){
        sum = 0;
        for (int i=0; i<r; i++){
            sum += table.at(i).at(j);
        }
        table.at(r).at(j) = sum;
    }
    for (int i=0; i<c+1; i++){
        if (i != c){
            cout << table.at(r).at(i) << " ";
        }else{
            cout << table.at(r).at(i) << endl;
        }
    }
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define ld long double
#define hell 1000000007
#define dd double
#define rep(i,a,n) for(ll i = a; i < n; i++)
#define sep(i,n,b) for(ll i=n-1;i>=b;i--)
#define pb push_back
#define mp make_pair
#define Mll map<ll,ll>
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll k;
	cin >> k;
	string s;
	cin >> s;
	if(s.length()<=k){
		cout << s;
	}	
	else{
		cout << s.substr(0,k) << "...";
	}
	return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  int a[20];
  for(int i=0;i<m;i++){
    cin>>a[i];
  }
  int x[60001];
  for(int i=0;i<=60000;i++){
    x[i]=60000;
  }
  x[0]=0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<m;j++){
      if(x[i]==0){
	x[i+a[j]]=1;
      }
      else if(i>=a[j]){
	x[i+a[j]]=min(x[i+a[j]],x[i]+1);
      }
    }
  }
  cout<<x[n]<<endl;
  return 0;
}



Measured memory_bytes: 3340
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
struct UnionFind{
    vector<int> d; //rootなら-size、それ以外はrootのindexをもつ
    UnionFind(int n=0) : d(n,-1){}
    //find: id->親のid
    int find(int x){
        if(d[x]<0) return x;
        return d[x] = find(d[x]);
    }
    //unite: 2つのindex(x,y)を含む木をくっつける
    bool unite(int x, int y){
        x = find(x); y = find(y);
        if(x==y) return false;
        if(d[x]>d[y]) swap(x,y); //xのサイズがyより小さい場合、yのindexをxにする。
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y){return find(x)==find(y);}
    int size(int x){return -d[find(x)];}
};
vector<int> to[100005];
vector<int> br[100005];
int main(){
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
        uf.unite(a,b);
    }
    rep(i,k){
        int c,d;
        cin >> c >> d;
        c--; d--;
        br[c].push_back(d);
        br[d].push_back(c);
    }
    rep(i,n){
        int ans = uf.size(i)-1;
        for(auto t : to[i]){
            if(uf.same(i,t)) ans--;
        }
        for(auto b : br[i]){
            if(uf.same(i,b)) ans--;
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main() {

  int N, ans = 0;
  cin >> N;
  
  for(long long i = 1; i <= N-1; i++) {
    for(long long j = 1; j <= N-1; j++) {
      if(i*j < N) ans++;
      else break;
    }
  } 
  
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
typedef pair<int, int> P;

bool pairsort1(const P& element1, const P& element2)
{//first昇順
	return element1.F < element2.F;
}
bool pairsort2(const P& element1, const P& element2)
{//first降順
	return element1.F > element2.F;
}
bool pairsort3(const P& element1, const P& element2)
{//second昇順
	return element1.S < element2.S;
}
bool pairsort4(const P& element1, const P& element2)
{//second降順
	return element1.S > element2.S;
}

int main() {
	int N;
	scanf("%d",& N);
	vector <pair<int, int>>ab(N), cd(N);
	vector<vector<bool>>map(N*2, vector<bool>(N*2));
	rep(i, N) {
		scanf("%d %d",& ab[i].F ,&ab[i].S);
		map[ab[i].F][ab[i].S]=true;
	}
	rep(i, N) {
		scanf("%d %d",& cd[i].F,& cd[i].S);
	}
	sort(all(cd), pairsort1);
	sort(all(ab),pairsort1);
	vector<pair<int,int>>pair(N);
	int atmp = 0 , btmp = 0;
	int count = 0;
	rep(i, N) {
		int j = 0;
		int atmp = 0;
		int btmp = -1;
		bool flag = false;
		while (ab[j].F < cd[i].F){
			if (ab[j].S < cd[i].S &&
			       btmp < ab[j].S &&
				map[ab[j].F][ab[j].S] ==true) {
				atmp = ab[j].F;
				btmp = ab[j].S;
				flag = true;
			}
			j++;
			if (j == N) {
				break;
			}
		}
		if (flag) {
			count++;
			map[atmp][btmp] = false;
		}
	}
	printf("%d\n",count);
}



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

int main(){
  int n, k;

  cin >> n;
  // char s[n-1];
  //ここがダメだった
  // 最初に10だけだったんだから入れとけばよかった
  // max +ちょいくらいの範囲を持たせておく
  char s[20] = "";
  
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  
  cin >> k;
  if(k <= n){
    for(int i = 0; i < n; i++){
      if(s[i] != s[k-1]){
        s[i] = '*';
      }
    }
  }
  cout << s << endl;
  return 0;
 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[51],b[51],c[51],d[51];
int now[11];
long long ans=0;
int n,m,q;
void check()
{
	long long res=0;
	for(int i=1;i<=q;i++)
	{
		if(now[b[i]]-now[a[i]]==c[i])res+=d[i];
	}
	ans=max(ans,res);
}
void dfs(int pos,int last)
{
	if(pos==n){
		check();return;
	}
	for(int i=last;i<=m;i++)
	{
		now[pos+1]=i;
		dfs(pos+1,i);
	}
}
int main()
{
	cin>>n>>m>>q;
	for(int i=1;i<=q;i++)
	{
		scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
	}
	dfs(0,1);
	printf("%lld\n",ans);
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,m,s,t;
    cin >> n >> m;
    matrix G(n*3);
    rp(i,m){
        ll u,v;
        cin >> u >> v;
        u--; v--;
        G[u*3].pb(v*3+1);
        G[u*3+1].pb(v*3+2);
        G[u*3+2].pb(v*3);
    }
    cin >> s >> t;
    s--; t--;
    queue<PLL> que;
    que.push(mp(s*3,0));
    vi seen(n*3,0);
    while(!que.empty()){
        PLL p=que.front(); que.pop();
        if(seen[p.first]==1) continue;
        if(p.first==t*3){
            print(p.second/3);
            return;
        }
        seen[p.first]=1;
        for(auto nod:G[p.first]){
            que.push(mp(nod,p.second+1));
        }
    }
    print(-1);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 20820
/*
 * 17-08-06_ARC080_D.cpp
 *
 *  Created on: 2017/08/06
 *      Author: ryoma
 */

#include<iostream>
#include<algorithm>

using namespace std;

int H, W, N;
int a[10010];
int out[110][110];
int main() {
	cin >> H >> W;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int cnt = 0;
	int c = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cnt++;
			if (i & 1)
				out[i][W - j - 1] = c + 1;
			else
				out[i][j] = c + 1;
			if (cnt == a[c]) {
				cnt = 0;
				c++;
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << out[i][j] << ((j < W - 1) ? " " : "\n");
		}
	}
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
int order(ll x){
    int count=0;
    while(x>0){
        count++;
        x/=10;
    }
    return count;
}
int main(void){
    ll n;cin>>n;ll x;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0)x=i;
    }
    cout<<max(order(x),order(n/x))<<endl;
}

Measured memory_bytes: 256
/*
次のC++言語のプログラムと同じ動作をするプログラムを作成してください。ただし、goto 文は使わないで実装してみましょう。

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10; -> 1桁ずつ下げて、下一桁が3になるかどうかをチェックしている
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}
 */

// 例：n = 30
// output: 3 6 9 12 13 15 18 21 23 24 27 30

#include <stdio.h>

int main(void)
{
    int n;
    int i, x;

    scanf("%d", &n);

    for (i = 3; i <= n; i++)
    {
        x = i;
        if (i % 3 == 0)
            printf(" %d", i);
        else
        {
            do {
                if (x % 10 == 3)
                {
                    printf(" %d", i);
                    break ;
                }
                x /= 10;
            }
            while(x != 0);
        }
    }
    printf("\n");
    return (0);
}


Measured memory_bytes: 2120
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        short n = scanner.nextShort();
        short m = scanner.nextShort();

        short[][] a = new short[n][m];
        short[]   b = new short[m];

        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                a[i][j] = scanner.nextShort();
            }
        }

        for(int i = 0; i < m; i++){
            b[i] = scanner.nextShort();
        }

        int x = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                x += a[i][j]*b[j];
            }
            System.out.println(x);
            x = 0;
        }

    }
}



Measured memory_bytes: 40764