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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int H, W; cin >> H >> W;
  string a[H]; rep(i,H) cin >> a[i];
  int count[26] = {}; rep(i,H) rep(j,W) count[a[i][j]-'a']++;
  int m[4] = {}; rep(i,26) m[count[i]%4]++;
  // debug(m,m+4);

  string result;
  if (H%2==0&&W%2==0) result = m[0]==26 ? "Yes" : "No";
  else if (H%2==0&&W%2==1) {
    bool ok = true;
    if (m[1]||m[3]) ok = false;
    if (m[2]>H/2) ok = false;
    result = ok ? "Yes" : "No";
  }
  else if (H%2==1&&W%2==0) {
    bool ok = true;
    if (m[1]||m[3]) ok = false;
    if (m[2]>W/2) ok = false;
    result = ok ? "Yes" : "No";
  }
  else if (H%2==1&&W%2==1) {
    if (m[1]==1&&m[3]==0) result = m[2] <= (H/2+W/2) ? "Yes" : "No";
    else if (m[1]==0&&m[3]==1) result = m[2]+1 <= (H/2+W/2) ? "Yes" : "No";
    else result = "No";
  }
  cout << result << endl;
  return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i])
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  
  int n,k;
  cin >> n >> k;
  
  int ans =1;
  
 for(int i=0;i<n;i++) {
        if(ans*2<ans+k)
            ans = ans*2;
          else
               ans+=k;
}
cout << ans << endl;
  
 return 0; 
}


Measured memory_bytes: 256
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

int main(){
	int n=ci(), r=ci();
	printf("%d\n",r+100*max(0,10-n));
	return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.io.*;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int opNum = Integer.parseInt(scan.nextLine());
		int cnt = 0;
		while(cnt < opNum){
			String tmp = scan.nextLine();
			String[] ops = tmp.split(" ");
			if(ops[0].equals("print")){
				print(Integer.parseInt(ops[1]),Integer.parseInt(ops[2]),str);
			}else if(ops[0].equals("replace")){
				str = replace(Integer.parseInt(ops[1]),Integer.parseInt(ops[2]), str, ops[3]);
			} else if(ops[0].equals("reverse")){
				str = reverse(Integer.parseInt(ops[1]),Integer.parseInt(ops[2]),str);
			}
			cnt++;
		}
	}

	public static void print(int i,int j,String str){
		String tmp = str.substring(i,j + 1);
		System.out.println(tmp);
	}

	public static String replace(int i,int j,String str,String rep){
		String first;
		String second;
		if(j == str.length() - 1){
			second = "";
		}else{
			second = str.substring(j + 1, str.length());
		}
		if(i == 0){
			first = "";
		}
		else{
			first = str.substring(0, i);
		}
		return str = first + rep + second;
	}

	public static String reverse(int i,int j,String str){
		String first;
		String second;
		if(j == str.length() - 1){
			second = "";
		}else{
			second = str.substring(j + 1, str.length());
		}
		if(i == 0){
			first = "";
		}
		else{
			first = str.substring(0, i);
		}
		String inside = str.substring(i ,j + 1);
		String n = "";
		for(int s = inside.length() - 1;s >= 0;s--){
			n += inside.charAt(s);
		}
		return first + n + second;
	}
}



Measured memory_bytes: 46112
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const ll INF=2e15;
const double PI=acos(-1);

vector<pair<ll,ll>> vectorCnt(vector<ll> a) {
    sort(a.begin(),a.end());
    int n=a.size();
    vector<pair<ll,ll>> b;
    ll cnt=1;
    rep(i,n-1) {
            if (a[i+1]!=a[i]) {
                b.push_back(make_pair(a[i],cnt));
                cnt=1;
            } else {
                ++cnt;
            }
    }
    b.push_back(make_pair(a[n-1],cnt));
    return b;
}

ll binary_power(ll a, ll n) {
    if (n==0) return 1;
    ll k=binary_power(a,n/2);
    if (n%2==0) return (k*k)%MOD;
    else return (((k*k)%MOD)*a)%MOD;
}


int main() {
    ios_base::sync_with_stdio(false); 

    int n;
    cin >> n;
    vector<ll> d(n);
    bool invalid=0;
    rep(i,n) {
        cin >> d[i];
        if (i==0 && d[i]!=0) invalid=1;
        if (i>0 && d[i]==0) invalid=1;
    }
    sort(d.begin(),d.end());
    vector<pair<ll,ll>> p=vectorCnt(d);
    int m=p.size();
    ll ans=1;
    repr(i,1,m-1) {
        ans=(ans*binary_power(p[i].second,p[i+1].second))%MOD;
        if (p[i].first+1!=p[i+1].first) invalid=1;
    }
    if (!invalid) cout << ans << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 6956
@$_=($<)x@@for@@=0..<>;/ (.*) /,$
$`[$1]=$$1[$`]=$' for@M=<>;for$i(@@){//,map$$_[$']-=$-=$$_[$']-$$_[$i]-$$i[$'],@@for@@}print~~grep/ .* /*$
$`[$&]<$',@M

Measured memory_bytes: 1536
N, M = map(int, input().split())
H = list(map(int, input().split()))
obs_list = [1] * N

for i in range(M):
    A, B = map(int, input().split())
    if H[A - 1] > H[B - 1]:
        obs_list[B - 1] = 0
    elif H[A - 1] < H[B - 1]:
        obs_list[A - 1] = 0
    else:
        obs_list[A - 1] = 0
        obs_list[B - 1] = 0
            
print(sum(obs_list))


Measured memory_bytes: 20112
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()




int main() {

	ll N, M;
	cin >> N >> M;
	vector<pair<ll, ll>> ab(M);
	vll vtx(N);
	rep(i, M) {
		ll a, b; cin >> a >> b;
		ab[i] = pair<ll, ll>(a, b);
	}
	sort(all(ab));
	rep(i, N) vtx[i] = i + 1;

	ll ans = 0;
	do {
		bool flag = true;
		rep(i, N - 1) {
			pair<ll, ll> tmp1 = pair<ll, ll>(vtx[i], vtx[i + 1]);
			pair<ll, ll> tmp2 = pair<ll, ll>(vtx[i + 1], vtx[i]);
			if (!binary_search(all(ab), tmp1) && !binary_search(all(ab), tmp2)) flag = false;
		}
		if (flag) ++ans;

	} while (next_permutation(vtx.begin() + 1, vtx.end()));
	
	cout << ans << endl;
}

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

using namespace std;

void output(int p, int q, int r, int s){
	if(p < r){
		swap(p, r);
		swap(q, s);
	}
	if(p == r && q < s){
		swap(q,s);
	}
	cout << p << " " << q << " " << r << " " << s << endl;
}
bool test(int a, int b, int c){
	if(b == 0 && c == 0){
		output(a, 0, 1, 0);
		return true;
	}
	for(int i = 1; i <= a; ++i){
		if(a%i == 0){
			int r = a/i;
			for(int j = -10000; j <= 10000; ++j){
				if(j == 0){
					continue;
				}
				if(c%j == 0){
					int s = c/j;
					if(i*s+j*r == b){
						output(i, j, r, s);
						return true;
					}
				}
			}
		}
	}
	return false;
}

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	while(a | b |c){
		if(!test(a,b,c)){
			cout << "Impossible" << endl;
		}
		cin >> a >> b >> c;
	}
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define    ll   long long int
#define    sz   200010
#define    md   1000000007
#define    py   printf("YES\n")
#define    pn   printf("NO\n")

using namespace std;


ll ara[sz];
ll num[sz];


int main()
{


    ll n,i,j,k,p,f=0;

    cin>>n;

    for(i=1; i<=n; i++)
    {
        cin>>num[i];
        if(num[i]!=i)
            f=1;
    }
    if(f==0)
    {
        py;
        return 0;
    }

    for(i=1; i<=n; i++)
    {
        for(j=i+1; j<=n; j++)
        {
            swap(num[i],num[j]);
            f=0;

            for(k=1; k<=n; k++)
            {
                if(num[k]!=k)
                {
                    f=1;
                    break;
                }
            }
            if(f==0)
            {
                py;
                return 0;
            }

           swap(num[i],num[j]);
        }
    }

    pn;


    return 0;
}


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

int main() {
  int n, ans[100], i;
  while (cin >> n) {
    if (n == -1)
      break;
    if (n == 0) {
      cout << 0 << endl;
      continue;
    }
    vector<int> v;
    while (n != 0) {
      v.push_back(n % 4);
      n /= 4;
    }
    for (int i = v.size() - 1; i >= 0; i--) {
      cout << v[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
struct ed{int a,b,c;};
using P=pair<int,int>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  vector<vector<int>>com(n);
  vector<unordered_map<int, int>>num(n);
  vector<ed>es(m);
  if(m==0){cout<<-1<<endl;return 0;}

  rep(i,m)
  {
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;c--;
    es[i]={a,b,c};
    com[a].push_back(c);
    com[b].push_back(c);
  }
  int cnt=0;
  rep(i,n)
  {
    num[i][-1]=cnt++;
    sort(all(com[i]));
    com[i].erase(unique(all(com[i])),com[i].end());
    rep(j,com[i].size())
    {
      num[i][com[i][j]]=cnt++;
    }
  }
  vector<int>dist(cnt+2,-1);
  vector<vector<P>>edge(cnt+2);
  rep(i,n)rep(j,com[i].size())
  {
    int t=num[i][-1];
    int tn=num[i][com[i][j]];
    edge[t].push_back({1,tn});
    edge[tn].push_back({0,t});
  }
  rep(i,m)
  {
    int to=num[es[i].a][es[i].c],from=num[es[i].b][es[i].c];
    edge[to].push_back({0,from});
    edge[from].push_back({0,to});
  }
  int start=0,end=num[n-1][-1];
  priority_queue<P,vector<P>,greater<P>>q;
  q.push({0,start});
  while(!q.empty())
  {
    P tp=q.top();q.pop();
    if(dist[tp.second]!=-1)continue;
    if(tp.second==end){cout<<tp.first<<endl;return 0;}
    dist[tp.second]=tp.first;
    for(P nn:edge[tp.second])
    {
      if(dist[nn.second]!=-1)continue;
      q.push({nn.first+tp.first,nn.second});
    }
  }
  cout<<-1<<endl;
  //rep(i,dist.size())cout<<i<<" "<<dist[i]<<endl;
  //cout<<end<<endl;
  /*
  rep(i,edge.size())rep(j,edge[i].size())
  {
    cout<<i<<" "<<edge[i][j].first<<" "<<edge[i][j].second<<endl;
  }
*/


  return 0;

}


Measured memory_bytes: 70540
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
signed main() {
    int n; cin >> n; n--;
    int a[110]; for (int i = 0; i < n; i++)cin >> a[i];
    long long dp[110][25];
    for (int i = 0; i <= 20; i++)dp[0][i] = 0;
    dp[0][a[0]] = 1;
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= 20; j++) {
            dp[i][j] = 0;
            if (j >= a[i])dp[i][j] += dp[i - 1][j - a[i]];
            if (j + a[i] <= 20)dp[i][j] += dp[i - 1][j + a[i]];
        }
    }
    int ans; cin >> ans;
    cout << dp[n - 1][ans] << endl;
}


Measured memory_bytes: 3112
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		while(n-->0)
		{
			int m=in.nextInt();
			int a[]=new int[m];
			int u=0;
			int mu=0;
			int d=0;
			int md=0;
			for(int i=0;i<m;i++)
			{
				a[i]=in.nextInt();
			}
			for(int i=0;i<m-1;i++)
			{
				u=a[i+1]-a[i];
				d=a[i+1]-a[i];
				mu=Math.max(u, mu);
				md=Math.min(d, md);
			}
			System.out.println(mu+" "+-md);
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<=n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define sec setprecision
#define Pair pair<ll,ll>
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2) % mod);
	else
		return (x * pow(x, n - 1)) % mod;
}
int main() {
	int l, r, d; cin >> l >> r >> d;
	int count = 0;
	for (int i = l; i <= r; i++)if (i % d == 0)count++;
	cout << count << endl;
}


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

int prime[1299709];
void init()
{
  for(int i = 2; i < 1300000; i++)
  {
    if(prime[i])
      continue;
    prime[i] = 1;
    for(int j = i + i; j < 1300000; j += i)
      prime[j] = -1;
  }
}

int main()
{
loop:
  init();
  int n;
  cin >> n;
  if(!n)
    return 0;
  if(prime[n] == 1)
  {
    cout << 0 << endl;
    goto loop;
  }
  int b;
  for(int i = 0; i < 1299709; i++)
  {
    if(prime[i] == 1 && i > n)
    {
      cout << i - b << endl;
      goto loop;
    }
    else if(prime[i] == 1)
      b = i;
  }
}

Measured memory_bytes: 6236
var min,max:longint;
procedure nhap;
var i,the,n:longint;
begin
   read(n);
   for i:=1 to n do
      begin
      read(the);
      if the>max then max:=the;
      if the<min then min:=the;
      end;
end;
 
procedure xuat;
begin
   write(max-min);
end;
 
begin
min:=maxlongint;
max:=-maxlongint;
nhap;
xuat;
end.

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;

  if (n <= k) P(x * n);
  else P(x * k + (n - k) * y);

  return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll D;
    cin >> D;

    vector<ll> C(26);
    REP(i, 26){
        cin >> C[i];
    }

    vector<vector<ll>> S(D+1, vector<ll>(26));
    vector<ll> t(D+1);

    for(ll i=1; i<=D; i++){
        REP(j, 26){
            cin >> S[i][j];
        }
    }
    for(ll i=1; i<=D; i++){
        cin >> t[i];
    }

    vector<ll> v(D+1);

    vector<ll> last(26, 0);

    v[0] = 0;
    for(ll i=1; i<=D; i++){
        v[i] = v[i-1] + S[i][t[i]-1];
        last[t[i]-1] = i;
        ll minus = 0;
        REP(j, 26){
            minus += C[j] * (i - last[j]);
        }
        v[i] -= minus;
    }

    for(ll i=1; i<=D; i++){
        cout << v[i] << endl;
    }
    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int dp[2][100500];
int a[100500];
int n;

int f(int t, int k){
	if(dp[t][k] != -1) return dp[t][k];
	int ret = 2;
	for(int i = 0; i < n; i++){
		if(k < a[i]) continue;
		if(k - a[i] == 0){
			ret = t;
			break;
		}
		ret = f(!t, k - a[i]);
		if(ret == t) break;
	}
	if(ret == 2) ret = !t;
	return dp[t][k] = ret;
}

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

	int k;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	memset(dp, -1, sizeof dp);
	int win = f(0, k);
	cout << (win == 0 ? "First" : "Second");
}

Measured memory_bytes: 5760
// Marcin Knapik
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< int , null_type,less< int >, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ull>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef pair<ll, ll>          ii;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<vll>             vvll;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vii>             vvii;
#define pll pair<long long, long long>

#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second

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

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<class T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }

const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll BIG_INF = 1e18;
const ll N = 1e6+7;
const ll T = 1<<20;
const ld inf = 1e18;

ll n, m, q;

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

    cin >> n;
    string s;
    cin >> s;

    if(sz(s) <= n)
    	cout << s << '\n';
    else{
    	cout << s.substr(0, n) << "...\n";
    }
}   	

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        ll num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    ll sum = 0;
    vector<ll> A(N);

    REP(i,N) {
        cin >> A[i];
        sum += A[i];
    }
    sum /= 2;

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

    cout << sum*2;
    int x = sum;
    REP(i,N-1){
        x = A[i] - x;
        cout << " " << x*2; 
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 100005;
int x[MAX_N];

int main()
{
	int N,K,minus = 0,plus = 0,zero = 0;
	cin >> N >> K;
	for (int i = 0; i < N; ++i)
	{
		cin >> x[i];
		if (x[i] > 0)
		{
			plus++;
		}
		else if (x[i] < 0)
		{
			minus++;
		}
		else
		{
			zero++;
		}
	}

	int ans = 1e9;
	int loop = min(minus+1,N-K+1);

	for (int i = 0; i < loop; ++i)
	{
		if (x[i] < 0 && x[K-1+i] < 0)
		{
			ans = min(ans, -1 * x[i]);
		}
		else if (x[i] < 0 && x[K-1+i] > 0)
		{
			ans = min(ans, min(-2 * x[i] + x[K-1+i], -1 * x[i] + x[K-1+i] * 2));
		}
		else
		{
			ans = min(ans, x[K-1+i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;
// << fixed << setprecision(10) <<

int main() {
int n;
cin >> n;
char s[n];
cin >> s;
int ans=0;
REP(i,n-1) {
  if(s[i]==s[i+1]) ans++;
}
cout << n-ans << endl;
return 0;
}


Measured memory_bytes: 384
#include<iostream> 
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath> 
#include<algorithm>
#define ll long long 
using namespace std;
const int maxn=500010, inf=1e9;
int n, m, x, y, cnt;
int f[2010][2010], col[2010], numcnt[2010];
bool v[2010][2010];

template<typename T>
inline void read(T &k)
{
	int f=1; k=0; char c=getchar();
	while(c<'0' || c>'9') c=='-'&&(f=-1), c=getchar();
	while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
	k*=f;
}

void dfs(int x)
{
	numcnt[col[x]]++;
	for(int i=1;i<=n;i++)
	if(v[x][i])
	{
		if(col[i]==col[x])
		{
			puts("-1");
			exit(0);
		}
		else if(col[i]==-1)
		{
			if(col[x]&1) col[i]=col[x]+1;
			else col[i]=col[x]-1;
//			col[i]=col[x];
			dfs(i);
		}
	}
}

int main()
{
	read(n); read(m);
	for(int i=1;i<=m;i++) read(x), read(y), v[x][y]=v[y][x]=1;
	for(int i=1;i<=n;i++) v[i][i]=1;
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) v[i][j]^=1;
	memset(col, -1, sizeof(col)); cnt=1;
	for(int i=1;i<=n;i++) 
	if(col[i]==-1) col[i]=cnt, dfs(i), cnt+=2; cnt--;
	f[0][0]=1; 
	for(int i=1;(i<<1)<=cnt;i++)
	for(int j=0;j<=n;j++)
	if(f[i-1][j]) f[i][j+numcnt[((i-1)<<1)|1]]=f[i][j+numcnt[(i<<1)]]=1;
	for(int i=n/2;~i;i--)
	if(f[cnt>>1][i]) return printf("%d\n", i*(i-1)/2+(n-i)*(n-i-1)/2), 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll dep(ll a,ll b){
	if(b==0){
		return a;
	}
	return dep(b,a%b);
}
int main() {
	ll n;
	cin>>n;
	ll ch[1000010];
	for(ll i=0;i<n;i++){
		cin>>ch[i];
	}
	ll ch2[1000010]={};
	for(ll i=2;i<1000010;i++){
		if(ch2[i]!=0){
			continue;
		}
		for(ll j=1;i*j<1000010;j++){
			ll now=i*j;
			if(ch2[now]==0){
				ch2[i*j]=i;
			}
		}
	}
	//for(ll i=0;i<1000010;i++){
		//cout << i<< " "<<ch2[i]<<endl;
	//}
	ll ch3[1000010]={};
	bool ans1=true;
	//cout <<ans1<<endl;
	for(ll i=0;i<n;i++){
		ll now=ch[i];
		while(now!=1){
			ll next=ch2[now];
			if(ch3[next]==1){
				ans1=false;
				break;
			}
			ch3[next]=1;
			while(now%next==0){
				now/=next;
			}
		}
		if(ans1==false){
			break;
		}
	}
	if(ans1){
		cout << "pairwise coprime";
		return 0;
	}
	ll gcd=ch[0];
	for(ll i=1;i<n;i++){
		gcd=dep(max(gcd,ch[i]),min(gcd,ch[i]));
	}
	if(gcd==1){
		cout << "setwise coprime";
	}
	else{
		cout << "not coprime";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 26964
#include<bits/stdc++.h>
using namespace std;
int a[200000][3],dp[200000][3];

int max_happiness(int i, int activity)
{
	if(i==1)
	{
		return a[1][activity];
	}
	if(dp[i][activity]==-1)
	{
		int m = 0;
		for(int j = 0; j < 3 ;j++)
		{
			if(j==activity)
				continue;
			m = max(m,max_happiness(i-1,j));
		}
		dp[i][activity] = m + a[i][activity];
	}
	return dp[i][activity];
}

int main()
{
	int n;
	cin>>n;
	for (int i = 1; i <= n; ++i)
	{
		dp[i][0] = -1;
		dp[i][1] = -1;
		dp[i][2] = -1;
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}

	int m = max(  max_happiness(n,0), max_happiness(n,1) );
	m = max(m, max_happiness(n,2) );
	cout<<m<<endl;
	
	return 0;
}

Measured memory_bytes: 9728
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {($(read_value!($iter, $t)),*)};
    ($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_|read_value!($iter, $t)).collect::<Vec<_>>()};
    ($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};
    ($iter:expr, usize1) => {read_value!($iter, usize) - 1};
    ($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};
}

fn main() {
    input! {
        n: usize,
        m: usize,
    }
    if n > 9 || m > 9 {
        println!("-1");
        return;
    }
    println!("{}", n * m);
}


Measured memory_bytes: 4352
n=int(input())
l=[]
for i in range(n):
    a=[int(j) for j in input().split()]
    if i==0:
        l.append(a)
    else:
        li=[]
        li.append(a[0]+max(l[-1][1],l[-1][2]))
        li.append(a[1]+max(l[-1][0],l[-1][2]))
        li.append(a[2]+max(l[-1][0],l[-1][1]))
        l.append(li)

print(max(l[-1]))


Measured memory_bytes: 24356
#include <stdio.h>
 
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if((a + b) % 2)  printf("%d\n",(a + b) / 2 + 1);
  else printf("%d\n",(a + b) / 2);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 10004, INF = 1000000009;

int h, n;
int a[N], b[N];

int dp[N];

int main()
{
    scanf("%d%d", &h, &n);
    for (int i = 0; i < n; ++i)
        scanf("%d%d", &a[i], &b[i]);
    for (int i = 1; i < h; ++i)
        dp[i] = INF;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < h - a[i]; ++j)
        {
            dp[j + a[i]] = min(dp[j + a[i]], dp[j] + b[i]);
        }
    }
    int ans = INF;
    for (int i = 0; i < n; ++i)
    {
        for (int j = max(0, h - a[i]); j < h; ++j)
            ans = min(ans, dp[j] + b[i]);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int debt = 100000;
  for (int i=0;i<n;i++) {
    debt = debt*105/100;
    debt = (debt+999)/1000;
    debt = debt*1000;
  }
  printf("%d\n", debt);
  return 0;
}

Measured memory_bytes: 2696
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll c[10001];
vector<int> g[10001];
ll s[10001];

int main(){
    int n;
    cin >> n;
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    ll m = 0;
    rep(i, n) cin >> c[i], m += c[i];

    sort(c, c+n);
    reverse(c, c+n);

    m -= c[0];

    s[0] = c[0];

    queue<int> que;
    que.push(0);
    int i = 1;
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(auto nv : g[v]){
            if (s[nv] > 0) continue;
            s[nv] += c[i];
            i++;
            que.push(nv);
        }
    }

    cout << m << endl;
    rep(i, n) cout << s[i] << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
 
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 1000000007;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 

int a[100005];
int tree[200005];

void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}

void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}

int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}

int digit(int a){
    int ans = 0;
    while(a!=0){
        ans++;
        a/=10;
    }
    return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    int n= s.length();
    vector<int> pos;
    for(int i=0;i<n-1;i++){
        if(s[i]=='R' && s[i+1]=='L')pos.pb(i);
    }
    int a[n] = {0};
    int ind = 0;
    for(int i=0;i<n;i++){
        if(s[i]=='L')continue;
        if(i>pos[ind])ind++;
        int steps = pos[ind]-i;
        if(steps%2){
            a[pos[ind]+1]++;
        }
        else{
            a[pos[ind]]++;
        }
    }
    ind = pos.size()-1;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='R')continue;
        if(i<pos[ind])ind--;
        int steps = i-pos[ind];
        if(steps%2){
            a[pos[ind]+1]++;
        }
        else{
            a[pos[ind]]++;
        }
    }
    for(int i=0;i<n;i++)cout << a[i] << " ";
    cout << endl;
	return 0;
}


Measured memory_bytes: 1232
#include <iostream>

using namespace std;

const int LIM = 1e+5 + 100;

bool used[LIM];
int cnt[LIM];

int main() {
  int n, m;
  cin >> n >> m;

  for (int i = 0; i < n; ++i)
    cnt[i] = 1;
  used[0] = true;

  for (int i = 0; i < m; ++i) {
    int from, to;
    cin >> from >> to;
    --from;
    --to;
    if (used[from])
      used[to] = true;
    --cnt[from];
    if (cnt[from] == 0)
      used[from] = false;
    ++cnt[to];
  }

  int ans = 0;
  for (int i = 0; i < n; ++i)
    if (used[i])
      ++ans;

  cout << ans << endl;

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int64_t>a(n);
  vector<int64_t>b(n);
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  for(int i=0;i<n;i++)
    cin >> b.at(i);
  vector<int64_t>h(n);
  for(int i=0;i<n;i++)
    h.at(i)=b.at(i)-a.at(i);
  sort(h.begin(),h.end(),greater());
  int64_t ans=0,m=0;
  for(int i=0;i<n;i++){
    if(h.at(i)>0){
      m+=h.at(i);
      ans++;
    }else{
      break;
    }
  }
  for(int i=h.size()-1;i>=0;i--){
    if(m<=0)
      break;
    m+=h.at(i);
    ans++;
  }
  if(m>0)
    cout << -1 << endl;
  else 
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5600
#include <iostream>
#include <map>
#define ll long long
#define maxn 100000
#define maxm 1000000000
ll v[maxn + 1];
ll s[maxn + 6];
std::map<long long, long long> mp;

int main() {
    ll n, m, a, rez = 0;
    std::cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        std::cin >> a;
        v[i] = a % m;
        s[i] = (s[i - 1] + v[i] ) % m;
        mp[s[i]]++;
    }
    mp[0]++;
    for(std::map<long long,long long>::const_iterator i = mp.begin(); i!= mp.end(); i++)
	{
		ll k = (i->second);
		rez += k * (k-1) / 2;
	}
    std::cout << rez;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    sum += s[i];
  }

  if (sum % 10 != 0) {
    cout << sum << endl;
  } else {
    sort(s.begin(), s.end());
    for (int i = 0; i < n; ++i) {
      if (s[i] % 10 != 0) {
        cout << sum - s[i] << endl;
        return 0;
      }
    }
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
//set many funcs template
//Ver.20180717
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

typedef struct{
    long long st;
    long long fi;
    long long kr;
}rs;

typedef struct{
    long long st;
    long long kz;
}mkj;

int sortfnc(const void *a,const void *b){
if(((rs*)a)->st == ((rs*)b)->st){return 0;}
if(((rs*)a)->st < ((rs*)b)->st){return -1;}
return 1;
}

void makemkj(rs g[],mkj x[],long long n){
    long long i,ms=0,nst=g[0].st;
    for(i=1;i<n;i++){
        if(g[i].st!=g[i-1].st){
            x[nst].kz=i-ms;
            x[nst].st=ms;
            nst=g[i].st;ms=i;
        }
    }
    x[nst].kz=n-ms;
    x[nst].st=ms;
}

long long n,m;
rs gr[524288];
mkj mk[524288];

long long color[524288]={0},flag;

long long rep(long long x,long long bc){
  if(color[x]!=0){
    if(color[x]==bc){flag=0;}
  }
  else{
    color[x]=3-bc;
    long long i;
    for(i=mk[x].st;i<mk[x].st+mk[x].kz;i++){
      rep(gr[i].fi,3-bc);
    }
  }
}

long long jud(long long x){
  if(mk[x].st==-1){return -1;}
  flag=1;
  rep(x,2);
  return flag;
}

long long main(void){
    long long i,j,sg=0,hs=0,nh=0,w;
    long long res;
    scanf("%lld%lld",&n,&m);
    for(i=0;i<m;i++){
      scanf("%lld%lld",&gr[2*i].st,&gr[2*i].fi);
      gr[2*i+1].fi=gr[2*i].st;
      gr[2*i+1].st=gr[2*i].fi;      
    }
    for(i=1;i<=n;i++){
      mk[i].st=-1;
    }
    qsort(gr,2*m,sizeof(gr[0]),sortfnc);
    makemkj(gr,mk,2*m);
    for(i=1;i<=n;i++){
      if(color[i]!=0){continue;}
      w=jud(i);
      if(w==-1){sg++;}
      if(w==0){hs++;}
      if(w==1){nh++;}
    }
    res=(n*n)-((n-sg)*(n-sg));
    w=nh*nh*2;
    w+=(hs*nh*2);
    w+=(hs*hs);
    printf("%lld\n",res+w);
    return 0;
}


Measured memory_bytes: 21884
#include <bits/stdc++.h>
using namespace std;
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
double res, PI = acos(-1);
int n;
main(){
	cin >> n;
    int x[n], y[n];
	rep(i, n) cin>>x[i]>>y[i];
	rep(i, n){
        vector<double> d;
        rep(j, n) if(i != j) d.push_back(atan2(y[j] - y[i], x[j] - x[i]));
		sort(begin(d),end(d));
		res = d[0] - d[d.size() - 1] + PI;
		rep(j, 1, d.size()) res=max(res,d[j] - d[j - 1] - PI);
        cout<<max(0.0, res / 2.0 / PI)<<'\n';
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;


int main(void) {
	int n;
	cin >> n;

	int count = 0;

	for (int i = 1; i < n; ++i) {
		int j = n - i;
		if (i != j && i > j) {
			++count;
		}
	}

	cout << count;

	return 0;
}

Measured memory_bytes: 256
""" A
    https://atcoder.jp/contests/abc173/tasks/abc173_a
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return reduce(lambda acc, _: acc + [readIntegerSet(m)], range(0, n), [])

def main(N):
    return (1000 - (N%1000))%1000

if __name__ == "__main__":
    _N = readInteger()

    print(main(_N))

Measured memory_bytes: 9568
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/multiprecision/cpp_int.hpp>
// ↓これいる？
#include <boost/graph/strong_components.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;
using namespace boost::numeric;
using namespace boost::multiprecision;
using ll = long long;
namespace bst = boost;
template<class T> void fill(T& v) { for (auto&& i : v) cin >> i; }

//#include "atcoder.hpp"

int main() {
    string s;
    unordered_map<string, int> r = {
      { "SUN",  7},
      { "MON",  6},

      { "TUE",  5},

      { "WED",  4},

      { "THU",  3},
      { "FRI", 2 },
      { "SAT",  1}

    };

    cin >> s;
    
    cout << r[s] << endl;
    
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string s;
  set<string> S;
  cin >> N;
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    S.insert(s);
  }
  cout << S.size() << endl;
}

Measured memory_bytes: 19124
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define all(x)              (x).begin(), (x).end()
#define inf                 1e18

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//	ifstream cin("input.txt");
//	ofstream cout("output.txt");
	int n;
	cin >> n;
	map <string, int> mp;
	ll mx = 0;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s; ++mp[s]; mx = max(mx, 1LL * mp[s]);
	}
	for (auto i : mp) {
		if (i.second == mx) {
			cout << i.first << endl;
		}
	}
}


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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int t=c-a,  l=d-b;
    cout<<c-l<<" "<<d+t<<" "<<a-l<<" "<<b+t<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
    int A,B;
    cin>>A>>B;

    if(A%3==0||B%3==0||(A+B)%3==0){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }

    return 0;
}


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

int main() {
    ll N, M; cin >> N >> M;
    cout << abs((N - 2) * (M - 2)) << endl;
}


Measured memory_bytes: 256
/* ex 7_1
   hangan2020 */

#include <stdio.h>

// Structure type for square's point
typedef struct point{
    int x_elem;
    int y_elem;
}point;

// Solve by creating perpendicular vectors
/*!! Created parallel vector should have head at the tail of original vector
     in order to follow anti-clockwise */

/*Shifting point in order to create the head of a
perpendicular vector with the same length*/
void shift_point(point or_point, point* sh_point, int dif_x, int dif_y){
    sh_point -> x_elem = or_point.x_elem - dif_y;
    sh_point -> y_elem = or_point.y_elem + dif_x;
}

int main(void){
    int x1, y1, x2, y2;
    int dif_x, dif_y;
    point a, b, c, d;
    point *pc, *pd; // Pointer to the other two points
    pc = &c; pd = &d;

    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

    // point a and b'coordinate
    a.x_elem = x1; a.y_elem = y1;
    b.x_elem = x2; b.y_elem = y2;

    // Values will be use for point shifting calculation
    dif_x = x2 - x1; // x element of ab vector
    dif_y = y2 - y1; // y element of ab vector

    /*Shifting point b in order to create a perpendicular
     vector from vector ab's head (same length)*/ 
    shift_point(b, pc, dif_x, dif_y); 
    /*Shifting point b in order to create a perpendicular
     vector from vector ba's head (same length)*/ 
    shift_point(a, pd, dif_x, dif_y);

    //Print c and d's coordinates
    printf("%d %d ", c.x_elem, c.y_elem);
    printf("%d %d\n", d.x_elem, d.y_elem);

    return 0;

}

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

int main() {
  int l, t, v;
  cin >> l >> t >> v;
  int vt= t*v;
  if(l<=vt){
    cout << "Yes" << endl;
  }
  else{
    cout << "No"<<endl;
  }
}

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

int f(string & s1, string & s2) {
    map<char, int> m;
    int sum = 0;
    for (int i = 0; i < s1.length(); i++)
        for (int j = 0; j < s2.length(); j++) {
        if (s1[i] == s2[j]) {
            m.insert(make_pair(s1[i], 1));
        }
    }
    for (auto i = m.begin(); i != m.end(); i++)
        sum += (*i).second;

    return sum;
}
int main() {
    string str, str1, str2;
    int t, Max = -1;
    cin >> t >> str;
    int s1, s2, len1, len2;
    int len = str.length();
    for (int i = 0; i < len - 1; i++) {
        str1 = str.substr(0, i+1);
        str2 = str.substr(i+1, len - (i+1));
        Max = f(str1, str2) > Max ? f(str1, str2) : Max;
    }
    cout << Max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>
#include <cctype>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    string s;
    cin >> s;
    bool f=false,f2=false;
    int pos=-1,pos2=-1;

    //先頭はAか？
    if(s[0] == 'A'){

        reps(i,2,s.length() - 1){
            if(s[i] == 'C'){
                if(!f){
                    f = true;
                    pos = i;
                }else{//Cが2つ以上ある
                    cout << "WA" << endl;
                    return 0;
                }
            }
        }
        if(!f){//Cが一つもない場合
            cout << "WA" << endl;
            return 0;
        }

        rep(i,s.length()){
            if(i == 0 || i == pos) continue;//最初とpos文字目は無視する
                if(isupper(s[i])){
                        cout << "WA" << endl;
                        return 0;
                }
        }

    }else{//先頭がAではない
        cout << "WA" << endl;
        return 0;
    }
    
    cout << "AC" << endl;

    return 0;
}

Measured memory_bytes: 256