akhauriyash/Code-Regression huggingface dataset:
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

n,k = inp
ans = 0.0
(1..n).each do|d|
  kc = 0
  c = 1
  while (d < k)
    d *= 2
    kc += 1
  end
  ans += 1.0/(2**kc)
end

p ans/n

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

string S[7];

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	for (int i = 0;i < H;i++)cin >> S[i];
	int ans = 0, cnt = 0;
	for (int i = 0;i < (1 << H);i++) {
		for (int j = 0;j < (1 << W);j++) {
			for (int h = 0;h < H;h++) {
				for (int w = 0;w < W;w++) {
					if ((i & (1 << h)) && (j & (1 << w))) {
						if (S[h][w] == '#')cnt++;
					}
				}
			}
			if (cnt == K) ans++;
			cnt = 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int a, b, c;
    cin >> a >> b >> c;
    if (min(a, b) == min(b, c))
        cout << b + min(a, c) << endl;
    else
        cout << min(a, b) + min(b, c) << endl;
}


Measured memory_bytes: 3624
import java.util.Scanner;
     
    public class Main{
    	public static void main(String[] args){
        	Scanner sc = new Scanner(System.in);
          	int w = sc.nextInt();
          	int h = sc.nextInt();
          	int x = sc.nextInt();
          	int y = sc.nextInt();
          
          	System.out.println((double)w*h/2.0 + " " + 
                               ((w==2*x && h==2*y) ? 1: 0));
        }
    }

Measured memory_bytes: 23508
import java.io.*;
import java.util.*;

public class Main {
	
	static long mod= (long) 1e9+7;
	
		
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Reader.init(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int n=Reader.nextInt(), x=Reader.nextInt(), t=Reader.nextInt();
		long ans = (n+x-1)/x;
		ans*=t;
		out.println(ans);
		
		out.flush();
		
	}

}


class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    /** call this method to initialize reader for InputStream */
    static void init() throws IOException {
        reader = new BufferedReader(
                new FileReader("C:\\Users\\samee\\Desktop\\GRE prep\\confusion.txt"));
        tokenizer = new StringTokenizer("");
    }
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
    /** get next word */
    static String nextLine() throws IOException{
        return reader.readLine();
    }
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }
    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}

Measured memory_bytes: 32808
#!/usr/bin/env python3
A = [[int(str) for str in input().strip().split()] for _ in range(3)]
N = int(input().strip())
b = [int(input().strip()) for _ in range(N)]


ans = False
for i in range(3):
    ans |= all([A[i][j] in b for j in range(3)])

for j in range(3):
    ans |= all([A[i][j] in b for i in range(3)])

ans |= all([A[i][i] in b for i in range(3)])
ans |= all([A[i][2 - i] in b for i in range(3)])

print('Yes' if ans else 'No')

Measured memory_bytes: 3064
<?php

fscanf(STDIN, "%d %d", $n, $m);
$h = explode(' ', trim(fgets(STDIN)));

$max_h = array_fill(0, $n, 0);

for ($i = 0; $i < $m; ++$i) {
    fscanf(STDIN, "%d %d", $a, $b);

    $max_h[$a - 1] = max($max_h[$a - 1], $h[$b - 1]);
    $max_h[$b - 1] = max($max_h[$b - 1], $h[$a - 1]);
}

$cnt = 0;
for ($i = 0; $i < $n; ++$i) {
    if ($max_h[$i] < $h[$i]) {
        ++$cnt;
    }
}

echo $cnt;


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

int main(){
    int n, l;
    cin >> n >> l;
    vector<string> v(n);
    for(int i=0; i<n; i++) cin >> v[i];
    sort(v.begin(), v.end());
    for(auto x: v) cout << x;
    cout << endl;
    return 0;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	vector<int> l(2 * n);
	FOR(i,0,2*n)cin >> l[i];
	sort(ALL(l));
	ll ans = 0;
	for(int i = 0; i < 2 * n; i+=2){
		ans += l[i];
	}
	ANS(ans);
	return 0;
}


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

bool compare(vector<int> &l, vector<int> &r){
    return l.at(1) < r.at(1);
}

int main() {
    int N;
    cin >> N;
    vector<vector<int>> X(N, vector<int>(2));
    for(int i = 0; i < N; i++) {
        cin >> X.at(i).at(0);
        X.at(i).at(1) = i;
    }
    sort(X.begin(), X.end());
    vector<int> index_map(N);
    for(int i=0; i<N; i++){
        index_map.at(X.at(i).at(1)) = i;
    }

    int mid = (N - 1) / 2;
    for(int i = 0; i < N; i++) {
        int position = index_map.at(i);
        int m = (mid >= position) ? mid + 1 : mid;
        cout << X.at(m).at(0) << endl;
    }

    return 0;
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
#define MAXNUM 2222
#define rep(i,s,t) for(int i=s;i<t;i++)
typedef long long ll;
vector<int> e[MAXNUM];
ll maxdp[MAXNUM],mindp[MAXNUM];int num[MAXNUM],isok[MAXNUM];
void dfs(int now,int p)
{
    mindp[now]=maxdp[now]=num[now]=0;ll maxnum=0,sum=0;int maxpos=0;
    for(int k:e[now])if(k!=p)
    {
        dfs(k,now);
        maxdp[k]+=num[k],mindp[k]+=num[k],num[now]+=num[k];
        sum+=maxdp[k];if(maxdp[k]>maxnum)maxnum=maxdp[k],maxpos=k;
    }
    maxdp[now]=sum;
    mindp[now]=max(0ll,mindp[maxpos]-(sum-maxnum));
    if(!mindp[now]&&(sum&1))mindp[now]=1;
    if(isok[now])num[now]++;
}
char tmps[MAXNUM];
const ll inf=1e18;
int main()
{
    int n,a,b;scanf("%d%s",&n,tmps+1);
    rep(i,1,n+1)isok[i]=tmps[i]=='1';
    rep(i,1,n)scanf("%d%d",&a,&b),e[a].push_back(b),e[b].push_back(a);
    ll res=inf;
    rep(i,1,n+1)
    {
        dfs(i,i);
        if(!mindp[i])res=min(res,maxdp[i]);
    }
    if(res==inf)printf("-1\n");
    else printf("%lld\n",res/2);
}

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

ll fun(ll x)
{
    if(x%2!=0 || x==0)
    return 0;

    return fun(x/2)+1;
}

int main()
{
    ll n, ans=0;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        ans+=(fun(a[i]));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(typename vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

typedef long  LL;

int N;
map<P4 , int> M;
map<P4 , int>::iterator it[4];
int C[444][4];
int p[4][4];
LL ans;

int main(){
	scanf("%d" , &N);
	repp(i,0,N){
		repp(j,0,4){
			scanf("%d" , C[i] + j);
		}
		repp(j,0,4){
			++M[M4P(C[i][j%4] , C[i][(j+1)%4] , C[i][(j+2)%4] , C[i][(j+3)%4])];
		}
	}
	repp(i,0,N){
		repp(j,0,4){
			--M[M4P(C[i][j%4] , C[i][(j+1)%4] , C[i][(j+2)%4] , C[i][(j+3)%4])];
		}
		repp(j,i+1,N){
			repp(k,0,4){
				--M[M4P(C[j][k%4] , C[j][(k+1)%4] , C[j][(k+2)%4] , C[j][(k+3)%4])];
			}
			repp(z,0,4){
				LL x = 1;
				repp(k,0,4){
					p[k][0] = C[i][k];
					p[k][1] = C[j][(4-k+z)%4];
					p[k][2] = C[j][(3-k+z)%4];
					p[k][3] = C[i][(k + 1) % 4];
					it[k] = M.find(M4P(C[i][k] , C[j][(4-k+z)%4] , C[j][(3-k+z)%4] , C[i][(k + 1) % 4]));
					if(it[k] == M.end()){
						x = 0;
					} else {
						x *= (LL)max(0 , (*it[k]).second);
						repp(s,0,4){
							--M[M4P(p[k][s] , p[k][(s+1)%4] , p[k][(s+2)%4] , p[k][(s+3)%4])];
						}
					}
				}
				ans += x;
				repp(k,0,4){
					if(it[k] != M.end()){
						repp(s,0,4){
							++M[M4P(p[k][s] , p[k][(s+1)%4] , p[k][(s+2)%4] , p[k][(s+3)%4])];
						}
					}
				}
			}
			repp(k,0,4){
				++M[M4P(C[j][k%4] , C[j][(k+1)%4] , C[j][(k+2)%4] , C[j][(k+3)%4])];
			}
		}
		repp(j,0,4){
			++M[M4P(C[i][j%4] , C[i][(j+1)%4] , C[i][(j+2)%4] , C[i][(j+3)%4])];
		}
	}
	printf("%lld\n" , ans / 3);
	return 0;
}


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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    char w;
    int ans;
    for(;;){
        ans=0;
        for(;;){
            scanf("%c",&w);
            if(w=='\n'){
                printf("%d\n",ans);
                break;
            }else{
                ans+=(static_cast<int>(w)-48);
            }
            if(ans==0){
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1120
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.List
import Data.Array.IO
import Control.Monad

type Memo = IOUArray (Int, Int) Int

main = do
  [n, m, r] <- map read . words <$> getLine :: IO [Int]
  rr <- map read . words <$> getLine :: IO [Int]
  input <- (\[x, y, z] -> zip3 x y z) . transpose <$> getInt2DListBC
  edge <- newArray ((1, 1), (n, n)) (10^9) :: IO Memo
  foldM memoize edge input
  foldM memoize edge [(i, i, 0) | i <- [1..n]]
  let index = [(k, i, j) | k <- [1..n], i <- [1..n], j <- [1..n]]
  foldM warshallFloyd edge index
  ans <- mapM (readMemo edge) $ permutations rr
  putStrLn . show . minimum $ ans

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getInt2DListBC :: IO [[Int]]
getInt2DListBC = map (map bsToInt . BC.words) . BC.lines <$> BC.getContents

memoize :: Memo -> (Int, Int, Int) -> IO Memo
memoize memo (x, y, d) = do
  writeArray memo (x, y) d
  writeArray memo (y, x) d
  return memo

warshallFloyd :: Memo -> (Int, Int, Int) -> IO Memo
warshallFloyd memo (k, i, j) = do
  x <- readArray memo (i, j)
  y <- readArray memo (i, k)
  z <- readArray memo (k, j)
  let minWeight = min x $ y + z
  writeArray memo (i, j) minWeight
  return memo

readMemo :: Memo -> [Int] -> IO Int
readMemo memo (_:[]) = return 0
readMemo memo (s:t:ts) = do
  d <- readArray memo (s, t)
  sum <- (+d) <$> readMemo memo (t:ts)
  return sum


Measured memory_bytes: 21884
N, K = map(int, input().split())
A = list(map(int, input().split()))

mod = 10**9+7

combs = [0]*N
combs[K-1]=1
for i in range(K,N):
    combs[i] = combs[i-1]*i%mod
    combs[i] *= pow(i+1-K,mod-2,mod)
    combs[i] %= mod

def solve(A):
    A.sort()
    ans = 0
    for i in range(N):
        ans += (combs[i]-combs[N-i-1])*A[i]
        ans %= mod
    return ans
print(solve(A))

Measured memory_bytes: 63344
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    string S;
    cin >> S;
    S[3] = '8';
    cout << S << endl;
}

Measured memory_bytes: 256
from functools import reduce

def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a%b)

def lcm(a, b):
  return a * b // gcd(a, b)

n = int(input())
t = [int(input()) for i in range(n)]

ans = reduce(lcm, t)
print(ans)

Measured memory_bytes: 3572
#include<stdio.h>

int main(void){
    int A,B,C = 0;
    scanf("%d %d",&A,&B);
    if(A > 12){
        printf("%d",B);
    }else if(6 <= A && A <= 12){
        printf("%d",B/2);
    }else{
        printf("%d",C);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll A, B;
  cin >> A >> B;

  ll ans  = 1;

  while(A*2 <= B){
    A*=2;
    ans++;
  }
  cout << ans << endl;
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

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

	ll val = 1;
	REP(i, N){
		ll cand1 = 2*val;
		ll cand2 = val+K;
		val = min(cand1, cand2);
	}	
	cout << val << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;


public class Main {
	public static void main(String args[]) throws InterruptedException {
		    Scanner sc = new Scanner(System.in);	
			
			int n = sc.nextInt();
			int[] tm = new int[n];
			int[] x = new int[n];
			int[] y = new int[n];
			int[] tmdst = new int[n];
			int[] dst = new int[n];
			int trfls = 0;
			for (int i = 0; i < n; i++) {
				tm[i] = sc.nextInt();
				x[i] = sc.nextInt();
				y[i] = sc.nextInt();
			}
			for (int i = 0; i < n; i++) {
				if (i == 0) {
					tmdst[i] = tm[0];
					dst[i] = Math.abs(x[i])+Math.abs(y[i]);
				}else{
					tmdst[i] = tm[i] - tm[i-1];
					dst[i] = Math.abs(x[i]-x[i-1])+Math.abs(y[i]-y[i-1]);
				}
			}
			for (int i = 0; i < n; i++) {
				if (traveling(dst[i],tmdst[i]) == true) {
					continue;
				}else{
					trfls++;
				}
			}
			if(trfls == 0){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}

		    sc.close(); }
	
	public static boolean traveling(int dst , int tmdst) {
		if (dst <= tmdst && (tmdst - dst) % 2 ==0 ) {
			return true;
		}else{
			return false;
		}
	}

}


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

constexpr int mod = 1e9 + 7;

struct mint {
  using ll = long long;
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
  friend std::ostream &operator<<(std::ostream &os, const mint &a) { return (os << a.x); }
};

constexpr int N = 2 * 100000;

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

  mint num = 0;
  for (int i = k; i <= n + 1; ++i) { num += (mint)i * ((mint)n - (mint)i + 1) + 1; }
  cout << num << endl;
}


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

using ll = long long;
using namespace std;

vector<vector<bool>> cake;
vector<vector<int>> ans;

std::vector<std::pair<int,int>> dir{{0,1},{1,0},{-1,0},{0,-1}};

void dfs(int y, int x, int si)
{
    vector<int> arr;
    arr.push_back(x);
    ans[y][x] = si;
    for(int i = x + 1; !cake[y][i]; i++){
        arr.push_back(i);
        cake[y][i] = true;
        ans[y][i] = si;
    }
    for(int i = x - 1; !cake[y][i]; i--){
        arr.push_back(i);
        cake[y][i] = true;
        ans[y][i] = si;
    }
    sort(arr.begin(), arr.end());
    bool next = true;
    
    for(int i = y + 1;next; i++){
        for(auto j : arr){if(cake[i][j] == true) next = false;}
        if(next){
            for(auto j : arr){cake[i][j] = true;ans[i][j] = si;}
        }
    }
    

    next = true;
    for(int i = y - 1;next; i--){
        for(auto j : arr){if(cake[i][j] == true) next = false;}
        if(next){
            for(auto j : arr){cake[i][j] = true;ans[i][j] = si;}
        }
    }
    
}

int main()
{
    int h,w,k;
    cin >> h >> w >> k;
    cake.resize(h + 2, vector<bool>(w + 2,true));
    ans.resize(h + 2, vector<int>(w + 2));
    vector<int> X, Y;

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            char t; cin >> t;
            cake[i][j] = (t == '#');
            if(t == '#'){
                Y.push_back(i);
                X.push_back(j);
            }
        }
    }

    for(int i = 0; i < (int)X.size(); i++) dfs(Y[i], X[i], i+1);

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++)cout << ans[i][j] << " ";
        cout << endl;
    }
}

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

class Program {
  static void Main() {
    int N = int.Parse(Console.ReadLine().Trim());
    var str = new Dictionary<string, long>();
    long count = 0;
    
    for(var i = 0; i < N; i++) {
      string s = Console.ReadLine().Trim();
      char[] c = new char[s.Length];
      c = s.ToCharArray();
      Array.Sort(c);
      s = new string(c);
      if(str.ContainsKey(s)) {
        count += str[s];
        str[s] += 1;
      } else {
        str.Add(s, 1);
      }
    }    
    Console.WriteLine(count);         
  }
}

Measured memory_bytes: 29520
#include <iostream>
using namespace std;
#define N 100001
int main(){
	int a[N]={},ct=0,n;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		while(a[i]%2==0){
			if(a[i]%2==0){
				a[i]/=2;
				ct++;
			}
		}
	}
	cout << ct << endl;
}


Measured memory_bytes: 640
n, m, l = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
B = [list(map(int, input().split())) for _ in range(m)]
C = []
for i in range(n):
    c_row = []
    for q in range(l):
        c = 0
        for j in range(m):
            c = c + A[i][j] * B[j][q]
        c_row.append(c)
    C.append(c_row)
def printmatrix(rc):
    for i in range(len(rc)):
        for j in range(len(rc[0])):
            print(rc[i][j],end = "")
            if j != len(rc[0])-1:
                print(" ",end = "")
            else:
                print("")
printmatrix(C)


Measured memory_bytes: 7144
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string s;
    cin >> s;
    set<char> kind(ALL(s));
    if (s.size() == kind.size()) cout << "yes" << endl;
    else cout << "no" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
int table[30][100];
#define INF 10000
int solve(vector<int> &cyc,vector<int>& day){
  rep(i,day.size())rep(j,cyc.size())table[j][i]=INF;
  table[0][0]=0;
  REP(i,1,day.size()){
    table[0][i]=min(table[0][i-1]+1,table[cyc.size()-1][i-1]);
    REP(j,1,cyc.size()){
      table[0][i]=min(table[0][i],table[j][i-1]+1);//take caffein
      if (day[i]>=cyc[j]){
	table[j][i]=table[j-1][i-1];
      }

    }
  }

  int ret=INF;
  rep(i,cyc.size())ret=min(ret,table[i][day.size()-1]);
  return ret;
}

main(){
  int n,m;
  while(cin>>n && n){
    vector<int> cyc,day(100,24);
    rep(i,n){
      int t;cin>>t;cyc.push_back(t);
    }
    
    cin>>m;
    rep(i,m){
      int d,time;cin>>d>>time;
      day[d-1]=min(day[d-1],time);
    }
    cout << solve(cyc,day)<<endl;
  }
  return false;
}

Measured memory_bytes: 0
a=list(input())
if int(len(a)%2)==1:
   a.pop(int((len(a)-1)/2))
s=0
for i in range (0,int(len(a)/2)):
   if a[i]==a[len(a)-i-1]:
       s=s
   else:
       s=s+1
print(s)

Measured memory_bytes: 2940
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

ll int H,W,K;
string s;
cin >> H >> W >> K;
vector<vector<string> > c(H,vector<string>(W));
vector<vector<string> > cn(H,vector<string>(W));
ll int ih=1;
ll int jw=1;
for(ll int i=0;i<H;i++){
	ih *=2;
	cin >> s;
	for(ll int j=0;j<W;j++){
		if(i == 0){
		jw *=2;
		}
		else{}
		c[i][j] = s[j]; 
		cn[i][j] = c[i][j];
	}
}
ll int counter;
ll int ans = 0;
for(ll int i=0;i<ih;i++){
	for(ll int j=0;j<jw;j++){
	counter = 0;
		for(ll int k=0;k<H;k++){
			if(i>>k&1){
				for(ll int l = 0;l<W;l++){
					c[k][l] = "!";
				}
			}
				else{}
		}
		for(ll int k=0;k<W;k++){
			if(j>>k&1){
				for(ll int l = 0;l<H;l++){
					c[l][k] = "!";
				}
			}
				else{}
		}
		
for(ll int k=0;k<H;k++){
	for(ll int l=0;l<W;l++){
		if(c[k][l] == "#"){
			counter += 1;
		}
		else{}
	}
}
if(counter == K){
	ans += 1;
}
else{}
for(ll int k=0;k<H;k++){
	for(ll int l=0;l<W;l++){
		c[k][l] = cn[k][l];
	}
}

}
}
cout << ans;









	return 0;

}



Measured memory_bytes: 3580
let readInt _ = stdin.ReadLine() |> int
let uniqList x = x |> List.groupBy id |> List.map fst

let rec toDivisor ans count n =
    if n % 2 = 0 && n / 2 < count then ans |> uniqList
    elif n % 2 = 1 && (n / 2 + 1) < count then ans |> uniqList
    elif n % count = 0 && count * count <> n then toDivisor (count :: (n / count) :: ans) (count + 1) n
    elif n % count = 0 then (count :: ans)
    else toDivisor ans (count + 1) n

let choice ok ng bool = if bool then ok else ng

()
|> readInt
|> fun x ->
    [ 1 .. 2 .. x ]
    |> List.map (toDivisor [] 1)
    |> List.filter (fun x -> x |> List.length |> (=) 8)
    |> List.length
    |> printfn "%d"


Measured memory_bytes: 30452
class Dice :
    def __init__(self, pane):
        self.pane = pane
    
    def roll_W(self):
        temp = self.pane[0]
        self.pane[0] = self.pane[2]
        self.pane[2] = self.pane[5]
        self.pane[5] = self.pane[3]
        self.pane[3] = temp

    def roll_S(self):
        temp = self.pane[0]
        self.pane[0] = self.pane[4]
        self.pane[4] = self.pane[5]
        self.pane[5] = self.pane[1]
        self.pane[1] = temp

n = int(input())
dice = []
for i in range(0, n):
    dice.append(Dice(input().split()))  

flag = False
for k in range(0, n):
    for i in range(k + 1, n):
        count = 0
        while True:
            t = dice[k].pane[0]
            f = dice[k].pane[1]
            if (dice[i].pane[0] == f or dice[i].pane[4] == f):
                dice[i].roll_S()
            if (dice[i].pane[0] == t and dice[i].pane[1] == f):
                break
            if (count >= 8):
                break
            count += 1
            dice[i].roll_W()

        for j in range(0, len(dice[k].pane)):
            if (dice[k].pane[j] != dice[i].pane[j]):
                break
            if (j == len(dice[k].pane) - 1):
                flag = True

        if (flag):
            break

if (flag):
    print('No')
else :
    print('Yes')




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

int main() {
  char c;
  cin >> c;

  if (c == 'a' || c=='i'||c=='u'||c=='e'||c=='o'){
      cout << "vowel" << endl;
  }
    else{
        cout << "consonant" << endl;
    }
  }

// が母音であるとき、vowel と、そうでないとき consonant


Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)

def divide(h, w)
  cand = [h / 3 * w, (h - h / 3 * 2) * w]
  min = cand.max - cand.min
  cand = [(h / 3.0).ceil * w, (h - (h / 3.0).ceil * 2) * w]
  min = [cand.max - cand.min, min].min

  1.upto(h - 1) do |i|
    cand = [i * w, (h - i) * (w / 2), (h - i) * (w - w / 2)]
    min = [cand.max - cand.min, min].min
  end

  min
end

puts [divide(h, w), divide(w, h)].min

Measured memory_bytes: 14280
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int x = sc.nextInt();
			int s;
			while(n!=0 || x!=0){
				s=0;
				for(int c=1;c<=n-2;++c){
					for(int d=c+1;d<=n-1;++d){
						for(int e=d+1;e<=n;++e){
							if(c+d+e==x){
								s=s+1;
							}
						}
					}
				}
				System.out.println(s);
				n = sc.nextInt();
				x = sc.nextInt();
			}
	}

}

Measured memory_bytes: 26692
num_of_observatory, num_of_road = map(int, input().split())
elevations = list(map(int, input().split()))
road_unions = []
for _ in range(num_of_road):
    road_unions.append(list(map(int, input().split())))

# つながっている展望台のリスト
to_observatorys = [[] for i in range(num_of_observatory)]

for road_union in road_unions:
    to_observatorys[road_union[0] - 1].append(elevations[road_union[1] - 1])
    to_observatorys[road_union[1] - 1].append(elevations[road_union[0] - 1])

num_of_good = 0
for i in range(num_of_observatory):
    # つながっている展望台がない または つながっている展望台よりも高い場合
    if len(to_observatorys[i]) == 0 or elevations[i] > max(to_observatorys[i]):
        num_of_good = num_of_good + 1

print(num_of_good)


Measured memory_bytes: 41340
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>
 
using namespace std;
typedef long long int ll;
 
#define C cout<<
#define E <<endl
#define CE cout<<endl
 
ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010];
bool r,ra,rb,rc[200010];
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc,vd,ve,vaa,vbb;
set<int> st;
 
 
 
template<typename MAIN> ostream & operator<<(ostream & osys,const vector<MAIN> target){ for(MAIN it:target)osys<<it<<" "; return osys; }
 
int main(){
cin>>s;
    r=true;
    a=0;
    
    for(int i=0;i<s.size();i++){
        if(s[i]=='R')a++;
        else{
                aa[i-1]+=a-a/2;
                aa[i]+=a/2;
                a=0;
        }
    }
    a=0;
    
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='L')a++;
        else{
                aa[i]+=a/2;
                aa[i+1]+=a-a/2;
                a=0;
        }
    }
    
    for(int i=0;i<s.size();i++){
        C aa[i]<<" ";
    }
    CE;
 
    
}

Measured memory_bytes: 2688
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr double pi = asin(1) * 2;
constexpr ll mod = 1000000007;


ll mpow(ll base, ll power) {
    if (power == 0) return 1;
    ll t = mpow(base, power / 2);
    return (t * t * (power % 2 ? base : 1)) % mod;
}

int main() {
    int n, m, s, t;
    map<int, set<int>> p;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        p[u].insert(v);
    }
    cin >> s >> t;
    queue<pair<pair<int, int>, int>> q;
    map<pair<int, int>, int> r;
    q.push(make_pair(make_pair(0, 0), s));
    while (!q.empty()) {
        auto v = q.front();
        q.pop();
        for (auto &e:p[v.second]) {
            int b = (v.first.second + 1) % 3;
            int c = v.first.first + (v.first.second == 2 ? 1 : 0);
            auto k = make_pair(e, b);
            if (r.find(k) == r.end()) {
                r[k] = c;
                q.push(make_pair(make_pair(c, b), e));
            }
        }
    }
    cout << (r.find(make_pair(t, 0)) == r.end() ? -1 : r[make_pair(t, 0)]) << endl;
}


Measured memory_bytes: 33024
N, M, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(Q)]

lst = [list() for _ in range(N + 1)]

for a, b, c, d in X:
    lst[b].append((a, c, d))


class Test:
    def __init__(self):
        self.max_ = 0

    def helper(self, idx, cnt, stack, tmp):
        if cnt == N + 1:
            self.max_ = max(self.max_, tmp)
            return

        for s, t, u in lst[cnt]:
            if stack[cnt - 1] - stack[s - 1] == t:
                tmp += u

        for i in range(idx, M + 1):
            stack.append(i)
            self.helper(i, cnt + 1, stack, tmp)
            stack.pop()


t = Test()
t.helper(1, 0, [], 0)

print(t.max_)


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

int main() {
	int n;
	while(scanf("%d",&n),n!=0){
		int sum=0;
		for(int i=0;i<n/4;i=i+1){
			int m;
			cin >> m;
			sum = sum + m;
		}
		cout << sum << endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3132
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=5050;
//templete
int main() {
	int K,X;
	cin>>K>>X;
	for(int i=X-K+1;i<=X+K-1;i++){
		cout<<i<<(i==X+K-1?"\n":" ");
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var q = int.Parse(Console.ReadLine());
        var t = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(s.Intersect(t).Count());
    }
}


Measured memory_bytes: 33644
#include <bits/stdc++.h>
using namespace std;
int main(){
    int i, cont=0;
    string s, t;
    cin >> s >> t;
    for(i=0; i<3; i++){
        if(s[i]==t[i]){
            cont++;
        }
    }
    cout << cont << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  vector<string> A(H+1);
  string S="";
  for(int i=0;i<=W;i++)
    S+='.';
  A[0]=S;
  for(int i=1;i<=H;i++){
    cin>>A[i];
    A[i]='.'+A[i];
  }
  vector<vector<int>> B(H+1,vector<int>(W+1));
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      int a=B[i-1][j],b=B[i][j-1];
      if(A[i][j]=='#' && A[i-1][j]=='.')
        a++;
      if(A[i][j]=='#' && A[i][j-1]=='.')
        b++;
      if(i==1)
        B[i][j]=b;
      else if(j==1)
        B[i][j]=a;
      else
        B[i][j]=min(a,b);
    }
  }
  cout<<B[H][W]<<endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

const int N = 1e5+5;
set<int> s;
int arr[N];

const int MAXN = 2e6+5;
ll factorial[MAXN], inverse[MAXN];

ll power(ll x,ll y, ll p)
{
    ll res = 1;     
    x = x % p; 
 
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
 
        y = y>>1; // y = y/2
        x = (x*x) % p;  
    }
    return res;
}

ll modInverse(ll a, ll m){
    return power(a,m-2,m);
}

void pre() {
    factorial[0] = 1LL; inverse[0] = modInverse(factorial[0], MOD);
    for (int i = 1; i < MAXN; i++) {
        factorial[i] = factorial[i - 1] * i % MOD;
        inverse[i] = modInverse(factorial[i], MOD);
    }
}

ll binomial_coefficient(ll n, ll k) {
	if(n < 0 || k > n) return 0;
    return factorial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	int n,tmp,pos1=-1, pos2=-1;
	cin>>n;
	FOR(i, 0, n+1) {
		cin>>arr[i];
		if(s.find(arr[i]) != s.end()) {
			pos2 = i;
			FOR(j, 0, i) {
				if(arr[j] == arr[i]) {
					pos1 = j;
					break;
				}
			}
		}
		s.insert(arr[i]);
	}
	// deb(pos1); deb(pos2);
	pre();
	FOR(k, 1, n+2) {
		ll ans = binomial_coefficient(n+1, k);	
		ll dups = binomial_coefficient(n + pos1 - pos2, k - 1);
		ans = (ans - dups + MOD) % MOD;
		cout<<ans<<endl;
	}
	
    return 0;
}

Measured memory_bytes: 37504
def main():
    A, B, K = map(int, input().split())
    r = set()
    for i in range(A, A + K):
        if A <= i and B >= i:
            r.add(i)

    for i in range(B, B - K, -1):
        if A <= i and B >= i:
            r.add(i)
    O = list(r)
    O.sort()
    for o in O:
        print(o)


main()


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int w, a, b;
  cin >> w >> a >> b;
  if(a<=b) {
    if(b-(a+w)>=0) cout << b-(a+w) << endl;
    else cout << 0 << endl;
  }
  else {
    if(a-(b+w)>=0)cout << a-(b+w) << endl;
    else cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(long long int i=a; i<n; i++)
#define rloop(i,a,n) for(long long int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define mod 1000000007
#define ll long long int
#define ull unsigned long long int 
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define stkll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power)
{
    ll ans=1;
    while(power>0)
    {
        if(power%2==1)
        {
            ans=(ans*B)%mod;
        }
        B=(B*B)%mod;
        power/=2;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1)
    { 
        return false; 
    }
    if(n<=3)
    { 
        return true;
    } 
    if(n%2==0 || n%3==0) 
    {
        return false; 
    }
    for(ll i=5; i*i<=n; i+=6) 
    {
        if(n%i==0 || n%(i+2)==0) 
        {
            return false; 
        }
    }
    return true; 
}
using namespace std;
int main() 
{
    FAST
    FO
    FI
    int n;
    IN n;
    vector<pair<int,int>> co(n);
    loop(i,0,n)
    {
        IN co[i].first>>co[i].second;
    }
    long double ans=0.0;
    ll fact=1;
    loop(i,0,n)
    {
        fact*=(i+1);
    }
    loop(i,0,n)
    {
        loop(j,0,n)
        {
            long double dist= sqrt(pow(co[i].first-co[j].first,2)+pow(co[i].second-co[j].second,2));
            dist*=((fact/(n+0.0)));
            ans+=dist;
        }
    }
    ans/=(fact+0.0);
    OUT fixed<<setprecision(10)<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin);i>(end);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" <<; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;


int main()
{
	// 入力
	string S;
	cin >> S;
	if (S == "A") cout << "T" << endl;
	else if (S == "T") cout << "A" << endl;
	else if (S == "C") cout << "G" << endl;
	else if (S == "G") cout << "C" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int n = in.nextInt();

        int list [] = new int [n];

        for (int i = 0; i < n; i++)
        {
            list[i] = in.nextInt();
        }
        int good = 1;
        int count = 0;
        int j = 0;
        while (good == 1)
        {
            if (list[j % n] % 2 == 0 )
            {
                list[j % n] = list[j % n]/2;
                
            }
            else
                {
                   good = 0;
                }
            j++;
            if (j%n==0)
            {
                count++;
            }

        }
        System.out.println(count);



    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


Measured memory_bytes: 20564
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a[200010],b[200010];
bool t1[200010],tn[200010];
vector<int> vc;

int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        if(a[i]==1)t1[b[i]]=true;//vc.push_back(b[i]);
    }
    
    for(int i=0;i<m;i++){
        if(b[i]==n and t1[a[i]]){
                    C "POSSIBLE" E;
                    return 0;
        }
    }
    C "IMPOSSIBLE" E;
    
    
    
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  long long n=s.size();
  vector<long long> c(26);
  for(int i=0;i<n;i++){
    c[s[i]-'a']++;
  }
  long long sum=0;
  for(int i=0;i<26;i++){
    sum+=c[i]*(c[i]-1)/2;
  }
  cout << n*(n-1)/2-sum+1 << endl;
}

Measured memory_bytes: 640
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

N = num()
used = {}
for _  in range(N):
    si = input()
    if si in used.keys():
        used[si] += 1
    else:
        used[si] = 0
l = sorted(used.items(),key=lambda x: x[1],reverse=True)
maxl = max([i[1] for i in l])
ans = []
for _,e in l:
    if e == maxl:
        ans.append(_)
    else:
        break
ans.sort()
for a in ans:
    print(a)

Measured memory_bytes: 45788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int h,w;cin>>h>>w;
  vector<vector<char>> s(h,vector<char>(w));
  rep(i,h)rep(j,w)cin>>s[i][j];
  rep(i,h)rep(j,w){
    if(s[i][j]=='#')continue;
    s[i][j]='0';
    for(int dx=-1;dx<=1;dx++){
      for(int dy=-1;dy<=1;dy++){
        int nx=i+dx,ny=j+dy;
        if(0<=nx&&nx<h&&0<=ny&&ny<w){
          if(s[nx][ny]=='#')s[i][j]++;
        }
      }
    }
  }
  rep(i,h)rep(j,w){
    cout<<s[i][j];
    if(j==w-1)cout<<endl;
  }
}

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

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

  vector<int> P(N);

  for (int i = 0; i < N; i++) {
    int p;
    cin >> p;
    P.at(i) = p;
  }

  int cnt = 0;

  for (int i = 0; i < N-2; i++) {
    if (P.at(i) > P.at(i+1) && P.at(i+1) > P.at(i+2)) {
      cnt++;
    } else if (P.at(i) < P.at(i+1) && P.at(i+1) < P.at(i+2)) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const int ma = 100010;
ll notprime[ma] = { false };
ll sim2017[ma] = { 0 };
ll pref[ma] = { 0 };
void init()
{
	notprime[0] = notprime[1] = 1LL;
	for (int i = 2; i < ma; i++)
		if (!notprime[i])
		{
			if (i > ma / i)
				continue;
			for (int j = i * i; j < ma; j += i)
				notprime[j] = 1LL;
		}
	sim2017[0] = 0LL;
	for (int i = 1; i < ma-1; i++)
	{
		if (i % 2 == 0)
			sim2017[i] = 0LL;
		else
		{
			if ((!notprime[i]) && (!notprime[(i + 1) / 2]))
				sim2017[i] = 1LL;
		}
	}
	pref[0] = sim2017[0];
	for (int i = 1; i < ma;i++)
		pref[i] = pref[i - 1] + sim2017[i];
}
int main()
{
	ofstream f("out.txt");
	f << 10000 << endl;
 
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	init();
	ll n;
	cin >> n;
	while (n--)
	{
		ll l, r;
		cin >> l >> r;
		cout << pref[r]-pref[l-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
import java.util.*;


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

		int a = sc.nextInt();
		int b = sc.nextInt();

		String kisu = "Odd";
		String gusu = "Even";

		if (a * b % 2 == 0) {
			System.out.println(gusu);
		} else {
			System.out.println(kisu);
		}

	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d){
	cout<<"Left"<<endl;
  }else if(a+b<c+d){
	cout<<"Right"<<endl;
  }else{	
    cout<<"Balanced"<<endl;
  }
}

Measured memory_bytes: 256
import java.io.File;
import java.io.FileInputStream;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		long sum = 0;
		int[] T = new int[N];
		for(int i = 0; i < N; i++){
			T[i] = sc.nextInt();
			sum += T[i];
		}
		
		int M = sc.nextInt();
		for(int i = 0; i < M; i++){
			int P = sc.nextInt();
			int X = sc.nextInt();
			System.out.println(sum-T[P-1]+X);
		}
	}
}

Measured memory_bytes: 23892