akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    ll q;
    cin>>q;
    rep(_,q){
        ll a,b;
        cin>>a>>b;
        ll n=a*b-1;
        if(a==b){
            cout<<(a-1)*2<<endl;
            continue;
        }
        ll left=1,right=1LL<<32;
        while(right-left>1){
            ll mid=(left+right)/2;
            ll c=(mid+1)/2*(mid+1-(mid+1)/2);
            if(c>n) right=mid;
            else left=mid;
        }
        cout<<left-1<<endl;
    }
    return 0;
}

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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL
#define endl "\n"

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	string s,t;
	cin >> n >> m >> s >> t;
	if(s.at(0) != t.at(0)) {
		cout << -1;
		return 0;
	}
	ll gc = __gcd(n,m);
	ll a = n/gc;
	ll b = m/gc;
	for(ll i = 0; i < a*b*gc; i+= a*b) {
		//cout << i/b << " " << i/a << endl;
		if(s.at(i/b) != t.at(i/a)) {
			cout << -1;
			return 0;
		}
	}
	cout << a*b*gc;
	return 0;
}



Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
using namespace std;

const int INF = 1 << 29;
const long long int Mod = 1000000007;
using ll = long long int;
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; ++i)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)



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

	if (s[s.size() - 1] == 's') {
		cout << s << "es" << endl;
	}
	else {
		cout << s << "s" << endl;
	}
}

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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;

  vector<int> A(N), C(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  C = A;
  for (int i = 0; i < N; i++) {
    C.at(i) -= i + 1;
  }

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

  int b = C.at(N / 2);

  long long ans = 0;

  for (int i = 0; i < N; i++) {
    ans += abs(A.at(i) - (b + i + 1));
  }

  cout << ans << "\n";
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define int int64_t
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define mod 1000*1000*1000+7
#define mem(dp,a) memset(dp,a,sizeof dp)
int32_t main()
{
    int h;cin>>h;
    int count=1;
    int ans=0;
    while(h>0)
    {
        if(h==1)
        {
            h-=1;
            ans+=count;
        }
        else
        {
            ans+=count;
            count*=2;
            h/=2;
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, M;
    cin >> N >> M;
    vl S(N), T(M);
    rep(i, N) cin >> S[i];
    rep(i, M) cin >> T[i];
    vvc<ll> dp(N + 1, vc<ll>(M + 1, 0));
    dp[0][0] = 0;
    rep(i,N)rep(j,M){
        if (S[i] == T[j])
            dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1]+1)%MOD;
        else
            dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1] - dp[i][j] + MOD)%MOD;
    }
    // rep(i,N+1){
    //     rep(j, M + 1) cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    cout << (dp[N][M]+1)%MOD << endl;
}

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

#define int long long int
#define pb push_back
#define mp make_pair

int32_t main()
{
     
     int n,t;
     
     cin>>n>>t;
     
     int ans=1e18;
     
     for(int i=1;i<=n;i++)
     {
          int x,y;
          
          cin>>x>>y;
          
          if(y<=t)
          ans=min(ans,x);
          
     }
     if(ans==1e18)
     cout<<"TLE";
     else
     cout<<ans;
     return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    println(problem147b(s))
}

fun problem147b(s: String): Int {
    val s1 = s.take(s.length / 2)
    val s2 = s.takeLast(s.length / 2)
    var count = 0
    for (i in 0 until s1.length) {
        if (s1[i] != s2[s2.length - i - 1]) {
            count++
        }
    }
    return count
}

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

typedef long long ll;
typedef long double lld;

#define ci(x) cin >> x 
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define x first
#define y second
#define ub upper_bound
#define lb lower_bound
#define pii pair <int ,int >
#define pll pair <ll ,ll > 
#define vpii vector<pii > v;
#define fore(i, a, b) for (int i=a; i<(b); i++)
#define cs(x) cout<<x<<" "
#define Yes printf("YES\n")
#define No printf("NO\n")
#define cl(x) cout<<x<<endl;
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define SET(arr,val) memset(arr,val,sizeof arr)



int main() {
	string n;
	ci(n);
	string ans = "";
	if (n[0] == max(n[0], n[1]) && n[0] == max(n[0], n[2])) {
		ans.push_back(n[0]);
		ans.push_back(n[0]);
		ans.push_back(n[0]);
	}
	else {
		ans.push_back(n[0]+1);
		ans.push_back(n[0]+1);
		ans.push_back(n[0]+1);
	}
	cout << ans;
}

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


Measured memory_bytes: 2064
n=gets.to_i
a=gets.chomp.chars
b=Array.new(a)
a.shift
min=now=a.count('E')
for i in 1...n do
  now+=(b[i-1]=='W' ? 1:0)+(b[i]=='E' ? -1:0)
  min>now&&min=now
end
puts min


Measured memory_bytes: 27396
#include<bits/stdc++.h>
using namespace std;
signed main() {
  int a,b,h,m;
  cin >> a >> b >> h >> m;
  double c = 0.5*m + 30.0*h;
  double d = 6.0*m;
  double s = max(c,d) - min(c,d);
  if(s > 180){
    s = 360 - s;
  }
  
  double y = s * (M_PI / 180);
  double x = sqrt((a*a + b*b) - (2 * a * b *cos(y)));
  printf("%.20f\n", x);
  return 0;
}


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

int main()
{
	long long K;
	scanf("%lld", &K);
	
	long long rem = 7 % K;
	for(int i = 1; i <= 1000000; i++)
	{
		if(rem == 0)
		{
			printf("%d", i);
			return 0;
		}
		
		rem = (rem * 10) % K;
		rem = (rem + 7) % K;
	}
	
	printf("-1");
}


Measured memory_bytes: 3796
#include <iostream>
using namespace std;
int main(void){
    int r;
    cin >> r;
    if(r < 1200){
        cout <<"ABC"<<endl;
    }
    else if(r >=1200 & r <2800){
        cout <<"ARC" <<endl;
    }
    else{
        cout <<"AGC" <<endl;
    }
    
    return 0;
}

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

int main(){
	int n,p;
	cin >> n >>p;
	int num[50];
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		num[a%2]++;
	}
	if(num[1]==0){
		long long ans=1;
		for(int i=0;i<n;i++)ans*=2;
		if(p==0)cout << ans << endl;
		else cout << 0 << endl;
	}else{
		long long ans=1;
		for(int i=1;i<n;i++)ans*=2;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::{HashMap, VecDeque};
fn corners_around(h: i64, w: i64, n: &(i64, i64)) -> Vec<(i64, i64)> {
    let mut res = Vec::new();
    let &(c_y, c_x) = n;
    for diff_x in -3..0 {
        for diff_y in -3..0 {
            let sx = c_x + diff_x;
            let sy = c_y + diff_y;
            let ex = sx + 3;
            let ey = sy + 3;
            if sx >= 0 && ex <= w && sy >= 0 && ey <= h {
                res.push((sy, sx));
            }
        }
    }
    res
}

fn solve(h: i64, w: i64, ns: &[(i64, i64)]) -> VecDeque<u64> {
    let mut res_map = HashMap::new();
    for n in ns {
        let corners = corners_around(h, w, n);
        for c in corners {
            *res_map.entry(c).or_insert(0) += 1;
        }
    }

    let mut res = VecDeque::new();
    for i in 1..10 {
        let n = res_map
            .values()
            .fold(0, |acc, x| if *x == i { acc + 1 } else { acc });

        res.push_back(n as u64)
    }
    let total_rect = (h - 2) * (w - 2);
    let remain = total_rect - res.iter().fold(0, |acc, n| acc + n) as i64;
    res.push_front(remain as u64);
    res
}

fn main() {
    input! {h: i64, w: i64, n:usize, ns: [(i64, i64); n]};
    let result = solve(h, w, &ns);
    for i in result {
        println!("{}", i);
    }
}


Measured memory_bytes: 56852
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long k){


    vector<int> res =
            {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    cout << res[k - 1] << endl;
}


signed main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 256
s=int(input())
import math
def comb(n,m):
    facn=math.factorial(n)
    facm=math.factorial(m)
    facmn=math.factorial(n-m)
    return facn//(facm*facmn)
end=s//3
ans=0
for i in range(1,end+1):
    ans+=comb(s-2*i-1,i-1)
print(ans%(10**9+7))

Measured memory_bytes: 9128
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int main(){
  int n, a[3];
  cin >> n >> a[0] >> a[1] >> a[2];
  vector<string> s(n);
  for(int i = 0; i < n; ++i){
  	cin >> s[i];
  }

  int flg = 1;
  vector<char> ans;
  if(a[0] + a[1] + a[2] == 0)flg = 0;
  else if(a[0] + a[1] + a[2] == 1){
  	for(int i = 0; i < n; ++i){
  		char fst = s[i][0] - 'A';
  		char scd = s[i][1] - 'A';
  		if(a[fst] == 0 && a[scd] == 0){
  			flg = 0;
  			break;
  		}
  		if(a[fst]){
  			--a[fst];
  			++a[scd];
  			ans.push_back(s[i][1]);
  		}
  		else{
  			++a[fst];
  			--a[scd];
  			ans.push_back(s[i][0]);
  		}
  	}
  }
  else{
  	for(int i = 0; i < n; ++i){
  		char fst = s[i][0] - 'A';
  		char scd = s[i][1] - 'A';
  		if(a[fst] == 0 && a[scd] == 0){
  			flg = 0;
  			break;
  		}
  		if(a[fst] == 0){
  			++a[fst];
  			--a[scd];
  			ans.push_back(s[i][0]);
  		}
  		else if(a[scd] == 0){
  			--a[fst];
  			++a[scd];
  			ans.push_back(s[i][1]);
  		}
  		else{
  			if(i < n - 1){
  				char nfst = s[i + 1][0] - 'A';
  				char nscd = s[i + 1][1] - 'A';
  				if(fst == nfst || fst == nscd){
  					++a[fst];
  					--a[scd];
  					ans.push_back(s[i][0]);
  				}
  				else{
  					--a[fst];
					++a[scd];
					ans.push_back(s[i][1]);
  				}
  			}
  			else{
  				++a[fst];
				--a[scd];
				ans.push_back(s[i][0]);
  			}
  		}
  	}
  }

  if(flg){
  	cout << "Yes" << endl;
  	for(int i = 0; i < n; ++i)cout << ans[i] << endl;
  }
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 6724
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}



int main() {

	/*string s; cin >> s;
	int a,b,c; cin >> a;
	vector<string>ss;*/
	Int n, s, t; cin >> n>>s>>t;
	if (s + t - n > 0) {
		cout << s + t - n;
	}
	else cout << 0;

	cout << endl;
	return 0;
}


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

int main(void)
{
    char ch1,ch2;
    cin>>ch1>>ch2;
    if(ch1<ch2)
    {
        cout <<"<"<<endl;
    }
    else if(ch1==ch2)
    {
        cout<<"="<<endl;
    }
    else
    {
        cout<<">"<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
   int sec,h,m;
   cin >> sec;
   h = sec / 3600;
   sec = sec - h * 3600;
   m = sec / 60;
   sec = sec - m * 60;
   cout << h << ":" << m <<":" << sec << endl;
}


Measured memory_bytes: 3084
import java.io.CharArrayReader;
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
    int a = sc.nextInt();
    String op = sc.next();
    int b = sc.nextInt();
    char c = op.charAt(0);
    if(c == '+'){
      System.out.println(a + b);
    }else if(c == '-'){
      System.out.println(a - b);
    }else if(c == '*'){
      System.out.println(a * b);
    }else if(c == '/'){
      System.out.println(a / b);
    }else if(c == '?'){
      break;
    }
  }
  }
}



Measured memory_bytes: 26316
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuffer oddStr = new StringBuffer();

        for (int i = 0; i < s.length(); i+=2) {
            oddStr.append(s.charAt(i));
        }
        System.out.println(oddStr.toString());
    }
}

Measured memory_bytes: 24184
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = (1 << 11), K = 11;
int n, k, q, a[N], val[N], used[N], m;
vector <int> pos[N];
int par[N];
multiset <int> st[N];

struct Fen {
	int f[N], sz = 0;
	Fen() {
		memset(& f, 0, sizeof(f));
	}
	void upd(int x, int y) {
		sz += y;
		for (; x < (1 << K); x |= (x + 1))
			f[x] += y;
	}
	int kth(int k) {
		if (sz < k)
			return -1;
		int cur = 0, s = 0;
		for (int i = (1 << (K - 1)); i > 0; i >>= 1)
			if (s + f[cur + i - 1] < k)
				s += f[cur + i - 1], cur += i;
		return cur;
	}
};
Fen F;

void upd(int x) {
	while ((int)st[x].size() > k - 1) {
		F.upd(*st[x].begin(), 1);
		st[x].erase(st[x].begin());
	}
}

void make_set(int x) {
	par[x] = x;
	st[x].insert(a[x]);
}

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

void union_set(int x, int y) {
	x = find_set(x), y = find_set(y);
	if (x == y) return;
	if ((int)st[x].size() < (int)st[y].size())
		swap(x, y);
	par[y] = x;
	for (int i : st[y])
		st[x].insert(i);
	st[y].clear();
	upd(x);
}

void add(int x) {
	upd(x);
	used[x] = 1;
	if (used[x - 1])
		union_set(x - 1, x);
	if (used[x + 1])
		union_set(x, x + 1);
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> k >> q;
	vector <int> b;
	for (int i = 1; i <= n; i++) cin >> a[i], b.pb(a[i]);
	sort(all(b));
	b.erase(unique(all(b)), b.end());
	m = b.size();
	for (int i = 1; i <= n; i++) {
		int x = lower_bound(all(b), a[i]) - b.begin() + 1;
		val[x] = a[i];
		a[i] = x;
		pos[x].pb(i);
		make_set(i);
	}
	int ans = 1e9;
	for (int i = m; i >= 1; i--) {
		for (int j : pos[i])
			add(j);
		int x = F.kth(q);
		if (x != -1)
			ans = min(ans, val[x] - val[i]);
	}
	cout << ans;
}


Measured memory_bytes: 4004
#include<iostream>
#include<cstdio>
void Blast (int MAP[8][8],int Y,int X);
using namespace std;
int main(){
    int x,y,n,Map[8][8];
    char in[9][8];
    cin>>n;

    for(int i=1;i<=n;i++){
        for(int j=0;j<8;j++){
            for(int k=0;k<8;k++){
                cin>>in[j][k];
                Map[j][k]=in[j][k] - '0';
            }
        }
        cin>>x>>y;

        Blast(Map,y-1,x-1);

        cout<<"Data "<<i<<":"<<endl;
        for(int j=0;j<8;j++){
            for(int k=0;k<8;k++){
                cout<<Map[j][k];
            }
            cout<<endl;
        }
    }
    return 0;
}

void Blast (int MAP[8][8],int Y,int X)
{
    int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
    MAP[Y][X]=0;
    for(int i=1;i<=3;i++){
        for(int j=0;j<4;j++){
            int ny=Y+dy[j]*i;
            int nx=X+dx[j]*i;
            if(MAP[ny][nx]==1&&ny>=0&&nx>=0&&ny<8&&nx<8){
                Blast(MAP,ny,nx);
            }
        }
    }
    return;
}

Measured memory_bytes: 1164
//ABC122 D
#include <iostream>
#include <vector>


void print(std::vector<std::vector<long long>> table){
 for(int i=0;i<table.size();i++){
  for(int j=0;j<table[i].size();j++){
   std::cout<<table[i][j]<<" ";
  }
  std::cout<<std::endl;
 }
}

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

/*
 long long neutral=1;
 long long a=0;
 long long ag=0;
 //long long agc=0;
 long long g=0;
 long long ga=0;
 //long long gac=0;
 long long ac=0;
 //long long acg=0;

 long long mod=1000000007;
 
 for(int i=0;i<N;i++){
  neutoral=neutoral*2+a+ag; //T,C
  a=neutoral+a+
 }
*/
 //a+4b+16c
 //A=0,C=1,G=2,T=3
 std::vector<std::vector<long long>> table(N,std::vector<long long>(4*4*4,0));
 //print(table);

 long long ans=0;
 long long mod=1000000007;
 for(int i=0;i<64;i++){
  if(i==1+4*2 || i==1+16*2 || i==2+4){
  }else{
   table[2][i]=1;
  }
 }

 for(int i=3;i<N;i++){
  for(int a=0;a<4;a++){
   for(int b=0;b<4;b++){
    for(int c=0;c<4;c++){
     for(int d=0;d<4;d++){
      if(a==1 && b==2 && c==0){
      }else if(a==1 && c==2 && b==0){
      }else if(a==2 && b==1 && c==0){
      }else if(a==1 && b==2 && d==0){
      }else if(a==1 && c==2 && d==0){
      }else{
       table[i][a+4*b+16*c]+=table[i-1][b+4*c+16*d];
       table[i][a+4*b+16*c]%=mod;
      }
     }
    }
   }
  }
 }
 for(int i=0;i<64;i++){
  ans+=table[N-1][i];
  ans%=mod;
 }
 //print(table);
 std::cout<<ans<<std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<map>

using namespace std;

int main(){
  int n;cin >> n;
  string w[n];
  map<string, int> m;
  bool ok = true;
  char p;
  for(int i=0;i < n;i++){
    cin >> w[i];
    if(m[w[i]])ok= false;
    m[w[i]] = 1;
    
    if(i){
      if(p != w[i][0])ok = false;
    }
    p = w[i][w[i].size()-1];
  }
  cout << (ok ? "Yes" : "No") << endl;
  
}


Measured memory_bytes: 256
using System;

class Problem
{
  public static void Main(string[] args)
  {
    var n = Console.ReadLine();
    if ((n[0] == n[1] && n[0] == n[2]) || (n[1] == n[2] && n[1] == n[3])) Console.WriteLine("Yes");
    else Console.WriteLine("No");
  }
}


Measured memory_bytes: 13140
class UnionFind:
    def __init__(self, elems):
        self.parent = dict()
        for e in elems:
            self.parent[e] = e

    def root(self, e):
        if self.parent[e] == e:
            return e

        self.parent[e] = self.root(self.parent[e])
        return self.parent[e]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        if self.same(x, y):
            return

        rx = self.root(x)
        ry = self.root(y)
        self.parent[rx] = ry


n, k, l = map(int, input().split())
uf1 = UnionFind(list(range(n)))
uf2 = UnionFind(list(range(n)))

for i in range(k):
    a, b = map(lambda x: int(x) - 1, input().split())
    uf1.unite(a, b)

for i in range(l):
    a, b = map(lambda x: int(x) - 1, input().split())
    uf2.unite(a, b)


ps = [(uf1.root(i), uf2.root(i)) for i in range(n)]
counts = dict()
for p in ps:
    if p in counts:
        counts[p] += 1
    else:
        counts[p] = 1


nums = [counts[p] for p in ps]
print(' '.join(map(str, nums)))

Measured memory_bytes: 85684
t = input()
a = int( t[0])*10+int(t[1])
b = int( t[2])*10 + int( t[3])
if 1 <= a <= 12:
    if 1 <= b <= 12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
else:
    if 1 <= b <= 12:
        ans = "YYMM"
    else:
        ans = "NA"
print(ans)

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main() {
	int x[3001], y[3001];
	int i = 0;

	while (1) {
		cin >> x[i] >> y[i];
		if (x[i] == 0 && y[i] == 0) {
			break;
		}
		i++;
	}

	for (int j = 0;j < i;j++) {
		if (y[j] < x[j]) {
			int box;
			box = y[j];
			y[j] = x[j];
			x[j] = box;
		}
		cout << x[j] << " " << y[j] << endl;
	}


	return 0;
}


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

int n;
std::vector<int> h;
void input()
{
    std::cin>>n;
    h.resize(n);
    for(int i=0;i<n;i++)std::cin>>h[i];
}

int main()
{
    input();
    bool res = true;
    for(int i=n-2;i>=0;i--){
        if(h[i]>h[i+1]){
            if(h[i]==h[i+1]+1)h[i]--;
            else res = false;
        }
    }
    std::cout<<(res?"Yes":"No")<<std::endl;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>


using namespace std;
const int MOD = 1000000009; // check!!!
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)
#define tenll(x) ((ll)1e##x)

int a[100][100];
int b[101][101];

int main(){

	int n; cin>>n;
	FOR(i,n) FOR(j,n) cin>>a[i][j];

	int ans = -INF;
	FOR(i,n){
		int s[101] = {};
		FOR(j,n) s[j+1] = s[j] + a[i][j];
		FOR(j,n) for(int k = j; k < n; k++){
			b[j][k] = max(0,b[j][k]) + s[k+1] - s[j];
			ans = max(ans,b[j][k]);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1240
#include <iostream>

int main() {
    int x, y;
    std::cin >> x >> y;

    if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) {
        if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
            std::cout << "Yes" << std::endl;
        } else {
            std::cout << "No" << std::endl;
        }
    } else if(x == 4 || x == 6 || x == 9 || x == 11) {
        if(y == 4 || y == 6 || y == 9 || y == 11) {
            std::cout << "Yes" << std::endl;
        } else {
            std::cout << "No" << std::endl;
        }
    } else {
        std::cout << "No" << std::endl;
    }
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, Q;
  scanf("%d %d", &N, &Q);
  vector<ll> A(N), X(N);
  for (int i = 0; i < N; ++i) { scanf("%lld", &A[i]); }
  for (int i = 0; i < Q; ++i) { scanf("%lld", &X[i]); }

  for (int i = 0; i < Q; ++i) {
    ll x = X[i];
    ll sum = 0, ans = 0;
    for (int left = 0, right = 0; left < N; ++left) {
      while (right < N and sum + A[right] <= x) {
        sum += A[right];
        ++right;
      }
      ans += (right - left);
      sum -= A[left];
    }
    printf("%lld\n", ans);
  }
  return 0;
}



Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N; cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) cin >> s[i];
  
  queue<int> AB,A,B,C;
  
  for (int i = 0; i < N; i++) {
    int n = s[i].size();
    if (s[i][0] == 'B' && s[i][n-1] == 'A') AB.push(i);
    else if (s[i][n-1] == 'A') A.push(i);
    else if (s[i][0] == 'B') B.push(i);
    else C.push(i);
  }
  
  string t;
  while (!AB.empty()) {
    t = t + s[AB.front()];
    AB.pop();
  }
  if (!A.empty()) {
    t = s[A.front()] + t;
    A.pop();
  }
  if (!B.empty()) {
    t = t + s[B.front()];
    B.pop();
  }
  while (!A.empty() && !B.empty()) {
    t = t + s[A.front()] + s[B.front()];
    A.pop(); B.pop();
  }
  
  while(!A.empty() || !B.empty() || !C.empty()) {
    if (!A.empty()) {
      t = t + s[A.front()];
      A.pop();
    }
    if (!B.empty()) {
      t = t + s[B.front()];
      B.pop();
    }
    if (!C.empty()) {
      t = t + s[C.front()];
      C.pop();
    }
  }
  
  int count = 0;
  for (int i = 1; i < t.size(); i++) {
    if (t[i] == 'B' && t[i-1] == 'A') count++;
  }
  cout << count << endl;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ll long long

int main(){
	ll n, m;
	cin >> n >> m;
	vector<ll> c(m, 0);
	REP(i, n){
		ll k;
		cin >> k;
		REP(j, k){
			ll temp;
			cin >> temp;
			temp -= 1;
			c[temp] += 1;
		}
	}
	ll ans = 0;
	REP(i, m){
		if (c[i] == n){ans += 1;}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
        "fmt"
        "math"
)

func main() {
        var n int
        fmt.Scanf("%d", &n)
        fmt.Printf("%d\n", find(n))
}

func find(n int) int {
        var num int
        for i := 1; i <= n; i++ {
                if i%2 == 1 && divisorNumIs(i, 8) {
                        num++
                }
        }
        return num
}

func divisorNumIs(n, divisor int) bool {
        life := divisor - 2
        limit := int(math.Sqrt(float64(n)))
        for i := 2; i <= limit+1; i++ {
                if n%i == 0 {
                        if n/i == i {
                                life--
                        } else {
                                life -= 2
                        }
                }
                if life < 0 {
                        break
                }
        }
        return life == 0
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[4];
    rep(i,2){
        cin >> A[i];
    }
    //sort(A,A+3);
    cout << A[1]+A[1]-A[0] << endl;
}

// int main(){
//     char X[3],Y[3];cin >> X >> Y;
//     cout <<(X[0]==Y[2] && X[1]==Y[1] && X[2]==Y[0] ? "YES" : "NO")<<endl;;
// }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  string A;
  map<string,int> gacha;
  
  for(int i = 0;i < N;i++){
  cin >> A;
  gacha[A]++;
  }
  cout << gacha.size() << endl;
}

Measured memory_bytes: 19180
fn main() {
    let mut buf = String::new();
    let _ = std::io::stdin().read_line(&mut buf).ok();
    let n: usize = buf.trim().parse().unwrap();
    let mut v = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        let _ = std::io::stdin().read_line(&mut buf).ok();
        let mut buf = buf.split_whitespace();
        let m: usize = buf.next().unwrap().parse().unwrap();
        let n: usize = buf.next().unwrap().parse().unwrap();
        v.push((m,n));
    }
    
    let mut board = [[true; 8]; 8];
    let mut row   = [true; 8];
    let mut diag0 = [true; 15];
    let mut diag1 = [true; 15];
    let mut sol = Vec::new();
    solver(0, &mut board, &mut row, &mut diag0, &mut diag1, &mut sol);
    for s in sol {
        if check_sol(&s, &v) {
            print_board(&s);
        }
    }
    //println!("{:?}",v);
    //println!("{:?}",sol);
}

fn solver(col: usize, board: &mut [[bool; 8]; 8], row: &mut [bool; 8], diag0: &mut [bool; 15], diag1: &mut [bool; 15], sol: &mut Vec<[[bool; 8]; 8]>) {
    if col == 8 {
        sol.push(*board);
    } else {
        for i in 0..8 {
            if row[i] && diag0[col + i] && diag1[col + 7 - i] {
                row[i] = false;
                diag0[col + i] = false;
                diag1[col + 7 - i] = false;
                board[col][i] = false;
                solver(col+1, board, row, diag0, diag1, sol);
                row[i] = true;
                diag0[col + i] = true;
                diag1[col + 7 - i] = true;
                board[col][i] = true;
            }
        }
    }
}

fn print_board(board: &[[bool; 8]; 8]) {
    for s_row in board.iter() {
        for grid in s_row {
            if *grid {
                print!(".");
            } else {
                print!("Q");
            }
        }
        println!()
    }
}

fn check_sol(board: &[[bool; 8]], con: &Vec<(usize, usize)>) -> bool {
    for c in con {
        if board[c.0][c.1] {
            return false;
        }
    }
    true
}



Measured memory_bytes: 5028
for(r={I:1,V:5,X:10,L:50,C:100,D:500,M:1000},k=n=s=0;p=n,i=require("fs").readFileSync("/dev/stdin","utf8")[k++];)(n=r[i])?n>p?s+=n-2*p:s+=n:(console.log(s),s=0)

Measured memory_bytes: 10144
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N;
int main(){
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    int ct = 0;
    ll i = 2;
    bool flag = false;
    while(1){
        rep(j,N) if(A[j]%i) flag = true;
        if(flag) break;
        else ct++, i *= 2;
    }
    cout << ct << endl;
}

Measured memory_bytes: 256
#165 
#C

from itertools import *

n,m,q = map(int, input().split())
# n,m,q = 3,4,3
# ln_condi = [[1, 3, 3, 100], [1, 2, 2, 10], [2, 3, 2, 10]]
ln_condi  = []
for i in range(q):
    ln_condi.append(list(map(int, input().split())))
#print(ln_condi)
p = list(range(1,m+1))
a = list(combinations_with_replacement(p,n))
#print(a)
summax  = 0
for i in a:
    sumd = 0
    for j in range(q):
        if i[ln_condi[j][1]-1] - i[ln_condi[j][0]-1] == ln_condi[j][2]:
            sumd +=  ln_condi[j][3]
    if sumd > summax:
        summax = sumd
print(summax)    


Measured memory_bytes: 21616
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
    long long int N, A, B;
    cin >> N >> A >> B;
    long long int l = (N / (A + B));
    long long int n = l * A;
    long long int k = N % (A + B);
    if (k < A)
    {
        n += k;
    }
    else
    {
        n += A;
    }
    cout << n << endl;
    return 0;
}

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

using namespace std;

int main(void){
//	FILE* fp_in = freopen("data.txt", "r", stdin);

	unsigned long long int N;
	cin >> N;
		
	int tmp = 1;
	int ans = 0;
	for(; tmp < N;) {
		tmp *= 3;
		ans ++;
	}
	cout << ans << endl;



//	while(1){}

	return 0;
}

Measured memory_bytes: 1156
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;

ll f(ll b, ll n) {
  ll ans = 0;
  while (n > 0) {
    ans += n % b;
    n = n / b;
  }
  return ans;
}

int main() {
  //
  ll n, s;
  cin >> n >> s;

  if (s == n) {
    cout << n + 1 << endl;
    return 0;
  }

  ll nsq = sqrt(n);
  for (ll b = 2; b <= nsq; b++) {
    if (f(b, n) == s) {
      cout << b << endl;
      return 0;
    }
  }
  ll ans = INF;
  for (ll p = 1; p <= nsq; p++) {
    ll b = (n - s) / p + 1;
    if (b < 2) {
      continue;
    }
    if (f(b, n) == s) {
      ans = min(ans, b);
    }
  }
  if (ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


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

namespace debug
{
    public static partial class Program
    {
        public static void Main()
        {
            var lr = Console.ReadLine().ToLongArray();
            var l = lr[0];
            var r = lr[1];

            var min = long.MaxValue;
            for (var i = l; i <= Math.Min(r, l + 2019); i++)
            {
                for (var j = i + 1; j <= Math.Min(r, l + 2019); j++)
                {
                    min = Math.Min(min, i * j % 2019);
                }
            }

            Console.WriteLine(min);
        }
    }

    public static partial class Program
    {
        //テンプレここから
        private static long GCD(long aaa, long bbb) => bbb == 0 ? aaa : GCD(bbb, aaa % bbb);
        private static long LCM(long aaa, long bbb) => aaa * bbb / GCD(aaa, bbb);
        private static long ToLong(this double ddd) => (long) ddd;
        private static long ToLong(this string str) => long.Parse(str);
        private static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
        private static long[] ToLongArray(this string str, char opr = ' ') => str.Split(opr).ToLong();
        private static long Diff(long aaa, long bbb) => Math.Abs(Math.Max(aaa, bbb) - Math.Min(aaa, bbb));
        private static long Sign(this long iii) => Math.Sign(iii);
        private static bool IsEven(this long iii) => iii % 2 == 0;
        private static readonly int[] _Dx = {0, -1, 0, 1};
        private static readonly int[] _Dy = {-1, 0, 1, 0};
        public const int MOD = 1000000007;
        public const string UPPER_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        public const string LOWER_ALPHABET = "abcdefghijklmnopqrstuvwxyz";
        private static long ToLong(this char ccc) => ccc.ToString().ToLong();
        private static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
        private static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

        private static string JoinToStr(this IEnumerable<long> array, string sep = "")
            => array.Select(xxx => xxx.ToString()).Join(sep);

        public static string JoinToStr(this IEnumerable<int> array, string sep = "")
            => array.Select(xxx => xxx.ToString()).Join(sep);

        //テンプレここまで
    }
}

Measured memory_bytes: 13396
MOD = 1000000007

def violate(s):
    if s[1:] == 'GAC' or s[1:] == 'ACG' or s[1:] == 'AGC':
        return True
    if s[:3] == 'GAC' or s[:3] == 'ACG' or s[:3] == 'AGC':
        return True
    if s[0] == 'A' and s[2:] == 'GC':
        return True
    if s[:2] == 'AG' and s[3] == 'C':
        return True
    return False

def dfs(i, s):
    if s in memo[i]:
        return memo[i][s]
    if i == n:
        return 1
    ret = 0
    for c in 'ATGC':
        if not violate(s + c):
            ret = (ret + dfs(i + 1, s[1:] + c)) % MOD
    memo[i][s] = ret
    return ret

if __name__ == '__main__':
    n = int(input())
    memo = []
    for _ in range(n + 1):
        memo.append({})

    print(dfs(0, 'TTT'))


Measured memory_bytes: 3880
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    ll a, b;
    cin >> a >> b;

    exrep(i, 1, 100000) {
        ll x = 0.08*(double)i;
        ll y = 0.1*(double)i;
        if(x == a && y == b) {
            out(i);
            re0;
        }
    }
    
    out(-1);
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> vp;
    unordered_map<int, int> um;
    for (int i = 1; i * i <= n; i++) {
        um[i] = i;
        um[n / (i + 1) + 1] = n / i;
    }
    for (auto p : um) {
        vp.push_back(p);
    }
    sort(vp.begin(), vp.end());
    const int mod = 1e9 + 7;
    int l = vp.size();
    vector<long long int> v1(l, 0), v2(l, 0);
    for (int i = 0; i < l; i++) {
        v1[i] = vp[i].second - vp[i].first + 1;
    }
    for (int i = 1; i < k; i++) {
        long long int s = 0;
        v2 = vector<long long int>(l, 0);
        for (int j = 0; j < l; j++) {
            s += v1[j];
            s %= mod;
            v2[l - 1 - j] += s * (vp[l - 1 - j].second - vp[l - 1 - j].first + 1);
            v2[l - 1 - j] %= mod;
        }
        
        v1 = v2;
    }
    cout << accumulate(v1.begin(), v1.end(), (long long int)0) % mod << endl;
}




Measured memory_bytes: 8088
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    map<string, int> ma;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        ma[s]++;
    }
    int m;
    cin >> m;
    int cnt = 1;
    for (int i = 0; i < m; ++i) {
        string t;
        cin >> t;
        if(ma.count(t)){
            printf(cnt%2 ? "Opened by " : "Closed by ");
            cnt++;
        }else {
            printf("Unknown ");
        }
        cout << t << "\n";
    }
    return 0;
}



Measured memory_bytes: 3332
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
int main() {
    ll n, k; cin >> n >> k;
    vector<P> array(n);
    rep(i, n) cin >> array[i].first >> array[i].second;
    sort(array.begin(), array.end());
    ll sum = 0;
    rep(i, n) {
        sum += array[i].second;
        if(k <= sum) {
            cout << array[i].first << endl;
            return 0; 
        }
    }
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = sc.nextInt();
    for(int i = 1; i < n; i++) {
      int a = sc.nextInt();
      ans = gcd(ans, a);
    }
    System.out.println(ans);
  }

  public static int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, (a % b));
  }
}

Measured memory_bytes: 48716
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace ARC090
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(Int);
            var A1 = ss.Next(Int, N);
            var A2 = ss.Next(Int, N);

            var max = 0;
            for (var i = 0; i < N; i++)
            {
                max = Math.Max(max, A1.Take(i + 1).Sum() + A2.Skip(i).Sum());
            }

            sw.WriteLine(max);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
        static readonly Func<string, int> Int = int.Parse;
        static readonly Func<string, long> Long = long.Parse;
        static readonly Func<string, double> Double = double.Parse;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 13780