akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
#define bcj int ff[SZ];\
int gf(int x) {return ff[x]?ff[x]=gf(ff[x]):x;}\
void uni(int a,int b) {int ga=gf(a),gb=gf(b); if(ga^gb) ff[ga]=gb;}
int n,k,l;
namespace G1
{
bcj
}
namespace G2
{
bcj
map<int,int> cnt[233333];
void pre()
{
	for(int i=1;i<=n;i++) ++cnt[gf(i)][G1::gf(i)];
	for(int i=1;i<=n;i++) printf("%d ",cnt[gf(i)][G1::gf(i)]);
}
}
int main()
{
	scanf("%d%d%d",&n,&k,&l);
	for(int i=1;i<=k;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		G1::uni(a,b);
	}
	for(int i=1;i<=l;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		G2::uni(a,b);
	}
	G2::pre();
}


Measured memory_bytes: 20992
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll oo = 1e15;
const int nodeCount = 1e6;
const int edgeCount = 3e6;
struct edge {
	int u, v, next;
	ll cap;
}E[edgeCount];
int n, e, parent[nodeCount], last[nodeCount];
ll cost[nodeCount];
void addEdge(int a, int b, ll cap) {
	E[e].u = a; E[e].v = b; E[e].cap = cap; E[e].next = last[a];
	last[a] = e++;
	E[e].u = b; E[e].v = a; E[e].cap = 0; E[e].next = last[b];
	last[b] = e++;
}
bool getPath(int src, int sink) {
	for (int i = 0; i < n; ++i)
		cost[i] = oo;
	cost[src] = 0;
	queue<int> q;
	q.push(src);
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (int e = last[u]; e != -1; e = E[e].next)
			if (E[e].cap > 0 && cost[E[e].v] == oo) {
				cost[E[e].v] = cost[E[e].u] + 1;
				parent[E[e].v] = e;
				q.push(E[e].v);
			}
	}
	return cost[sink] != oo;
}
ll calc(int src, int sink) {
	ll flow = 0;
	while (getPath(src, sink)) {
		ll z = oo;
		for (int cur = sink; cur != src; cur = E[parent[cur]].u)
			z = min(z, E[parent[cur]].cap);
		for (int cur = sink; cur != src; cur = E[parent[cur]].u) {
			E[parent[cur]].cap -= z;
			E[parent[cur] ^ 1].cap += z;
		}
		flow += z;
	}
	return flow;
}
int main()
{
	memset(last, -1, sizeof(last));
	int N;
	cin >> N;
	vector<int> v(N);
	ll total = 0;
	ll total2 = 0;
	for (auto &x : v) {
		cin >> x;
		total += x;
		if (x > 0)
			total2 += x;
		//x *= -1;
	}
	n = N;
	int src = n++;
	int sink = n++;
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j < i; ++j)
			if (i%j == 0)
				addEdge(i - 1, j - 1, oo);
	}
	for (int i = 0; i < v.size(); ++i) {
		if (v[i] < 0)
			addEdge(i, sink, -v[i]);
		else {
			addEdge(src, i, v[i]);
		}
	}
	ll f = calc(src, sink);
	queue<int> q;
	q.push(src);
	vector<bool> vis(n);
	vis[src] = true;
	ll res = 0;
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		if (u < N)
			res += v[u];
		for(int e=last[u];e!=-1;e=E[e].next)
			if (E[e].cap > 0 && !vis[E[e].v]) {
				vis[E[e].v] = true;
				q.push(E[e].v);
			}
	}
	cout << res << endl;
	//cout << f << endl;
	return 0;
}

Measured memory_bytes: 8448
fn main() {
    let f: Vec<i32> = read_vec();
    let num = f[0];
    let price = f[1];

    if price <= 500 * num {
        println!("Yes");
    } else {
        println!("No");
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
n,m=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]
B=[list(map(int,input().split())) for i in range(m)]
for a in A:
    m=float('Inf')
    p=0
    for i,b in enumerate(B):
        if m>abs(a[0]-b[0])+abs(a[1]-b[1]):
            m=abs(a[0]-b[0])+abs(a[1]-b[1])
            p=i+1
    print(p)

Measured memory_bytes: 9212
l=list(map(int,input()))

n=3
for i in range(2**n):
    s = str(l[0])
    sum_s = l[0]
    for j in range(n):
        #j桁目が1の時
        if (i>>j)&1:
            s+='+'+str(l[j+1])
            sum_s+=l[j+1]
        #ｊ桁目が0の時
        else:
            s+='-'+str(l[j+1])
            sum_s-=l[j+1]

    if sum_s==7:
        print(s+'=7')
        exit()

Measured memory_bytes: 3064
N = int(input())
h = list(map(int,input().split()))
# dp[i] 足場iに辿り着くまでに支払うコストの総和の最小値
# dp[0] = 0, dp[1] = 0, dp[2] = abs(h[1] - h[0])
dp = [0 for i in range(N+1)]
dp[2] = abs(h[1] -h[0])
for i in range(3,N+1):
    dp[i] = min(dp[i-1]+abs(h[i-1]-h[i-2]),dp[i-2]+abs(h[i-1]-h[i-3]))
print(dp[N])

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

#define ll long long

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, m, a[101], sum = 0;
	cin >> n >> m;
	for (int i=1; i<=n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	sort (a+1, a+1+n);
	for (int i=n; i>=n-m+1; i--) {
		int nw = a[i]*4*m;
		if (nw < sum) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n, m;
  cin >> n;
  map<int, int> c;
  for (int i = 0; i < n; ++i) {
    int x; cin >> x;
    c[x]++;
  }
  bool ok = 1;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int x; cin >> x;
    c[x]--;
    if (c[x] < 0) ok = 0;
  }
  if (ok) cout << "YES\n";
  else cout << "NO\n";
  return 0;
}

Measured memory_bytes: 9600
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i,s,n) for(int i =(int)s;i<(int)n;++i)
#define rep(i,n) REP(i, 0, n)
int N;
vector<string> ans;
string S;
void dfs(string k, int it) {
  if(it == N) {
    ans.push_back(k);
    return;
  }
  rep(i, 2) {
    if(i == 1 && S[it] == 'z') continue;
    char aim = S[it] + i;
    bool before = false;
    rep(i, it) if(k[i] == aim) before = true;
    bool ok = before ^ i;
    if(it == 0 && i == 1) ok = true;
    if(S[it] == 'a' && i == 0) ok = true;
    if(ok) {
      string temp = k;
      temp.push_back(aim);
      dfs(temp, it + 1);
    }
  } 
}
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  while(cin >> S && S != "#") {
    ans.clear();
    N = S.length();
    dfs("", 0);
    sort(ans.begin(), ans.end());
    int n = ans.size();
    cout << n << endl;
    if(n <= 10) {
      for(string& k : ans) cout << k << endl;
    }else {
      rep(i, 5) cout << ans[i] << endl;
      for(int i = n - 5; i <= n - 1; ++i)
	cout << ans[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4560
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 2010;

int n, m;
char s[N];
bool mp[N][N];
int cnt[N][N], rcnt[N][N], ccnt[N][N];

int main() {


	int q;
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", s);
		for (int j = 1; j <= m; ++j)
			mp[i][j] = s[j - 1] == '1';
	}
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j) {
			cnt[i][j] = cnt[i][j - 1] + mp[i][j];
			rcnt[i][j] = rcnt[i][j - 1] + (mp[i][j] && mp[i][j - 1]);
			ccnt[i][j] = ccnt[i][j - 1] + (mp[i][j] && mp[i - 1][j]);
		}
	for (int j = 1; j <= m; ++j)
		for (int i = 1; i <= n; ++i) {
			cnt[i][j] += cnt[i - 1][j];
			rcnt[i][j] += rcnt[i - 1][j];
			ccnt[i][j] += ccnt[i - 1][j];
		}
	while (q--) {
		int x1, x2, y1, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		printf("%d\n", cnt[x2][y2] - cnt[x1 - 1][y2] - cnt[x2][y1 - 1] + cnt[x1 - 1][y1 - 1]
		              -rcnt[x2][y2] + rcnt[x2][y1] + rcnt[x1 - 1][y2] - rcnt[x1 - 1][y1]
		              -ccnt[x2][y2] + ccnt[x2][y1 - 1] + ccnt[x1][y2] - ccnt[x1][y1 - 1]);
	}

	return 0;
}


Measured memory_bytes: 53120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1 << 30;
ll ans = 0;
ll ch[31][100100]={};
ll chh[31][100100]={};
ll chhh[100100]={};
 
int main()
{
ll n,c;
cin >> n>>c;
 
rep(i, n)
{
    ll s,t,c;
    cin >> s>>t>>c;
    if(ch[c][s]==0)ch[c][s]=1;
    else ch[c][s]=0;
    if(ch[c][t]==0)ch[c][t]=-1;
    else ch[c][t]=0;
}
rep1(i,c+1)rep1(j,100100){
    if(ch[i][j]==1){
        if(ch[i][j-1]!=-1){
            ch[i][j]=0;
            ch[i][j-1]=1;
        }
        else {
            ch[i][j]=0;
            ch[i][j-1]=0;
        }
    }
}
rep1(i,c+1)rep(j,100100){
    if(j==0) chh[i][j]=ch[i][j];
    else chh[i][j]=ch[i][j]+chh[i][j-1];
}
rep1(i,c+1)rep1(j,100100){
    chhh[j]+=chh[i][j];
}
rep1(j,100100){
    if(ans<chhh[j])ans=chhh[j];
}
/* for (int i = 0; i < 20; ++i) {
    cout << chh[1][i] << " ";
}cout  << endl;
for (int i = 0; i < 20; ++i) {
    cout << chh[2][i] << " ";
}cout  << endl;
 */
cout << ans << endl;
 
return 0;
}

Measured memory_bytes: 48768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 2e9 + 55;

int dgSum(int x){
    int tot = 0;
    while(x){
        tot += (x % 10);
        x /= 10;
    }

    return tot;
}

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

    int n;  cin >> n;

    int fRes = BIG;
    for(int x = 1; x < n; x++){
        int y = n - x;
        fRes = min(fRes, dgSum(x) + dgSum(y));
    }

    cout << fRes << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli f(lli n) {
	if (n < 2)
		return 1;
	return n * f(n - 2);
}




int main(void) {

	lli N;
	cin >> N;

	/*
	
	
	*/


	if (N % 2 == 1) {
		cout << 0 << endl;
	}
	else {

		lli pow5 = 10;

		lli total = 0;

		for (int i = 1; pow5 <= N; i++) {

			total += N / pow5;
			pow5 *= 5;
		}
		
		//cerr << total << endl;

		cout << total << endl;

	}

	//cerr << f(N) << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i=0; i<(n); i++)//第一引数の変数をカウンタ変数としてn回回す
using veci = vector<int>;
int main(){
  int n;
  cin >> n;
  veci a(n);
  rep(i, n){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  ll ans = 0;
  ans = max(abs(a.at(0) - a.at(n-1)), abs(a.at(n-1) - a.at(0)));
  cout << ans << endl;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  ll N;
  scanf("%lld", &N);
  ll T, A;
  scanf("%lld %lld", &T, &A);

  ll min_temp_offset = INF;

  ll ans = -1;
  vector<ll> h_list;
  for (ll i = 1; i <= N; i++) {
    ll h;
    scanf("%lld", &h);

    ll temp = T * 1000 - h * 6;
    ll temp_offset = abs(temp - A * 1000);
    if (temp_offset < min_temp_offset) {
      ans = i;
      min_temp_offset = temp_offset;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3732
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;
#define ll long long

int main(){
    string S;
    ll ans = 0, cnt = 0;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'A' || S[i] == 'T' || S[i] == 'C' || S[i] == 'G'){
            cnt++;
        }else{
            ans = max(ans,cnt);
            cnt = 0;
        }
    }
    ans = max(ans,cnt);
    cout << ans << endl; 
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
 
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }

//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
#define EACH(a,A) for(auto a: A)
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 
//cin,cout高速化のおまじない＋桁数指定
inline VLL cinvll(LL N){
  VLL A(N);
  REP(i,N){
    cin >> A[i];
  }
  return move(A);
}
struct Fast{
	Fast(){
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast;

LL nCr(LL n, LL r) {
  LL num = 1;
  for (LL i = 1; i <= r; i++) {
    num = num * (n - i + 1) / i;
  }
  return num;
}


void func(){
  LL N;
  cin >> N;
  string S;
  cin >> S;
  LL cnt=0;
  REP(i,1000){
    char n_str[10];
    sprintf(n_str,"%.3d",(int)i);
    string T(n_str);
    //cout << T << endl;

    bool canMake = false;
    LL j=0;
    for(;j<S.length();j++){
      if(S[j]== T[0]){
        break;
      }
    }
    j++;
    for(;j<S.length();j++){
      if(S[j]== T[1]){
        break;
      }
    }
    j++;
    for(;j<S.length();j++){
      if(S[j]== T[2]){
        canMake=true;
        break;
      }
    }
    j++;
    if(canMake){
      cnt++;
    }
  }
  cout << cnt;
} 
int main()
{
  func();
  return 0;
}
 

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 100000000000000
#define int long long

using namespace std;

int graph[301][301];
int graph2[301][301];

signed main()
{
	int n=0,m=0,l=0;
	cin >> n >> m >> l;	
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			graph[i][j] = INF;
	for (int i=0; i<m; i++)
	{
		int a=0,b=0,c=0;
		cin >> a >> b >> c;
		a--;
		b--;
		if (c<=l){
			graph[a][b] = c;
			graph[b][a] = c;
		}
	}
	for (int k=0; k<n; k++)
	{
		for (int i=0; i<n; i++)
		{
			for (int j=0; j<n; j++)
			{
				if (graph[i][k]!=INF && graph[k][j]!=INF)
				{
					graph[i][j] = min(graph[i][j], graph[i][k]+graph[k][j]);
				}	
			}
		}
	}
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<n; j++)
		{
			if (graph[i][j]<=l)
			{
				graph2[i][j] = 1;
			}
			else
				graph2[i][j] = INF;
		}
	}
	for (int k=0; k<n; k++)
	{
		for (int i=0; i<n; i++)
		{
			for (int j=0; j<n; j++)
			{
				if (graph2[i][k]!=INF && graph2[k][j]!=INF)
				{
					graph2[i][j] = min(graph2[i][j], graph2[i][k]+graph2[k][j]);
				}	
			}
		}
	}
	int q=0;
	cin >> q;
	for (int i=0; i<q; i++)
	{
		int s=0,t=0;
		cin >> s >> t;
		s--;
		t--;
		if (graph2[s][t]==INF)
			cout << -1 << endl;
		else
			cout << graph2[s][t]-1 << endl;
	}	
	return 0;
}


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

const int kMod = 1000000007;

long long Gcd(long long x, long long y) {
  return !y ? x : Gcd(y, x % y);
}

struct Point {
  long long x, y;

  Point Perpendicular() {
    return {-y, x};
  }

  Point Direction() {
    long long a = x, b = y;
    if (a == 0 && b == 0) return {0, 0};

    long long g = Gcd(abs(a), abs(b));
    a /= g;
    b /= g;

    if (a < 0) a *= -1, b *= -1;
    if (a == 0 && b < 0) b *= -1;

    return {a, b};
  }

  friend bool operator <(const Point& a, const Point& b) {
    return make_pair(a.x, a.y) < make_pair(b.x, b.y);
  }

  friend bool operator ==(const Point& a, const Point& b) {
    return make_pair(a.x, a.y) == make_pair(b.x, b.y);
  }
};

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

  int n;
  cin >> n;

  vector<Point> a(n);
  for (auto& p: a) {
    cin >> p.x >> p.y;
  }

  vector<int> pw(n + 1);
  pw[0] = 1;
  for (int i = 1; i <= n; ++i) {
    pw[i] = (pw[i - 1] + pw[i - 1]) % kMod;
  }

  vector<Point> dirs;
  map<Point, int> cnt;
  for (auto p: a) {
    auto dir = p.Direction();
    dirs.push_back(dir);
    ++cnt[dir];
  }

  sort(dirs.begin(), dirs.end());
  dirs.erase(unique(dirs.begin(), dirs.end()), dirs.end());

  int result = 1;
  Point zero = {0, 0};
  for (auto dir: dirs) {
    if (dir == zero) continue;
    if (!cnt[dir]) continue;
    auto perp = dir.Perpendicular().Direction();
    if (!cnt.count(perp)) {
      result = (1LL * result * pw[cnt[dir]]) % kMod;
      continue;
    }

    result = (1LL * result * (pw[cnt[dir]] + pw[cnt[perp]] - 1LL + kMod)) % kMod;
    cnt[perp] = 0;
  }

  result = (result + cnt[zero]) % kMod;
  result = (result + kMod - 1) % kMod;

  cout << result << '\n';
}

Measured memory_bytes: 22692
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,k; cin >> n >> k;
    vector<ll> a(n), cnt(n+1,0);
    rep(i,n){
        cin >> a[i];
        cnt[a[i]]++;
    }
    vector<ll> num;
    rep(i,n+1)if(cnt[i] > 0)num.emplace_back(cnt[i]);
    sort(all(num),greater<ll>());
    ll ans = 0;
    for(int i = num.size(); k < i; i--){
        ans += num[i-1];
    }
    cout << ans << endl;
}

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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  if(s[n-1] == 's'){
    cout << s << 'e' << 's' << endl;
  }
  else{
    cout << s << 's' << endl;
  }
}


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

int main() {
    ll A,B,N;cin >> A >> B >> N;
    ll x;
    if (N >= B) x = B - 1;
    else x = N;
    int ans = ((A * x) / B) - A * (x / B);
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
using namespace std;
int n,m,q;
vector<int> a,b,c,d;
int ans=0;
void dfs(vector<int> s){
  if(s.size()==n+1){
    int now=0;
    for(int i=0;i<q;i++) if(s[b[i]]-s[a[i]]==c[i]) now+=d[i];
    ans=max(ans,now);
    return;
  }
  s.push_back(s.back());
  while(s.back()<=m){
    dfs(s);
    s.back()++;
  }
}

int main(){
  cin>>n>>m>>q;
  a=b=c=d=vector<int>(q);
  for(int i=0;i<q;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
  dfs(vector<int>(1,1));
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  long long a, b, k;
  cin >> a >> b >> k;
  long long cnt = 1;
  b = (b / k) * k;
  a = ((a + k - 1) / k) * k;
  cnt += (b -a) / k;
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t a, b, c, d;
  cin >> a >> b >> c >> d;
  int64_t S = max(a * c, a * d), T = max(b * c, b * d);
  int64_t U = max(S, T);
  cout << U << endl;
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


from heapq import heapify, heappop, heappush, heappushpop


class PriorityQueue:
    def __init__(self, heap):
        '''
        heap ... list
        '''
        self.heap = heap
        heapify(self.heap)

    def push(self, item):
        heappush(self.heap, item)

    def pop(self):
        return heappop(self.heap)

    def pushpop(self, item):
        return heappushpop(self.heap, item)

    def __call__(self):
        return self.heap

    def __len__(self):
        return len(self.heap)


def dijkstra(graph, s, N):
    '''
    graph...隣接リスト形式 リスト内要素は(ノード, エッジ長)
    s...始点ノード
    N...頂点数

    return
    ----------
    D ... 各点までの最短距離
    P ... 最短経路木における親
    '''
    pq = PriorityQueue([])
    P = [None] * N
    D = [float('inf')] * N
    D[s] = 0
    pq.push((D[s], s))  # (最短距離, 次のノード)
    while pq:
        d, v = pq.pop()
        if D[v] < d:  # この辺を扱っても最短距離にならない
            continue  # is_visitedなくてもこれを使うことで最小のものを再び探索するのを防げる
        for to, cost in graph[v]:
            if D[to] > D[v] + cost:  # v周りにおける最短経路の候補の更新
                D[to] = D[v] + cost
                pq.push((D[to], to))
                P[to] = v
    return D, P


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

N, M = read_ints()
# 1から出発したときの最短経路木の親を出力すれば良い
# 必ずYes

graph = defaultdict(lambda: [])
for _ in range(M):
    a, b = read_ints()
    a -= 1
    b -= 1
    graph[a].append((b, 1))
    graph[b].append((a, 1))

D, P = dijkstra(graph, 0, N)
ans = []
for p in P[1:]:
    ans.append(p + 1)
print('Yes')
print(*ans, sep='\n')


Measured memory_bytes: 125144
package main

import "fmt"
import "sort"
import "math"

func main() {
	var n, k int64
	fmt.Scan(&n, &k)
	inputs := make([]int, n)
	for i := 0; i < int(n); i++ {
		fmt.Scan(&inputs[i])
	}
	sort.Ints(inputs)
	// count
	var left = int64(math.MinInt64)
	var right = int64(math.MaxInt64)
	for left+1 < right {
		var x = (left + right) / 2
		var total = int64(0)
		for i := 0; i < int(n); i++ {
			if inputs[i] < 0 {
				var leftInner = int64(-1)
				var rightInner = int64(n)
				for leftInner+1 < rightInner {
					c := (leftInner + rightInner) / 2
					if int64(inputs[c]*inputs[i]) < x {
						rightInner = c
					} else {
						leftInner = c
					}
				}
				total += (n - rightInner)
			} else {
				var leftInner = int64(-1)
				var rightInner = int64(n)
				for leftInner+1 < rightInner {
					c := (leftInner + rightInner) / 2
					if int64(inputs[c]*inputs[i]) < x {
						leftInner = c
					} else {
						rightInner = c
					}
				}
				total += rightInner
			}
			if int64(inputs[i]*inputs[i]) < x {
				total = total - 1
			}
		}
		total = total / 2
		ok := total < k
		if ok {
			left = x
		} else {
			right = x
		}
	}
  	fmt.Println(left)
}

Measured memory_bytes: 7680
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	nextReader = newScanner()
	s := nextString()

	m := make(map[string]int)
	for _, c := range s {
		m[string(c)]++
	}
	if len(m) != 2 {
		fmt.Println("No")
		return
	}
	if m[string(s[0])] != 2 {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int n[100],gyou,i,j,m,change = 0,minj;

  scanf("%d",&gyou);

  for(i = 0;i < gyou;i++){
    scanf("%d",&n[i]);
  }

  for(i = 0;i < gyou;i++){
    minj = i;

    for(j = i;j < gyou;j++){
      if(n[j] < n[minj]){
	minj = j;
      }
    }
    m = n[i];
    n[i] = n[minj];
    n[minj] = m;
    if(i != minj) change++;
  }

  for(i = 0;i < gyou;i++){
    if(i > 0) printf(" ");
    printf("%d",n[i]);
  }

  printf("\n");
  printf("%d\n",change);

  return 0;
}


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

long long binsearch(long long ans,long long digit){
	string s;
	long long dig = 1;
	for(int i=0;i<digit;i++){
		dig *= 10;
	}
	int lb = 10,ub = -1;
	while(lb-ub>1){
		long long mid = (lb+ub)/2;
		if(digit==0 && mid==0){
			return 1000;
		}
		cout << "? " << (ans*10+mid)*(10000000000/dig) << endl;
		cin >> s;
		if(s[0]=='Y'){
			lb = mid;
		}else{
			ub = mid;
		}
	}
	if(lb==10){
		return 100;
	}
	return lb;
}
	
int main(){
	long long i,j,n,ans=0,ans1;
	string s;
	for(i=0;i<9;i++){
		int n = binsearch(ans,i);
		if(n==1000){
			ans = 9;
			for(i=0;i<20;i++){
				cout << "? " << ans << endl;
				cin >> s;
				if(s[0]=='Y'){
					cout << "! " << (ans+1)/10 << endl;
					return 0;
				}else if(ans>1000000000){
					cout << "! " <<  1000000000 << endl;
					return 0;
				}
				ans = ans*10+9;
			}
		}
		if(n==100){
			ans = ans*10 + 9;
			continue;
		}else if(n==0){
			ans = ans*10;
		}else{
			ans = ans*10 + n-1;
		}
		cout << "? " << ans+1 << endl;
		cin >> s;
		if(s[0]=='Y'){
			ans++;
			ans1 = ans;
			for(j=0;j<10;j++){
				ans *= 10;
				cout << "? " << ans << endl;
				cin >> s;
				if(s[0]=='N'){
					cout << "! " << ans/10 << endl;
				    return 0;
				}
				if(s[0] == 'Y' && ans > 1000000000){
					cout << "! " << ans1 << endl;
					return 0;
				}
			}
		}
	}
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;

  int ans;
  if (a==b)
    ans=c;
  else if (b==c)
    ans=a;
  else
    ans=b;

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

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

int main(){
  int n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  int ans[n+1]={};
  for(int i=0; i<n-1; i++){
    for(int j=i+1; j<n; j++){
      int dis = min(j-i, abs(x-i)+1+abs(y-j));
      dis = min(dis, abs(y-i)+1+abs(x-j));
      ans[dis]++;
    }
  }
  for(int i=1; i<n; i++){
    cout << ans[i] << endl;
  }
  return 0;
}


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

int main() {
    int64_t N;
    std::cin >> N;

    int64_t A[N];
    int64_t sum = 0;
    for (int i = 0; i < N; ++i) {
        std::cin >> A[i];
        sum += A[i];
    }

    int64_t min = INT64_MAX;
    for (int64_t i = -100; i <= 100; ++i) {
        int64_t cost = 0;
        for (int j = 0; j < N; ++j) {
            cost += (A[j] - i) * (A[j] - i);
        }

        min = std::min<int64_t>(min, cost);
    }

    std::cout << min << std::endl;

    return 0;
}


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

g = [['#']*100 for _ in range(50)] + [['.']*100 for _ in range(50)]
for k in range(2):
    cnt = 0
    flag = False
    c = '.' if k == 0 else '#'
    for i in range(51*k, 50*(k+1), 2):
        for j in range(0, 100, 2):
            if cnt == ab[k]-1:
                flag = True
                break
            g[i][j] = c
            cnt += 1
        if flag:
            break
print(100, 100)
for i in g:
    print(''.join(i))


Measured memory_bytes: 9260
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
#define int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define sz(s) (int)(s.size())
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 
     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);



    //start from here

    int h, w;
    cin >> h >> w;
    if(h == 1 || w == 1) cout << 1;
    else if(h%2 == 0 || w%2 == 0) cout << (h*w)/2;
    else cout << (h*w)/2 + 1;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,m;
	cin >> n >> m;
	string a[50],b[50];
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=0;i<m;i++) cin >> b[i];

	bool ans=false;
	for(int i=0;i<=n-m;i++){
		for(int j=0;j<=n-m;j++){
			bool flag=true;
			for(int k=0;k<m;k++){
				for(int l=0;l<m;l++){
					if(a[i+k][j+l]!=b[k][l]) flag=false;
				}
			}
			if(flag) ans=true;
		}
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    ll n;
    cin >> n;
    string ans = "";
    while(n > 0) {
        n --;
        ans.pb(char(n%26 + 'a'));
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << '\n';
}

int main() {
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y>>z;
repo(i,x,y+1){
  if(i-x<=z-1||y-i<=z-1)std::cout << i << '\n';
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define BUF 1e5
#define INF 1 << 30
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
constexpr ll mod = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    vector<double> a(N);
    cin >> a;
    double res = 0;
    for (int i = 0; i < N; i++) {
        res += 1 / a[i];
    }
    cout << setprecision(9) << 1 / res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		
		if(X == 7 || X == 5 || X == 3) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define int long long
#define F first
#define S second
#define pb push_back
#define p2(n) (1<<(n))
#define lg2(n) __lg(n)
using namespace std;
using ll = long long;
using pii = pair<long long,long long>;
using ld = long double;
mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);
const int N = 1e6+10;

int n;
int fac[N];
int cnt[N];

void init(){
    memset(fac,-1,sizeof(fac));
    fac[1] = 1;
    rep(i,2,N){
        if(fac[i]==-1){
            fac[i] = i;
            for(int j=i*2;j<N;j+=i)
                fac[j] = i; 
        }
    }
}

void solve(){
    init();
    cin >> n;
    rep(i,0,n){
        int x; cin >> x;
        while(x!=1){
            cnt[fac[x]]++;
            int t = fac[x];
            while(x%t==0)
                x /= t;
        }
    }
    bool flag = 1;
    rep(i,0,N){
        if(cnt[i]==n){
            cout << "not coprime\n";
            return;
        }
        if(cnt[i]>1)
            flag = 0;
    }
    cout << (flag ? "pairwise coprime\n" : "setwise coprime\n");
}

signed main(){
    Rushia_mywife
    //int t; cin >> t;
    //while(t--)
    solve();
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<int> A(N);
    int max_a = -INF;
    int max_index = -1;
    int min_a = INF;
    int min_index = -1;
    REP(i,N){
        int a; cin >> a;
        A[i] = a;

        if(max_a < a){
            max_a = a;
            max_index = i;
        }
        if(min_a > a){
            min_a = a;
            min_index = i;
        }
    }


    if(min_a>=0){//全部非負の場合
    cout << N-1 << endl;
        REP(i,N-1){
            cout << i+1 << " " << i+2 << endl;
        }
    }else if(max_a<0){//全部負の場合
        cout << N-1 << endl;
        REP(i,N-1){
            cout << N-i << " " << N-i-1 << endl;
        }
    }else{
        if(max_a >= -min_a){
            cout << 2*N-2 << endl;
            REP(i,N){
                if(i!=max_index) cout << max_index+1 << " " << i+1 << endl;
            }
            REP(i,N-1){
                cout << i+1 << " " << i+2 << endl;
            }
        }else{
            cout << 2*N-2 << endl;
            REP(i,N){
                if(i!=min_index) cout << min_index+1 << " " << i+1 << endl;
            }
            REP(i,N-1){
                cout << N-i << " " << N-i-1 << endl;
            }
        }
    }


    return 0;
}

Measured memory_bytes: 3580
open System.Linq
open System.Collections.Generic

type Query =
    | Rev
    | AddFst of str: string
    | AddLst of str: string

let s = stdin.ReadLine()
let q = stdin.ReadLine() |> int
let queries = 
    [|
        for i in 1..q -> stdin.ReadLine().Split()
    |]

let parse (query:_[]) =
    match query with
    | [|"1"|] -> Rev
    | [| "2"; "1"; x3|] -> AddFst(x3)
    | [| "2"; "2"; x3|] -> AddLst(x3)


let buildStr (queries:seq<Query>)  : string =

    let charArray = new LinkedList<char>(s.ToCharArray())
    let mutable doesRev = false 
    let build query = 
        match query with
        | Rev -> doesRev <- not doesRev
        | AddFst(str2) -> if not doesRev then charArray.AddFirst(char str2) |> ignore else charArray.AddLast(char str2) |> ignore
        | AddLst(str2) -> if doesRev then charArray.AddFirst(char str2) |> ignore else charArray.AddLast(char str2) |> ignore

    for query in queries do
        build query

    if not doesRev then new string(charArray.ToArray()) else new string(charArray.Reverse().ToArray())


queries
|> Array.map parse
|> buildStr
|> stdout.WriteLine

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N,M,Q;
  cin >> N >> M >> Q;
  int L[M], R[M], p[Q], q[Q];
  for(int i = 0;i<M;i++) cin >> L[i] >> R[i];
  for(int i = 0;i<Q;i++) cin >> p[i] >> q[i];

  int c[501][501] = {0};
  for(int i = 0;i<M;i++){
    c[L[i]][R[i]]++;
  }
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      c[i][j] += c[i-1][j] + c[i][j-1] - c[i-1][j-1];
    }
  }
  for(int i=0;i<Q;i++){
    int pi = p[i], qi = q[i];
    cout << c[qi][qi] - c[qi][pi-1] - c[pi-1][qi] +c[pi-1][pi-1] << endl;
  }
}



Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long int ll;

#define rep(x, a, b) for (int x = a; x < b; x++)

int
main()
{
  int n, k;
  vector<int> freq(26, 0);

  cin >> n >> k;

  rep(i, 0, n) {
    string str;

    cin >> str;

    freq[str[0] - 'A']++;
  }

  int cnt = 0;

  for (;;) {
    sort(freq.begin(), freq.end(), greater<int>());

    if (freq[k-1] == 0) break;

    rep (i, 0, k) freq[i]--;
    cnt++;
  }

  cout << cnt << endl;
  
  return 0;
}


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

main(){
	int N;
	cin >> N;
	string W[N];
	for (int i = 0;i<N;i++){
		cin >> W[i];
	}
	bool check = true;
	char last = W[0][0];
	for (int i = 0;i<N;i++){
		int size = W[i].length();
		if(last != W[i][0]){
			check = false;
		}
		for(int j=0;j<i;j++){
			if(W[i] == W[j]){
				check = false;
				break;
			}
		}
		if (check == false)
			break;
		last = W[i][size - 1];
	}
	if(check){
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  ll t, d;
};
bool operator<(const ST& a, const ST& b){
  return a.d > b.d;
}

int main(){
  int N, K;
  cin >> N >> K;
  vector<ST> v;
  rep(i,N){
    ll t, d;
    cin >> t >> d;
    v.push_back((ST){t,d});
  }
  sort(ALLOF(v));

  ll sum = 0;
  map<ll,ll> mx, nx;
  vector<ll> w;
  vector<ST> w2;
  rep(i,N){
    if(i<K){
      sum += v[i].d;
      if(mx.count(v[i].t) > 0) w.push_back(v[i].d);
      else {
        mx[v[i].t] = v[i].d;
      }
    }else{
      if(mx.count(v[i].t) == 0 && nx.count(v[i].t) == 0){
        nx[v[i].t] = v[i].d;
        w2.push_back(v[i]);
      }
    }
  }

  ll x = mx.size();
  ll ret = sum + x * x;
  rep(i,w2.size()){
    if(x >= K) break;
    if(w.size()-1-i < 0) break;
    sum -= w[w.size()-1-i];
    sum += w2[i].d;
    x++;
    ret = max(ret, sum + x*x);
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 8816
x = int(input())

l = []
for i in range(400):
    l.append((i + 1 - 200) ** 5)

for i in range(400):
    for j in range(400):
        if ((i + 1 - 200) ** 5 - (j + 1 - 200) ** 5 == x):
            print ("%s %s" % ((i + 1 - 200), (j + 1 - 200)))
            exit (0)

Measured memory_bytes: 9196
n = int(input())
a = list(map(int, input().split()))
sort_a = sorted(a, reverse=True)
alice = [sort_a[i] for i in range(n) if i%2==0]
bob = [sort_a[i] for i in range(n) if i%2!=0]
point_alice = sum(alice)
point_bob = sum(bob)
print(point_alice - point_bob)

Measured memory_bytes: 3064
S = list(map(int,input().split()))
count5 = 0
count7 = 0
for i in range(3):
    if S[i] == 5:
        count5 += 1
    elif S[i] == 7:
        count7 += 1
if count5 ==2 and count7 == 1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
const int INF = 1e18, MOD = 998244353;
int n;
void search(string s, char c) {
    if (s.size() == n) {
        cout<<s<<endl;
    } else {
        for (char i = 'a'; i <= c; i++) {
            if (i == c) search(s + i, c + 1);
            else search(s + i, c);
        }
    }
}
signed main() {
    cin>>n;
    search("", 'a');
}

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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if((a * 100 + b * 10 + c) % 4 == 0){
		cout << "YES" << endl;
		return 0;
	}else{
		cout << "NO" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char a[110][110];
int main()
{
	int x,y;
	cin>>x>>y; 
	for(int i=1;i<=x;i++)
		for(int j=1;j<=y;j++)
			cin>>a[i][j];
	for(int i=0;i<=x+1;i++)
	{
		for(int j=0;j<=y+1;j++)
		{
			if(i==0 || i==x+1 || j==0 || j==y+1)
				cout<<'#';
			else 
				cout<<a[i][j];
		}
		cout<<'\n';
	}
	return 0;
}


Measured memory_bytes: 256
ss = gets.chomp
t = gets.chomp
s = nil
ok = false
(ss.length - t.length).downto(0) do |i|
  ok = true
  for j in 0...t.length do
    if ss[i + j] != t[j] && ss[i + j] != "?"
      ok = false
      break
    end
  end
  if ok
    s = ss.dup
    s[i, t.length] = t
    s.tr!("?", "a")
    break
  end
end
puts ok ? s : "UNRESTORABLE"


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define ff first
#define ss second
#define p pair<int,int>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define pi acos(-1)
struct str{
    int ax,ay,bx,by;
};
int main()
{
    fast;
    int h,w;
    cin>>h>>w;
    vector<str>ans;
    int a[h+5][w+5];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
           cin>>a[i][j];

        }
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w-1;j++)
        {
            if(a[i][j]&1)
            {
                a[i][j+1]++;
                ans.pb({i+1,j+1,i+1,j+2});
            }
            else continue;
        }
        if(i==h-1)continue;
        if(a[i][w-1]&1)
        {
            a[i+1][w-1]++;
            ans.pb({i+1,w,i+2,w});
        }
    }
    cout<<ans.size()<<endl;
    for(auto i:ans)
    {
        cout<<i.ax<<" "<<i.ay<<" "<<i.bx<<" "<<i.by<<endl;
    }
}



Measured memory_bytes: 6280
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    string a,b;
    cin >> a >> b;
    if(a.size() > b.size()) cout << "GREATER" << endl;
    else if(a.size() < b.size()) cout << "LESS" << endl;
    else {
        rep(i,a.size()) {
            int na = a[i]-'0';
            int nb = b[i]-'0';
            if(na > nb) {
                cout << "GREATER" << endl;
                return 0;
            }
            else if(na < nb) {
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;



int main()
{
    bool b[3][3];
    int a[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> a[i][j];
            b[i][j] = false;
        }
    }
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(tmp == a[j][k]){
                    b[j][k] = true;
                }
            }
        }
    }
    bool ex = false;

    for(int i = 0; i < 3; i++){
        if(b[i][0] && b[i][1] && b[i][2]){
            ex = true;
        }
    }
    for(int i = 0; i < 3; i++){
        if(b[0][i] && b[1][i] && b[2][i]){
            ex = true;
        }
    }
    if((b[0][0] && b[1][1] && b[2][2]) || (b[0][2] && b[1][1] && b[2][0])){
        ex = true;
    }
    if(ex){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

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

using namespace std;

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

  vector<pair<pair<string, int>, int>> p(N);

  string S;
  int P;
  for (int i = 0; i < N; ++i) {
    cin >> S >> P;
    p[i] = make_pair(make_pair(S, -P), i);
  }

  sort(p.begin(), p.end());
  for (auto e: p) cout << e.second + 1 << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class AizuOnlineJudge {
    static void Main() {
        Console.WriteLine(
            Math.Abs(
                Console.ReadLine()
                    .Split()
                    .Select(int.Parse)
                    .OrderBy(q => q)
                    .Select((q, i) => i == 0 || i == 3 ? q : -q)
                    .Sum()
            )
        );
    }
}



Measured memory_bytes: 18584