akhauriyash/Code-Regression huggingface dataset:
#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 n,q;string s;cin>>n>>q>>s;
  vector<int> vec(n+1);
  rep(i,n){
    if(s[i]=='A'&&s[i+1]=='C')vec[i+1]=vec[i]+1;
    else vec[i+1]=vec[i];
  }
  rep(i,q){
    int l,r;cin>>l>>r;
    l--;r--;
    cout<<vec[r]-vec[l]<<endl;
  }
}

Measured memory_bytes: 3816
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
        q:usize,
        c:[Usize1;n],
        mut lr:[(Usize1,Usize1);q],
    };
    let mut bt = SEG::<SUM>::new(n + 111);
    let mut ql = vec![vec![]; n + 5];
    let mut qid = vec![vec![]; q + 5];
    for (i, &(l, r)) in lr.iter().enumerate() {
        ql[r].push(l);
        qid[r].push(i as usize);
    }

    let mut lst = vec![!0; n + 1];
    let mut anss = vec![0; q + 1];
    for i in 0..n {
        if lst[c[i]] != !0 {
            bt.add(lst[c[i]], &(-1));
        }
        bt.add(i, &1);
        lst[c[i]] = i;
        for j in 0usize..qid[i].len() as usize {
            anss[qid[i][j]] = bt.query_range(ql[i][j]..=i);
        }
    }

    for i in 0..q {
        println!("{}", anss[i]);
    }
}

pub trait Monoid {
    type T: Clone;
    fn id() -> Self::T;
    fn op(a: &Self::T, b: &Self::T) -> Self::T;
}
pub struct SUM {}
impl Monoid for SUM {
    type T = i64;
    fn id() -> Self::T {
        0
    }
    fn op(a: &Self::T, b: &Self::T) -> Self::T {
        *a + *b
    }
}
/// Segment Tree
pub struct SEG<M: Monoid> {
    n: usize,
    buf: Vec<M::T>,
}
impl<M: Monoid> SEG<M> {
    pub fn new(n: usize) -> SEG<M> {
        SEG {
            n,
            buf: vec![M::id(); 2 * n],
        }
    }
    pub fn update(&mut self, k: usize, a: M::T) {
        let mut k = k + self.n;
        self.buf[k] = a;
        while k > 0 {
            k >>= 1;
            self.buf[k] = M::op(&self.buf[k << 1], &self.buf[(k << 1) | 1]);
        }
    }
    pub fn add(&mut self, k: usize, a: &M::T) {
        let mut k = k + self.n;
        self.buf[k] = M::op(&self.buf[k], a);
        while k > 0 {
            k >>= 1;
            self.buf[k] = M::op(&self.buf[k << 1], &self.buf[(k << 1) | 1]);
        }
    }
    pub fn get(&self, i: usize) -> M::T {
        self.query(i, i + 1)
    }
    pub fn query_range<R: std::ops::RangeBounds<usize>>(&self, range: R) -> M::T {
        let l = match range.start_bound() {
            std::ops::Bound::Excluded(&x) => {
                assert!(x > 0);
                x - 1
            }
            std::ops::Bound::Included(&x) => x,
            std::ops::Bound::Unbounded => 0,
        };
        let r = match range.end_bound() {
            std::ops::Bound::Excluded(&x) => x,
            std::ops::Bound::Included(&x) => (x + 1),
            std::ops::Bound::Unbounded => self.n,
        };
        self.query(l, r)
    }
    pub fn query(&self, l: usize, r: usize) -> M::T {
        let mut vl = M::id();
        let mut vr = M::id();
        let mut l = l + self.n;
        let mut r = r + self.n;
        while l < r {
            if l & 1 == 1 {
                vl = M::op(&vl, &self.buf[l]);
                l += 1;
            }
            if r & 1 == 1 {
                r -= 1;
                vr = M::op(&self.buf[r], &vr);
            }
            l >>= 1;
            r >>= 1;
        }
        M::op(&vl, &vr)
    }
}


Measured memory_bytes: 84396
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	int n, i;
	cin >> n;
	int arr[n];
	fo(i, 0, n)
	cin >> arr[i];
	
	sort(arr, arr + n, greater <int>());
	ll ans = arr[0];
	int cnt = n - 2;
	fo(i, 1, n) {
		if(cnt) {
			ans += arr[i];
			--cnt;
		}
		if(cnt) {
			ans += arr[i];
			--cnt;
		}
	}
	cout << ans;
}


Measured memory_bytes: 4424
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
map<int, int> factor(int m) {
	map<int, int>res;
	for (int i = 2; i*i <= m; i++) {
		while (m%i == 0) {
			res[i]++;
			m /= i;
		}
	}
	if (m != 1)res[m]++;
	return res;
}

/*--------Library Zone!--------*/


signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a << " " << b << " " << 3 * c - a - b << endl << 4 * c - 2 * a - b << " " << c << " " << 2 * a + b - 2 * c << endl << a + b - c << " " << 2 * c - b << " " << 2 * c - a << endl;
	endre;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int t = 0;
		while(t==0){
			string[] str = Console.ReadLine().Split(' ');
			int x = int.Parse(str[0]);
			int y = int.Parse(str[1]);
			if(x==0 && y==0){
				t = 1;
			} else {
				string s = "";
				if(x > y){
					s = y + " " + x;
				} else {
					s = x + " " + y;
				}
				Console.WriteLine(s);
			}
		}
	}
}


Measured memory_bytes: 9176
#include<bits/stdc++.h>
    using namespace std;
  #define int long long int
    #define endl "\n"
    #define MOD 1000000007
    #define mod 1000000007
    #define M 1000000007
    
    #define pb push_back
    #define take(a,b,c) for(int b=0;b<c;b++) cin>>a[b]
  //  #define mp make_pair
  #define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
  #define mx 400005
  #define fiint(a,b) memset(a,b,sizeof(a))  
  #define bitcount __builtin_popcount
  #define fori(i,a,b) for(int i=a;i<b;i++)
  #define ford(i,a,b) for(int i=a;i>=b;i--)
  #define debug(x) cout<<x<<endl;
  #define cases(t) int t; cin>>t; while(t--)
  #define inf1 INT_MAX
  #define all(a) a.begin(),a.end()
  #define vec vector<int>
  #define pii pair<int,int>
  #define plii pair<int,int>
  #define pint pair<int,int>
  #define ff first
  #define ss second
  #define lb lower_bound
  #define ub upper_bound
  #define bs binary_search
  #define sz(x) (int)x.size()
#define PI                    3.14159265359

bool prime[10000001];

void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}



signed  main() 
{ 
	int n;cin>>n;
	vector<double> p(n + 1 );
	fori(i,1,n+1)cin>>p[i];
	vector <vector<double> > dp(n+1, vector<double>(n+1));
	dp[1][0] = 1-p[1];
	dp[1][1] = p[1]; 
	fori(i,2,n+1)
		fori(j,0,i+1)
				if(i!=1 && j==0)
					dp[i][j] = dp[i-1][j]*(1-p[i]);
				else
				{dp[i][j] = dp[i-1][j]*(1-p[i]) + dp[i-1][j-1] * p[i];    }
	double ans=0.00;
	ford(i,n,n/2 + 1)	
	 ans+= dp[n][i];	
	 cout << fixed << setprecision(10) << ans << endl;
	
}




 


Measured memory_bytes: 72448
sx, sy, tx, ty = map(int, input().split())

a = tx - sx
b = ty - sy

ans = str()

# 一往復目
ans += 'R' * a
ans += 'U' * b
ans += 'L' * a
ans += 'D' * b

ans += 'D'
ans += 'R' * (a+1)
ans += 'U' * (b+1)
ans += 'L' 

ans += 'U'
ans += 'L' * (a+1)
ans += 'D' * (b+1)
ans += 'R'

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;
/// khodaya komak kon
/// ya navid navid
const int N=5e5+100;
ll val[N];
ll t[20];
ll dp[(1<<16)];
vector <int> f(ll x){
    vector <int> bit;
    while(x){
        bit.pb(x%2);
        x/=2;
    }
    while(bit.size()<16){
        bit.pb(0);
    }
    return bit;
}
int32_t main(){
    ll n;
    cin >> n;
    for (int i=0;i<n-1;i++){
        ll u,v,w;
        cin >> u >> v >> w;
        u++;
        v++;
        val[u] ^= w;
        val[v] ^= w;
    }
    ll ans=0;
    for (int i=1;i<=n;i++){
        t[val[i]]++;
     ///   cout << i << " " << val[i] << endl;
        if (t[val[i]]==2 && val[i]!=0) ans++;
        t[val[i]]%=2;
    }
    t[0]=0;
    memset(dp,69,sizeof dp);
    ll cnt1=0;
    for (int i=0;i<=15;i++){
        cnt1+=(t[i] << i);
     //   cout << t[i] << endl;
    }
    dp[0]=0;
    vector <pii> a;
    for (int i=0;i<(1<<16);i++){
        vector <int> bit=f(i);
       ll cnt=0;
        if (bit[0]) continue;
        for (int j=0;j<16;j++){
            cnt+=bit[j];
        }
        a.pb({cnt,i});
    }
  //  cout << cnt1 << endl;
    sort(a.begin(),a.end());
    for (int i=0;i<a.size();i++){
        ll x=a[i].S;
        vector <int> bit=f(x);
        for (int j=0;j<16;j++){
            if (bit[j]) dp[x]=min(dp[x],dp[(x^(1<<j))]+1);
            for (int k=j+1;k<16;k++){
                if (!bit[j] || !bit[k]) continue;
                if (bit[(j^k)]) dp[x]=min(dp[x],2+dp[(x^((1<<j) + (1<<k) + (1<<(j^k))))]);
                else dp[x]=min(dp[x],1+dp[(x^((1<<j) + (1<<k) + (1<<(j^k))))]);
               // if (x==14){
                 //   cout << dp[x] << " " << j << " " << k << " " << (j^k) << " " << 1+dp[(x^((1<<j) + (1<<k) + (1<<(j^k))))] << endl;
                //}
            }
        }

    }
    cout << dp[cnt1]+ans << endl;
}


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

using namespace std;

const int N = 3010;
long long dp[N][N][2];
int a[N];

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

  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    dp[i][i][0] = a[i];
    dp[i][i][1] = -a[i];
  }
  for (int r = 1; r < n; ++r) {
    for (int l = r - 1; l >= 0; --l) {
      dp[l][r][0] = max(a[l] + dp[l + 1][r][1], dp[l][r - 1][1] + a[r]);
      dp[l][r][1] = min(-a[l] + dp[l + 1][r][0], dp[l][r - 1][0] - a[r]);
    }
  }
  cout << dp[0][n - 1][0];

  return 0;
}

Measured memory_bytes: 141568
N = int(input())
A = []
m = 0
count = 0
for _ in range(N):
    a = int(input())
    A.append(a)
    if a > m:
        m = a
        count = 1
    elif a == m:
        count += 1
B = A[:]
B.sort(reverse=True)

for a in A:
    if a == m:
        if count > 1:
            print(a)
        else:
            print(B[1])
    else:
        print(m)


Measured memory_bytes: 14112
#include <bits/stdc++.h>
#define int long long 

using namespace std;

bool b[200003];

signed main(){
	int n , k;
	cin>>n>>k;
	vector<int> a(n+1) , c;
	for(int i = 1 ; i <= n ; i++) cin>>a[i];
	int cc = 1;
	while(!b[cc]){
		b[cc] = 1;
		cc = a[cc];
		k--;
		if(k == 0) {
			cout << cc << endl;
			return 0;
		}
	}
	int ccc =cc;
	do{
		c.push_back(cc);
		cc = a[cc];
	}while(cc != ccc);
	cout << c[k % c.size()] << endl;
}

Measured memory_bytes: 5904
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        k: usize,
    }

    if k > comb(n - 1, 2) {
        println!("-1");
        return;
    }

    println!("{}", n - 1 + comb(n - 1, 2) - k);

    for i in 2..=n {
        println!("1 {}", i);
    }

    let mut count = comb(n - 1, 2);

    for i in 2..n {
        for j in i + 1..=n {
            if count == k {
                return;
            }
            count -= 1;

            println!("{} {}", i, j);
        }
    }
}

fn comb(n: usize, k: usize) -> usize {
    if n < k {
        return 0;
    }

    let mut a = 1;
    let mut b = 1;

    for i in 0..k {
        a *= n - i;
        b *= i + 1;
    }

    a / b
}


Measured memory_bytes: 2144
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BBingo {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        vector<vector<int>> A(3, vector<int>(3));
        REP(i, 3) REP(j, 3) cin >> A[i][j];

        int N;
        cin >> N;
        set<int> found;
        REP(i, N) {
            int b;
            cin >> b;
            found.insert(b);
        }
        REP(i, 3) {
            bool ok = true;
            REP(j, 3) {
                if (found.count(A[i][j]) == 0)  {
                    ok = false;
                }
            }
            if (ok) {
                cout << "Yes" << endl;
                return;
            }
        }
        REP(j, 3) {
            bool ok = true;
            REP(i, 3) {
                if (found.count(A[i][j]) == 0)  {
                    ok = false;
                }
            }
            if (ok) {
                cout << "Yes" << endl;
                return;
            }
        }
        int j = 0;
        bool ok = true;
        REP(i, 3) {
            if (found.count(A[i][j]) == 0) {
                ok = false;
            }
            j++;
        }
        if (ok) {
            cout << "Yes" << endl;
            return;
        }
        j = 2;
        ok = true;
        REP(i, 3) {
            if (found.count(A[i][j]) == 0) {
                ok = false;
            }
            j--;
        }
        if (ok) {
            cout << "Yes" << endl;
            return;
        }
        cout << "No" << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BBingo solver;
    solver.solve(in, out);
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD ((int)(1e9) + 7)
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define filename "lynext"
#define freop freopen(filename ".cik","w",stdout);freopen(filename ".gir","r",stdin)
const long long int N = ((long long int)1e5) + 5;
const long long int M = ((long long int)1e2) + 5;
const long long int llinf = (long long int)1e18;
const int inf = INT_MAX;
typedef long long int lli;

int n, k;
int arr[M];
int mn = INT_MAX;
int dp[N][2];

bool f (int stones, bool h)
{
	if (dp[stones][h] != -1)
		return (bool)dp[stones][h];
	if (stones == mn)
		return (bool)(dp[stones][h] = h);
	if (stones < mn)
		return (bool)(dp[stones][h] = !h);
	for (int i = 1; i <= n; i++)
	{
		if (arr[i] <= stones && f(stones - arr[i],!h) == h)
			return (bool)(dp[stones][h] = h);
	}
	return (bool)(dp[stones][h] = !h);
}

int main ()
{
	fast;
	//freop;
	cin >> n >> k;
	memset(dp, -1, sizeof dp);
	for (int i = 1; i <= n; i++)
		cin >> arr[i],mn = min(arr[i],mn);
	bool t = f(k,true);
	if (t)
		return cout << "First\n",0;
	cout << "Second\n";

}


Measured memory_bytes: 8832
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int k = S.length();
		S = S.replaceAll("x", "");
		if(S.length() >= 7) {
			System.out.println("YES");
		}else if(k - S.length() >= 8){
			System.out.println("NO");
		}else {
			System.out.println("YES");
		}
		sc.close();
	}

}

Measured memory_bytes: 23380
#include<cstdio>
#include<cstring>
#include<algorithm>

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

using namespace std;

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

short dp[5000][5000];
int dfs(int i,int j){
	if(i==m || j==n) return 0;
	if(dp[i][j]!=-1) return dp[i][j];
	if(a[i]==b[j]) return dp[i][j]=dfs(i+1,j+1)+1;
	else           return dp[i][j]=dfs(i+1,j);
}

int main(){
	scanf("%d%d",&m,&n);
	rep(i,m) scanf("%d",a+i);
	rep(j,n) scanf("%d",b+j);

	memset(dp,-1,sizeof dp);
	int ans=0;
	rep(j,n) ans=max(ans,dfs(0,j));
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 49972
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_H (100)
#define MAX_W (100)
#define SIZE_BUF (30)

using namespace std;

int main() {
  // read inputs
  int H, W;
  char ass[MAX_H][MAX_W], buf[SIZE_BUF];
  scanf("%d %d", &H, &W);
  fgets(buf, SIZE_BUF, stdin);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      scanf("%c", &ass[i][j]);
    }
    fgets(buf, SIZE_BUF, stdin);
  }

  // count the number of occurences of each letter
  int ns[26] = {};
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      ns[ass[i][j] - 'a']++;
    }
  }
  //   for (int k = 0; k < 26; k++) {
  //     printf("%d ", ns[k]);
  //   }
  //   printf("\n");

  // place a letter in the center cell
  if (H % 2 == 1 && W % 2 == 1) {
    int num_place = 1;
    for (int k = 0; k < 26; k++) {
      if (ns[k] % 2 == 1) {
        ns[k]--;
        num_place--;
        if (num_place == 0) {
          break;
        }
      }
    }
    if (num_place > 0) {
      printf("No\n");
      return 0;
    }
  }
  //   for (int k = 0; k < 26; k++) {
  //     printf("%d ", ns[k]);
  //   }
  //   printf("\n");

  // place letters in the center row and column
  if (H % 2 == 1 || W % 2 == 1) {
    int num_place = 0;
    if (H % 2 == 1) {
      num_place += (W / 2) * 2;
    }
    if (W % 2 == 1) {
      num_place += (H / 2) * 2;
    }
    for (int k = 0; k < 26; k++) {
      if (ns[k] % 4 == 2) {
        ns[k] -= 2;
        num_place -= 2;
        if (num_place == 0) {
          break;
        }
      }
    }

    if (num_place > 0) {
      for (int k = 0; k < 26; k++) {
        if (num_place % 4 == 0 && ns[k] % 4 == 0) {
          const int num_use = min(ns[k], num_place);
          ns[k] -= num_use;
          num_place -= num_use;
        }
      }
      if (num_place > 0) {
        printf("No\n");
        return 0;
      }
    }
  }
  //   for (int k = 0; k < 26; k++) {
  //     printf("%d ", ns[k]);
  //   }
  //   printf("\n");

  // place the rest of the letters
  int is_possible = 1, num_place = ((H / 2) * 2) * ((W / 2) * 2);
  for (int k = 0; k < 26; k++) {
    if (ns[k] % 4 != 0) {
      is_possible = 0;
    }
    const int num_use = min(ns[k], num_place);
    ns[k] -= num_use;
    num_place -= num_use;
  }
  //   for (int k = 0; k < 26; k++) {
  //     printf("%d ", ns[k]);
  //   }
  //   printf("\n");
  if (is_possible) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

Measured memory_bytes: 128
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>

int main(){
  int N, K;
  scanf("%d", &N);
  scanf("%d", &K);
  std::set<int > st;
  for (int i=0; i<K; i++){
    int d;
    scanf("%d", &d);
    int A;
    for (int j=0; j<d; j++){
      scanf("%d", &A);
      st.insert(A);
    }
  }
  std::cout << N-st.size() << std::endl;
  return 0;
}


Measured memory_bytes: 3236
def main():
    N, K = map(int, input().split())
    x, y = zip(*(
        map(int, input().split())
        for _ in range(N)
    ))

    f(N, K, x, y)


def f(N, K, x, y):
    ans = abs(max(x) - min(x)) * abs(max(y) - min(y))
    if K == N:
        print(ans)
        return

    def r(x, y, x_start=0, y_start=0):
        for xi in range(x_start, N):
            for yi in range(y_start, N):
                yield x[xi], y[yi], xi, yi

    # for x1, y1 in zip(x, y):
    #     for x2, y2 in zip(x, y):
    # for x1, y1 in r(x, y):
    #     for x2, y2 in r(x, y):
    sorted_x = sorted(x)
    sorted_y = sorted(y)
    for min_x, min_y, xi, yi in r(sorted_x, sorted_y):
        for max_x, max_y, _, _ in r(sorted_x, sorted_y, x_start=xi+1, y_start=yi+1):

            # s = abs(x1-x2) * abs(y1-y2)
            # if s == 0:
            #     continue

            # min_x = min(x1, x2)
            # max_x = max(x1, x2)
            # min_y = min(y1, y2)
            # max_y = max(y1, y2)

            contains_count = 0
            for x3, y3 in zip(x, y):
                if min_x <= x3 <= max_x and min_y <= y3 <= max_y:
                    contains_count += 1
            if contains_count >= K:
                s = (max_x - min_x) * (max_y - min_y)
                ans = min(ans, s)

    print(ans)


if __name__ == "__main__":
    main()


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

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	int f[] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int a[] = new int[m];
		for(int i=0; i<m; i++) {
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		int dp[] = new int[n+1];
		Arrays.fill(dp, -1);
		dp[0]=0;
		for(int i=1; i<=n; i++) {
			for(int j=0; j<m; j++) {
				if(i-f[a[j]]>=0 && dp[i-f[a[j]]]>=0) {
					dp[i] = Math.max(dp[i], dp[i-f[a[j]]]+1) ;
				}
			}
		}
		int keta = dp[n];
		int rem = n;
		StringBuilder sb = new StringBuilder();
		while(rem>0) {
			for(int i=m-1; i>=0; i--) {
				if(rem-f[a[i]]>=0 && keta == dp[rem-f[a[i]]]+1) {
					sb.append(a[i]);
					keta--;
					rem -= f[a[i]];
					break;
				}
			}
		}
		System.out.println(sb);
		sc.close();
	}



}


Measured memory_bytes: 22868
n = int(input())
C = list(str(input()))

W = []
R = []
for i in range(n):
    if C[i] == 'W':
        W.append(i)
    else:
        R.append(i)

W.reverse()
#print(W)
#print(R)
nR = []
nW = []
ans = 0
for i in range(len(R)):
    r = R.pop()
    if len(W) > 0:
        w = W.pop()
        if w < r:
            nR.append(w)
            nW.append(r)
            ans += 1
        else:
            R.append(r)
            W.append(w)
            nW += W
            nR += R
            break
    else:
        R.append(r)
        nW += W
        nR += R
        break
#print(ans)
nR.sort()
nW.sort()
if len(nR) == 0 or len(nW) == 0:
    print(ans)
    exit()
for idx in nW:
    if idx < nR[0]:
        ans += 1
print(ans)


Measured memory_bytes: 98928
#include<stdio.h>
int main()
{
    int a,b;
    char op;
    while(1)
    {
        scanf("%d %c %d", &a, &op, &b);
        if(op=='+')
        {
            printf("%d\n",a+b);
        }
        else if(op=='-')
        {
            printf("%d\n",a-b);
        }
        else if(op=='*')
        {
            printf("%d\n",a*b);
        }
        else if(op=='/')
        {
            printf("%d\n",a/b);
        }
        else
        {
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 600
from math import sqrt
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
d1,d2,d3,di=0,0,0,abs(x[0]-y[0])
for i in range(n):
    d1+=abs(x[i]-y[i])
    d2+=(x[i]-y[i])**2
    d3+=abs(x[i]-y[i])**3
    if di < abs(x[i]-y[i]):
        di=abs(x[i]-y[i])
d2=sqrt(d2)
d3=d3**(1/3)
print(d1,d2,d3,di,sep='\n')


Measured memory_bytes: 5696
#include<cstdio>
#define mod 1000000007
int n;
long long f[300005],ans=0;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&f[i]);
	for (int k=0;k<=60;k++)
	{
		int x=0,y=0,cnt=0;
		for (int i=1;i<=n;i++) if (f[i]&(1ll<<k)) ++x;else ++y;
		for (int i=1;i<=n;i++) if (f[i]&(1ll<<k)) cnt=(cnt+y)%mod,--x;else cnt=(cnt+x)%mod,--y;
		ans=(ans+(1ll<<k)%mod*cnt%mod)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    
    def readlines():
        for i in range(m):
            p, y = map(int, input().split())
            yield p, y, i

    cityies = sorted(readlines())

    def convert():
        prev = 0
        now = 1
        for p, y, i in cityies:
            if p == prev:
                now += 1
            else:
                now = 1
            yield i, "{:06}{:06}".format(p, now)

            prev = p

    print("\n".join(number for i, number in sorted(convert())))


main()


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

#define g(x) ((x*(x+1))/2)

int main(){
    int N;
    cin >> N;
    long long s=0;
    for(int i=1; i<=N; i++){
        s += i*g((long long)N/i);
    }
    cout << s << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#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>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

// 1_indexed
class BIT {
private:
    int n;
    vector<ll> a;
public:
    BIT(int _n);
    void add(int idx, ll v);
    ll sum(int i);
    ll sum(int i, int j);
    ~BIT();
};

BIT::BIT(int _n) {
    n = _n;
    a.assign(n, 0ll);
}

void BIT::add(int idx, ll x) {
    while (idx <= n) {
        a[idx] += x;
        idx += (idx & -idx);
    }
}

ll BIT::sum(int i) {
    ll ret = 0;
    while (i > 0) {
        ret += a[i];
        i -= (i & -i);
    }
    return ret;
}

ll BIT::sum(int i, int j) {
    ll l = sum(i-1);
    ll r = sum(j);
    return r-l;
}

BIT::~BIT() {
}

typedef tuple<int, int, int> T;
int main(int argc, char const *argv[]) {
    int n,Q; cin>>n>>Q;
    vector<ll> c(n);
    vector<T> q(Q);
    BIT ft(n);
    rep(i,n) cin>>c[i];
    rep(i,Q) {
        int idx = i;
        int l,r; cin>>l>>r;
        q.emplace_back(r,l,i);
    }

    sort(q.begin(), q.end());
    int C = 0;
    vector<int> x(n+10, -1);
    vector<int> ans(Q);
    for (const auto& [r, l, idx]: q) {
        for (int i = C; i < r; ++i) {
            if (x[c[i]]==-1) {
                ft.add(i+1, 1);
            }
            else {
                ft.add(x[c[i]], -1);
                ft.add(i+1, 1);
            }
            x[c[i]] = i+1;
        }
        chmax(C,r);
        ans[idx] = ft.sum(l,r);
    }

    for (auto &&e: ans) cout << e << '\n';
    return 0;
}

Measured memory_bytes: 27208
#include<bits/stdc++.h>
#define MAX INT_MAX
#define F first
#define S second
using namespace std;
vector<int> town[2000];
vector<int> cost[2000];
typedef pair<int,int> P;
int main(void)
{
	int n,m;
	int a,b,c,d;
	int s,g,v,p;
	char ch,ch1,ch2,ch3;
	
	int flg[2000];
	int length[2000];
	int x,y;
	P pp;
	priority_queue<P,vector<P>,greater<P>> que;
	
	int i;
	cin>>n>>m;
	
	for(i=0;i<m;i++){
		cin>>a>>ch>>b>>ch1>>c>>ch2>>d;
		
		town[a].push_back(b);
		cost[a].push_back(c);
		
		town[b].push_back(a);
		cost[b].push_back(d);
		
	}
	
	cin>>s>>ch>>g>>ch>>v>>ch>>p;
	
	fill(length,length+(n+1),MAX);
	fill(flg,flg+(n+1),0);
	
	que.push(P(0,s));

	while(que.size()!=0){
		pp=que.top();
		que.pop();
		x=pp.F;
		y=pp.S;
		if(x<length[y]){
			length[y]=x;
			flg[y]=1;
			for(i=0;i<town[y].size();i++){
				if(flg[town[y][i]]==0){
					que.push(P(x+cost[y][i],town[y][i]));
				}
			}
		}
	}
		
	while(!que.empty()){
		que.pop();
	}
	int wk;
	wk=length[g];
//	cout<<wk<<endl;
	
	fill(length,length+(n+1),MAX);
	fill(flg,flg+(n+1),0);
	
	que.push(P(0,g));

	while(que.size()!=0){
		pp=que.top();
		que.pop();
		x=pp.F;
		y=pp.S;
		if(x<length[y]){
			length[y]=x;
			flg[y]=1;
			for(i=0;i<town[y].size();i++){
				if(flg[town[y][i]]==0){
					que.push(P(x+cost[y][i],town[y][i]));
				}
			}
		}
	}
	
	int wk1;
	wk1=length[s];
	//cout<<wk1<<endl;
	
	cout<<v-p-wk-wk1<<endl;
	return 0;
}
	


Measured memory_bytes: 3152
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0

n = iin()
d = [int(x) for x in input().split()]
d.sort()

neko = int(n/2 - 1)
nuko = neko + 1
if d[neko] != d[nuko]:
    for i in range(d[nuko]-d[neko]):
        nya = nya + 1
    
print(nya)

Measured memory_bytes: 14428
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0) break;

            for(int i=0; i<H; i++){
                if(i ==0 || i == H-1) {
                    for (int j = 0; j < W; j++) {
                        System.out.print('#');
                    }
                }else{
                    for(int j = 0; j < W; j++){
                        if(j == 0 || j == W-1){
                            System.out.print('#');
                        }else{
                            System.out.print('.');
                        }
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 38776
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

int a, b, c;
cin >> a >> b >> c;
if(a==b && b==c){
	cout << "Yes" << endl;
} else {
	cout << "No" << endl;
}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
int K;
using ll = long long;
int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    ll sum = accumulate(ALL(A), 0LL);
    sum /= 2;

    ll over = 0;
    for (int i = 0; i < N; i += 2) {
        over += A[i];
    }

    vector<ll> ans(N);
    ans[0] = over - sum;
    for (int i = 0; i < N - 1; i++) {
        ans[i + 1] = A[i] - ans[i];
    }

    for (int i = 0; i < N; i++) {
        cout << ans[i] * 2;
        if (i != N - 1) cout << " ";
    }
    cout << endl;
}


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

double S(long long N){
  double ans=0;
  while(N>0){
    ans += N%10;
    N /= 10;
  }
  return (double)ans;
}


void test(){
  vector<double> V(50000);
  for(int i=0; i<50000; i++){
    V[i] = (i+1)/(double)S(i+1);
  }
  vector<bool> check(50000,false);
  double minv = 50000.0;
  for (int i=49999; i>=0; i--){
    if (minv >= V[i]){
      check[i] = true;
      minv = V[i];
    }
  }
  for(int i=0; i<50000; i++){
    //cout << V[i] << endl;
    if (check[i]) cout << i+1 << endl;
  }
}


int main(){
  //test();
  int K;
  cin >> K;
  int count = 0;
  long long dif = 1;
  long long ans = 0;
  while(count<K){
    if ((ans+dif)/(double)S(ans+dif) <= (ans+dif*10)/(double)S(ans+dif*10)){
      ans += dif;
      cout << ans << endl;
      count++;
    } else{
      dif *= 10;
      ans += dif;
      cout << ans << endl;
      count++;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <stack>
#define _GLIBCXX_DEBUG
using namespace std;

int main()
{
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(max(max(a*c,a*d), b*c), b*d)<< endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

bool kaibun(string s) {
  string t = s;
  reverse(s.begin(), s.end());
  if (s == t) {
    return true;
  }
  else {
    return false;
  }
}

int main() {
  FAST;
  string S;
  cin >> S;
  int N = S.size();
  string T, U;
  for (int i = 0; i < (N - 1) / 2; i++) {
    T += S.at(i);
  }
  for (int i = (N + 3) / 2 - 1; i < N; i++) {
    U += S.at(i);
  }
  if (kaibun(S) && kaibun(T) && kaibun(U)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
#include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;

int arr[100][100];
signed main(){
    int n, m;
    cin >> n >> m;
    int a[n];
    int b[n];
    rep(i,n) cin >> a[i];
    b[0]=a[0];
    FOR(i,1,n) {
        b[i] = b[i-1] + a[i];
    } 
    map<int, int> mp;

    rep(i,n) {
        mp[b[i]%m]++;
    }
    mp[0]++;
    int ans = 0;
    for(auto e: mp) {
        ans += e.second*(e.second-1)/2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9084
#!/usr/bin/env perl

use strict;
use warnings;

my @array = split //, <>;
chomp $array[$#array];

for (my $i = -1; $i < 2; $i += 2) {
  for (my $j = -1; $j < 2; $j += 2) {
    for (my $k = -1; $k < 2; $k += 2) {
      if ($array[0] + $array[1] * $i + $array[2] * $j + $array[3] * $k == 7) {
        print $array[0], ($i < 0 ? '-' : '+');
        print $array[1], ($j < 0 ? '-' : '+');
        print $array[2], ($k < 0 ? '-' : '+');
        print $array[3], "=7\n";
        exit;
      }
    }
  }
}


Measured memory_bytes: 640
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N; cin >> N;
	cout << "ABC" << N << endl;


	return 0;

}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N, M;
  cin >> N >> M;
  cout << (N * (N-1))/2 + (M * (M-1))/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  int c = a * b % 2;
  if (c != 0){
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000000
#define maxs(x,y) (x = max(x , y))
#define mins(x,y) (x = min(x , y))
using namespace std;
typedef long long int ll;

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


}


Measured memory_bytes: 256
import java.util.Scanner;

public class  Main {
    public static int getNumOfPie(int A, int P) {
        return (int) (A * 3 + P) / 2;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int P = scan.nextInt();
        System.out.println(getNumOfPie(A, P));
    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>

using namespace std;
int n;
unsigned long long ans;
int a[100]; // 10^5
int ten;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  cin >> n;
  int k = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[k];
    ans += a[k];
    if (a[k] % 10) {
      k++;
    }
  }

  if (ans % 10) {
    cout << ans << endl;
  } else if (k > 0){
    sort(a, a+k);
    cout << ans - a[0] << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
入力 = input
出力 = print
ぜろ = 0
いち = 1
曲の数 = 入力()
整数化 = int
浮動小数点化 = float
曲の数 = 整数化(曲の数)
曲名 = [ぜろ]
時間 = [ぜろ]
曲名.remove(ぜろ)
時間.remove(ぜろ)
範囲 = range
for 制御変数 in 範囲(ぜろ,曲の数):
    入力された値 = 入力().split()
    曲名.append(入力された値[ぜろ])
    時間.append(入力された値[いち])
    時間[制御変数] = 整数化(浮動小数点化(時間[制御変数]))
寝た時の曲名 = 入力()
まだわからん = ぜろ
寝たタイミング = まだわからん
for 制御変数 in 範囲(ぜろ,曲の数):
    if(曲名[制御変数] == 寝た時の曲名):
        寝たタイミング = 制御変数
        break
寝ていたときに流れていた曲の時間 = まだわからん
for 制御変数 in 範囲(寝たタイミング + いち,曲の数):
    寝ていたときに流れていた曲の時間 += 時間[制御変数]
出力(寝ていたときに流れていた曲の時間)

Measured memory_bytes: 3320
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

import itertools
import math

f = [1]*n

for i in range(1, n):
	f[i]= f[i-1]*(i+1)
    
permutations_lis = itertools.permutations(xy)# 全ての場合のリストを生成
# 以下出力
total_d = 0
for one_case in permutations_lis: 
  x_cur = None
  y_cur = None
  d = 0
  for x, y in one_case:
    #print(x,y, end=' ')
    if x_cur is None:
      x_cur = x
      y_cur = y
    else:
      d += math.sqrt((x_cur-x)**2 + (y_cur-y)**2)
      #print(math.sqrt((x_cur-x)**2 + (y_cur-y)**2), end=' ')
      x_cur, y_cur = x, y
      
  total_d += d
      
print(total_d/f[n-1])

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int possible_solution(int n,int x)
{
    return max(x,n-x);
}

int solve(string s)
{
    int n = s.size();
    int ret = n;

    for(int i = 0; i < n-1; i++)
    {
        if(s[i] != s[i+1]) ret = min(ret,possible_solution(n,i+1));
    }

    return ret;
}

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

    string s;
    cin>> s;

    int sol = solve(s);
    cout<< sol;

    return 0;
}


Measured memory_bytes: 512
n=input()
#n=int(input())
#li=input().split()
#li=list(map(int,input().split()))
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import math
#import numpy as np
if n=="A":
    ans="T"
elif n=="T":
    ans="A"
elif n=="C":
    ans="G"
elif n=="G":
    ans="C"




print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll n;
	cin >> n;
	cout << (n % 2 ? n * 2 : n) << endl;
	return 0;
}

Measured memory_bytes: 256
DIV = 1_000_000_007
n = gets.to_i
l = n.times.map{ gets.chomp }
l.delete('-')
s = l.size
u = l.count('U')
d = l.count('D')
pos_u = [0]*s
pos_d = [-d]*s
l.each_with_index do |str, i|
  if str == 'U' then (i+1...s).each{ |j| pos_u[j]+= 1 }
  else (0...i).each{ |j| pos_d[j]+= 1 }
  end
end
dp = (s+1).times.map{ [0]*(s+1) }
dp[0][0] = 1
for i in (1..s)
  for j in (0..i)
    dp[i][j] = dp[i-1][j-1]*(pos_u[i-1]-(j-1)) if j > 0
    dp[i][j] += dp[i-1][j]*(pos_d[i-1]-(j-i)) if j < i
    dp[i][j] %= DIV
  end
end
p dp[s][u]

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

int main() {
	int n;
	while (cin >> n, n) {
		vector<pair<double, string>> v;
		for (int i = 0; i < n; i++) {
			string l;
			int p, a, b, c, d, e, f, s, m;
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			v.push_back(make_pair(-double(f * s * m - p) / (a + b + c + m * (d + e)), l));
		}
		sort(begin(v), end(v));
		for (auto it = begin(v); it != end(v); it++) {
			cout << it->second << endl;
		}
		cout << "#" << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long 
#define pb push_back
#define fr first
#define sc second
#define MAX ((ll)(2e17+100))
#define MX ((ll)(1e6+100))
#define ARRS ((ll)(3e6+600))
#define HS ((ll)(233))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define LG 21
#define mul(a,b) a=((a)*(b))%MOD
using namespace std;

ll n,m;
string s,t;


int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	cin>>s>>t;
	ll k=__gcd(n,m);
	ll p=n*m/k;
	for(int i=0; i<k; i++){
		if(s[i*(n/k)]!=t[i*(m/k)]){
			cout<<-1;
			return 0;
		}
	}
	cout<<p;



}


Measured memory_bytes: 640
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

# 数列生成  # 自動的に辞書順に並んでる
p_list = list(itertools.permutations([i for i in range(1, n + 1)], n))

a = p_list.index(p)
b = p_list.index(q)

print(abs(a - b))


Measured memory_bytes: 13988
use std::io::*;
use std::str::FromStr;

fn main() {
    let stdin = stdin();
    let mut stdinlock = stdin.lock();
    let mut str1 = String::new();
    stdinlock.read_to_string(&mut str1).unwrap();
    let mut iter1 = str1.trim().split_whitespace().map(|x| u32::from_str(x).unwrap());
    let _n = iter1.next().unwrap();
    let mut an:Vec<_> = iter1.collect();
    an.sort();
    an.push(0);
    let mut k = &an[0];
    let mut counter: u32 = 0;
    let mut needs: u32 = 0;
    for (count, j) in an.iter().enumerate() {
        /*
        if j > &100000 {
            needs += (an.len() - 1 - count) as u32;
            break;
        }
        */
        if k == j {
            counter += 1;
        } else {
            if *k > counter {
                needs += counter;
            } else {
                needs += counter - *k;
            }
            k = j;
            counter = 1;
        }
        //println!("{}, {}, (j,k) = {}, {}", counter, needs, j, k);
    }
    println!("{}", needs);
}


Measured memory_bytes: 6396
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

a = [readints() for i in range(3)]
n = readint()

for i in range(n):
    b = readint()
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
                a[j][k]=0
ans = 0
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]==0:
        ans = 1
        break
    if a[0][i]==a[1][i]==a[2][i]==0:
        ans = 1
        break
if a[0][0]==a[1][1]==a[2][2]:
    ans = 1
if a[0][2]==a[1][1]==a[2][0]:
    ans = 1
print('Yes'if ans else 'No')

Measured memory_bytes: 38384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	m := sc.ReadInt()
	q := sc.ReadInt()
	abcds := make([]ABCD, q)
	for i := 0; i < q; i++ {
		a := sc.ReadInt()
		b := sc.ReadInt()
		c := sc.ReadInt()
		d := sc.ReadInt()
		abcds[i] = ABCD{a, b, c, d}
	}

	nodes := make([]seqANode, 0, 200000)
	for a := m; a >= 1; a-- {
		nodes = append(nodes, seqANode{0, a})
	}

	cur := make([]int, n)
	maxScore := 0
	for len(nodes) > 0 {
		node := nodes[len(nodes)-1]
		nodes = nodes[:len(nodes)-1]

		cur[node.pos] = node.a

		if node.pos == n-1 {
			score := computeScore(abcds, cur)
			if score > maxScore {
				maxScore = score
			}
		} else {
			for a := m; a >= node.a; a-- {
				nodes = append(nodes, seqANode{node.pos + 1, a})
			}
		}
	}

	fmt.Println(maxScore)
}

func computeScore(abcds []ABCD, seqA SeqA) int {
	totalD := 0
	for _, abcd := range abcds {
		if seqA[abcd.B-1]-seqA[abcd.A-1] == abcd.C {
			totalD += abcd.D
		}
	}
	return totalD
}

type SeqA []int

type ABCD struct {
	A int
	B int
	C int
	D int
}

type seqANode struct {
	pos int
	a   int
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  if(k == 0){
    cout << (ll)n*n << endl;
    return 0;
  }
  ll ans = 0;
  rep2(i, k+1, n+1){
    ll add = n / i;
    add *= i - k;
    ll add2 = n % i;
    // cerr << i << " " << add << " " << add2 << endl;
    if(add2 >= k) add += add2 - k + 1;
    ans += add;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256