akhauriyash/Code-Regression huggingface dataset:
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int R, G, B, N;
    cin >> R >> G >> B >> N;

    ll ans = 0;
    FOR(r, 0, N)
    FOR(g, 0, N)
    {
        ll sum = R * r + G * g;
        ll diff = N - sum;
        if (diff >= 0 && diff % B == 0)
            ans++;
    }

    cout << ans << endl;

    return 0;
}


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

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

using ll = long long;

using namespace std;

template<typename T>
void dump(T *arr, int h, int w){
	rep(i,h){
		rep(j,w) cout << arr[i][j] << "\t";
		cout << "\n";
	}
}

template<typename T>
void dump(T *arr, int a){
	rep(i,a) cout << arr[i] << "\t";
	cout << "\n";
}

const int INF = 1e5;

int h[INF];
int maxs[INF], mins[INF];

int main(){
	string s;
	cin >> s;

	int len = s.size();
	int pl=1, pr=1;
	int ps[len] = {};
	repi(i,2,len){
		if(s[i-1] == s[i] && s[i] == 'L'){
			ps[i] = pl;
			pl++;
		}else pl=1;
		if(s[len-i] == s[len-i-1] && s[len-i] == 'R'){
			ps[len-i-1] = pr;
			pr++;
		}else pr=1;
	}
	int times = 1e5;
	int ans[len] = {};
	rep(i,len){
		if(s[i] == 'L'){
			ans[i - ps[i] - (times-ps[i])%2]++;
		}else{
			ans[i + ps[i] + (times-ps[i])%2]++;
		}
	}
	rep(i,len){
		cout << ans[i] << " ";
	}
	cout << "\n";

	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<stdlib.h>
void fun(char *);
void fun(char *s)
{
    int a[26]={0};
    int i;
    while(*s)
    {
        a[*s-'a']++;
        s++;
    }
    for(i=0;i<26;i++)
    {
        if(a[i]==0)
        {
            printf("%c\n",'a'+i);
            return;
        }
    }
    printf("None\n");
}
int main()
{
    char a[100005];
    scanf("%s",a);
    fun(a);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
int main(){
  int n;
  int button[100005];
  int index=1;
  int cnt=1;
  bool flag[100005]={false};
  bool ans=false;
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&button[i]);
  }
  while(flag[index]==false&&ans==false){
    if(button[index]==2){
      ans=true;
    }else{
      flag[index]=true;
      index=button[index];
      cnt++;
    }
  }
  if(ans){
    printf("%d\n",cnt);
  }else{
    printf("-1\n");
  }
  return(0);
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define inf 10000000000000007
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
#define ll long long
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

string s;

signed main() {
	cin >> s;
	if (s[0] == s[s.size() - 1]) {
		if ((s.size() - 3) % 2)cout << "First" << endl;
		else cout << "Second" << endl;
	}
	else {
		if ((s.size() - 2) % 2)cout << "First" << endl;
		else cout << "Second" << endl;
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int n,k;
  cin>>n>>k;
  int l[n];
  rep(i,n) cin>>l[i];
  sort(l, l + n, greater<int>());
  int ans = 0;
  rep(i, k) ans+=l[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    n,m=map(int,input().split())
    s = []
    for i in range(m):
        ss = list(map(int,input().split()))
        s.append(ss)
    # for i in range(m-1):
    #     tmp = s[i][0]
    #     for j in range(i+1,m):
    #         if tmp == s[j][0]:
    #             print(-1)
    #             return
    # print(s)
    if n == 1:
        low = 0
        up = 10
    elif n ==2:
        low = 10
        up = 100
    elif n ==3:
        low =100
        up = 1000
    f = 0

    # print(str(up)[0])
    for i in range(low,up):
        str_i = str(i)
        f = 0
        for j,stmp in enumerate(s):
            if stmp[0]-1 <= len(str_i):
                if int(str_i[stmp[0]-1]) == stmp[1]:
                    continue
                else:
                    f =1
                    break
            else:
                f = 1
                break
        if f == 0:
            print(i)
            return
    print(-1)


if __name__=='__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    string S;
    cin >> S;

    int cnt=0;
    int len=S.size();
    for(int i=0; i<len; i++){
        if(S[i]=='o'){
            cnt++;
        }
    }
    if(cnt+(15-len)>=8){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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

int main() {
  int n,a,b;
  cin >> n;
  a = n/100;b = n%100;
  if(a == 0 || b == 0){
    if(a == 0 &&(b >= 1 && b <= 12)){
      cout << "YYMM" << endl;
    }
    else if(b == 0 &&(a >= 1 && a <= 12)){
      cout << "MMYY" << endl;
    }
    else{
      cout << "NA" << endl;
    }
  }
  else if((a >= 1 && a <= 12) && (b > 12)){
    cout << "MMYY" << endl;
  }
  else if((a > 12) && (b >= 1 && b <= 12)){
    cout << "YYMM" << endl;
  }
  else if(a >12 && b > 12){
    cout << "NA" << endl;
  }
  else{
    cout << "AMBIGUOUS";
  }
}


Measured memory_bytes: 384
a = input()
b = a.split()
x = int(b[0])
y = int(b[1])
z = int(b[2])

if(x+y == z):
  print("Yes")
elif(x+z == y):
  print("Yes")
elif(y+z == x):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9104
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   
   
   int x,y;
   
   cin>>x>>y;
   
   string ans = "No";
   
   for(int a=0;a<=x;a++)
   {
       int b = x - a;
       
       if((2*a + 4*b)==y)
       {
           ans="Yes";
           break;
       }
   }
   
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 3652
import fractions
n,x = map(int, input().split())
ls = list(map(int, input().split()))
a = []
for i in ls:
    a.append(abs(i - x))
ans = a[0]
for i in range(n-1):
    ans = fractions.gcd(ans, a[i+1])
print(ans)

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

int main() {
  int a;
  cin >> a;
  int b[a];
  int c[a+1];
  int d = 0;
  for(int i = 0;i < a;i++){
    cin >> b[i];
  }
  for(int i = 0;i < a+1;i++){
    if(i == 0){
      c[i] = b[i];
    }else if(i == a){
      c[i] = 0-b[i-1];
    }else{
      c[i] = b[i] - b[i-1];
    }
    
    if(c[i] > 0){
      d += c[i];
    }

  }
  cout << d << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,Q;
  cin >> N >> Q;

  dsu d(N);
  rep(_,Q){
    int t,u,v;
    cin >> t >> u >> v;
    if(t==0){
      d.merge(u,v);
    }
    else if(t==1){
      if(d.same(u,v)) cout << 1 << endl;
      else  cout << 0 << endl;
    }
  }

  return 0;
}

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

class UNKO
{
    static void Main()
    {
        string member;

        List<double> hensas = new List<double>();

        while((member = Console.ReadLine())!="0")
        {
            int number = int.Parse(member);
            string[] Data = Console.ReadLine().Split(' ');

            double[] scores = new double[number];

            for (int i=0;i<Data.GetLength(0);i++)
            {
                scores[i] = int.Parse(Data[i]);
            }

            double SUM = Enumerable.Sum(scores);

            double ave = SUM / scores.GetLength(0);

            double[] scomave2 = new double[scores.GetLength(0)];

            for (int i = 0; i < scores.GetLength(0);i++)
            {
                scomave2[i] = (scores[i] - ave) * (scores[i] - ave);
            }

            double bunsan = Enumerable.Sum(scomave2)/scores.GetLength(0);

            double hensa = Math.Sqrt(bunsan);

            hensas.Add(hensa);
            
        }


        for (int i=0;i<hensas.Count;i++)
        {
            Console.WriteLine(hensas[i]);
        }


    }
}

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

int main(){
  string numbers;
  cin >> numbers;

  int sum = 0;

  for(int i = 0; i < 3; i++){
    if(numbers.at(i) == '1'){
      sum++;
    }
  }

  cout << sum << endl; 
}


Measured memory_bytes: 3560
#include<stdio.h>
#include<math.h>
int main()
{
	int N, K, X, Y;
	scanf("%d %d %d %d", &N, &K, &X, &Y);
	if(N <= K) printf("%d\n", X*N);
	else if(N > K) printf("%d\n",K*X+Y*(N-K));
	return 0;
	}

Measured memory_bytes: 128
import copy
s_l = list(input())
s_r = copy.copy(s_l)
s_r.reverse()
left = 0
right = 0

if len(s_l) == 1:
    print(0)
elif len(s_l) == 2:
    if s_l[0] == s_l[1]:
        print(0)
    else:
        print(1)
else:
    for i in range(len(s_l)-1):
        if s_l[i] == "0":
            if s_l[i+1] == "0":
                s_l[i+1] = "1"
                left += 1
        else:
            if s_l[i+1] == "1":
                s_l[i+1] = "0"
                left += 1
        if s_r[i] == "0":
            if s_r[i+1] == "0":
                s_r[i+1] = "1"
                right += 1
        else:
            if s_r[i+1] == "1":
                s_r[i+1] = "0"
                right += 1
    print(min(left,right))

Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
#define int long long 

int nsize;
int arr[10007][101];
int dp[100007][101];
int f(int w, int index){
    if(w<0) return INT_MIN;
    if(index==nsize) return 0;
    int &ans = dp[w][index];
    if(ans!=-1) return ans;
    
    ans = 0;
    ans = max(arr[index][1]+f(w-arr[index][0], index+1), f(w, index+1));
    return ans;
}

int32_t main(){
    memset(dp,-1,sizeof(dp));
    cin>>nsize;
    
    int w;
    cin>>w;
    for(int i=0;i<nsize;i++){
        cin>>arr[i][0];
        cin>>arr[i][1];
    }
    cout<<f(w,0);
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int ans;
int main(void){
    string s; cin>>s;
    for(int i=0;i<s.size();i++){
        for(int j=i;j<s.size();j++){
            bool x=true;
            for(int k=i;k<=j;k++){
                if(s[k]=='A'||s[k]=='T'||s[k]=='G'||s[k]=='C'){
                    
                }else{
                    x=false;
                }
            }
            if(x){
                ans=max(ans,j-i+1);
            }
        }
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 3592
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#define STR 100
int main(){
    int k,a,b;
    scanf("%d %d %d",&k,&a,&b);
    for(int i=a;i<b+1;i++){
        if(i%k==0){
            printf("OK");
            return 0;
        }
    }
    printf("NG");
    return 0;
}

Measured memory_bytes: 1692
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long;

const int limit = 50;

int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
	visited[v] = true;
	for (int v2 = 0; v2 < n; v2++) {
		if (graph[v][v2] == false) continue;//繋がってない
		if (visited[v2] == true) continue;//もう見た
		dfs(v2);
	}
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;//整数だから一つずらす
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;//隣接行列を管理
	}
	int ans = 0;
	for (int i = 0; i < m; ++i) {
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;//今見ている頂点の隣接を解除
		for (int j = 0; j < n; ++j) visited[j] = false;//初期化
		dfs(0);
		bool bridge = false;
		for (int j = 0; j < n; ++j) if (visited[j] == false) bridge = true;//橋があるかを判定
		if (bridge) ans += 1;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;//隣接をつなげる
	}
	cout << ans << endl;
}

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

int main() {
  ll a;
  double b;
  cin >> a >> b;
  ll c = (ll)llround(b* 100.0);
  cout << a * c /100 << endl;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m, C; cin >> n >> m >> C;
    vi B(m); for(auto& e : B) cin >> e;

    int res = 0;
    rep(i, n){
        int sum = C;
        rep(j, m){
            int A; cin >> A;
            sum += B[j] * A;
        }
        if(sum > 0){
            res++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;

    int res = 0;
    rep(n, 1, N+1){
        if(n % 2 == 0) continue;

        int cnt = 0;
        rep(i, 1, n+1){
            if(n % i == 0){
                cnt++;
            }
        }
        if(cnt == 8){
            res++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int H, W;

void print_frame(){
	for( int i = 1 ; i <= H ; i++ ){
		for( int j = 1 ; j <= W ; j++ ){
			if( (i + j) % 2 == 0 ) printf("#");
			else printf(".");
		}
		printf("\n");
	}
	printf("\n");
}

int main(void){
	while(1){
		scanf("%d %d", &H, &W);
		if( H == 0 && W == 0) break;

		print_frame();
	}

	return 0;
}

Measured memory_bytes: 2684
S = input()

i = 1
buf = S[0]
ans = 1

while i <= len(S) - 1:
    if buf == S[i]:
        # 2文字ずらすと，何をとってもOK (Siは2文字，Si+1は1文字なので)
        i = i + 2
        if i <= len(S): # ズラした分，末尾じゃなければ+1
            ans += 1
        buf = ""
    else:
        # 違う文字ならそのまま入れ替えればOK
        ans += 1
        buf = S[i]
        i = i + 1

print(ans)

Measured memory_bytes: 41180
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <iomanip>
using namespace std;
int main(){
	int n;
	cin>>n;
	set<string> t;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		t.insert(s);
	}
	cout<<t.size()<<endl;
	return 0;
}


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

int a[100],n;

int main()
{
	for(int i=1;i<=9;++i)
		for(int j=1;j<=9;++j)
			a[i*j]=1;
	scanf("%d",&n);
	if(a[n]) puts("Yes");
	else puts("No");
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    Int y, x;
} p_t;

Int gcd(Int x, Int y) {
    Int n = max(x, y);
    Int m = min(x, y);
    return m == 0 ? n : gcd(m, n % m);
}

int main() {
    Int n, m;
    cin >> n >> m;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    Int x = 1;
    for (Int i = 0; i < n; i++) {
        Int p = a[i] / 2;
        Int q = gcd(a[i] / 2, x);
        x *= p / q;
        if (x > m) {
            dump(0);
            return 0;
        }
    }
    if (x > m) {
        dump(0);
        return 0;
    }
    for (Int i = 0; i < n; i++) {
        if ((2 * x / a[i]) % 2 == 0) {
            dump(0);
            return 0;
        }
    }
    Int c = m / x;
    dump((c + 1) / 2);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef vector<int> vi;
const int MAX=1e5+5;

struct vertex{ int ind, x, y;};
bool cmp_x(const vertex &a, const vertex &b){
	return a.x<b.x;
}
bool cmp_y(const vertex &a, const vertex &b){
	return a.y<b.y;
}
vector<vertex> vx;

struct edge{int u, v, cost;};
vector<edge> eg;
bool cmp_cost(const edge &a, const edge &b){
	return a.cost<b.cost;
}

int par[MAX];
int rk[MAX];
//初期化
void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		rk[i]=0;
	}
}
//根を求める
int find(int x){
	if(par[x]==x){
		return x;
	}
	else{
		return par[x]=find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	
	if(rk[x]<rk[y]){
		par[x]=y;
	}
	else{
		par[y]=x;
		if(rk[x]==rk[y])rk[x]++;
	}
}
//xとyが同じ集合に属するか判定
bool same(int x,int y){
	return find(x)==find(y);
}

int main(){
	int N;
	cin>>N;
	rep(i,N){
		int x,y;
		cin>>x>>y;
      	vertex v={i,x,y};
		vx.push_back(v);
	}
	//xでソートして辺を追加
	sort(vx.begin(),vx.end(),cmp_x);
	rep(i,N-1){
		edge e={vx[i].ind, vx[i+1].ind, abs(vx[i].x-vx[i+1].x)};
		eg.push_back(e);
	}
	//yでソートして辺を追加
	sort(vx.begin(),vx.end(),cmp_y);
	rep(i,N-1){
		edge e={vx[i].ind, vx[i+1].ind, abs(vx[i].y-vx[i+1].y)};
		eg.push_back(e);
	}
	sort(eg.begin(),eg.end(),cmp_cost);
	lli ans=0;
	init(N);
	rep(i,2*N-2){
		edge e=eg[i];
		if(!same(e.u,e.v)){
			unite(e.u,e.v);
			ans=ans+(lli)e.cost;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 6132
#include <map>
#include <cstdio>

using namespace std;
const int Max_N(505);

int N, Ans[Max_N * Max_N];
map<int, int> X, S;

int main()
{
	scanf("%d", &N);
	for (int i = 1, x;i <= N;++i)
	{
		scanf("%d", &x);
		if (X.count(x))
		{
			puts("No");
			return 0;
		}
		X[x] = i;
	}
	for (map<int, int>::iterator it = X.begin();it != X.end();++it)
	{
		int x, i, cnt = 1;
		Ans[x = it -> first] = i = it -> second;
		for (int j = 1;j < x && cnt < i;++j)
			if (!Ans[j])
				Ans[j] = i, ++cnt;
		if (cnt < i)
		{
			puts("No");
			return 0;
		}
	}
	for (int i = 1;i <= N * N;++i)
	{
		if (!Ans[i])
		{
			if (S.empty())
			{
				puts("No");
				return 0;
			}
			Ans[i] = S.begin() -> first;
			if ((--S[S.begin() -> first]) == 0)
				S.erase(S.begin() -> first);
		}
		if (X.count(i) && X[i] < N)
			S[X[i]] = N - X[i];
	}
	puts("Yes");
	for (int i = 1;i <= N * N;++i)
		printf("%d ", Ans[i]);
	return 0;
}

Measured memory_bytes: 2176
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, M, R;
    scan(N, M, R);
    auto r = aryread();
    auto G = new long[][](N, N);
    foreach (ref row; G)
        row[] = long.max / 2;
    foreach (i; 0 .. N)
        G[i][i] = 0;
    foreach (i; 0 .. M)
    {
        long A, B, C;
        scan(A, B, C);
        A--, B--;
        G[A][B] = G[B][A] = C;
    }
    foreach (_; 0 .. 3)
        foreach (i; 0 .. N)
            foreach (j; 0 .. N)
                foreach (k; 0 .. N)
                    if (G[i][k] + G[k][j] < G[i][j])
                    {
                        G[i][j] = G[i][k] + G[k][j];
                    }
    r[] -= 1;
    r.sort();
    long ans = long.max;
    do
    {
        long d;
        foreach (i; 0 .. R - 1)
            d += G[r[i]][r[i + 1]];
        ans = ans.min(d);
    }
    while (nextPermutation(r));
    writeln(ans);
}


Measured memory_bytes: 1276
#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;
using ll = long long;
using Graph = vector<vector<int>>;
const int INF = 1001001001;
const int MOD = 1000000007;


int main(){
    int n;
    cin >> n;
    vector<double> p(n);
    rep(i, n) cin >> p[i];

    vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0));
    dp[0][0] = 1.0;

    for (int i=0;i<n;++i) {
        for (int j=0;j<=i;++j) {
            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j    ] += dp[i][j] * (1.0 - p[i]);
        }
    }


    double ans = 0.0;
    for (int i=(n+1)/2;i<=n;++i) ans += dp[n][i];
    cout << fixed << setprecision(10) << ans << endl;
}

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

int main(void) {
    int n;
    int W;
    long long w, v;
    long long dp[2][100000];
    int i, j;

    cin >> n >> W;
    for(i = 0; i < n; i++) {
        cin >> w >> v;
        for(j = 0; j <= W; j++) {
            if(j >= w) dp[(i+1)%2][j] = max(dp[(i)%2][j-w] + v, dp[(i)%2][j]);
            else dp[(i+1)%2][j] = dp[i%2][j];
        }
    }

    cout << dp[(n)%2][W] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <cstdio>
int cnt(int a){
    int res = 0;
    while(a > 0){
        res +=  a % 10;
        a /= 10;
    }
    return res;
}
#define min(x,y) x < y ? x : y
int main(){
    int a,b,n;
    std::cin >> n;
    int ans = 1000000;

    for(int i = 1;i <= n / 2 + 1; i++){
        ans = min(ans,cnt(i) + cnt(n - i));
    }
    std::cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int n, q, y[51], res;
  char name[51][32];
  scanf("%d%d", &n, &q);
  rep(i, n) scanf("%d%s", y+i, name[i]);
  y[n] = 51;
  rep(i, n+1) if(y[i] > q){res = i-1; break;}

  puts(res < 0?"kogakubu10gokan":name[res]);
  return 0;
}

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

#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    int t, p, r;
    while (cin >> t >> p >> r, t) {
        vector<vector<int>> result(t, vector<int>(3+p,0));
        loop (t, i) result[i][0] = i+1;
        loop (r, i) {
            int tid, pid, time;
            string msg;
            cin >> tid >> pid >> time >> msg;
            if (msg == "CORRECT") {
                if (result[tid-1][pid+2] != -1) {
                    result[tid-1][1]++;
                    result[tid-1][2] += result[tid-1][pid+2]*1200 + time;
                    result[tid-1][pid+2] = -1;
                }
            } else {
                if (result[tid-1][pid+2] != -1)
                    result[tid-1][pid+2]++;
            }
        }
        sort(all(result),
                [](vector<int> a, vector<int> b) {
                    if (a[1] != b[1]) return a[1] > b[1];
                    if (a[2] != b[2]) return a[2] < b[2];
                    return a[0] < b[0];
                });
        for (auto t : result)
            cout << t[0] << ' ' << t[1] << ' ' << t[2] << endl;
    }
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  int ans;
  if (N <= K) {
    ans = X * N;
  } else {
    ans = X * K + Y * (N - K);
  }

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

Measured memory_bytes: 256
fun main() {
    val mod = 1000000007
    val (N, K) = readLine()!!.split(" ").map(String::toInt)
    var sum = 0L

    for (i in K..N + 1) {
        val j = i.toLong()
        val min = j * (j - 1) / 2
        val max = (N * 2 - j + 1) * j / 2
        sum += (max - min + 1)
        sum %= mod
    }

    println(sum)
}



Measured memory_bytes: 36324
#include<stdio.h>
#include<stdlib.h>

int partiton(int*,int,int);
void swap(int*,int*);

int main (){
  int n,*Data,i,num;

  scanf("%d",&n);
  
  Data=(int *)malloc(n*sizeof(int));

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

  num=partiton(Data,n,0);

for(i=0;i<n;i++){
  if(i==num) printf("[");
    printf("%d",Data[i]);
    if(i==num) printf("]");
    if(i!=n-1) printf(" ");
  }
printf("\n");
}

int partiton(int *Data,int n,int p){
  int mid,i,j;
  mid=Data[n-1];
  i=p-1;

  for(j=p;j<n-1;j++){
    if(Data[j]<=mid){
      i=i+1;
      swap(&Data[i],&Data[j]);
    }
  }
    swap(&Data[i+1],&Data[n-1]);
   return i+1;
}

void swap(int *x,int *y){
  int chage;
  chage=*x;
  *x=*y;
  *y=chage;
}


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

class Program
{
    static void Main(string[] args)
    {
        var a = new HashSet<int>();
        var dp = new long[1000010];
        var mod = 1000000007;

        var input = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
        int N = input[0], M = input[1];

        for (var i = 0; i < M; i++) a.Add(int.Parse(Console.ReadLine()));
        for (var i = 0; i < 1000010; i++) dp[i] = 0;

        dp[0] = 1;

        for (var i = 1; i <= N; i++)
        {
            if (a.Contains(i)) continue;
            if (i > 1 && !a.Contains(i - 2)) dp[i] += dp[i - 2];
            if (!a.Contains(i - 1)) dp[i] += dp[i - 1];

            dp[i] %= mod;
        }
        
        Console.WriteLine(dp[N]);
    }
}


Measured memory_bytes: 42932
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll N,M;
    cin >> N >> M;
    ll out = N*M - 2*(N+M-2);
    if(out<0) out *= -1;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)

t = []
for a in s:
    if a != "x":
        t.append(a)
t = "".join(t)
m = len(t)

sw = 1
for i in range(m//2):
    if t[i] == t[-1-i]:
        pass
    else:
        sw = 0
        
if sw == 0:
    ans = -1
else:
    ans = 0
    i,j = 0,0
    while i+j<n:
        if s[i] == s[-1-j]:
            i += 1
            j += 1
        elif s[i] == "x":
            i += 1
            ans += 1
        elif s[-1-j] == "x":
            j += 1
            ans += 1
            
        else:
            ans = -float("Inf")
            
print(ans)

Measured memory_bytes: 9972
#include <iostream>
#include <vector>
#include <string>
 
 
using namespace std;
 
int n, q, A[25];
 
bool check(int i, int m) {
    if (m == 0) return true;
    if (i >= n) return false;
    bool res = check(i + 1, m) || check(i + 1, m - A[i]);
    return res;
}
 
int main()
{
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
 
    cin >> q;
    for(int i=0;i<q;i++) {
        int m;
        cin >> m;
        if (check(0, m)) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
 
    return 0;
}

Measured memory_bytes: 3096
n,y=map(int,input().split())
y //=1000
for i in range(n+1):
    for j in range(n-i+1):
        if n -(i+j) < 0:
            break
        if 9*i+4*j+n == y:
            print(i,j,n-(i+j))
            exit()
print('-1','-1','-1')

Measured memory_bytes: 9096
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define SZ(x) ((int)(x).size())
#define TC(tc) while (tc--)
#define VI vector<int>
#define PII pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int m, n; cin >> m >> n;
	if (m == n) cout << "Yes";
	else cout << "No";
	return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
//#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl << flush
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "") << flush;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

void init_io() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
}

const ll MOD = 1e9 + 7;

int main() {
    init_io();
    ll N;
    cin >> N;
    V<ll> A(N + 1, 0);
    for(ll i = 1; i <= N; i++) cin >> A[i];
    ll cnt = 0;
    ll space = 0, frog = 0;
    ll ans = 1;
    for(ll i = 1; i <= N; i++) {
        frog++;
        space += A[i] - A[i - 1] - 1;
        DEBUG(frog);
        DEBUG(space);
        if(i < N && frog == space + 2) {
            cnt++;
            (ans *= frog) %= MOD;
            frog--;
            space++;
        }
    }
    DEBUG(cnt);
    for(ll i = 1; i <= N - cnt; i++) (ans *= i) %= MOD;
    cout << ans << endl;
#ifdef DEBUG_MODE
    {
        ll po = 3;
        for(ll i = 1; i <= 11; i++) (po *= i) %= MOD;
        cout << po << endl;
    }
#endif
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

int compare(const void * x1, const void * x2)   // функция сравнения элементов массива
{
	return (*(int*)x1 - *(int*)x2);              // если результат вычитания равен 0, то числа равны, < 0: x1 < x2; > 0: x1 > x2
}

int main() {
	int n;
	cin >> n;
	vector<int> D(n);
	for (int i = 0; i < n; i++)
		cin >> D.at(i);
	sort(D.begin(), D.end());
	cout << D[n / 2] - D[n / 2 - 1];
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(){
  int n,r[100],c[100];
  int i,j,l,q,k;
  int  m[100][100];
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    scanf("%d%d",&r[i],&c[i]);
  c[0]=r[1];

  for(i=1;i<=n;i++){
    m[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      for(k=i;k<j;k++){
	q=m[i][k]+m[k+1][j]+c[i-1]*c[k]*c[j];
        if(k==i)m[i][j]=q;
	else
	  if(m[i][j]>q)m[i][j]=q;
      }
    }
  }

      printf("%d\n",m[1][n]);

  return 0;
}



Measured memory_bytes: 2104
#!/usr/bin/python
# -*- Coding: utf-8 -*-

def main():
    S = raw_input()
    ans = ''
    if S == 'A':
        ans = 'T'
    elif S == 'T':
        ans = 'A'
    elif S == 'C':
        ans = 'G'
    elif S == 'G':
        ans = 'C'
    return ans
print(main())

Measured memory_bytes: 2568
N = int(input())
As = list(map(int, input().split()))
Q = int(input())
 
sumAs = 0
dictAs = [0] * 100000
for i in range(len(As)):
  sumAs += As[i]
  dictAs[As[i] - 1] += 1


for _ in range(Q):
  b, c = map(int, input().split())
  sumAs += dictAs[b - 1] * (c - b)
  dictAs[c - 1] += dictAs[b - 1]
  dictAs[b - 1] = 0
  print(sumAs)

Measured memory_bytes: 84256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,n,r;
  cin>>k>>n;
  vector<int> a(n);
  for(auto& i:a)cin>>i;
  r=k+a[0]-a[n-1];
  for(int i=0;i<n-1;++i)r=max(r,a[i+1]-a[i]);
  cout<<k-r;
}

Measured memory_bytes: 1024
using namespace std;
typedef long long ll;
#include <bits/stdc++.h>
#define endl "\n";
int board[3][3];
bool vis[3][3];
bool bingo(){
    int da = 0 , ad = 0;
    for(int i = 0; i < 3; i++){
        int garo = 0;
        for(int j = 0; j < 3; j++){
            if(vis[i][j] == 1) garo++;

            if(i == j){
                if(vis[i][j] == 1) da++;
            }
            if(i+j == 2){
                if(vis[i][j] == 1) ad++;
            }
        }
        if(garo == 3){
            return 1;
        }
    }
    for(int j = 0; j < 3; j++){
        int sero = 0;
        for(int i = 0; i < 3; i++){
            if(vis[i][j] == 1) sero++;
        }
        if(sero == 3){
            return 1;
        }
    }
    if(da == 3 or ad == 3) return 1;
    return 0;
}
int main(void){
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++) cin >> board[i][j];
    }
    memset(vis, 0, sizeof(vis));
    
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int num;
        cin >> num;
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(board[i][j] == num) vis[i][j] = 1;
            }
        }
    }
    
    if(bingo()) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

int n,m;
vector<int> a[300];

int solve(){
  /* rep(i,n){
    rep(j,a[i].size()){
      cout<<a[i][j]<<" ";
    }
    cout<<endl;
  }
  cout<<endl;*/
  if(a[0].size() == 0) return INF;
  vector<int> x(300);
  rep(i,m){
    x[i]=0;
  }
  int mx=0,num=0;
  rep(i,n){
    x[a[i][0]]++;
    if(mx<x[a[i][0]]){
      mx=x[a[i][0]];
      num=a[i][0];
    }
  }
  // cout<<mx<<" "<<num<<endl<<endl;
  rep(i,n){
    rep(j,a[i].size()){
      // cout<<i<<" "<<j<<endl;
      if(a[i][j]==num){
	a[i].erase(a[i].begin() + j);
	break;
      }
    }
    
  }
  return min(mx,solve() );
}
      

signed main(){
  cin.tie(0);	
  //ios::sync_with_stdio(false);
 
  cin>>n>>m;
  
  rep(i,n){
    rep(j,m){
      int num;
      cin>>num;
      a[i].push_back(num);
    }
  }
  cout<<solve()<<endl;

  return 0;
}


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

int main(void){
  int T, D, ta, tb, da, db; cin >> T >> D >> ta >> tb >> da >> db;
  double t, A, B;
  A = 0; B = 0;
  while(1){
    if(B + db > D) break;
    B += db;
  }
  double ans = 111;
  while(B >= 0){
    A = 0;
    while(1){
      t = (ta*A + tb*B)/(A + B);
      ans = min(ans, abs((double)T-t));
      A += (double)da;
      if(A+B > D) break;
    }
    B -= (double)db;
  }
  printf("%f\n", ans);
  return 0;
}

Measured memory_bytes: 1188
import java.math.BigInteger;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigInteger A = new BigInteger(sc.next()), B = new BigInteger(sc.next());
		sc.close();
		System.out.println(A.multiply(B));
	}
}


Measured memory_bytes: 248764
import itertools
import math
N = int(input())
town = []
for _ in range(N):
  town.append(list(map(int, input().split())))
ind = [i for i in range(N)]
dis = 0
for ind in itertools.permutations(ind):
  for j in range(N):
    if j == N-1:
      break
    dis += ((town[ind[j]][0] - town[ind[j+1]][0])**2 + (town[ind[j]][1] - town[ind[j+1]][1])**2)**0.5
print(dis/math.factorial(N))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3];
    while(cin>>a[0]>>a[1]>>a[2])
    {
        sort(a,a+3);
        int t=2*a[2]-a[1]-a[0];
        if(t%2==0)
          t=t/2;
        else
        t=(3+t)/2;
        cout<<t<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin >> n;
   n=n%10;
   switch(n)
   {
       case 0:
       case 1:
       case 6:
       case 8:
       cout << "pon";
       break;
       case 2:
       case 4: 
       case 5:
       case 7:
       case 9: 
       cout << "hon";
       break;
       case 3:
       cout << "bon";
       break;
     }
     return 0;
  }

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s, t;
	cin >> s >> t;
	
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	
	if( s < t ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


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

int main()
{
  int A,B,K ;
  cin>>A>>B>>K ;
  /*高橋君:A枚、青木君B枚*/
  for(int i=0;i<K;i++){
    if(i%2==0){
      if(A%2!=0){
        A-- ;
        B+=(A/2) ;
        A/=2 ;
      }else{
        B+=(A/2) ;
        A/=2 ;
      }
    }else{
      if(B%2!=0){
        B-- ;
        A+=(B/2) ;
        B/=2 ;
      }else{
        A+=(B/2) ;
        B/=2 ;
      }
    }
  }
  cout<<A<<" "<<B<<endl ;
  
  return 0 ;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
const int maxn=400010;
int n;
int a[maxn];
int ps[maxn],rk[maxn];
int rv[maxn];
long long ans;
int In() {
	register char c;
	for(;c=getchar(),c!='-'&&(c<'0'||c>'9'););
	register bool f=c=='-';
	register int s=f?0:c-'0';
	for(;c=getchar(),c>='0'&&c<='9';)s=s*10+c-'0';
	return f?-s:s;
}
bool cmp(const int &x,const int &y) {
	return a[x]<a[y];
}
void cmin(register long long &a,register long long b) {
	a>b?a=b:0;
}
int dmin(register int a,register int b) {
	return a<b?a:b;
}
int main() {
	ans=1ll<<60;
	n=In();
	for(register int i=1;i<=n;++i)a[i]=In(),a[i+n]=In();
	if(n==1) return puts("0"),0;
	for(register int i=1;i<=n*2;++i)ps[i]=i;
	std::sort(ps+1,ps+n*2+1,cmp);
	for(register int i=1;i<=n*2;++i)rk[ps[i]]=i;
	for(register int i=1;i<=n*2;++i)if(ps[i]<=n) rv[rv[i]=rk[ps[i]+n]]=i;
	register int lm=2;
	while(rv[lm]!=1&&lm<rv[lm])++lm;
	register int xx=a[ps[rv[n*2]]];
	for(register int i=n*2-1;i>=1;--i) {
		cmin(ans,1ll*(a[ps[n*2]]-a[ps[lm]])*(a[ps[i]]-a[ps[1]]));
		cmin(ans,1ll*(a[ps[n*2]]-a[ps[1]])*(a[ps[i]]-dmin(a[ps[lm]],xx)));
		if(rv[i]==n*2||rv[i]>i) break;
		xx>a[ps[rv[i]]]?xx=a[ps[rv[i]]]:0;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6400
a1, b1 = map(int,input().split())
a2, b2 = map(int,input().split())
a3, b3 = map(int,input().split())
a4, b4 = map(int,input().split())
a5, b5 = map(int,input().split())
a6, b6 = map(int,input().split())
a7, b7 = map(int,input().split())
def f(x,y):
    print(int(x-y))
f(a1,b1)
f(a2,b2)
f(a3,b3)
f(a4,b4)
f(a5,b5)
f(a6,b6)
f(a7,b7)


Measured memory_bytes: 5600
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
		}
		sc.close();
		Arrays.sort(A);
		// 0があるなら答えは必ず0
		if(A[0] == 0) {
			prtln(0);
			return;
		}
		long answer = 1L;
		for(int i = 0; i < N; i++) {
			if(A[i] <= (long)(1e18) / answer) {
				answer *= A[i];
			} else {
				prtln(-1);
				return;
			}
		}
		prtln(answer);
	}

	public static <T> void prtln(T t) { System.out.println(t); }
}

Measured memory_bytes: 51072