akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <set>
#include <map>
#include <list>

using namespace std;

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

const ll mod = 998244353;
const ll inf = (ll) 1e18;

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

  int n, k;
  cin >> n >> k;

  if (n < (k - 1) * 2 + 1) {
    cout << -1 << endl; // impossible
    return 0;
  }

  vector<vector<int> > ans(n, vector<int>(3));
  int ap, bp, cp, pp;
  ap = n/2;
  bp = 0;
  cp = 0;
  pp = 0;
  while (ap < n) {
    ans[pp][0] = k + ap;
    ans[pp][1] = k + bp + n;
    ans[pp][2] = k + cp + n * 2;
    ap++;
    bp++;
    cp += 2;
    pp++;
  }
  ap = 0;
  cp = 1;
  while (cp < n) {
    ans[pp][0] = k + ap;
    ans[pp][1] = k + bp + n;
    ans[pp][2] = k + cp + n * 2;
    ap++;
    bp++;
    cp += 2;
    pp++;
  }

  for (auto &x: ans) {
    cout << x[0] << " " << x[1] << " " << x[2] << endl;
  }

  return 0;
}


Measured memory_bytes: 7680
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int S[] = new int[n];
    for(int i = 0; i < n; i++){
      S[i] = sc.nextInt();
    }
    int q = sc.nextInt();
    int T[] = new int[q];
    for(int i = 0; i < q; i++){
      T[i] = sc.nextInt();
    }

    int ans = 0;

    for(int i = 0; i < q; i++){
      int left = -1;
      int right = n -1;

      while(right - left > 1){
        int mid = (left + right)/2;
        
        if(S[mid] >= T[i]) right = mid;
        else left = mid;
      }
      
      if(S[right] == T[i]) ans++;
    }

    System.out.println(ans);

    sc.close();
  }
}


Measured memory_bytes: 68760
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const int MOD = 1000000007;
int main() {
    int N;
    cin >> N;
    int res = 0;
    rep(i, 0, N) {
        int a = N - i;
        if((1 <= a && a <= 9) || (100 <= a && a <= 999) ||
           (10000 <= a && a <= 99999)) {
            res++;
        }
    }
    cout << res << endl;
}

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



int main() {
    int n;
    cin >> n;
    
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    
    vector<int> c(4);
    rep(i,n) {
        if(s[i] == "AC")
            c[0]++;
        else if(s[i] == "WA")
            c[1]++;
        else if(s[i] == "TLE")
            c[2]++;
        else
            c[3]++;
    }
    
    cout << "AC x " << c[0] << endl;
    cout << "WA x " << c[1] << endl;
    cout << "TLE x " << c[2] << endl;
    cout << "RE x " << c[3] << endl;
    
    return 0;
}




Measured memory_bytes: 6424
#include<iostream>
using namespace std;
int main(){
	int kane[] = {0,6000,4000,3000,2000};
	for(int i = 0; i < 4; i++){
		int t,n,sum = 0;
		cin >> t >> n;
		sum += kane[t] * n;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-

s = input()

ans = []
for i in range(len(s)):

    if s[i] == "0":
        ans.append("0")
    
    elif s[i] == "1":
        ans.append("1")

    elif s[i] == "B":
        # リストが空ではない確認
        if ans:
            # 文字列が残っている時のみ削除を行う
            del ans[-1]

print("".join(ans))

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>

using namespace std;

typedef unsigned uint;
// typedef long long Int;

const int INF = 1001001001;
// const Int INFLL = 1001001001001001001LL;

int main(void)
{
	int n, i, j, k;
	static char str [1024][2048];
	
	while (1){
		scanf("%d", &n);
		if (n == 0)break;
		
		for (i = 0; i < n; i++){
			scanf("%s", str[i]);
		}
		
		for (i = 1; i < n; i++){
			for (j = 0; str[i][j] != '\0'; j++){
				if (str[i][j] == '.'){
					if ('a' <= str[i][j + 1] && str[i][j + 1] <= 'z'){
						str[i][j] = '+';
					}
				}
			}
		}
		
		for (i = n - 1; i > 0; i--){
			k = 1;
			j = 0;
			while (1){
				if (str[i][j] == '+')break;
				j++;
			}
			while (str[i - k][j] == '.'){
				
				str[i - k][j] = '|';
				k++;
			}
		}
		
		for (i = 0; i < n; i++){
			for (j = 0; str[i][j] != '\0'; j++){
				if (str[i][j] == '.') str[i][j] = ' ';
			}
		}
		
		for (i = 0; i < n; i++){
			printf("%s\n", str[i]);
		}
	}
	
	return (0);
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
#define yn(f) cout<<(f?"yes":"no")<<endl
#define Yn(f) cout<<(f?"Yes":"No")<<endl
#define YN(f) cout<<(f?"YES":"NO")<<endl
#define COUT(x) cout<<(x)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

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

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  int a,b,c,d; cin>>a>>b>>c>>d;
  if(a+b==c+d) COUT("Balanced");
  else if(a+b<c+d) COUT("Right");
  else COUT("Left");
}













Measured memory_bytes: 256
#define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 15
#define _MAX 81
int main(void)
{
	int n;
	while (1) {
		scanf_s("%d", &n);
		if (n == 0) break;
		int x,y,m[MAX][MAX] = { 0 };
		x = n / 2; y = n / 2 + 1;
		m[x][y] = 1;
		for (int i = 2; i <= n*n; ++i) {
			++x; ++y;
			if (m[x % n][y % n] != 0) {
				--x; ++y;
				m[x % n][y % n] = i;
			}
			else m[x % n][y % n] = i;
		}
		for (int i = 0; i < n*n; ++i) {
			printf("%4d", m[i % n][i / n]);
			if (i % n == n - 1) printf("\n");
		}
	}
}

Measured memory_bytes: 1208
#include<iostream>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  int c = 0;
  int p[999];
  for(int i=1; i<1000; i++){
    c = c + i;
    p[i] = c;
  }
  for(int j=1; j<1000; j++){
    if(b-a == j){
      cout << p[j] - b;
    }
  }
  return 0;
}

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

int main(){
  int N;
  cin>>N;
  int a[1000000],b[1000000],c[1000000];
  for(int i=1;i<N+1;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  int dp[100010][4];
  dp[1][1]=a[1];
  dp[1][2]=b[1];
  dp[1][3]=c[1];
  for(int i=2;i<N+1;i++){
    dp[i][1]=max(dp[i-1][2]+a[i],dp[i-1][3]+a[i]);
    dp[i][2]=max(dp[i-1][3]+b[i],dp[i-1][1]+b[i]);
    dp[i][3]=max(dp[i-1][1]+c[i],dp[i-1][2]+c[i]);
  }
  int ans=max(dp[N][1],max(dp[N][2],dp[N][3]));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6324
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
template<class T>
struct BIT {
	int n;
	vector<T> d;
	BIT(int n = 0) : n(n), d(n + 1){}
	void add(int i, T x) { // a[i]+=x
		for (i++; i <= n; i += i & -i) {
			d[i] += x;
		}
	}
	T sum(int i) { // return a[1]+a[2]+...a[i]
		T x = 0;
		for (i++; i; i -= i & -i) {
			x += d[i];
		}
		return x;
	}
};
int main() { // 二次元平面で考える
	int n, q;
	cin >> n >> q;
	// 範囲に置き換える
	// この時完璧に範囲に含まれるような奴はいらない
	V Prev(n + 1, -1);
	VV R(n);
	rep(i, n) {
		int x;
		cin >> x;
		if (Prev[x] != -1) {
			R[Prev[x]].push_back(i);
		}
		Prev[x] = i;
	}
	// 右から調べていってそれよりも下にあるような点は除外する
	VE<VE<P<int>>> Q(n);
	rep(i, q) {
		int l, r;
		cin >> l >> r;
		l--, r--;
		Q[l].push_back(make_pair(r, i));
	}
	V ans(q, 0);
	BIT<int> t(n);
	for (int i = n - 1; i >= 0; i--) {
		for (auto c : R[i]) t.add(c, 1);
		for (auto c : Q[i]) {
			int tmp = c.first - i + 1;
			tmp -= t.sum(c.first);
			ans[c.second] = tmp;
		}
	}
	rep(i, q) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 58096
n = int(input())
a = n // 4
b = n // 7
flg = False

for i in range(a + 1):
  for j in range(b + 1):
    y = i * 4 + j * 7
    if y == n:
        flg = True
        
if flg:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

//int main()
//{
//	string n;
//	int k;
//	cin >> n >> k;
//	//vector<int> h(n);
//	int ans = 0;
//	for (int i = 1; i <= (n); ++i) {
//		//h[i-1] = i;
//		string numstr = to_string(i);
//		int total_count = numstr.length();
//		int zero_count = count(numstr.begin(), numstr.end(), '0');
//		if (total_count - zero_count == k) {
//			ans++;
//		}
//	}
//	//rep(i, n) h[i]=i;
//	//sort(h.begin(), h.end());
//	//k = min(n, k);
//	/*ll ans = 0;
//	rep(i, k) {
//		h.pop_back();
//	}
//	rep(i, h.size()) ans += h[i];*/
//	cout << ans << endl;
//	return 0;
//

//int main()
//{
//	ll n;
//	int k;
//	cin >> n >> k;
//	//vector<int> h(n);
//	ll ans = 0;
//	
//	for (ll i = 1; i <= (n); ++i) {
//		ll temp = i;
//		int count = 0;
//		
//		while (temp > 0) {
//			ll num = temp % 10;
//			if (num != 0) {
//				count++;
//			}
//			temp /= 10;
//			if (count > k) {
//				if (num != 0) {
//					i += 8;
//				}
//				break;
//			}
//		}
//		if (count == k) {
//			ans++;
//		}
//	}
//	//rep(i, n) h[i]=i;
//	//sort(h.begin(), h.end());
//	//k = min(n, k);
//	/*ll ans = 0;
//	rep(i, k) {
//		h.pop_back();
//	}
//	rep(i, h.size()) ans += h[i];*/
//	cout << ans << endl;
//	return 0;
//}

int main()
{
	string s;
	cin >> s;
	rep(i, s.length()) {
		s[i] = 'x';
	}
	cout << s << endl;
	return 0;
}

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


int minmax(deque<int> c[5],int f,int bd=0){
	
	if(f==0){
		for(int i = bd ; i < 5 ; i++){
			if( c[i].size() ){
				int r;
				if(f){
					r = c[i].back();
					c[i].pop_back();
				}else{
					r = c[i].front();
					c[i].pop_front();			
				}
				return r;
			}
		}
	}else{
		for(int i = 4 ; i >= 0; i--){
			if( c[i].size() ){
				int r;
				if(f){
					r = c[i].back();
					c[i].pop_back();
				}else{
					r = c[i].front();
					c[i].pop_front();			
				}
				return r;
			}
		}
	}
	return -1;
}
int main(){
	int N;
	while(cin >> N && N){
		deque<int> c[5];
		int A[100];
		for(int i = 0 ; i < N ; i++){
			cin >> A[i];
			c[min(4,A[i])].push_back(A[i]);
		}
		sort(c[4].begin(),c[4].end());
		
		vector<int> res;
		//0^0^1^1
		//1^0^1
		if( c[0].size() == N ){
			for(int i = 0 ; i < N ; i++) cout << 0 << endl;
			return 0;
		}
		if( c[0].size() > 0 ){
			if( c[0].size() % 2 == 0 ){
				while( c[1].size() ) res.push_back(minmax(c,0,1));
				while( c[0].size() ) res.push_back(minmax(c,0));
			}else{
				while( c[1].size() > 1 ) res.push_back(minmax(c,0,1));
				res.push_back(minmax(c,0));
				res.push_back(minmax(c,0,1));
				while( c[0].size() ) res.push_back(minmax(c,0));
				
				
			}
		}else{
			while( c[1].size() ) res.push_back(minmax(c,0,1));
		}
		assert( c[0].size() == 0 );
		if( c[4].size() > 0 ){
		}else if( c[2].size() >= 1 && c[3].size() == 1 ){
			res.push_back(minmax(c,0));
		}
		while( res.size() != N ) res.push_back(minmax(c,1));
	
		
		for(int i = 0 ; i < res.size() ; i++)
			cout << res[res.size()-i-1] << endl;
		return 0;
	}
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n) for(int i=a; i<n; i++)
#define SPEED ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(0)
int main() 
{
	SPEED; 
	int n,b,sum=0,count=1;
	cin>>n>>b;
	int a[n];
	forr(i,0,n) cin>>a[i];
	forr(i,0,n)
	{
	    sum+=a[i];
	    if(sum<=b) count++;
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li          long
#define ll          long long
#define ull         unsigned long long
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pli         pair<li,li>
#define pll         pair<ll,ll>
#define pb          push_back
#define fo(i,k,n)   for(int i = k;i<n; i++)
#define ro(i,k,n)   for(int i = k; i>=n; i--)
#define fd(i,k,n,d) for(int i = k; i<n; i+=d)
#define tc          int t;cin>>t;while(t--)
#define all(v)      v.begin(),v.end()
#define inf         INT_MAX
#define ninf        INT_MIN
#define W(x)        cout<<x<<endl
#define WW(x,y)     cout<<x<<' '<<y<<endl;
#define in(x)       cin>>x
#define v(x)        vector<x>
#define int         long long
#define ar(x,y)       array<x,y>
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

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

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

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

template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = res*a;
        b>>=1;
        a*=a;
    }
    return res;
}

template<class T>
T power(T a,T b,T m){
    T res = (T)1;
    a%=m;
    while(b>0){
        if(b&1)res = (res*a)%m;
        b>>=1;
        a = (a*a)%m;
    }
    return res;
}

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

struct dsu{
  map<int,int> pr,sz;
  dsu(){
    (this->pr).clear();
    (this->sz).clear();
  }
  void make(int x){
    pr[x] = x;
    sz[x] = 1;
  }
  int getpar(int x){
    if(pr[x] == x)return x;
    return pr[x] = getpar(pr[x]);
  }
  void merge(int x,int y){
    x = getpar(x);
    y = getpar(y);
    if(sz[x]<sz[y])swap(x,y);
    pr[y] = x;
    sz[x]+=sz[y];
    sz[y] = 0;
  }
};

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


void solve(){
    int n;
    cin>>n;
    v(int) a(n+1,1);
    fo(i,2,n+1){
      for(int j = i;j<=n; j+=i){
        a[j]+=1;
      }
    }
    int ans = 1;
    fo(i,2,n+1)ans+=(i*a[i]);
    cout<<ans<<"\n";
}

signed main(){
    fastio();
    int cs = 1;
    //cin>>cs;
    while(cs--){
        solve();
    }
}


Measured memory_bytes: 81336
n=int(input())
ki=[[] for _ in range(n)]
for _ in range(n-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  ki[a].append(b)
  ki[b].append(a)
# 0とn-1の最短ルートのうち0側に属するものn-1側に属するもの
from collections import deque
d_from_b=[-1]*n
d_from_w=[-1]*n
d_from_b[0]=0
todo=deque([0])
while todo:
  t=todo.popleft()
  l=ki[t]
  for li in l:
    if d_from_b[li]==-1:
      d_from_b[li]=d_from_b[t]+1
      todo.append(li)

d_from_w[n-1]=0
todo=deque([n-1])
while todo:
  t=todo.popleft()
  l=ki[t]
  for li in l:
    if d_from_w[li]==-1:
      d_from_w[li]=d_from_w[t]+1
      todo.append(li)
b_cnt=0
for i in range(n):
  if d_from_b[i]<=d_from_w[i]:
    b_cnt+=1
if n-b_cnt<b_cnt:
  print('Fennec')
else:
  print('Snuke')
#print(root)
#print(d_from_b,d_from_w)

Measured memory_bytes: 33688
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010], mp[100010];
string s[100010];
int main(){
    int n, k, m;
    while(cin>>n>>m){
        memset(mp, -1, sizeof mp);
        int ans1=0, ans2=0;
        for(int i=0; i<m; ++i){
            cin>>a[i]>>s[i];
            if(s[i][0]=='A'){
                if(mp[a[i]]==-1){
                    mp[a[i]]=i;
                    ++ans1;
                }
            }
        }
        for(int i=0; i<m; ++i){
            if(s[i][0]=='W'){
                if(mp[a[i]]>i){
                    ++ans2;
                }
            }
        }
        cout<<ans1<<" "<<ans2<<endl;
    }
  return 0;
}




Measured memory_bytes: 6528
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        sc.useDelimiter(",");
//        DecimalFormat df = new DecimalFormat("0.00000000");
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = Integer.parseInt(sc.next());
        long sum = 0;
        long ans = 1000000000;
        for (int j = 0; j <= 100; j++) {
            for (int i = 0; i < n; i++) {
                sum += (a[i] - j) * (a[i] - j);
            }
            ans = Math.min(sum, ans);
            sum = 0;
        }
        out.println(ans);
        out.flush();
    }
}

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

using namespace std;

int main(void) {

  long long H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> C(6, vector<char>(6, '-'));
  long long B = 0;
  for (long long i=0; i<H; i++) {
    for (long long j=0; j<W; j++) {
      cin >> C.at(i).at(j);
      if (C.at(i).at(j) == '#') {
        B++;
      }
    }
  }
  
  long long count = 0;
  vector<vector<char>> c = C;
  long long black = B;

  for (long long tmp = 0; tmp < (1 << H + W); tmp++) {
    c = C;
    black = B;
    bitset<12> s(tmp);
    // ビット列を出力
    for (int h = 0; h < H; h++) {
      long long bit = 1 << h;
      if (s.to_ullong() & bit) {
        for (int i = 0; i < W; i++) {
          if (c.at(h).at(i) == '#') {
            black--;
            c.at(h).at(i) = '-';
          }
        }
      }
    }
    for (int w = 0; w < W; w++) {
      long long bit = 1 << (w + H);
      if (s.to_ullong() & bit) {
        for (int i = 0; i < H; i++) {
          if (c.at(i).at(w) == '#') {
            black--;
            c.at(i).at(w) = '-';
          }
        }
      }
    }

    if (black == K) {
      count++;
    }
   
  }


  cout << count << endl;

}


Measured memory_bytes: 3572
#include <iostream>

using namespace std;

int main(){
    int n;
    int ans = 0;
    cin >> n;
    for(int i = 0;i < n;i++){
        int x;
        cin >> x;
        ans += x;
    }
    ans = ans - n;
    cout << ans << endl;
    return 0;
}

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

#define dbg(x) cout << #x"=" << x << endl;
typedef long long LL;

int main(){
   // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    LL A,B,K;
    cin >> A >> B >> K;
    LL x = min(A, K);
    A -= x;
    K -= x;
    B -= min(B, K);
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String [] args)throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int ans = 0;
        for(int i = 1;i < str.length();i++){
            if(str.charAt(i) != str.charAt(i - 1))++ans;
        }
        System.out.print(ans);
    }
}


Measured memory_bytes: 10836
import java.util.*;

public class Main {
  Scanner sc = new Scanner(System.in);
  double x, h;
  void run() {
    for(;;) {
      x = sc.nextInt();
      h = sc.nextInt();
      if (x == 0 && h == 0) break;
      //System.out.println(x + "|" + h);
      double l = Math.sqrt(x*x/4 + h*h);
      double res = x*x + 2 * x * l;
      System.out.println(res);
    }
  }
  public static void main(String args[]) {
    new Main().run();
  }
}

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

void topological_sort(long now, vector<long>& visited, vector<long>& result, vector<vector<long>>& edges){
    if(visited[now])return;
    visited[now] = true;
    for(auto i : edges[now]){
        topological_sort(i, visited, result, edges);
    }
    result.push_back(now);
}

int main(){
    long N, M;
    cin >> N >> M;

    vector<vector<long>> edges(N), redges(N);
    for(int i = 0, A, B; i < N - 1 + M; ++i){
        cin >> A >> B;
        edges[A - 1].push_back(B - 1);
        redges[B - 1].push_back(A - 1);
    }

    vector<long> tps;
    {
        vector<long> vst(N);
        for(long i = 0; i < N; ++i){
            topological_sort(i, vst, tps, edges);
        }
    }

    vector<long> idx(N);
    iota(idx.begin(), idx.end(), 0);
    sort(idx.begin(), idx.end(), [&](auto a, auto b){return tps[a] < tps[b];});

    vector<long> ans(N);

    for(auto i : tps){
        if(redges[i].empty())continue;
        ans[i] = idx[redges[i][0]];
        for(auto j : redges[i]){
            ans[i] = min(idx[j], ans[i]);
        }
        ans[i] = tps[ans[i]] + 1;
    }

    for(auto i : ans)cout << i << endl;
}

Measured memory_bytes: 18408
#include <stdio.h>

int k,s,i,j;

int main(){
  scanf("%d %d",&k,&s);
  int ans=0;
  for (i=0;i<=k;i++){
    for (j=0;j<=k;j++){
      if (0<= s-i-j && s-i-j <=k){ans++;}
    }
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio() ios_base::sync_with_stdio(false);
#define rmod(x, y) ((((x)%(y))+(y))%(y))
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<typename T, typename R = null_type, typename C = less<T>>
tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update> ordered_set(){
	return tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update>();
}


int main(){
	ll x; cin >> x;
	ll ans = 1000ll*(x/500);
	x %= 500;
	ans+= 5ll*(x/5);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
<?php
$X = (int)fgets(STDIN);
for ($b = -100; $b < 1000; $b++) {
    $pow_b = -pow($b, 5);
    if ($pow_b === $X) {
        echo 0 . ' ' . $b;
        exit;
    }
    if ($pow_b > $X) {
        continue;
    }
    for ($a = 0; $a < 1000; $a++) {
        $pow_a = pow($a, 5);
        $sum = $pow_a + $pow_b;
        if ($sum === $X) {
            echo $a . ' ' . $b;
            exit;
        }
        if ($sum > $X) {
            break;
        }
    }
}


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

#define Int register int
#define INF 0x3f3f3f3f
#define MAXN 500005

int n,k,cnt,sum,root,a[MAXN],ans[MAXN],minn[MAXN << 2],son[MAXN << 2][2];

void change (int &x,int l,int r,int pos,int d){
	if (!x) x = ++ cnt;
	if (l == r) return minn[x] = d,void ();
	int mid = (l + r) >> 1;
	if (pos <= mid) change (son[x][0],l,mid,pos,d);
	else change (son[x][1],mid + 1,r,pos,d);
	minn[x] = min (minn[son[x][0]],minn[son[x][1]]);
} 

int query (int x,int l,int r,int tl,int tr){
	if (!x) return INF;
	if (l >= tl && r <= tr) return minn[x];
	int mid = (l + r) >> 1,res = INF;
	if (tr > mid) res = min (res,query (son[x][1],mid + 1,r,tl,tr));
	if (tl <= mid) res = min (res,query (son[x][0],l,mid,tl,tr));
	return res;
}

template <typename T> inline void read (T &t){t = 0;char c = getchar();int f = 1;while (c < '0' || c > '9'){if (c == '-') f = -f;c = getchar();}while (c >= '0' && c <= '9'){t = (t << 3) + (t << 1) + c - '0';c = getchar();} t *= f;}
template <typename T,typename ... Args> inline void read (T &t,Args&... args){read (t);read (args...);}
template <typename T> inline void write (T x){if (x < 0){x = -x;putchar ('-');}if (x > 9) write (x / 10);putchar (x % 10 + '0');}

int toop = 1,to[MAXN << 1],nxt[MAXN << 1],deg[MAXN],head[MAXN];
void Add_Edge (int u,int v){to[++ toop] = v,nxt[toop] = head[u],head[u] = toop;}

signed main(){
	read (n,k);memset (minn,0x3f,sizeof (minn));
	for (Int i = 1,x;i <= n;++ i) read (x),a[x] = i;
	for (Int i = n;i;-- i){
		int lr = query (root,1,n,a[i],min (n,a[i] + k - 1));
		if (lr != INF) Add_Edge (a[i],a[lr]),deg[a[lr]] ++;
		int rr = query (root,1,n,max (1,a[i] - k + 1),a[i]);
		if (rr != INF) Add_Edge (a[i],a[rr]),deg[a[rr]] ++;
		change (root,1,n,a[i],i); 
	}
	priority_queue <int,vector <int>,greater<int> > q;
	for (Int i = 1;i <= n;++ i) if (!deg[i]) q.push (i);
	while (!q.empty()){
		int u = q.top();q.pop ();ans[u] = ++ sum;
		for (Int i = head[u];i;i = nxt[i]) if (-- deg[to[i]] == 0) q.push (to[i]);
	}
	for (Int i = 1;i <= n;++ i) write (ans[i]),putchar ('\n');
	return 0;
}

Measured memory_bytes: 35152
#include<iostream>
#include<cmath>
#include <vector>
using namespace std;

int main(){

  long A = 0;
  long B = 0;

  cin >> A >> B;

  long r = 0;
  long x = 0;
  long tmp = 0;
  long ans = 0;

  x = A * B;

  if (A < B) {
    tmp = A;
    A = B;
    B = tmp;
  }

  r = A % B;
  while (r != 0) {
    A = B;
    B = r;
    r = A % B;
  }

  ans = x / B;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 888
#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

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

    sort(v.begin(), v.end());

    int sum = 0;
    for (int x : v)
        sum += x;

    int excl = 0;
    if (sum % 10 == 0) {
        excl = -1;
        for (int x : v) {
            if (x % 10 != 0) {
                excl = x;
                break;
            }
        }
    }

    if (excl == -1)
        cout << "0\n";
    else
        cout << sum - excl << '\n';

    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    A, B, C, K = map(int, rl().split())
    
    if K <= A:
        print(K)
    elif K <= A + B:
        print(A)
    else:
        print(A - (K - A - B))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 61672
import java.util.Scanner;
public class Main {

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

		int  r = sc.nextInt();
		int  D = sc.nextInt();
		int  X = sc.nextInt();
		
		int X_1 = r * X - D;
		int X_2 = r * X_1 - D;
		int X_3 = r * X_2 - D;
		int X_4 = r * X_3 - D;
		int X_5 = r * X_4 - D;
		int X_6 = r * X_5 - D;
		int X_7 = r * X_6 - D;
		int X_8 = r * X_7 - D;
		int X_9 = r * X_8 - D;
		int X_11 = r * X_9 - D;
		
		System.out.println(X_1);
		System.out.println(X_2);
		System.out.println(X_3);
		System.out.println(X_4);
		System.out.println(X_5);
		System.out.println(X_6);
		System.out.println(X_7);
		System.out.println(X_8);
		System.out.println(X_9);
		System.out.println(X_11);
	}
	
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  
  cin>>N;
  
  vector<string> S(N);
for (int i = 0; i < N; i++) {
  cin >> S.at(i);
}
  
  sort(S.begin(), S.end());
  
  int sw=1;
  string sw1=S.at(0);
  
  for (int i = 1; i < N; i++) {
  if(sw1!=S.at(i)){
    sw++;
    sw1=S.at(i);
  }
}
  
  cout<<sw<<endl;
}



  

Measured memory_bytes: 9524
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a,b,c) for(b=(c);b<(a);b++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll gcd(ll, ll);
ll combination(ll, ll);
int main() {
	ll n;
	cin >> n;
	vector<ll> x;
	ll xin, lastxin;
	cin >> lastxin;
	ll answer;
	for (int i = 0; i < n; i++) {
		cin >> xin;
		x.push_back(abs(xin-lastxin));
		lastxin = xin;
	}
	answer = x[0];
	for (int i = 0; i < n; i++) {
		answer = gcd(answer, x[i]);
	}
	cout << answer;
	return 0;
}


inline ll kaizyo(ll x) {
	long ans = 1;
	for (int z = 0; z < x; z++) {
		ans *= (x - z);
	}
	return ans;
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

Measured memory_bytes: 1400
//Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define     ff      	    	first
#define     pb 	         	push_back
#define     ss          		second
#define     ll      	    	long long
#define     MAX  	       	5000
#define     mpi         		map<int, int>
#define     mpll        		map<ll, ll>
#define     pll         		pair<ll, ll>
#define     plld        		pair<ll, double>
#define     SKILLER     		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     vi          		std::vector<int>
#define     vll         		std::vector<ll>
#define     vs          		std::vector<string>
#define     vvi         		std::vector<std::vector<int>>
#define     vvll        		std::vector<std::vector<ll>>
#define     all(v)      		v.begin(), v.end()
#define     allr(v)      		v.rbegin(), v.rend()
#define     loop(i, a, b) 	for(int i = a; i < b; i++)
#define 	  debug(x) 		cout << x <<" " <<"\n";
#define 	  debug1(x, y) 	cout << x << " " << y  << "\n";
#define 	  debug2(x, y, z) 	cout << x << " " << y << " " << z<<"\n";
#define 	  int 			ll
#define 	  endl 			'\n'
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
    	SKILLER;
    	
        int n; cin >> n;
        vector<int> v(n);
        for(auto &x:v)
        	cin >> x;
        int ans = 0;
        //sort(all(v));
        for(int i = 0; i < n - 2; i++)
        	for(int j = i + 1; j < n - 1; j++)
        		for(int k = j + 1; k < n; k++){

        			vector<int> r = {v[i], v[j], v[k]};
        			if(r[0] == r[1] || r[1] == r[2] || r[0] == r[2])
        				continue;
        			sort(all(r));
        			if(r[0] + r[1] > r[2]){
        			//	cout << r[0] << r[1] << r[2] <<"\n";
        				ans++;
        			}
        		}
        cout << ans ;
    	return 0;
}

Measured memory_bytes: 3660
#include <stdio.h>

#define RANGE 10010
 
int C[RANGE] = {0};
 
int main()
{
  int i, j;
  int N;
  int a;
  scanf("%d", &N);
  for (i = 0; i < N; i++){
    scanf("%d", &a);
    C[a]++;
  }
     
  int last = 0;
  for (i = 0; i < RANGE; i++){
    if (C[i] != 0) last = i;
  }
     
  for (i = 0; i < last; i++)
    for (j=0; j<C[i]; j++) printf("%d ", i);

  for (i = 0; i < C[last] - 1; i++) printf("%d ", last);
 
  printf("%d\n", last);
     
  return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<vector>

using ll = long long;
using namespace std;

const ll MOD = 1000000007;

void addMod(ll& a, ll b)
{
    a = ( a%MOD + b%MOD ) % MOD;
}

int main()
{
    int H, W, K;
    cin >> H >> W >> K;

    vector<int> fib{1, 1, 2, 3, 5, 8, 13, 21, 34};

    vector<vector<ll>> dp(H+1, vector<ll>(W, 0));
    dp.at(0).at(0) = 1;

    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            // DP(i, j) -> DP(i+1, j-1)への遷移
            if(j == 1) // DP(i, 1) -> DP(i+1, 0) は別処理
            {
                addMod( dp.at(i+1).at(j-1), fib.at(W-2) * dp.at(i).at(j) );
            }
            else if(j > 1)
            {
                addMod( dp.at(i+1).at(j-1), fib.at(j-1) * fib.at(W-j-1) * dp.at(i).at(j) );
            }


            // DP(i, j) -> DP(i+1, j) への遷移
            if(j == 0 || j == W-1) // 両端は特別処理
            {
                addMod( dp.at(i+1).at(j), fib.at(W-1) * dp.at(i).at(j) );
            }
            else
            {
                addMod(dp.at(i+1).at(j), fib.at(j) * fib.at(W-j-1) * dp.at(i).at(j));
            }


            // DP(i, j) -> DP(i+1, j+1) への遷移
            if(j == W-2) // DP(i, W-2) -> DP(i+1, W-1) は別処理
            {
                addMod( dp.at(i+1).at(j+1), fib.at(W-2) * dp.at(i).at(j) );
            }
            else if(j < W-2)
            {
                addMod( dp.at(i+1).at(j+1), fib.at(j) * fib.at(W-j-2) * dp.at(i).at(j) );
            }
        }
    }

    cout << dp.at(H).at(K-1) % MOD << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N, K, C;
  string S;
  cin >> N >> K >> C;
  cin >> S;

  ll front[N] = {}, back[N] = {}, last_work[N] = {};
  ll rest = 0;
  rep(i, N){
    if(i == 0){
      front[i] = (S[i] == 'o');
      if(S[i] == 'o') rest = C + 1;
      last_work[i] = S[i] == 'o' ? 0 : LLONG_MIN;
    }
    else if(S[i] == 'x' || rest > 0){
      front[i] = front[i-1];
      last_work[i] = last_work[i-1];
    }
    else{
      front[i] = front[i-1] + 1;
      rest = C + 1;
      last_work[i] = i;
    }
    rest--;
  }
  rrep(i, N){
    if(i == N-1){
      back[i] = (S[i] == 'o');
      if(S[i] == 'o') rest = C + 1;
    }
    else if(S[i] == 'x' || rest > 0){
      back[i] = back[i+1];
    }
    else{
      back[i] = back[i+1] + 1;
      rest = C + 1;
    }
    rest--;
  }
  // debug(front)
  // debug(back)

  vector<ll> ans;
  rep(i, N){
    if(i == 0){if(back[i+1] < K) ans.push_back(i+1);}
    else if(i == N-1){if(front[i-1] < K) ans.push_back(i+1);}
    else if(S[i] == 'o'){
      if(last_work[i-1] + C < i && front[i-1] + back[i+1] < K)  
        ans.push_back(i+1);
    }
  }
  for(auto n: ans) cout << n << endl;
  return 0;
}



Measured memory_bytes: 8052
#include <bits/stdc++.h>
#include <iostream>
#include <string>

#define f(i,n) for(int i = 0; i < n; i++)
#define fll(i,n) for(long long int i = 0; i < n; i++)
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define inf INT_MAX
#define pb push_back
#define all(x) x.begin(),x.end()
#define debug(x) cout<<" [ " << #x << " is: " << x << " ] "<<endl;
#define ans(x) cout<<x<<endl;
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define mem(x,i) memset(x,i,sizeof x)

#define cin_vi(v,n) f(i,n){int temp;cin>>temp;v.pb(temp);}
#define cin_vll(v,n) fll(i,n){ll temp;cin>>temp;v.pb(temp);}
#define sort_desc(a) sort(a.begin(), a.end(), greater<int>());
#define sort_desc_ll(a) sort(a.begin(), a.end(), greater<long long int>());

using namespace std;

bool isPalindrome (string s) {	
	// debug(s);
	bool flag = false;
	for (int i = 0; i < s.length()/2; ++i) {
		// cout<<s[i];
		if (s[i]==s[s.length()-1-i]){
		}
		else {
			flag=true;
			break;
		}
	}
	if(flag) return false;
	else return true;
}

int main () {
	
	fast;

	string s;
	cin>>s;
	if (isPalindrome(s.substr(0,s.length())))
		if (isPalindrome(s.substr(0,(s.length()-1)/2)))
			if (isPalindrome(s.substr((s.length()+3-1)/2,s.length()))){
				cout<<"Yes\n";
				return 0;
			}
	// else 
	cout<<"No\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  bool f;
  int n, i;
  while (cin >> n) {
    f = 0;
    for (i = 0; i < 10; i++) {
      if (n & 1 << i) {
        if (f) {
          cout << ' ';
        }
        cout << (1 << i);
        f = 1;
      }
    }
    cout << endl;
  }
  return 0;
}

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

int main()
{
    long long n;
    cin >> n;
    long long minm = 1000000000000000;

    for (long long i = 1; i*i <= n; ++i)
    {
       if(n % i == 0)
       {
          minm = min(minm, i + n/i - 2);
       }
    }

    cout << minm;
    return 0;
}

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

class Program
{
    public static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = s[0];
        int X = s[1];
        int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
        List<int> d = new List<int>();
        for (int i = 0; i < n; i ++) {
            d.Add(Math.Max(x[i],X) - Math.Min(x[i],X));
        }
        d.Distinct();
        int result = d[0];
        for(int i = 1; i < d.Count(); i ++) {
            result = gcd(result, d[i]);
        }
        Console.WriteLine(result);
    }
    public static int gcd(int a, int b) {
        if (a < b) return gcd(b,a);
        while (b != 0) {
             var remainder = a % b;
             a = b;
             b = remainder;
         }
         return a;
    }
}

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

using namespace std;


int main()
{
    int N,M;cin >> N>>M;
    int s[M];
    int c[M];
    int res = -1;
    int S[N];
    for(int i=0;i<N;++i)
    {
        S[i]=-1;
    }

    for(int i=0;i<M;++i)
    {
        cin >> s[i] >> c[i];
    }
    for(int i=0;i<M;++i)
    {
        if(S[s[i]-1]==-1)
        {
            S[s[i]-1]=c[i];
        }
        else{
            if(S[s[i]-1]!=c[i])
            {
                cout <<-1<<endl;
                return 0;
            }
        }
        
    }

    if(N!=1 && S[0] ==0) {cout << -1 << endl;return 0;}
    if(N==1 && M==0)
    {
        cout << 0 << endl;
        return 0;
    }

    for(int i=0;i<N;++i)
    {
        if(i==0 && S[i]==-1)
        {
            cout << 1;
        }
        else if(S[i]!=-1)
        {
            cout << S[i];
        }
        else cout << 0;
    }
    cout << endl;
}

Measured memory_bytes: 256
/*
[agc032] B - Balanced Neighbors
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int N;

void solve() {
    cout << (N / 2) * (N / 2 - 1) / 2 * 4 + (N % 2 == 0 ? 0 : N - 1) << endl;
    int s = N / 2 * 2 + 1;
    for (int i = 1; i <= N / 2; i++) {
        for (int j = i + 1; j <= N / 2; j++) {
            cout << i << " " << j << endl;
            cout << s - i << " " << j << endl;
            cout << i << " " << s - j << endl;
            cout << s - i << " " << s - j << endl;
        }
    }

    if (N % 2 == 1) {
        for (int i = 1; i < N; i++) {
            cout << i << " " << N << endl;
        }
    }
}

int main() {
    cin >> N;

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

  int a[201],b[201],c[201];

  int n;
  cin >> n;

   int sum[201] = {0};
  
  for(int i=0;i<n;i++) {
    cin >> a[i] >> b[i] >> c[i];
  }


  int d[201],e[201],f[201];
  int flag[3];
  for(int i=0;i<n;i++) {
    flag[0] = flag[1] = flag[2] = 0;
    for(int j=n-1;j>=0;j--) {
      
      if(i != j) {
	//cout << "a["<<i<<"]("<< a[i] <<") =?="<< " a["<<j<<"]("<<a[j]<<")" << endl;
	//cout << "b["<<i<<"]("<< b[i] <<") =?="<< " b["<<j<<"]("<<b[j]<<")" << endl;
	//cout << "c["<<i<<"]("<< c[i] <<") =?="<< " c["<<j<<"]("<<c[j]<<")" << endl<<endl;
	
	if(a[i] == a[j]) {
	  d[i] = 0;
	  flag[0] = 1;
	}
	if(b[i] == b[j]){
	  e[i]  = 0;
	  flag[1] = 1;
	}
	if(c[i] == c[j] ){
	  f[i] = 0;
	  flag[2] = 1;
	}
      }
    }
    if(flag[0] == 0) d[i] = a[i];
    if(flag[1] == 0) e[i] = b[i];
    if(flag[2] == 0) f[i] = c[i];
    // cout << d[i] << " " << e[i] << " "  << f[i] << endl;
      
  }

  for(int i=0;i<n;i++)
    cout << d[i]+e[i]+f[i]<< endl;
     
   
  return 0;

}
    

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

int main() {
  int num;
  cin >> num;
  bool y = false;
  
  for (int i=0; i<num; i++){
    char s;
    cin >> s;
    
    if (s == 'Y'){
      cout << "Four" <<endl;
      y = true;
      break;
    }
    else{
      continue;
    }
  }
  
  if (y != true){
    cout << "Three" <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000010
#define mod 1000000007
const int N = 200010 , LOG = 19;

bool ok[4];
char s[N];

string S = "NWSE";

int main(){
    scanf("%s",s);
    for(int i = 0 ;s[i] != '\0';i++){
    	for(int j = 0 ;j < 4;j++){
    		if(s[i] == S[j]){
    			ok[j] = true;
    		}
    	}
    }
    int cur1 = ok[0] + ok[2];
    int cur2 = ok[1] + ok[3];
    if(cur1 % 2 == 0 && cur2 % 2 == 0)
    	puts("Yes");
    else
    	puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;

typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
ll n,m,k;

vector<ll> A;

int main()
{
    ll a,b,c,d,e,f;
    ll c1,c2,c3;

    cin >> n >> m;

    for(c1 = 0; c1 < n; c1++){
        cin >> a;
        A.push_back(a);
    }

    ll mi = 9999999999;
    ll nm = 0;
    ll ma = 0;

    for(c1 = 0; c1 < n; c1++){

        mi = min(mi , A[c1]);
        ll temp = A[c1]-mi;

        if(temp == ma){
            nm++;
        }
        if(temp > ma){
            nm = 1;
            ma = temp;
        }

    }

     mi = 0;
     ll nM = 0;
     ma = 0;

    for(c1 = n-1; c1 >= 0; c1--){

        ma = max(ma , A[c1]);
        ll temp = ma - A[c1];

        if(temp == mi){
            nM++;
        }
        if(temp > mi){
            nM = 1;
            mi = temp;
        }

    }
   // cout << nm << " " << nM << "\n";
    cout << min(nm,nM) << "\n";

    return 0;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

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

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

bool jud(int y,int x,int h,int w){
	return (0<=y and y<h)and(0<=x and x<w);
}

int main(){
	using type=tuple<int,int,int,int,int>;//tuple(0 or 1,cnt,y,x,dp).
	
	int h,w;
	cin>>h>>w;
	
	int ch,cw,dh,dw;
	cin>>ch>>cw>>dh>>dw;
	ch--, cw--, dh--, dw--;
	
	vector<string> s(h);
	REP(i,h) cin>>s[i];
	
	vvi dp(h,vi(w,INF));
	dp[ch][cw]=0;
	priority_queue<type> pque;
	int cnt=0;
	pque.push(type(1,cnt--,ch,cw,0));
	while(!pque.empty()){
		int y,x,value;
		tie(ignore,ignore,y,x,value)=pque.top();
		pque.pop();
		if(value>dp[y][x]) continue;
		
		FOR(i,-2,2)FOR(j,-2,2){
			int ny=y+i,nx=x+j;
			if(jud(ny,nx,h,w)){
				bool flag=false;
				REP(k,4){
					if(i==dy[k] and j==dx[k]) flag=true;
				}
				
				if(s[ny][nx]=='.'){
					if(chmin(dp[ny][nx],dp[y][x]+(flag?0:1))) pque.push(type((flag?1:0),cnt--,ny,nx,dp[ny][nx]));
				}
			}
		}
	}
	
	if(dp[dh][dw]==INF) cout<<-1<<endl;
	else cout<<dp[dh][dw]<<endl;
}

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

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end)for(int i=start;i<end;i++)
#define SORT(v) sort(v.begin(),v.end())
typedef long long ll;

int main()
{
    ll n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(!(i%3==0||i%5==0))ans+=i;
    }
    cout<<ans;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n, r; cin >> n >> r;
  if(n < 10){
    cout << r + 100 * (10 - n) << endl;
  }else{
    cout << r << endl;
  }

  return 0;
}


Measured memory_bytes: 256
const MOD: i64 = 1000000000 + 7;

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let len = s.len();
    let mut dp = vec![vec![0i64; 13]; len];
    match s[0] {
        '?' => {
            for i in 0..10 {
                dp[0][i] = 1;
            }
        },
        c => dp[0][c as usize - 48] = 1,
    }
    for i in 1..len {
        match s[i] {
            '?' => {
                for m in 0..10 {
                    for n in 0..13 {
                        let new_r = ((m + 10 * n) % 13) as usize;
                        dp[i][new_r] += dp[i - 1][n as usize];
                        dp[i][new_r] %= MOD;
                    }
                }
            },
            c => {
                let num = c as i64 - 48;
                for n in 0..13 {
                    let new_r = ((num + 10 * n) % 13) as usize;
                    dp[i][new_r] += dp[i - 1][n as usize];
                    dp[i][new_r] %= MOD;
                }
            },
        }
    }
    println!("{}", dp[len - 1][5]);
}

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()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 18684
#include<iostream>
using namespace std;
 
int main(){
  int K, N;
  cin >> K >> N;
  int i[N];
  int min =0;
  for (int k=0; k<N; k++){
    cin >> i[k];
  }
  for (int j=0; j<N-1; j++){
    if(min<i[j+1]-i[j]){
      min = i[j+1]-i[j];
    }
  }
  if (min<i[0]+K-i[N-1]){
    min = i[0]+K-i[N-1];
  }
  cout<< K-min << endl;
  return 0;
}

Measured memory_bytes: 1024
//ABC142A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int n;
	cin >> n;
	double ans;
	if(n%2 == 0){
		ans = 0.5;
	}else{
		ans = (n+1.0)/(2.0*n);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256