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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> h(n);
    REP(i, n)
    {
        cin >> h[i];
        // dump(h[i]);
    }
    ll res = 1;
    FOR(i, 1, n)
    {
        bool flag = true;
        // dump(h[i]);
        if (h[i - 1] > h[i])
            flag = false;
        else
        {
            // dump(flag);
            FOR(j, 0, i)
            {
                if (i == j)
                    continue;
                if (h[j] > h[i])
                {
                    // dump(i);
                    // dump(j);
                    flag = false;
                    break;
                }
            }
        }
        // dump(flag);
        if (flag)
        {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0;i<(n);++i)
const ll MOD=1e9+7;

struct BipartiteMatching{
    int n,time;
    vector<vector<int>> G;
    vector<int> match,used,dead;
    BipartiteMatching(int n):n(n),time(0),G(n),
        match(n,-1),used(n,-1),dead(n,0){}
    void add_edge(int u,int v){
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    int dfs(int v){
        used[v]=time;
        for (int u:G[v]){
            if (dead[u]) continue;
            int w=match[u];
            if (w<0||(used[w]<time&&dfs(w))){
                match[v]=u;
                match[u]=v;
                return 1;
            }
        }
        return 0;
    }
    int build(){
        int res=0;
        for (int v=0;v<n;++v){
            if (dead[v]) continue;
            if (match[v]<0){
                ++time;
                res+=dfs(v);
            }
        }
        return res;
    }
    int disable(int v){
        int u=match[v];
        if (u>=0) match[u]=-1;
        match[v]=-1; dead[v]=1;
        ++time;
        return u>=0?dfs(u)-1:0;
    }
    int enable(int v){
        dead[v]=0;
        ++time;
        return dfs(v);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X,Y,E; cin >> X >> Y >> E;
    BipartiteMatching BM(X+Y);
    rep(i,E){
        int x,y; cin >> x >> y;
        BM.add_edge(x,X+y);
    }
    cout << BM.build() << endl;
}


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

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, -1, 0, 1 , 1,  1, -1, -1 };

VI pm;
int n;

int main() {
	vector<bool> is_pm( 10000000, true );
	for ( int i = 3; i * i <= 10000000; i += 2 ) {
		if ( is_pm[ i ] ) {
			for ( int j = i * i; j < 10000000; j += i ) {
				is_pm[ j ] = false;
			}
		}
	}
	while ( ~scanf("%d", &n) && n ) {
		if ( n % 2 == 0 ) {
			n--;
		}
		for ( int i = n; i >= 13; i -= 2 ) {
			if ( is_pm[ i ] && is_pm[ i - 2 ] && is_pm[ i - 6 ] && is_pm[ i - 8 ] ) {
				printf( "%d\n", i );
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2324
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) (vec).begin(),(vec).end()
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,co,num;
string str;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>str;
	for(int i=0;i<str.size();i++) if(str[i]=='R') co++;
	for(int i=co;i<str.size();i++) if(str[i]=='R') num++;
	cout<<num<<endl;
	return 0;
}


Measured memory_bytes: 3768
import java.io.*
import java.util.*

fun solve(N: Long, A: LongArray, B: LongArray){
    val n = N.toInt()
    var ans = 0L
    var ans2 = 0L
    var rest = 0L
    var rest2 = 0L
    for ( i in 0 until n+1){
        var b = B.getOrElse(i){0} + rest
        if (A[i] > b){
            ans += b
            rest = 0
        }else{
            ans += A[i]
            if (rest >= A[i]){ rest = B.getOrElse(i){0} }
            else rest = b-A[i]
        }
    }
    for ( i in n - 1 downTo -1){
        var b = B.getOrElse(i){0} + rest2
        var a = A[i+1]
        if (a > b){
            ans2 += b
            rest2 = 0
        }else{
            ans2 += a
            if (rest2 >= a){ rest2 = B.getOrElse(i){0} }
            else rest2 = b-a
        }
    }
    println(Math.max(ans, ans2))
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val A = LongArray((N+1).toInt())
    for (i in 0 until (N+1).toInt()) {
        A[i] = sc.next().toLong()
    }
    val B = LongArray(N.toInt())
    for (i in 0 until N.toInt()) {
        B[i] = sc.next().toLong()
    }
    solve(N, A, B)
}



Measured memory_bytes: 57048
import java.util.Scanner;


public class Main {

	public static void main(String[] args) throws Exception{

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] array = new int[n];

		for(int i = 0 ; i < n ; i++ ){
			array[i] = in.nextInt();
		}

		for(int j = n-1 ; j >= 0;j--){
			if(j < 0 || j != n -1){
				System.out.print(" ");
			}
			System.out.print(array[j]);
		}
		System.out.println();
		in.close();

	}

}

Measured memory_bytes: 19656
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 998244353;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
ll n, v[10010],ct;
int main() {
	cin >> n;
	rep(i, n) {
		cin >> v[i];
		while (v[i] % 2 == 0) {
			++ct; v[i] /= 2;
		}
	}
	cout << ct << endl;
	return 0;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
A = [0] + A + [0]

tmp = 0
for i in range(N + 1):
    tmp += abs(A[i] - A[i + 1])

for i in range(N):
    ans = tmp - abs(A[i] - A[i + 1]) - abs(A[i + 1] - A[i + 2]) + abs(A[i] - A[i + 2])
    print(ans)


Measured memory_bytes: 13920
w,h,n=map(int,input().split())
lst=[]
for _ in range(n):
    x,y,a=map(int,input().split())
    if a==1 or a==2:
        lst.append([x,a])
    else:
        lst.append([y,a])
answer=0
for i in range(h):
    for j in range(w):
        ans=True
        for k in range(n):
            nuri,c=lst[k]
            if c==1:
                if j<nuri:
                    ans=False
                    break
            elif c==2:
                if j>=nuri:
                    ans=False
                    break
            elif c==3:
                if i<nuri:
                    ans=False
                    break
            else:
                if i>=nuri:
                    ans=False
                    break
        if ans==True:
            answer+=1
print(answer)

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

int main()
{
    long long N;
    long long ans = 1;
    long long mod = 1000000007;
    cin >> N;
    vector<long> num_count(N, 0);
    num_count[0] = 3;
    rep(i, N)
    {
        int A;
        cin >> A;
        ans *= num_count[A];
        ans %= mod;
        num_count[A]--;
        num_count[A + 1]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

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

  int p[n];
  int min[n];
  cin >> p[0];
  min[0] = p[0];
  for (int i = 1; i < n; i++) {
    cin >> p[i];
    if (p[i] < min[i - 1]) {
      min[i] = p[i];
    } else {
      min[i] = min[i - 1];
    }
  }

  int cnt = 1;
  for (int i = 1; i < n; i++) {
    if (p[i] < min[i - 1]) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


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

int main(){
    int n;
    cin>>n;
    map<string,int>mp;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        mp[s]++;
    }
    int mx=0;
    for(auto p: mp) mx=max(mx,p.second);
    for(auto p: mp){
        if(p.second!=mx) continue;
        cout<<p.first<<endl;
    }
    

}

Measured memory_bytes: 25216
#include <stdio.h>

int main()
{
	int N;
	static int a[2 * 100000];
	static int ans[2 * 100000];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}

	for (int i = N; i >= 1; i--) {
		int sum = 0;
		for (int t = i; t <= N; t += i) {
			sum += ans[t - 1];
			sum %= 2;
		}
		if (sum != a[i - 1]) {
			ans[i - 1] = 1;
		}
		else {
			ans[i - 1] = 0;
		}
	}

	int ansn = 0;
	for (int i = 0; i < N; i++) {
		ansn += ans[i];
	}
	printf("%d\n", ansn);
	bool first = true;
	for (int i = 0; i < N; i++) {
		if (ans[i] == 1) {
			if (first) {
				first = false;
			}
			else {
				putchar(' ');
			}
			printf("%d", i + 1);
		}
	}
	if (ansn != 0) {
		putchar('\n');
	}

	return 0;
}


Measured memory_bytes: 2432
#n=int(input())
n,a,b=map(int,input().split())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
dif=b-a-1
if dif%2==0:
    print(min(n-b,a-1)+2+(dif-1)//2)
else:
    print(dif//2+1)




Measured memory_bytes: 2940
n,x,m = map(int,input().split())
p = [0 for i in range(m)]
p[x] = 1
k = x
ans = 0
ans += k
me = [k]
mem = [k]
fin = 0
for i in range(n-1):
    k = k**2%m
    if p[k] == 0:
        p[k] = i+2
        ans += k
        mem.append(k)
        me.append(ans)
    else:
        sp = k
        ss = i+2
        fin = 1
        break
if fin == 0:
    print(ans)
else:
    for i in range(m):
        if mem[i] == sp:
            spi = i+1
            break
    if spi == 1:
        ans0 = 0
    else:
        ans0 = me[spi-2]
    uu = ans - ans0
    ans0 += ((n-spi+1)//(ss-spi))*uu
    for i in range((n-spi+1)%(ss-spi)):
        ans0 += mem[spi+i-1]
    print(ans0)

Measured memory_bytes: 73828
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>
#include<bitset>
#include<stack>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll, ll> lltpl;

int dy[8] = { 2,2,-2,-2,1,1,-1,-1 };
int dx[8] = { 1,-1,1,-1,2,-2,2,-2 };



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


const int IINF = 1e9 + 7;
const ll LINF = 1e18 + 7;
constexpr ll MOD = 1e9 + 7;



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

// vector
template <typename T>
istream& operator>>(istream & is, vector<T> & vec) { for (T& x : vec) is >> x; return is; }
// pair
template <typename T, typename U>ostream& operator<<(ostream & os, pair<T, U> & pair_var) { os << "(" << pair_var.first << ", " << pair_var.second << ")"; return os; }
// vector
template <typename T>ostream& operator<<(ostream & os, const vector<T> & vec) { os << "{";	for (int i = 0; i < vec.size(); i++) { os << vec[i] << (i + 1 == vec.size() ? "" : ", "); }os << "}"; return os; }
// map
template <typename T, typename U>ostream& operator<<(ostream & os, map<T, U> & map_var) { os << "{";	repi(itr, map_var) { os << *itr; itr++; if (itr != map_var.end()) os << ", "; itr--; }os << "}"; return os; }
// set
template <typename T>ostream& operator<<(ostream & os, set<T> & set_var) { os << "{"; repi(itr, set_var) { os << *itr; itr++; if (itr != set_var.end()) os << ", "; itr--; }os << "}"; return os; }


ll dp[100005][2];
vector<int> G[100005];

void dfs(int now, int pa = -1) {

	//dp[now][0] = dp[now][1] = 1;

	for (int to : G[now]) {

		if (to == pa)continue;
		dfs(to, now);
		dp[now][0] *= (dp[to][0] + dp[to][1]);
		dp[now][1] *= (dp[to][0]);
		dp[now][0] %= MOD;
		dp[now][1] %= MOD;
	}
}


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	
	for (int i = 0; i < 100005; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			dp[i][j] = 1;
		}

	}
	vector<int> X(N), Y(N);

	for (int i = 0; i < N - 1; i++)
	{
		cin >> X[i] >> Y[i];
		X[i]--;
		Y[i]--;
		G[X[i]].push_back(Y[i]);
		G[Y[i]].push_back(X[i]);
	}

	dfs(0);

	cout << (dp[0][0] + dp[0][1]) % MOD << endl;
}


Measured memory_bytes: 14976
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>

using namespace std;

typedef struct {
  int l, r, x;
} A;

const long long P = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<A> a(m);
  for(int i = 0; i < m; i++) cin >> a[i].l >> a[i].r >> a[i].x;
  vector<vector<vector<long long>>> dp(n + 1);
  vector<vector<pair<int, int>>> b(n + 1);
  for(int i = 0; i < m; i++) {
    b[a[i].r].push_back(make_pair(a[i].l, a[i].x));
  }
  for(int i = 0; i < n + 1; i++) {
    dp[i].resize(n + 1);
    for(int j = 0; j < n + 1; j++) dp[i][j].resize(n + 1);
  }
  long long ans = 0;
  dp[0][0][0] = 1;
  for(int i = 0; i <= n; i++) for(int j = 0; j <= n; j++) for(int k = 0; k <= n; k++) {
    int maxCol = max(max(i, j), k);
    for(int l = 0; l < b[maxCol].size(); l++) {
      int count = 0;
      if(b[maxCol][l].first <= i) count++;
      if(b[maxCol][l].first <= j) count++;
      if(b[maxCol][l].first <= k) count++;
      if(b[maxCol][l].second != count) dp[i][j][k] = 0;
    }
    if(maxCol == n) ans = (ans + dp[i][j][k]) % P;
    else {
      dp[maxCol + 1][j][k] = (dp[maxCol + 1][j][k] + dp[i][j][k]) % P;
      dp[i][maxCol + 1][k] = (dp[i][maxCol + 1][k] + dp[i][j][k]) % P;
      dp[i][j][maxCol + 1] = (dp[i][j][maxCol + 1] + dp[i][j][k]) % P;
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

    long long N;
    scanf("%lld",&N);

    long long L;
    scanf("%lld",&L);

    std::vector<std::string> S(N);
    REP(i, N)
        std::cin >> S[i];

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

    REP(i, N)
        cout << S[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <numeric>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> cnt(n, 1), possible(n);
  possible[0] = 1;
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    if (cnt[x] == 1) {
      cnt[y] += cnt[x];
      cnt[x] = 0;
      possible[y] |= possible[x];
      possible[x] = 0;
    }
    else {
      cnt[x]--;
      cnt[y]++;
      if (possible[x])
        possible[y] = 1;
    }
  }
  int ans = accumulate(possible.begin(), possible.end(), 0);
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1024
import itertools
import math 

N = int(input())
coordList = []
permList = []
distList = []
distance = 0

for i in range(N):
  x = input().split()
  coordList.append(x)

permList = list(itertools.permutations(coordList))

for perm in range(len(permList)):
  xList = []
  yList = []
  #print('Reset values!')
  for coord in range(len(permList[perm])):
    for num in range(len(permList[perm][coord])):
      if len(xList) != N and num + 1 < 2:
        xList.append(int(permList[perm][coord][num]))
        #print(xList)
      if len(yList) != N and num + 1 < 2:
        yList.append(int(permList[perm][coord][num + 1]))
        #print(yList)
      elif len(xList) and len(yList) == N: 
        for i in range(N):
          if i + 1 < N: 
            dist = math.sqrt(((xList[i] - xList[i+1]) ** 2) + ((yList[i] - yList[i+1]) ** 2))
            distList.append(dist)

for i in range(len(distList)):
  distance += distList[i]

print(distance / math.factorial(N))

Measured memory_bytes: 16928
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k,q;
    cin>>n>>k>>q;
    long long int a[q],score[n],answer[n];
    for(int i=0;i<n;i++)
    {
        score[i]=k;
        answer[i]=q;
    }
    for(int i=0;i<q;i++)
    {
        cin>>a[i];
        a[i]--;
        answer[a[i]]--;
    }
    for(int i=0;i<n;i++)
    {
        score[i]=score[i]-answer[i];
        if(score[i]>0)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
}

Measured memory_bytes: 5928
N, M = map(int, input().split())

slist = []
for i in range(M):
    swlist = list(map(int, input().split()))
    slist.append(swlist[1:])

plist = list(map(int, input().split()))

numlist = []
for i in range(2**N):
    numbin = str(bin(i+1024))
    numbin = numbin[-N:]
    numlist.append(numbin)

answer = 0
for j in numlist:
    # スイッチ状態がjのとき
    flag = True
    for i in range(M):
        # i番目のルールについて
        total = 0
        for k in slist[i]:
            total += int(j[-k])
        if(total%2 != plist[i]):
            flag = False
            break
    if(flag==True):
        answer += 1

print(answer)



Measured memory_bytes: 3064
function Main(input){  
     var input = input.split("\n");
     var inputs = input[0];
    
	if(inputs === 'A'){
    console.log('T');
    }else if(inputs === 'C'){
    console.log('G');
    }else if(inputs === 'G'){
    console.log('C');
    }else if(inputs === 'T'){
    console.log('A');
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

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

using namespace std;

void solve() {
    long long a, b, x;
    cin >> a >> b >> x;
    long long ans;
    
    if (a > 0)
    {
        ans = b/x - (a-1)/x;
    }
    else if (a == 0 && b > 0)
    {
        ans = b/x + 1;
    }
    else
    {
        ans = 1;
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}

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


int n, e, cnt;
vector<int> adj[10];
bool isTaken[10];

void dfs(int u)
{
    for (int i = 0; i < adj[u].size(); i++){
        int v = adj[u][i];
        if (isTaken[v] == 0){
            isTaken[v] = 1;
            dfs(v);
        }
    }
    int tr = 1;
    for (int i = 1; i <= n; i++){
        if (isTaken[i] == 0) {
            tr = 0;
        }
    }
    if (tr == 1) ++cnt;
    isTaken[u] = 0;
    isTaken[1] = 1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int u, v;
    cin>>n>>e;
    for (int i = 0; i < e; i++){
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    isTaken[1] = 1;
    dfs(1);

    cout<<cnt<<endl;

}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	cout<<string(S.size(),'x')<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int A, B, C;

int ans1() { // 全ての組み合わせを調べる
    return max({
        10*A + B + C, // 10*A + C + B, 
        10*B + A + C, // 10*B + C + A, 
        10*C + A + B, // 10*C + B + A, 
    });
}

int ans2() {
    return 9 * max({A, B, C}) + A + B + C;
}

int main() {

    cin >> A >> B >> C; // 入力

    //cout << ans1() <<endl;
    cout << ans2() <<endl;

    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int cnt[100010];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		cnt[A]++;
	}
	int ans = 0, even = 0;
	for (int i = 0; i < 100010; i++) {
		if (cnt[i] != 0) {
			if (cnt[i] % 2 == 1) ans++;
			else even++;
		}
	}
	ans += even - even % 2;
	cout << ans << endl;
}

Measured memory_bytes: 640
from collections import defaultdict, deque
from itertools import product

def primes(N):
    sieve = [True] * (N+1)
    sieve[:1] = [False, False]
    for i in range(N):
        if sieve[i]:
            for j in range(2*i, N+1, i):
                sieve[j] = False
    return sieve

cave = defaultdict(int)
cave[(0, 0)] = 1
sieve = primes(10**6)
D = [[0, 1], [-1, 0], [0, -1], [1, 0]]
where = [[10**7, 10**7], [0, 0]]

c = 0 # cycle
d = 3 # direction
x, y = 0, 0
dx, dy = 1, 0
for i in range(2, 10**6+1):
    if abs(x+dx) > c or abs(y+dy) > c:
        if d == 3:
            x, y = x+dx, y+dy
            c += 1
            d = 0
            dx, dy = D[d]
        else:
            d += 1
            dx, dy = D[d]
            x, y = x+dx, y+dy
    else:
        x, y = x+dx, y+dy
    where.append([x, y])
    cave[(x, y)] = i

M, N = map(int, input().split())

while N:
    x, y = where[N]
    Q = deque([[x, y]])
    DP = [0] * (M+1)
    DP[N] += sieve[N]
    searched = [False] * (M+1)
    while Q:
        #print(x, y)
        x, y = Q.popleft()
        ny = y - 1
        p = DP[cave[(x, y)]]
        for nx in range(x-1, x+2):
            n = cave[(nx, ny)]
            if 1 <= n <= M:
                DP[n] = max(DP[n], p + sieve[n])
                if not searched[n]:
                    searched[n] = True
                    Q.append([nx, ny])
    A = max(DP)
    B = 0
    if A:
        for i in range(M+1):
            if sieve[i] and DP[i] == A:
                B = i
    print(A, B)

    M, N = map(int, input().split())


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, k;
  std::cin >> n >> k;
  std::vector<int64_t> h(n);
  std::cin >> h;

  std::sort(h.begin(), h.end());

  std::cout << summation(h.cbegin(),
                         std::next(h.cbegin(), std::max<int64_t>(0, n - k)))
            << std::endl;

  return 0;
}


Measured memory_bytes: 1792
a=int(input())
b=int(input())
c=int(input())
x=int(input())
count=0

for A in range(a+1):
    for B in range(b+1):
        for C in range(c+1):
            if 500*A+100*B+50*C==x:
                count+=1

print(count)

Measured memory_bytes: 3060
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int n , k;
	cin >> n >> k;
    if(n%k==0)cout << 0 << endl;
	else cout << 1 << endl;
}

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


int main() {

    int n, a[200001], b[200001];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", a+i);
        b[i] = a[i];
    }
    sort(b, b+n);
    
    for (int i = 0; i < n; i++) {
        int left = b[n/2-1];
        int right = b[n/2];
        
        if (a[i] < right)
            printf("%d\n", right);
        else
            printf("%d\n", left);
        
    }
    
    
    return 0;
}



Measured memory_bytes: 3712
#define rep(i, n) for(ll i = 0; i < n; i++)
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

vector<ll> make_tonari(ll n) {
	vector<ll> ans;
	if (n>=1) ans.push_back(n-1);
	ans.push_back(n);
	if (n<=8) ans.push_back(n+1);
	return ans;
}

int main() {
	// a[n][i]:n桁で(i+1)番目に小さいルンルン数
	// n=0は未定義
	vector<vector<ll>> a(11, vector<ll>());
	for (ll i=1;i<=9;i++) a[1].push_back(i);

	// tonari[i]:iと絶対値の差が1以下の数
	vector<vector<ll>> tonari(10,vector<ll>());
	rep(i,10) tonari[i] = make_tonari(i);

	ll k;
	cin >> k;

	if (k<=9) cout << k << endl;
	else {
		ll cnt = 9;
		ll keta = 1;
		while(1) {
			for(ll lun : a[keta]) {
				vector<ll> shimo = make_tonari(lun % 10LL);
				for(ll s : shimo) {
					ll next_lun = 10LL * lun + s;
					a[keta+1].push_back(next_lun);
					cnt++;
					//printf("%lld %lld\n", cnt, next_lun);
					if (cnt >= k) {
						cout << next_lun << endl;
						return 0;
					}
				}
			}
			keta++;
		}
	}

	return 0;
}


Measured memory_bytes: 1272
N,M=map(int,input().split())
a=[]
for i in range(N):
    a.append(list(map(int,input().split())))
mod=998244353

B=[]
for i in range(M):
    b=0
    for j in range(N):
        b+=a[j][i]*2**j
    B.append(b)

base=[]
for i in range(M):
    t=B[i]
    for b in base:
        t=min(t,t^b)
    if t!=0:
        base.append(t)

res=M-len(base)
ans=pow(2,N-1,mod)*(pow(2,M,mod)-pow(2,res,mod))
print(ans%mod)


Measured memory_bytes: 3828
#include <cstdio>
#include <cctype>
#include <utility>
#include <complex>
#include <cmath>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, int &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

using P = complex<double>;
P read() {int x = in(), y = in(); return P(x, y);}
double x(P p) {return p.real();}
double y(P p) {return p.imag();}
double dot(P a, P b) {return x(a) * x(b) + y(a) * y(b);}

int main() {
	P p1 {read()}, p2 {read()}, u = (p2 - p1);
	for (int q = in(); q; q--) {
		P p {read()}, r {dot(u, p - p1) / norm(u) * u + p1};
		printf("%.10lf %.10lf\n", x(r), y(r));
	}
}


Measured memory_bytes: 2772
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define len(x) (int)x.length()
#define ac(x, i) get<i>(x)
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll ,ll>
#define pli pair<ll, int>
#define ff first
#define ss second
#define trace(x)    cerr << #x << ": " << x << "\n"
#define trav0(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 0; i < n; i++) cerr << a[i] << ", "; cerr << "]\n"
#define trav1(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 1; i <= n; i++) cerr << a[i] << ", "; cerr << "]\n"
#define trap0(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 0; i < n; i++) cerr << "(" << a[i].ff << ", " << a[i].ss << "), "; cerr << "]\n"
#define trap1(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 1; i <= n; i++) cerr << "(" << a[i].ff << ", " << a[i].ss << "), "; cerr << "]\n"
#define travMap(a)  cerr << #a << "[" << sz(a) <<  "] = ["; for (auto i : a) cerr << "(" << i.ff << ", " << i.ss << "), "; cerr << "]\n"
#define traverse(a) cerr << #a << "[" << sz(a) <<  "] = ["; for (auto i : a) cerr << i << ", "; cerr << "]\n"
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
const int infi = 1e9;
const ll infl = 1e18;
const int MOD = 1e9 + 7;
template <typename Map> bool map_compare (Map const &lhs, Map const &rhs) { return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin());}
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 mt(seed);
int randint(int p = MOD) { return mt() % p;}
ll randlong(ll p = infl) { return mt() % p;}
#define random_permute(x) shuffle(all(x), mt)
ll log_2 (ll n) { return (n > 1ll)? 1ll + log_2(n/2): 0ll;}
inline void add(ll&a, ll b) {a += b; if (a >= MOD) a -= MOD;}
inline void sub(ll&a, ll b) {a -= b; if (a < 0) a += MOD;}

signed main() {
#ifdef HP
  freopen("input.txt", "r", stdin);
#endif
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  ll x;
  cin >> x;
  ll ans = 0;
  ll p = x / 500;
  ans += (1000) * p;
  x -= p * 500;
  p = x / 5;
  ans += 5 * p;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n;
	int m;

	scanf("%d", &n);

	int a[n], b[n];

	for(m = 0; m < n; m++){
		scanf("%d", &a[m]);
		b[n - 1 - m] = a[m];
	}

	for(m = 0; m < n; m++){
		printf("%d", b[m]);
		if(m < n - 1)
			printf(" ");
	}

	printf("\n");

	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
//#define int long long

void solve() {
	int len;
	string a,b,c;
	cin >> a;
	cin >> b;
	cin >> c;
	
	char curr = 'A';
	int a_ind = 0;
	int b_ind = 0;
	int c_ind = 0;
	
	while(true) {
		if(curr == 'A') {
			len = a.length();
			if(a_ind == len) {
				cout << "A" << endl;
				break;
			}
			
			curr = a[a_ind]-32;
			a_ind++;
			
		} else if(curr == 'B') {
			len = b.length();
			if(b_ind == len) {
				cout << "B" << endl;
				break;
			}
			curr = b[b_ind]-32;
			b_ind++;
		} else {
			len = c.length();
			if(c_ind == len) {
				cout << "C" << endl;
				break;
			}
			curr = c[c_ind]-32;
			c_ind++;
		}
	}

}
		
			
		

int32_t main() {
	IOS;
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

struct state
{
  int city;
  double cost;
  unsigned ticket;
  state(int c, double d, unsigned t) : city(c), cost(d), ticket(t) {}
  bool operator<(const state& that) const
  {
    return cost > that.cost;
  }
};

int main()
{
  int N, M, P, A, B;
  while (scanf("%d%d%d%d%d", &N, &M, &P, &A, &B) != EOF && N != 0) {
    --A;  --B;
    static int tickets[8];
    for (int i = 0; i < N; i++) {
      scanf("%d", &tickets[i]);
    }
    vector<pair<int,int> > g[30];
    for (int i = 0; i < P; i++) {
      int x, y, z;
      scanf("%d%d%d", &x, &y, &z);
      --x;  --y;
      g[x].push_back(make_pair(y, z));
      g[y].push_back(make_pair(x, z));
    }

    static double dists[30][1<<8];
    for (int i = 0; i < M; i++) {
      fill_n(dists[i], 1<<N, 1e10);
    }
    dists[A][(1<<N)-1] = 0;
    priority_queue<state> q;
    q.push(state(A, 0.0, (1<<N)-1));
    while (!q.empty()) {
      const int n = q.top().city;
      const double cost = q.top().cost;
      const unsigned ticket = q.top().ticket;
      q.pop();
      if (n == B) {
        printf("%.3f\n", cost);
        goto NEXT;
      }

      for (vector<pair<int,int> >::const_iterator it(g[n].begin()); it != g[n].end(); ++it) {
        const int to = it->first;
        const int d = it->second;
        for (int i = 0; i < N; i++) {
          if (ticket & (1<<i)) {
            const unsigned s = ticket & ~(1<<i);
            const double c = cost + static_cast<double>(d) / tickets[i];
            if (c < dists[to][s]) {
              dists[to][s] = c;
              q.push(state(to, c, s));
            }
          }
        }
      }
    }
    puts("Impossible");
NEXT:
    ;
  }
  return 0;
}

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

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

    vector<int> ans(N, -1);
    for (int i = 0; i < M; i++)
    {
        if(ans[s[i]] != -1 && ans[s[i]] != c[i]) {
            cout << "-1" << endl;
            return 0;
         }
         else ans[s[i]] = c[i];
    }

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


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

using namespace std;

int N;
string S;

int main(){
    cin >> N;
    cin >> S;
    int ans=0,x=0;
    for(int i=0;i<N;i++){
        if(S[i]=='I') x++;
        else x--;
        ans = max(ans,x);
    }
    cout << ans;
}

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

int main() {
	int N,tmp;
	cin >> N;
	string W[N];
	int flg = 0;
	for (int i = 0; i < N; i++) {
		cin >> W[i];

	}
	for (int i = 1; i < N; i++) {
		tmp = W[i-1].size() - 1;
		if (W[i - 1][tmp] != W[i][0]) {
			flg = 1;
		}
		for (int j = 0; j < i; j++) {
			if (W[j] == W[i]) {
				flg = 1;
			}
		}
	}

	if (flg == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define pf printf
#define sf scanf
#define pb push_back
#define MAX5 100005
#define MAX6 1000005
#define MAX7 10000005
#define FOR(i,n) for(i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define mod7 1000000007
typedef long long int ll;
typedef long double lld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vstr;
const double PI=2*acos(0.0);
int CASE=1,TEST=0;
struct vpair{
    double a;
    int indx;
    vpair(double a,int b){this->a=a;this->indx=b;}
};
bool cmp(vpair &a,vpair &b){
    if(a.a<b.a)return true;
    else if(a.a==b.a){
        if(a.indx>b.indx)return true;
        else return false;
    }else{
        return false;
    }
}
int arr[2][105];
int n,a,b,c,d,l,r,m=-1;
string s;
vi v;
int ans(int x){
    int temp=0;
    for(int i=0;i<=x;i++){
        temp+=arr[0][i];
    }
    for(int i=x;i<n;i++){
        temp+=arr[1][i];
    }
    return temp;
}

int main(void){
    sf("%d",&n);
    for(int i=0;i<n;i++){
        sf("%d",&arr[0][i]);
    }
    for(int i=0;i<n;i++){
        sf("%d",&arr[1][i]);
    }
    int i=0,j=0;
    for(int i=0;i<n;i++){
        m=max(m,ans(i));
    }
    pf("%d\n",m);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
vector<int> check;

void dfs(const Graph &G, int v, int c) {
    seen[v] = true;
    check[v] = c;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v, c); // 再帰的に探索
    }
}

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取(無向グラフ)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    // 全頂点が訪問済みになるまで探索
    int count = 0;
    seen.assign(N, false);
    
    check.assign(N, -1);
    
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue; // v が探索済みだったらスルー
        dfs(G, v, count); // v が未探索なら v を始点とした DFS を行う
        ++count;
    }
    sort(check.begin(), check.end());
    int ans = 1;
    int num = 1; //グループの人数チェッカー
    int num_x = check[0]; //そのグループの番号
    FOR(i,1,N) {
        if (check[i] == check[i-1]) { //同じグループなら
            num++;
            ans = max(ans,num);
        }
        else {
            num_x = check[i];
            num = 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 24256
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    N = II()
    A = LMIIS()
    A.sort()
    n = A[-1]
    r = A[0]
    for i in range(1,N-1):
        if abs(A[i]-n/2) < abs(r-n/2):
            r = A[i]

    print(n,r)


    

if __name__ == '__main__':
    main()

Measured memory_bytes: 88428
#include <iostream>

using namespace std;

int main()
{
    int num;
    int input[5001];

    while (cin >> num) {
        if (!num)
            break;

        for (int i = 0; i < num; i++)
            cin >> input[i];

        int sum_max = input[0];
        for (int i = 0; i < num; i++) {
            int tmp = 0;
            for (int j = i; j < num; j++) {
                tmp += input[j];
                
                sum_max = max(tmp, sum_max);
            }
        }
        cout << sum_max << endl;
    }

    return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>

#define ll long long
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int m;
	cin>>m;
	cout<<"ABC"<<m<<endl;
	
	
return 0;
}


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

using namespace std;

int main(){
    int n, k;
    vector<int> v;
    cin >> n >> k;
    int count = n;
    for(int i = 0;i < n;i++) v.push_back(0);
    int d;
    for(int i= 0;i < k;i++){
        cin >> d;
        for(int j = 0;j < d;j++){
            int a;
            cin >> a;
            v[a - 1]++;
            if(v[a - 1] == 1){
                count--;
            }
        }
    }
    cout << count << endl;
    return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    ll N, M, K; cin >> N >> M >> K;
    vector<ll> A(N + 1), B(M + 1), SA(N + 1), SB(M + 1);
    SA[0] = 0, SB[0] = 0;
    for(ll i = 1; i <= N; i++) {
        cin >> A[i];
        SA[i] = SA[i - 1] + A[i];
    } 
    for(ll i = 1; i <= M; i++) {
        cin >> B[i];
        SB[i] = SB[i - 1] + B[i];
    }
    ll sum = 0, ans = 0, ret = 0;
    for(int i = N; i >= 0; i--) {
        sum = SA[i];
        ret = i;
        if(sum > K) continue;
        else {
            auto itr = upper_bound(SB.begin(), SB.end(), K - sum) - SB.begin();
            ret += (ll)itr;
        }
        ans = max(ans, ret);
    } 
    cout << ans - 1 << endl;
    return 0;
}


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

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define DEBUG 0
#define LIM 1000000007

int main(){

	lli n,m,c;
	cin>>n>>m>>c;
	vector<lli> b(m);
	REP(i,m)cin>>b[i];
	map<lli,vector<lli>> a;

	lli ans=0;
	REP(i,n){
		lli sum = c;
		REP(j,m){
			lli tmp;
			cin>>tmp;
			sum += (tmp)*b[j];
		}
		if(sum > 0)ans++;
	}

	cout<<ans<<endl;

	return 0;
}

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

int main(){

	int a, b;
	cin >> a >> b;

	if(a < b) cout << "a < b" << endl;
	if(a > b) cout << "a > b" << endl;
	if(a == b) cout << "a == b" << endl;
	
	return 0;

}


Measured memory_bytes: 3076
import sys
inf=float("inf")  

icase=0
if icase==0:
    nv,ne=map(int,input().split())
    dp=[[inf]*nv for i in range(nv)] 

    for i in range(ne):
        si,ti,di=map(int,input().split())
        dp[si][ti]=di
elif icase==1:
    nv,ne=4,6
    dp=[[inf,1,5,inf], [inf,inf,2,4], [inf,inf,inf,1], [inf,inf,7,inf]]    
elif icase==2:
    nv,ne=4,6
    dp=[[inf,1,-5,inf], [inf,inf,2,4], [inf,inf,inf,1], [inf,inf,7,inf]]    
elif icase==3:
    nv,ne=4,6
    dp=[[inf,1,5,inf], [inf,inf,2,4], [inf,inf,inf,1], [inf,inf,-7,inf]]
for i in range(nv):
    dp[i][i]=0

for k in range(nv):
    for i in range(nv):
        for j in range(nv):
            dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j])


for i in range(nv):
    if dp[i][i]<0:
        print("NEGATIVE CYCLE")
        sys.exit()
for i in range(nv):
    for j in range(nv):
        if dp[i][j]==inf:
            dp[i][j]="INF"
for i in range(nv):
    for j in range(nv-1):
        print(dp[i][j],end=" ")
    print(dp[i][nv-1])



Measured memory_bytes: 6292
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main() {
	int n;
	cin>>n;
	int a = n%10;
	if(a == 2 || a == 4 || a == 5|| a == 7|| a == 9){
		cout << "hon"<<endl;
	}else if(a == 3){
		cout << "bon" << endl;
	}else{
		cout << "pon" << endl;
	}
	return 0;
}


Measured memory_bytes: 3624
import sys
from collections import defaultdict
import networkx as nx

input = sys.stdin.buffer.readline

N, M = map(int, input().split())
LR_dict = defaultdict(lambda: 10 ** 9)
for _ in range(M):
    l, r, c = map(int, input().split())
    LR_dict[(l, r)] = min(LR_dict[(l, r)], c)

G = nx.DiGraph()
G.add_nodes_from(range(1, N + 1))
G.add_weighted_edges_from([(x + 1, x, 0) for x in range(1, N)])
G.add_weighted_edges_from((l, r, c) for (l, r), c in LR_dict.items())

try:
    print(nx.dijkstra_path_length(G, 1, N))
except nx.NetworkXNoPath:
    print(-1)


Measured memory_bytes: 238276