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

void solve(int TestCase) {
    int x;
    cin >> x;
    
    int ret = 0;
    ret += x / 500 * 1000;
    x %= 500;
    ret += x / 5 * 5;
    x %= 5;

    cout << ret << endl;
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t = 1;
    //cin >> t;
    for(auto i = 1; i <= t; ++i) {
        //cout << "Case #"<< i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 256
N = int(input())
s = input()
p = 0
ans = ''
for c in s:
    if c == '(':
        p += 1
    elif c == ')':
        p -= 1
    if p == -1:
        p = 0
        ans = '(' + ans + c
    else:
        ans = ans + c

ans += ')' * p
print(ans)


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args)throws IOException{
		int[] outputData = new int[3];
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));

		String inputValue = br.readLine();
		String[] inputData = inputValue.split(" ");

		for(int i = 0; i < inputData.length; i++){
			outputData[i] = Integer.parseInt(inputData[i]);
		}

		Arrays.sort(outputData);
		System.out.println
			(outputData[0] + " " + outputData[1] + " " + outputData[2]);
	}

}

Measured memory_bytes: 24136
#include <stdio.h>

int main(void)
{
	int n,a,b,c;
	
	scanf("%d",&n);
	
	switch(n){
	case 1:
		printf("Hello World\n");
		break;
	case 2:
		scanf("%d %d",&a,&b);
		c=a+b;
		printf("%d\n",c);
		break;
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdint>
#include <cmath>

int main()
{
	double x = 0, y = 0;
	std::int16_t theta = 90;
	double const pi = std::acos(-1.0);
	std::int16_t d, t;
	char comma;

	for (std::cin >> d >> comma >> t; d != 0 || t != 0; std::cin >> d >> comma >> t) {
		x += d * std::cos(pi * theta / 180);
		y += d * std::sin(pi * theta / 180);
		theta -= t;
		if (theta < 0) {
			theta += 360;
		}
		else {
			theta %= 360;
		}
	}
	std::cout << static_cast<std::int32_t>(x) << '\n'
			  << static_cast<std::int32_t>(y) << std::endl;

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
int a,b,c,d,p,cost;
int main(){
	cin >>a;
	cin >>b;
	cin >>c;
	cin >>d;
	cin >>p;
	if(p<=c){
		cost=b;
	}else{
		cost=b+(p-c)*d;
	}
	if(cost<a*p){
		cout << cost<<endl;
	}else{
		cout << a*p<<endl;
	}
	return 0;
}

Measured memory_bytes: 3044
#include <iostream>
#include <cstdio>
#include <cstring>
//#define fre
#define DEBUG
using namespace std;
int main()
{
    int k;
    scanf("%d", &k);
    int e = k / 2, o = (k & 1 ? (k + 1) / 2 : k / 2);
    printf("%d\n", e * o);
}

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

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

using namespace std;

int main(){
	int n; cin>>n;
	int cnt=0;
	for(int i=1;i<=n;i++) if(i%2==1) cnt++;
	printf("%.9f\n",1.0*cnt/n);

	return 0;
}


Measured memory_bytes: 764
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

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

    int N; cin >> N;
    ll A[N], B[N+1];
    F0R(i, N+1) cin >> B[i];
    F0R(i, N) cin >> A[i];

    ll ans = 0;
    F0R(i, N) {
        ll V = min(A[i], B[i]); A[i] -= V; B[i] -= V; ans += V;

        V = min(A[i], B[i+1]); A[i] -= V; B[i+1] -= V; ans += V;
    }
    cout << ans << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 1792
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
if n >= m:
    print(0)
else:
    d = [0 for _ in range(m - 1)]
    for i in range(m - 1):
        d[i] = x[i + 1] - x[i]
    d.sort(reverse = True)
    print(sum(d[n - 1:]))


Measured memory_bytes: 13960
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll n,m;
cin>>n>>m;
map<ll,ll>rensou;
ll sum=0;
ll k;
ll a;
for(int i=0;i<n;i++){
    cin>>k;
    for(int j=0;j<k;j++){
        cin>>a;
        rensou[a]++;
    }
}
for(auto f:rensou){
    if(f.second==n){
        sum++;
    }
}
cout<<sum<<endl;
}












Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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;
}

int main(void) {
    double T, X;
    cin >> T >> X;
    printf("%.4f\n", T / X);
    return 0;
}


Measured memory_bytes: 384
N, M = map(int, input().split())
S = "x" + input()[::-1]
#print("S:", S)

current = 1
masu = [1]

while 1:
  flag = 1
  for i in range(min(current + M, N + 1), current, -1):
    if S[i] == "0":
      flag = 0
      masu.append(i)
      current = i
      break
  if flag:
    print(-1)
    exit()
  if current == N + 1:
    masu = masu[::-1]
    #print("masu:", masu)
    answer = []
    for i in range(1, len(masu)):
      answer.append(- masu[i] + masu[i - 1])
    print(*answer)
    exit()

Measured memory_bytes: 52028
#include<cmath>
#include<cstdlib>
#include<string>
#include<sstream>
#include<vector>
#include<iostream>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<algorithm>
using namespace std;

int main(){
    int n;
    int a;
    map<int, int> m_odd, m_even;

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a;
        if(i % 2 == 0){
            if(m_even.find(a) == m_even.end()){
                m_even[a] = 1;
            }
            else{
                m_even[a]++;
            }
        }
        else{
            if(m_odd.find(a) == m_odd.end()){
                m_odd[a] = 1;
            }
            else{
                m_odd[a]++;
            }
        }
    }

    int max_even = 0;
    int max_odd = 0;
    int next_even = 0;
    int next_odd = 0;
    int n_odd, n_even, k_odd, k_even;
    for(auto it: m_even){
        if(it.second > max_even){
            n_even = it.first;
            max_even = it.second;
        }
    }
    for(auto it: m_even){
        if(it.second > next_even && it.first != n_even){
            k_even = it.first;
            next_even = it.second;
        }
    }
    for(auto it: m_odd){
        if(it.second > max_odd){
            n_odd = it.first;
            max_odd = it.second;
        }
    }
    for(auto it: m_odd){
        if(it.second > next_odd && it.first != n_odd){
            k_odd = it.first;
            next_odd = it.second;
        }
    }
    /*
    cout << n_even << ": " << max_even << endl;
    cout << n_odd << ": " << max_odd << endl;
    cout << k_even << ": " << next_even << endl;
    cout << k_odd << ": " << next_odd << endl;
    */
    if(n_even == n_odd){
        cout << min(n - next_even - max_odd, n - max_even - next_odd) << endl;
    }
    else{
        cout << n - max_even - max_odd << endl;
    }
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define ll long long
#define lb(x) ((x)&(-x))
#define pii pair<int,int>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define de(x) cout<<x<<" x"<<endl
#define LCAFA rep(i,1,20)rep(j,1,n+1)fa[j][i]=fa[fa[j][i-1]][i-1]
#define all(x) x.begin(),x.end()
#define ls(x) x<<1
#define rs(x) x<<1|1
using namespace std;
const int N=2e5+9;
const ll mod=998244353;
int d[N],cnt,vis[N],stk[N];
vi g[N];
ll dp[N][3],temp[3];
ll add(ll x,ll y){
	return ((x+y)%mod+mod)%mod;
}
ll mul(ll x,ll y){
	return ((x*y)%mod+mod)%mod;
}
void dfs(int u,int f){
	for(auto v:g[u]){
		if(v==f)continue;
		d[v]=d[u]+1;
		dfs(v,u); 
	}
}
void dfs2(int u,int f){
	for(auto v:g[u]){
		if(v==f)continue;
		dfs2(v,u);
		if(vis[v])vis[u]=1;
	}
	if(vis[u])stk[++cnt]=u;
}
void sol(int u,int f){
	if(g[u].size()==1){
		if(vis[u])dp[u][0]=2,dp[u][1]=1;
		else dp[u][0]=3;
		return;
	}
	dp[u][0]=1;
	for(auto v:g[u]){
		if(v==f)continue;
		sol(v,u);
		rep(i,0,3)temp[i]=0;
		rep(i,0,3)rep(j,0,3)temp[min(2,i+j)]=add(temp[min(2,i+j)],mul(dp[u][i],dp[v][j]));
		rep(i,0,3)dp[u][i]=temp[i];
	//	cout<<v<<' '<<u<<" uv\n\n";
	//	cout<<dp[u][0]<<' '<<dp[u][1]<<' '<<dp[u][2]<<"checkdp\n";
	}
	dp[u][0]=add(dp[u][0],mul(2,dp[u][0]+dp[u][1]+dp[u][2])); 
}
int main(){
	int n;
	scanf("%d",&n);
	rep(i,1,n){
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].pb(v),g[v].pb(u);
	}
	dfs(1,0);
	int p=1;
	rep(i,1,n+1)if(d[i]>d[p])p=i;
	d[p]=0;
	dfs(p,0);
	int e=1;
	rep(i,1,n+1)if(d[i]>d[e])e=i;
	vis[e]=1;
	dfs2(p,0);
	memset(vis,0,sizeof vis);
	if(cnt&1){
	//	cout<<"comein\n";
		int u=stk[cnt/2+1];d[u]=0;dfs(u,0);
		rep(i,1,n+1)if(d[i]==cnt/2)vis[i]=1;
		ll ans[3]={1,0,0};
		for(auto v:g[u]){
		//	cout<<v<<"  v\n";
			sol(v,u);
			dp[v][0]-=dp[v][1]+dp[v][2];
			ans[2]=add(mul(ans[2],dp[v][0]),mul(ans[1],dp[v][1]));
			ans[1]=add(mul(ans[1],dp[v][0]),mul(ans[0],dp[v][1]));
			ans[0]=mul(ans[0],dp[v][0]);
		//	cout<<dp[v][0]<<' '<<dp[v][1]<<' '<<dp[v][2]<<"dp\n";
		//	cout<<ans[0]<<' '<<ans[1]<<' '<<ans[2]<<"check\n";
		}
		printf("%lld",ans[2]);
	}
	else{
		int u=stk[cnt>>1],v=stk[cnt/2+1];
		d[u]=0;d[v]=0;
		dfs(u,v);dfs(v,u);
		rep(i,1,n+1)if(d[i]==cnt/2-1)vis[i]=1;
		sol(u,v);sol(v,u);
		ll ans=mul(dp[u][1],dp[v][1]);
		printf("%lld",ans);
	}
}


Measured memory_bytes: 24576
#include<iostream>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;

int main(){
  int n;
  while(cin >> n){
    if(n==0)break;
    string step;
    bool isLeftUp = false, isRightUp = false, isUp = false;
    int cnt = 0;

    rep(i,n){
      cin >> step;
      if(step[0] == 'l'){
	if(step[1] == 'u')isLeftUp = true;
	else isLeftUp = false;
      }else{
	if(step[1] == 'u')isRightUp = true;
	else isRightUp = false;
      }

      if(isLeftUp && isRightUp && !isUp){
	isUp = true; cnt++;
      }

      if(!isLeftUp && !isRightUp && isUp){
	isUp = false; cnt++;
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1200
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<cstring>
#include<queue>
#include<numeric>

using namespace std;

int main() {
    char input;
    int num;
    cin >> input;
    num = (int)input;
    if (num > 90)cout << "a" << endl;
    else cout << "A" << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
typedef long long ll;
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
int main()
{
    fast();
    int n,j,sum=0;
    cin>>n>>j;
    int a[n+1];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<j;i++)
        sum=sum+a[i];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

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

			for (int i = 0; i < s.length(); i++) {
				String tmp = s.substring(i, s.length()) + (0 < i ? s.substring(0, i) : "");

				if (tmp.equals(t)) {
					System.out.println("Yes");
					return;
				}
			}
			System.out.println("No");
		}
	}
}


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

int main(){
  int n;
  long long k;
  cin>>n>>k;
  vector<pair<int,long long>> a(n);
  for(int i=0; i<n; i++)cin>>a.at(i).first>>a.at(i).second;

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

  long long num=0;
  for(int i=0; i<n; i++){
    num+=a.at(i).second;
    if(num>=k){
      cout<<a.at(i).first<<endl;
      break;
    }
  }

}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>

using namespace std;

int main(){
  int num[4];
  int N;
  cin>>N;
  for(int i=0;i<4;i++){
    num[i]=(N%int(pow(10,i+1)))/pow(10,i);
  }
  if(num[3]+num[2]+num[1]+num[0]==7){
    cout<<num[3]<<"+"<<num[2]<<"+"<<num[1]<<"+"<<num[0]<<"=7"<<endl;
  }  else if(num[3]+num[2]+num[1]-num[0]==7){
    cout<<num[3]<<"+"<<num[2]<<"+"<<num[1]<<"-"<<num[0]<<"=7"<<endl;
  }  else if(num[3]+num[2]-num[1]-num[0]==7){
    cout<<num[3]<<"+"<<num[2]<<"-"<<num[1]<<"-"<<num[0]<<"=7"<<endl;
  }  else if(num[3]-num[2]-num[1]-num[0]==7){
    cout<<num[3]<<"-"<<num[2]<<"-"<<num[1]<<"-"<<num[0]<<"=7"<<endl;
  }  else if(num[3]+num[2]-num[1]+num[0]==7){
    cout<<num[3]<<"+"<<num[2]<<"-"<<num[1]<<"+"<<num[0]<<"=7"<<endl;
  }  else if(num[3]-num[2]-num[1]+num[0]==7){
    cout<<num[3]<<"-"<<num[2]<<"-"<<num[1]<<"+"<<num[0]<<"=7"<<endl;
  }  else if(num[3]-num[2]+num[1]+num[0]==7){
    cout<<num[3]<<"-"<<num[2]<<"+"<<num[1]<<"+"<<num[0]<<"=7"<<endl;
  }  else if(num[3]-num[2]+num[1]-num[0]==7){
    cout<<num[3]<<"-"<<num[2]<<"+"<<num[1]<<"-"<<num[0]<<"=7"<<endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
typedef struct
{
  double x;
  double y;
} point;
void func(point,point,int);
void printPoint(point);
int main(void)
{
  int n;//input
  point p1,p2;
  p1.x=0.0;
  p1.y=0.0;
  p2.x=100.0;
  p2.y=0.0;
  scanf("%d",&n);
  printPoint(p1);
  func(p1,p2,n);
  return 0;
}
void func(point p1,point p2,int n)
{
  point p3,p4,p5;
  if(n==0) printPoint(p2);
  else
    {
      p3.x=p1.x+(p2.x-p1.x)/3.0;
      p3.y=p1.y+(p2.y-p1.y)/3.0;
      p5.x=p1.x+(p2.x-p1.x)*2.0/3.0;
      p5.y=p1.y+(p2.y-p1.y)*2.0/3.0;
      p4.x=p3.x+(p5.x-p3.x)*1.0/2.0-(p5.y-p3.y)*sqrt(3.0)/2.0;
      p4.y=p3.y+(p5.x-p3.x)*sqrt(3.0)/2.0+(p5.y-p3.y)*1.0/2.0;
      func(p1,p3,n-1);
      func(p3,p4,n-1);
      func(p4,p5,n-1);
      func(p5,p2,n-1);
    }
}
void printPoint(point p)
{
  printf("%f %f\n",p.x,p.y);
}



Measured memory_bytes: 2048
import std.stdio;

void main() {
	ulong n;
	readf("%s", &n);

	auto primes = new ulong[0];
	auto divs = new uint[0];

	for (ulong i = 2;i * i <= n;++i) {
		uint c;
		while (n % i == 0) {
			n /= i;
			++c;
		}
		primes ~= i;
		divs ~= c;
	}

	if (n != 1) {
		primes ~= n;
		divs ~= 1;
	}

	uint ans;
	foreach (e;divs) {
		uint b = 1;
		while (b <= e) {
			e -= b;
			++b;
			++ans;
		}
	}
	writeln(ans);
}


Measured memory_bytes: 21704
#include <bits/stdc++.h>
#define N 200010
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int n,A[N],B[N];ll Ans;
int main()
{
	n=read(); for(int i=1;i<=n;i++)
		A[i]=read(), B[i]=read();
	for(int i=n;i>=1;i--)
	{
		int xd=(1ll*A[i]+Ans)%B[i];
		if(xd) Ans+=(B[i]-xd);
	}
	cout << Ans << endl;
	return 0;
}

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

int main(){
    string n;
    cin >> n;
 
    for(int i = 0;i < 3;i++){
        if(n[i] == '1'){
            n[i] = '9';
        }else if(n[i] == '9'){
            n[i] = '1';
        }
    }
    cout << n << endl;
  
    
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val s = sc.next.toCharArray

  s.map(c => c match {
    case 'A' => 'T'
    case 'T' => 'A'
    case 'C' => 'G'
    case 'G' => 'C'
  }
  ).foreach(print)
  println()
}


Measured memory_bytes: 25496
package main

import "fmt"

func main() {
  var a, b, c, x int
  fmt.Scan(&a, &b, &c, &x)
  ap, bp, cp := 500, 100, 50
  count := 0
  for ai := 0; ai <= a; ai++ {
    for bi := 0; bi <= b; bi++ {
      for ci := 0; ci <= c; ci++ {
        if ap*ai+bp*bi+cp*ci == x {
          count++
        }
      }
    }
  }
  fmt.Println(count)
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

struct UnionFind {
  vector<int> par;
  vector<int> sz;

  UnionFind(int n) { init(n); }

  void init(int n) {
    par.resize(n);
    sz.resize(n);
    REP(i, n) {
      par[i] = i;
      sz[i] = 1;
    }
  }

  int find(int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sz[x] < sz[y]) {
      par[x] = y;
      sz[y] += sz[x];
    } else {
      par[y] = x;
      sz[x] += sz[y];
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int size(int x) { return sz[find(x)]; }
};

int main() {
  int N, K, L;
  cin >> N >> K >> L;
  UnionFind uf1(N);
  REP(i, K) {
    int p, q;
    cin >> p >> q;
    p--, q--;
    uf1.unite(p, q);
  }
  UnionFind uf2(N);
  REP(i, L) {
    int r, s;
    cin >> r >> s;
    r--, s--;
    uf2.unite(r, s);
  }
  map<P, int> mp;
  REP(i, N) mp[P(uf1.find(i), uf2.find(i))]++;
  REP(i, N) {
    if (i != 0) cout << " ";
    cout << mp[P(uf1.find(i), uf2.find(i))];
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define digit(x) floor(log10(x))+1
#define mod 1000000007
#define L_MAX 1e18
using ll = long long;
using ld = long double;
using ii = pair<ll,ll>;
using iii = tuple<ll,ll,ll>;
using matrix = vector<vector<ll>>;
using arr = vector<ll>;
using vs = vector<string>;
using pv = vector<ii>;
using umap = unordered_map<ll,ll>;
#define in1(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define in3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " is " << x << endl;
void showArr(arr a){
    for(auto i : a) cout<<i<<" ";
    cout<<endl;
}
ll dx[]={-1,1,-1,1,0,0,-1,1};
ll dy[]={-1,1,0,0,-1,1,1,-1};
int main(){
    fast;
    ld r;
    cin>>r;
    cout<<fixed<<setprecision(5)<<2*3.1415926535*r<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3776
#include<stdio.h>
#include<limits.h>

#define UD -1
#define SIZE 100
int memo[SIZE][SIZE];
int r[SIZE];
int c[SIZE];

void init(){
	int i, j;
	for( i = 0; i < SIZE; i++ ){
		for( j = 0; j < SIZE; j++ ){
			memo[i][j] = UD;
		}
	}
}

//M_a??¨M_b??????????????§??????????????°????±?????????¢??°???
int get(int a, int b){
	int i;
	if( memo[a][b] != UD ){ return memo[a][b]; }
	if( a >= b ){ return 0; }
	if( a+1 == b ){ return (memo[a][b] = r[a] * c[a] * c[b]); }
	int min = INT_MAX;
	for( i = 0; a+i<b; i++ ){
		int temp = get(a, a+i) + get(a+i+1, b) + r[a] * c[a+i] * c[b];
		if( temp < min ){ min = temp; }
	}

	return (memo[a][b] = min);
}

int main(){
	int i, j, n;
	init();
	scanf("%d", &n);
	for( i = 0; i < n; i++ ){
		scanf("%d %d", &r[i], &c[i]);
	}
	printf("%d\n", get(0, n-1));
	/*
	for( i = 0; i < n; i++ ){
		printf("%6d", i+1);
	}
	printf("\n");
	for( i = 0; i < n; i++ ){
		printf("%2d:", i+1);
		for( j = 0; j < n; j++ ){
			printf("%6d", memo[i][j]);
		}
		printf("\n");
	}
	*/
	return 0;
}

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

const int N = 2e3 + 10;
typedef long long ll;
int n, l[N], l2[N];
ll ans;

bool cmp(int a, int b) { return a > b; }

int main() {
    cin >> n;
    rep(i, 1, n) {
        scanf("%d", &l[i]);
        l2[i] = -l[i];
    }
    sort(l + 1, l + n + 1, cmp);
    sort(l2 + 1, l2 + n + 1);
    // rep(i, 1, n) printf("%d ", l[i]); puts("");
    // rep(i, 1, n) printf("%d ", l2[i]); puts("");
    rep(b, 2, n - 1) {
        rep(a, 1, b - 1) {
            if (l[a] >= l[b] * 2) continue;
            int x = lower_bound(l2 + 1, l2 + n + 1, l[b] - l[a]) - l2;
            if (x > n) x = n;
            else if (x > 1) x--;
            x -= b;
            /* if ((lower_bound(l2 + 1, l2 + n + 1, -l[a]) - l2) <= x) --x;
            if ((lower_bound(l2 + 1, l2 + n + 1, -l[b]) - l2) <= x) --x;
            printf("%d %d %d\n", a, b, x);*/
            ans += x;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from fractions import gcd

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

N = ni()
A = nl()
assert len(A) == N


def solve():
    al = [None] * N
    ar = [None] * N
    al[0] = A[0]
    ar[-1] = A[-1]
    for i in range(1, N):
        al[i] = gcd(al[i - 1], A[i])
        ar[N - 1 - i] = gcd(ar[N - i], A[N - 1 - i])
    gmax = max(al[-2], ar[1])
    gmi = 0 if gmax == ar[1] else N - 1
    for i in range(1, N - 1):
        g = gcd(al[i - 1], ar[i + 1])
        if gmax < g:
            gmax = g
            gmi = i
    return gmax


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 16164
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define f(ii,n) for(ii=0;ii<n;ii++)
#define F(ii,a,n) for(ii=a;ii<n;ii++)
#define read(array,n) for(ll i=0;i<n;i++) cin>>array[i];
#define inf 1000000007;
// function to transform string to lowercase --> transform(s.begin(),s.end(),s.begin(),::tolower)
void swap(ll *xp,ll *yp){
	ll temp = *xp;
	*xp = *yp;
	*yp = temp;
}

ll power(ll i,ll j){
	ll prod=1;
	while(j>0){
		if(j&1){
			prod=prod*i;
		}
		j=j>>1;
		i=i*i;
	}
	return prod;
}

void solve(){
	ll n,i,j;
	cin>>n;
	set<string> ss;
	string s;
	for(i=0;i<n;i++){
		cin>>s;
		ss.insert(s);
	}
	cout<<ss.size()<<endl;
}
int main(){
	// freopen("filename.txt","r",stdin);
	solve();
	
	// ll t;
	// cin>>t;
	// while(t--){
	// 	solve();
	// }
}

Measured memory_bytes: 19260
from collections import deque
n , m = map(int,input().split())
route = [[] for i in range(n+1)]
for i in range(m):
    x , y , z = map(int,input().split())
    route[x].append(y)
    route[y].append(x)
    
visit = [0 for i in range(n+1)]
ans = 0
for i in range(1,n+1):
    if visit[i] == 0:
        ans += 1
        visit[i] = ans
        d = deque()
        d.append(i)
        while d:
            now = d.popleft()
            for j in route[now]:
                if visit[j] == 0:
                    visit[j] = ans
                    d.append(j)
print(max(visit))

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define all(a) a.begin(),a.end()
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;

int main(){
    int n,k;
    cin >> n >> k;
    int ans=k;
    rp(i,n-1){
        ans *= (k-1);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){

    long long N, K;
    cin >> N >> K;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];

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

    long long index;
    for(index = 1; index < N; index++) if(A[0] != A[index]) break;

    long long ans = 0;
    for(long long i = index; i < N; i += K - 1) ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
K = int(input())
M = 10**6+1

def solve():
    count = 1
    res = 0
    c = 7 % K
    while count < M:
        res = (res * 10) % K
        res = (res + c) % K
        if res == 0:
            return count
        count += 1
    return -1

if __name__ == "__main__":
    print(solve())


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

void solve(int N, vector<int> x, vector<int> y)
{
    vector<int64_t> f0(N), f1(N);
    for (int i = 0; i < N; i++)
    {
        f0.at(i) = x.at(i) - y.at(i);
        f1.at(i) = x.at(i) + y.at(i);
    }
    sort(f0.begin(), f0.end());
    sort(f1.begin(), f1.end());
    cout << max(f0.at(N - 1) - f0.at(0), f1.at(N - 1) - f1.at(0)) << endl;
}

int main()
{
    int N;
    cin >> N;
    vector<int> x(N);
    vector<int> y(N);
    for (int i = 0; i < N; i++)
    {
        cin >> x.at(i);
        cin >> y.at(i);
    }
    solve(N, move(x), move(y));
    return 0;
}


Measured memory_bytes: 8008
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,A;cin>>N;REP(i,N){cin>>A;if(A%2){cout<<"first"<<endl;return 0;}}
  cout<<"second"<<endl;
  return 0;
}

Measured memory_bytes: 3596
N, A, B = map(int, input().split())
AB = A + B
S = input()
ansA, ansB = 0, 0
for s in S:
    if s == 'a' and ansA + ansB < AB:
        ansA += 1
        print('Yes')
    elif s == 'b' and ansA + ansB < AB and ansB < B:
        ansB += 1
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4016
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if (a-b>=a+b && a-b>=a*b)
    printf("%d\n", a-b);
    else if (a+b>=a-b && a+b>=a*b)
    printf("%d\n", a+b);
    else if (a*b>=a+b && a*b>=a-b)
    printf("%d\n", a*b);
    return 0;
}



Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>

using namespace std;

struct Student {
    string name;
    string surname;
    int day;
    int month;
    int year;
    bool sort_by_date;

    Student() {}

    Student(string new_name, string new_surname, int new_day, int new_month, int new_year,
            int new_sort) {
        name = new_name;
        surname = new_surname;
        day = new_day;
        month = new_month;
        year = new_year;
        sort_by_date = new_sort;
    }
};

ostream& operator<<(ostream& cout, Student& s) {
    cout << s.name << ' ' << s.surname << ' ' << s.day << '.' << s.month << '.' << s.year;
    return cout;
}

istream& operator>>(istream& cin, Student& s) {
    cin >> s.name >> s.surname >> s.day >> s.month >> s.year;
    return cin;
}

bool comp(const Student& a, const Student& b) {
    if (a.sort_by_date) {
        return tie(a.year, a.month, a.year, a.surname, a.name) <
               tie(b.year, b.month, b.year, b.surname, b.name);
    }
    return tie(a.surname, a.name, a.year, a.month, a.year) <
           tie(b.surname, b.name, b.year, b.month, b.year);
}

int main() {
    int n;
    cin >> n;
    cout << !n;
}




Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top = 0, S[1000];

void push(int x) {
  S[++top] = x;
}

int pop(void) {
  top--;
  return S[top+1];
}

int main(void) {
  int a, b;
  top = 0;
  char s[100];
  while(scanf("%s",s) != EOF) {
    if(s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if(s[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    } else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}




Measured memory_bytes: 2092
#include <stdio.h>          // printf(), getc()
#include <ctype.h>          // isdigit()

#define MAX_N 100000
#define swap(x, y) { card_t t = x; x = y; y = t; }

typedef struct card_tbl
{
	char mark;
	int val;
	int seq;
} card_t;

card_t a[MAX_N];

int
partition(int p, int r)
{
	int j;

	int x = a[r].val;
	int i = p - 1;
	for (j = p; j < r; ++j)
	{
		if (a[j].val <= x)
		{
			i++;
			swap(a[i], a[j]);
		}
	}

	swap(a[i + 1], a[r]);
	return i + 1;
}

void
quicksort(int p, int r)
{
	if (p < r)
	{
		int q = partition(p, r);
		quicksort(p, q - 1);
		quicksort(q + 1, r);
	}
}

int
main(int argc, char** argv)
{
	int n, m;
	int i;
	int c;

	c = getc(stdin);
	n = 0;
	while (isdigit(c))
	{
		n = n * 10 + c - '0';
		c = getc(stdin);
	}

	for (i = 0; i < n; ++i)
	{
		while (c == ' ' || c == '\n')
			c = getc(stdin);

		a[i].mark = c;
		c = getc(stdin);
		while (c == ' ')
			c = getc(stdin);

		m = 0;
		while (isdigit(c))
		{
			m = m * 10 + c - '0';
			c = getc(stdin);
		}

		a[i].val = m;
		a[i].seq = i;
	}

	quicksort(0, n - 1);

	for (i = 0; i < n - 1; ++i)
	{
		if (a[i].val == a[i + 1].val && a[i].seq > a[i + 1].seq)
			break;
	}

	if (i >= n - 1)
		printf("Stable\n");
	else
		printf("Not stable\n");

	for (i = 0; i < n; ++i)
		printf("%c %d\n", a[i].mark, a[i].val);

	return 0;
}



Measured memory_bytes: 2824
#include<bits/stdc++.h>
#define FOR(i,a,b) for(register int i=a;i<=b;i++)

using namespace std;

inline int read(){
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

int main(){
	
	int A=read(); int P=read();
	cout<<(int)((A*3+P)/2); 

	return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12){
        if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)cout << "Yes";
        else cout << "No";
    }else if(x == 4 || x == 6 || x == 9 || x == 11){
        if(y == 4 || y == 6 || y == 9 || y == 11)cout << "Yes";
        else cout << "No";
    }else if(x == 2 && y == 2)cout << "Yes";
    else cout << "No";
	return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		
		if(a < b && b < c){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26244
#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;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

int main() 
{


    fast();
 

    ll n,k;
    cin>>n>>k;
    vec q(n);
    f(i,0,n)
    {
      cin>>q[i];
    }
    ll c[n]={0};
    f(i,0,n)
    {
      f(j,i+1,n)
      {
        if(q[i]>q[j])
        {
          c[i]++;
        }
      }
    }
    ll b[n]={0};
    f(i,0,n)
    {
      f(j,0,n)
      {
        if(i!=j&&q[i]>q[j])
        {
          b[i]++;
        }
      }
    }
    

    // f(i,0,n)
    // {
    //   cout<<array[i]<<edl;
    // }
    ll ans=0;
     f(i,0,n)
    {
      ans=(ans%MOD+(b[i]*(((k*(k-1))/2)%MOD))%MOD)%MOD;
    }
    f(i,0,n)
      ans=(ans%MOD+((c[i]*k)%MOD))%MOD;
    cout<<ans;

   

  

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}


Measured memory_bytes: 256
#あっとのTECH LOG
N, M, K = map(int, input().split())
F = [[] for _ in range(N)]
B = [[] for _ in range(N)]

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

for _ in range(K):
    c, d = map(int, input().split())
    c, d = c - 1, d - 1
    B[c].append(d)
    B[d].append(c)


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # すべての頂点に対して親を検索する
    def all_find(self):
        for n in range(len(self.par)):
            self.find(n)


UF = UnionFind(N)
for iam in range(N):
    for friend in F[iam]:
        UF.union(iam, friend)

ans = [UF.size[UF.find(iam)] - 1 for iam in range(N)]
for iam in range(N):
    ans[iam] -= len(F[iam])

for iam in range(N):
    for block in B[iam]:
        if UF.same(iam, block):
            ans[iam] -= 1

print(*ans, sep=' ')

Measured memory_bytes: 48512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

vector<int> edge[100010];
int dp[100010][3];
void bfs(int s, int t){
	queue<pair<int,int>> que;
	que.push({s,0});
	dp[s][0]=0;
	while(que.size()){
		int from, num;
		tie(from,num) = que.front();
		que.pop();
		for(int to:edge[from]){
			if(dp[to][(num+1)%3]!=INF) continue;
			dp[to][(num+1)%3]=num+1;
			que.push({to, num+1});
		}
	}
}
int main() {
	int n,m; cin>>n>>m;
	rep(i,m){
		int u,v; cin>>u>>v;
		u--; v--;
		edge[u].push_back(v);
	}
	int s,t; cin>>s>>t;
	s--; t--;
	rep(i,100010)rep(j,3) dp[i][j]=INF;
	bfs(s, t);
	if(dp[t][0]!=INF){
		cout<<dp[t][0]/3<<endl;
	}else{
		cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main()
{
    ll n, m, q;
    cin >> n >> m >> q;
    ll l, r;
    vector<vector<ll>> a(n, vector<ll>(n, 0));
    for (ll i = 0; i < m; i++)
    {
        cin >> l >> r;
        a[l - 1][r - 1]++;
    }
    ll ruiseki[n + 1][n + 1];
    for (ll i = 0; i < n; i++)
    {
        for (ll j = 0; j < n; j++)
        {
            ruiseki[i][j + 1] = ruiseki[i][j] + a[i][j];
        }
    }
    ll x, y;
    for (ll i = 0; i < q; i++)
    {
        cin >> x >> y;
        ll sum = 0;
        for (ll i = x - 1; i < y; i++)
        {
            sum += ruiseki[i][y] - ruiseki[i][x - 1];
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld\n",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define mod (int)(1e9 + 7) 
using namespace std;

void dfs(vector<int> g[],int i, int& c, vector<int>& vis){
	vis[i] = 1;
	c++;
	for(int ch: g[i]){
		if(vis[ch] == -1){
			dfs(g, ch, c, vis);
		}
	}
}

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> g[n+1];
	for(int i = 1; i <= m; i++){
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> group;
	vector<int> vis(n+1, -1);
	for(int i = 1; i <= n; i++){
		if(vis[i] == -1){
			int c = 0;
			dfs(g, i, c, vis);
			group.push_back(c);
		}
	}
	cout << *max_element(group.begin(), group.end());
	// int ans = 0;
	// while(1){
	// 	int f = 0;
	// 	for(int& x: group){
	// 		if(x > 0){
	// 			x--;
	// 			f = 1;
	// 		}
	// 	}
	// 	if(!f)break;
	// 	ans++;
	// }
	// cout << ans;
	
	// for(int i = 1; i <= n; i++){
	// 	for(int x: g[i]){
	// 		cout << x <<" ";
	// 	}cout << endl;
	// }
}


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

int main()
{
    int n;
    cin >> n;
    long W;
    cin >> W;
    vector<long> wt(n);
    vector<long> v(n);
    for(long i=0;i<n;i++)
        cin >> wt[i] >> v[i];
    unsigned long long  dp[n+1][W+1];
    for(long i=0;i<=n;i++)
        dp[i][0] = 0;
    for(long i=0;i<=W;i++)
        dp[0][i] = 0;
    for(long i=1;i<=n;i++)
    {
        for(long j=1;j<=W;j++)
        {
            if(wt[i-1]<=j)
            {
                dp[i][j] = max(v[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
            }
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[n][W] << "\n";

}



Measured memory_bytes: 82500
#include <iostream>
using namespace std;
int main(){
    int a,b,i;
    cin >> a;
    int x[a];
    for(i=0;i<a;i++) cin>>x[i];
    for(b=a-1;b>=0;b--){
        cout<<x[b];
        if(b!=0) cout<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3080
#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 ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll spf[1000005],c[1000005],a[1000005];
int main()
{
    ios_base::sync_with_stdio(false);
    ll n,i,j,k,x,y,t,m,g;

    cin >> n;
    for(i=1;i<=n;i++)
    {
        cin >> a[i];
        if(i==1)
            g=a[i];
        else
            g=__gcd(a[i],g);
    }

    for(i=1;i<=1e6;i++)
        spf[i]=i;
    for(i=2;i<=1e6;i++)
    {
        if(spf[i]==i)
        {
            for(j=i*i;j<=1e6;j+=i)
            {
                if(spf[j]==j)
                    spf[j]=i;
            }
        }
    }

    bool no=false;
    for(i=1;i<=n;i++)
    {
        x=a[i];
        while(1)
        {
            if(x==1)
                break;
            y=spf[x];
            while(x%y==0)
                x/=y;
            c[y]++;
            if(c[y]>1)
                no=true;
        }
    }

    if(!no)
        cout<<"pairwise coprime"<<endl;
    else
    {
        if(g==1)
            cout<<"setwise coprime"<<endl;
        else
            cout<<"not coprime"<<endl;
    }
}

Measured memory_bytes: 26972
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll dp[301][301][301];
int main() {
	int N, M;
	cin >> N >> M;
	dp[0][N - 1][1] = 1;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j <= N - 1; j++) {
			for (int k = 1; k <= N - j; k++) {
				if (j > 0) (dp[i + 1][j - 1][k] += (dp[i][j][k] * j) % MOD) %= MOD;
				(dp[i + 1][j][N - j] += (dp[i][j][k] * k) % MOD) %= MOD;
				(dp[i + 1][j][k] += (dp[i][j][k] * (N - j - k)) % MOD) %= MOD;
			}
		}
	}
	cout << dp[M][0][N] << endl;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<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); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    cout << n*(n-1)/2 << endl;

    return 0;
}


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

int main(){
	int ans;
	long long n, k;	
	std::cin>>n>>k;

	std::vector<int> aList(n);
	std::vector<int> arrCount(n, 0);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	for(int i=0; i<n; i++)
		aList[i]-=1;

	int cur= 0;

	while(arrCount[cur]==0){
		arrCount[cur]++;		
		cur= aList[cur];
	}

	int begLoop= cur;
	long long loopLen= 0;

	while(arrCount[cur]==1){
		arrCount[cur]++;
		loopLen++;		
		cur= aList[cur];		
	}

	cur= 0;
	long long befLoop= 0;
	while(cur != begLoop){
		befLoop++;
		cur= aList[cur];
	}

	if(k> befLoop){
		k= k-befLoop;
		k= k%loopLen;

		cur= begLoop;

		for(int i=0; i<k; i++)
			cur= aList[cur];
		
		ans= cur;
	}
	else{
		cur= 0;
		for(int i=0; i< k; i++)
			cur= aList[cur];
		
		ans= cur;
	}

	std::cout<<ans+1<<std::endl;

	return 0;

}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair <int, int>;
const int N = 15 + 10;
vector <pi> a[N];
bool b[N];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		int m;
		cin >> m;
		while (m--)
		{
			int u, v;
			cin >> u >> v;
			a[i].emplace_back(make_pair(u, v));
		}
	}
	int ans = 0;
	for (int i = 0; i < (1 << n); ++i)
	{
		memset(b, 0, sizeof(b));
		for (int j = 1, k = i; j <= n; ++j, k /= 2)
			b[j] = k % 2;
		bool ok = 1;
		for (int j = 1; ok && j <= n; ++j)
			if (b[j])
			{
				for (auto k : a[j])
				{
					if (b[k.first] != k.second)
					{
						ok = 0;
						break;
					}
				}
			}
		if (ok)
			ans = max(ans, accumulate(b + 1, b + 1 + n, 0));
	}
	cout << ans;
}


Measured memory_bytes: 256