akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;

int f(int X) {
	string s = to_string(X);
	int sum = 0;
	for(auto c : s) {
		sum += c - '0';
	}
	return sum;
}

int main() {
	int X;
	cin >> X;
	if(X % f(X) == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_set>
 
using namespace std;
 
int main () {
  int H, W;
  cin >> H >> W;
  string data[H];

  for (int i = 0; i < H; i++) {
    string tmp;
    cin >> tmp;
    data[i] = tmp;
  }

  unordered_set<int> exclude_h;
  unordered_set<int> exclude_w;

  for (int h = 0; h < H; h++) {
    int flag = true;
    for (int w = 0; w < W; w++) {
      if (data[h][w] == '#') {
        flag = false;
        break;
      }
    }
    if (flag) {
      exclude_h.insert(h);
    }
  }

  for (int w = 0; w < W; w++) {
    int flag = true;
    for (int h = 0; h < H; h++) {
      if (data[h][w] == '#') {
        flag = false;
        break;
      }
    }
    if (flag) {
      exclude_w.insert(w);
    }
  }

  for (int h = 0; h < H; h++) {
    if (exclude_h.count(h) != 0) {
      continue;
    }
    for (int w = 0; w < W; w++) {
      if (exclude_w.count(w) != 0) {
        continue;
      }
      cout << data[h][w];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  long long int x[11],r,D,i;
scanf("%lld%lld%lld",&r,&D,&x[0]);
  for(i=0;i<11;i++)
  {
	x[i+1]=r*x[i]-D;
  }
  for(i=1;i<11;i++)
    printf("%lld\n",x[i]);
return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int a,b,c,n;
    while(~scanf("%d%d%d%d",&a,&b,&c,&n))
    {
        int sum=0,x,y,z;
        for(x=0; x<=a; x++)
        {
            for(y=0; y<=b; y++)
            {
                for(z=0; z<=c; z++)
                {
                    if(500*x+100*y+50*z==n)
                        sum++;
                }
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        a: usize,
        s: String,
    }
    if a >= 3200 {
        println!("{}", s);
    } else {
        println!("red");
    }
}


Measured memory_bytes: 4352
#include <iostream>

int main(){
        long long int a,count=1,mem,i=0;
        std::cin >> a;
        while(mem!=a) {
                if((a==4||a==2||a==1)&&i==0) {mem=a; i++;}
                if(a%2==0) a=a/2;
                else a=3*a+1;
                count++;
        }
        std::cout << count;
        return 0;
}


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

int main() {
    int n;
    std::cin >> n;
    std::set<int> nums;
    for (int i = 0, tmp; i < n; ++i) {
        std::cin >> tmp;
        nums.insert(tmp);
    }
    if (nums.size() == n) std::cout << "YES";
    else std::cout << "NO";
    return 0;
}

Measured memory_bytes: 12972
import java.util.Scanner;
public class Main {
	void run(){
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		String p = scan.next();
		int sLen = s.length();
		int pLen = p.length();
		for(int i = 0;i < sLen;i++){
			boolean check = true;
			for(int j = 0;j < pLen;j++){
				int index;
				if(sLen <= i + j){
					index = (sLen - (i + j)) * -1; 
				}else{
					index = i + j;
				}
				char sC = s.charAt(index);
				char pC = p.charAt(j);
				if(sC != pC){
					check = false;
					break;
				}
			}
			if(check){
				System.out.println("Yes");
				break;
			}else if(i == sLen - 1){
				System.out.println("No");
				break;
			}
		}
	}
	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 26280
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define For(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n, k; cin >> n >> k;

    int t = 1;
    int cnt = 0;
    while(t <= n){
        t *= k;
        cnt++;
    }

    cout << cnt << endl;
    

return 0;
}

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

int main(void)
{
    int n,k;
    cin>>n>>k;
    int ans=1;
    for(int i=1;i<=n;++i)
    {
        ans=min(ans*2,ans+k);
    }
    cout <<ans <<endl;
    return 0;
}


Measured memory_bytes: 256
//Author: Rahul Purohit

#include<bits/stdc++.h>
#define vi vector<int>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll  long long int
#define pi pair<ll,ll>
#define f first
#define mp make_pair
#define mod 1000000007
#define s second
#define pb push_back
#define mp make_pair
#define N 100001
using namespace std;
int gcd(int a, int b)
{
	if(b==0)
		return a;
	else
		return (b,a%b);
}
/*ll isp[N]={1};
void sieve(int n)
{
	isp[0]=isp[1]=0;
	for(int i=2;i<=n;i++)
	{
		if(isp[i]==1)
		{
			for(int j=i*i;j<=n;j+=i)
			{
				isp[j]==0;
			}
		}
	}
}*/
ll pow(int x,int  y,int m)
{
	ll ans=1;
	while(y!=0)
	{
		if(y%2==1)
		{
			ans=(ans*x)%m;
		}
		x=(x*x)%m;
		y/=2;
	}
	return ans;
}
template <class x>
void swap(x &a,x &b)
{
	x tp;
	tp=a;
	a=b;
	b=tp;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

    ll n;
    cin>>n;
    string a;
    cin>>a;
    ll temp=0;
    rep(i,0,n)
    {
        if(a[i]=='R')
        {
            ++temp;
        }
    }
    //cout<<temp<<endl;
    if(temp>n/2)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    if (n % 2 == 0) {
        printf("%.7lf\n", 0.5);
    } else {
        printf("%.7lf\n", (n / 2 + 1) / (double)n);
    }
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>

using namespace std;

int main(){

	int n, w, h, s, t;
	
	while(cin>>n, n){
		
		cin>>w>>h;
		
		bool field[600][600]={false};
		
		for(int i=0; i<n; ++i){
			int x, y;
			cin>>x>>y;
			field[x][y] = true;			
		}
		
		cin>>s>>t;
		
		int ma=0;
		
		for(int x=1; x<=w; ++x){
			for(int y=1; y<=h; ++y){
			
				int cnt=0;
				
				for(int dx=0; dx<s; ++dx){
					for(int dy=0; dy<t; ++dy){
						
						cnt+=field[x+dx][y+dy];
					}
				}
				
				ma = max(ma, cnt);
			}
		}
		
		cout << ma << endl;
	}
	
	return 0;
}

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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

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

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

int main(void)
{
    ll a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,W;
  cin>>n>>W;
  ll w[n],v[n];
  REP(i,n)
    cin>>w[i]>>v[i];

  ll dp[W+1];
  REP(i,W+1)dp[i]=0;

  REP(i,n){
    for(ll j=W; j>=0; j--){
      if(j+w[i]<=W)
        dp[j+w[i]] = max(dp[j+w[i]],dp[j]+v[i]);
    }
  }

  ll ans=0;
  REP(i,W+1)
    ans=max(ans,dp[i]);
  cout<<ans<<endl;

}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
int comp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}
int main() {
  int n,k,l[50],ans=0,i;
  scanf("%d %d",&n,&k);
  for (i=0; i<n; i++) {
    scanf("%d",&l[i]);
  }
  qsort(l, n, sizeof(int), comp);
  for (i=0; i<k; i++) {
    ans+=l[n-i-1];
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
s = input()
alpha = "abcdefghijklmnopqrstuvwxyz"
tmpset = set()
n = len(s)
if n != 26:
    for i in range(n):
        tmpset.add(s[i])
    for i in range(26):
        if alpha[i] not in tmpset:
            s = s + alpha[i]
            print(s)
            exit()
else:
    if s == "zyxwvutsrqponmlkjihgfedcba":
        print(-1)
    else:
        for i in range(n - 1, 0, -1):
            if s[i] > s[i - 1]:
                tmpset.add(s[i])
                for j in range(26):
                    if alpha[j] in tmpset:
                        if s[i - 1] < alpha[j]:
                            s = s[:i - 1] + alpha[j]
                            print(s)
                            exit()
            else:
                tmpset.add(s[i])


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define EPS (1e-5)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000
#define MAXB 40



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int hoge[MAXB+2] = {}, fuga[MAXB+2] = {};
	int t = 1ll<<MAXB, ans = 0;
	int N, K, num;
	
	cin>>N>>K;
	
	rep(i,N){
		cin>>num;
		for(int i = 0; num; i++,num >>= 1) hoge[i] += num&1;
	}
	

	
	for(int i = 0, r = 1; i <= MAXB; i++, r <<= 1){
		fuga[i] += max(hoge[i],N-hoge[i])*r;
		fuga[i+1] += fuga[i];
	}
		
	for(int i = MAXB, temp = 0; i >= 0; i--, t>>=1){
		if((K>>i)&1){
			if(i)ans = max(ans,temp+fuga[i-1]+hoge[i]*t);
			temp += (N-hoge[i])*t;
		} else temp += hoge[i]*t;
		if(!i) ans = max(ans,temp);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#include <time.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const int Nmax=2e5+1;
const int Nd=61;
const int INF=1e5;


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

  ll ans;
  ans=a*c;
  ans=max(a*d,ans);
  ans=max(b*c,ans);
  ans=max(b*d,ans);
  cout<<ans<<endl;
}


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

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

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair 

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
	if(debug_flag){
		cout<<str<<endl;
	}
}

void debugs(string str){
	if(debug_flag){
		cout<<str;
	}
}

long n=1, a=1, b=1, c=1, d=1;

bool check(int m){
	return m*c-(n-1-m)*d<=b-a && b-a<=m*d-(n-1-m)*c;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout.precision(10);

	cin>>n>>a>>b>>c>>d;
	for(int i=0; i<n-1; ++i){
		if(check(i)){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;

	return 0;
}



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

int main()
{
    int n ; cin >> n ;
    int x, ans;
    if(n%1000 == 0) x = n/1000;
    else x = n/1000 + 1;

    ans = x*1000 - n;
    cout << ans << endl;

}

Measured memory_bytes: 3592
// https://atcoder.jp/contests/arc069/tasks/arc069_b
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
const int MAXN = 1e5 + 4;
char s[MAXN];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cin >> s;
    s[n] = s[0], s[n + 1] = s[1];
    bitset<100005> a;
    REP(i, 4) {
        a[0] = i & 1, a[1] = (i >> 1) & 1;
        FOR(j, 2, n + 2) a[j] = (s[j - 1] == 'x') ^ a[j - 1] ^ a[j - 2];
        if (a[0] == a[n] && a[1] == a[n + 1]) {
            REP(j, n) cout << (a[j] ? "W" : "S");
            cout << "\n";
            return 0;
        }
    }
    cout << "-1\n";
    return 0;
}


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

int n;
int a[20];

int solve(int i,int m)
{
    if(m==0) return 1;
    if(i>=n) return 0;
    if(m<0) return 0;
    int res = solve(i+1,m) || solve(i+1,m-a[i]);
    return res;
}


int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }

    int q;
    cin>>q;
    for(int i=0;i<q;i++)
    {
        int m;
        cin>>m;
        if(solve(0,m))
        {
            cout<<"yes"<<endl;
        }
        else
        {
            cout<<"no"<<endl;
        }
        
    }
    return 0;
}



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

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

  vector<int> p(N);
  rep(i, N) {
    cin >> p[i];
    p[i]--;
  }
  p.push_back(0);

  int ans = 0;
  rep(i, N) {
    if (p[i] == i) {
      swap(p[i], p[i + 1]);
      ++ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
    int N;
    long long d[100];

    scanf("%d", &N);
    int i = 0;

    for(i = 0; i < N; i++){
        scanf("%lld", &d[i]);
    }
    long long sum = 0;
    int j = 0;
    for(i = 0; i < N; i++){
        for(j = i+1; j < N; j++){
            sum += d[i]*d[j];
        }
    }

    printf("%lld", sum);
  	return 0;

}

Measured memory_bytes: 128
// Created by ahmed_drawy on 11/09/19.
///dp educational contest atcoder
#include <bits/stdc++.h>
#include <string.h>
#pragma clang diagnostic push
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
using namespace std;
#define lp(i,start , end)       for(int i = start ; i<end ; ++i)
#define lllp(i,start , end)       for(ll i = start ; i<end ; ++i)
#define inN(arr ,  n) for(int i = 0 ; i< n ; ++i)  cin>>arr[i];
#define Rlp(i,start , end)      for(int i = start ; i>end ; --i)
#define all(v)                   ((v).begin(),(v).end())
#define sz(v)                  (int)((v).size())
#define clr(v,d)                memset(v , d , sizeof(v))
#define inf 0x3f3f3f3f
//#define dbg (v)    for(auto it : v)cout<<it<<' ';
typedef long long               ll;
typedef vector<int>             vi;
typedef vector  <ll>            vll;
typedef vector<vector<int> >    adj;
typedef pair<int ,int>          pii;
const double EPS =1e-7;
const int OO = 1e6;
#define endl '\n'
#define cint(c) (int)c -'0';
#define itc(c) (char)c +'A';
bool sortpair( const pair<int , int> & x, const pair<int , int> & y){
    return  x.first != y.first ? x.first < y.first : x.second > y.second ;
}
int dcomp(double x , double y){
    return fabs(x-y) <= EPS? 0: x>y?1:-1;
}

void smile() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
//    freopen("/home/tw3/Desktop/Desktop/training/in.txt", "r", stdin);
//    freopen("/home/tw3/Desktop/Desktop/training/out.txt" , "w" , stdout);
#endif
}
#define fastin smile()

int n , m;
const int N = 3000 +3;
ll dp[N][N];
string s, t;
ll lcs(int i , int j ){
    if(i == n || j ==m )
        return 0 ;
    ll &ret = dp[i][j];
    if(~ret)
        return ret;
    ret = 0;
    if(s[i] == t[j])
        ret =1 +  lcs(i+1 , j+1);
    else {
        ret = max(ret, lcs(i + 1, j));
        ret = max(ret, lcs(i, j + 1));
    }
    return ret;
}
void build(int i , int j){
    if(i == n || j ==m )
        return  ;
    if(s[i] == t[j]) {
        cout << s[i];
        build(i+1, j+1);
        return ;
    }
    if(dp[i+1][j] > dp[i][j+1] )
        build(i+1, j);
    else build(i, j+1);
    return ;

}
int main() {
    fastin;
    cin >> s >> t;
    n = sz(s), m = sz(t);
    for (int k = 0; k < n; ++k) {
        dp[k][m] = 0 ;
    }
    for (int k = 0; k < m; ++k) {
        dp[n][k] = 0 ;
    }
    for (int i = n-1; i >=0 ; --i) {
        for (int j = m-1; j>=0 ; --j) {
            ll &ret = dp[i][j];
            ret = 0;
            if(s[i] == t[j])
                ret =1 +  dp[i+1][j+1];
            else {
                ret = max(ret, dp[i + 1][j]);
                ret = max(ret, dp[i][j+1]);

            }
        }
    }
//    clr(dp , -1);
//    lcs(0,0);
    build(0,0);


}

Measured memory_bytes: 70912
// at_keyence2020b.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
int main()
{
    int n;cin >> n;
    vector<pair<ll, ll> >v;
    for (int i = 0;i < n;i++) {
        ll pos, arm;cin >> pos >> arm;
        v.push_back(make_pair(pos-arm,pos+arm));
    }
    sort(v.begin(), v.end());
    ll idx = 1e12;
    int out = 0;
    for (int i = n - 1;i >= 0;i--) {
        if (v[i].second <= idx) {
            out++;
            idx = v[i].first;
        }
    }
    cout << out << "\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N, K;
    cin >> N >> K;
    vector<int>Hs(N);
    for (int i=0; i<N; i++){
        cin >> Hs[i];
    }
    sort(all(Hs));
    int ans = pow(10,9);
    for (int i=0; i<N-K+1; i++){
        int hmax, hmin;
        hmax=Hs[i+K-1];
        hmin = Hs[i];
        chmin(ans, hmax - hmin);
    }
    cout << ans << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = {0, 1, 0, -1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'u', 'r', 'd', 'l'};
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

signed main() {
  char c;
  cin >> c;
  cout << ++c << endl;
  return 0;
}

Measured memory_bytes: 256
input()
num_list = raw_input().split()
num_list = map(int, num_list)

def selection_sort(num_list, count): 
    for i in range(0, len(num_list)):
        minj = i 
        for j in range(i, len(num_list)):
            if num_list[j] < num_list[minj]:
                minj = j 
                temp = num_list[minj]
        if minj != i:
            num_list[minj] = num_list[i]
            num_list[i]= temp
            count += 1
        i += 1
    return count, num_list

count = 0 
count, num_list = selection_sort(num_list, count)
num_list = map(str, num_list)
print " ".join(num_list)
print count

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

int main()
{
    long n, m; cin>>n>>m;
    string s, t; cin>>s>>t;
    if (n>m) {
        swap(n, m);
        swap(s, t);
    }

    auto g=__gcd(n, m);
    auto res=n*m/g;

    for(int i=0, j=0; i<n && j<m; i+=n/g, j+=m/g) {
        if (s[i]!=t[j]) {
            cout<<-1<<endl;
            return 0;
        }
    }

    cout<<res<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
void printvec(vector<int> a){
    rep(i, a.size()-1){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[a.size()-1]);
}
 
int main()
{
    int a, b;
    cin >> a>> b;
    printf("%d %d\n", a*b, 2*(a+b));
    return 0;
}


Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, K;
ll l[100];

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

  rep( i, N )
    std::cin >> l[i];

  std::sort( l, l+N, std::greater<ll>() );

  ll ans = 0;

  rep( i, K )
    ans += l[i];

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3568
X,N = map(int,input().split())
p = list(map(int,input().split()))

p.sort()
if X not in p or p == []:
    print(X)
else:
    idx = p.index(X)
    for i in range(1,idx+2):
        if i == idx+1:
            before = p[0] - 1
            break
        if p[idx - i +1] - p[idx - i] == 1:
            continue
        else:
            before = p[idx-i+1] -1
            break
    for i in range(1,N-idx+1):
        if i == N-idx:
            after = p[-1] + 1
            break
        if p[idx + i] - p[idx + i -1] == 1:
            continue
        else:
            after = p[idx + i - 1] +1
            break
    if X-before > after-X:
        print(after)
    else:
        print(before)

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

int main(){
  string s;
  cin>>s;
  int num = s.length();
  vector<int> nums(num);
  int cnt = 0;
  for(int i=0;i<s.length();i++){
    if(s[i] == 'L'){
      nums[i] += cnt/2;
      nums[i-1] += cnt/2;
      nums[i-1] += cnt%2;
      cnt = 0; 
    } else {
      cnt++;
    }
  }
  cnt = 0;
  for(int i=s.length()-1;i>=0;i--){
    if(s[i] == 'R'){
      nums[i] += cnt/2;
      nums[i+1] += cnt/2;
      nums[i+1] += cnt%2;
      cnt = 0; 
    } else {
      cnt++;
    }
  }
  for(int i=0;i<s.length();i++) cout<<nums[i]<<" ";cout<<endl;
  return 0;
}

Measured memory_bytes: 1024
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    n = str(n)
    if "7" in n:
        print("Yes")
    else:
        print("No")




if __name__=="__main__":
    main()


Measured memory_bytes: 9436
/*
ID: lalitkumar__
TASK: A
LANG: C++14
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
//	freopen("beads.in","r",stdin);
//	freopen("beads.out","w",stdout);

int x,y;
cin>>x>>y;
if(x==1 && y==1)
{  int xx = 300000+300000+400000;
	cout<<xx<<endl;
	return 0;
}
int ans = 0;
if(x==1)
{
	ans+=300000;
}
if(x==2)
{
	ans+=200000;
}
if(x==3)
{
	ans+=100000;
}
if(y==1)
{
	ans+=300000;
}
if(y==2)
{
	ans+=200000;
}
if(y==3)
{
	ans+=100000;
}
cout<<ans<<endl;


}

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

const int INF = 1e9;

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

    int n;
    cin >> n;
    vector<double> p(n);
    for (int i = 0; i < n; i++)
        cin >> p[i];
    vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0));
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            if (j) dp[i][j] = dp[i - 1][j - 1] * p[i - 1];
            dp[i][j] += dp[i - 1][j] * (1 - p[i - 1]);
        }
    }
    double ans = 0;
    for (int i = 0; i <= n; i++) {
        if (i > n / 2)
            ans += dp[n][i];
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 73676
n=int(input())
s=list(input())
ans=s.count('R')*s.count('G')*s.count('B')
for i in range(n):
    if s[i]=='R':
        s[i]=1
    elif s[i]=='G':
        s[i]=2
    elif s[i]=='B':
        s[i]=4
for i in range(n):
    for j in range(i+1,n):
      k=2*j-i
      if k>=n:
        continue
      if s[i]+s[j]+s[k]==7:
          ans-=1
print(ans)

Measured memory_bytes: 9120
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}



int main(void){
	int n;cin>>n;ll a;
	vector<ll> A;
	ll ans = LINF;
	ll sum = 0;
	rep(i,n){
		cin>>a;
		A.push_back(a);
		sum += a;
		if(i!=0) A[i] += A[i-1];
	}
	rep(i,n-1){
		ans = min(ans, abs(sum - 2 * A[i]));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll gcd(ll a,ll b){
	return(a==0)?b:gcd(b%a,a);
}
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t;
    cin>>t;
    ll a,ans=1;
    for(int i=0;i<t;++i){
    	cin>>a;
   		ans=lcm(ans,a);
   	}
   	cout<<ans;
   	return 0;
}

Measured memory_bytes: 3584
import Data.Fixed (Milli)

kai :: [Milli] -> String
kai [a,b,p,c,d,q]  = unwords $ map show
                   [(p*d - b*q)/(a*d - b*c)
                   ,(a*q - p*c)/(a*d - b*c)]

outp n s = do
  if (length s) <= n then return ()
  else do
    putStrLn $ kai $ s !! n
    outp (n + 1) s

main = do
  s <- getContents
  let s' = map (map (read :: String -> Milli)) $ (map words. lines) s

  outp 0 s'

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {}

int main(void) {
  int a,b;cin>>a>>b;
  string s;cin>>s;
  for(int i=0;i<a+b+1;++i) {
    if(i==a) {
      if(s[i]!='-') {
        pr("No");
        return 0;
      }
    } else {
      if(s[i]=='-') {
        pr("No");
        return 0;
      }
    }
  }
  pr("Yes");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(void){
  int N;
  cin >> N;
  int a[110];
  for(int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N, greater<int>());
  int Alice = 0, Bob = 0;
  for(int i = 0; i < N; i++){
    if(i % 2 == 0){
      Alice += a[i];
    }
    else{
      Bob += a[i];
    }
  }
  cout << Alice - Bob << endl;
  return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<algorithm>
using namespace std;
char a[2005][2005];
int num[2005][2005];
int main()
{
    int h,w;
    scanf("%d%d",&h,&w);
    getchar();
    for(int i=0; i<h; i++)
    {
        scanf("%s",a[i]);
    }
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            int cnt=0,k=j;

            while(1)
            {
                if(a[i][k]=='#'||k>w-1)
                {
                    break;
                }

                cnt++;
                k++;
            }
            int s=j;
            for(int l=j; l<j+cnt; l++)
            {
                num[i][s]+=cnt;
                s++;
            }
            j+=cnt;

        }
    }

    int maxx=0;
    for(int j=0; j<w; j++)
    {
        for(int i=0; i<h; i++)
        {
            int cnt=0,k=i;
            while(1)
            {
                if(a[k][j]=='#'||k>h-1) break;
                cnt++;
                k++;
            }
            int s=i;
            for( int l=i; l<i+cnt; l++)
            {
                num[s][j]+=cnt-1;
                s++;
            }
            i+=cnt;
        }
    }
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            maxx=max(maxx,num[i][j]);
        }
    }
    printf("%d\n",maxx);
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    for (int i = 0; i < n - 1; i++){
        if (a[i] == i + 1) {
            swap(a[i], a[i+1]);
            ans++;
        }
    }
    if (a.back() == n) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll;
#define rll register ll
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// input a signed integer
	template <class I>
	inline void read (I &x, int p) {
		for (c = gc(); c < '0' || c > '9'; c = gc()) ;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = ( (x << 1) + (x << 3) + (c & 15) ) % p; 
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	// no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} 
using io :: gi;
using io :: read;
using io :: putc;
using io :: print;
const int N=20;
const ll inf=1e18;
int a[N];
#define pii pair<int,int>
#define mp make_pair
map<pii,ll> f[N][N];
inline ll dfs(ri i,ri j,ri x,ri y){
	if(f[i][j].find(mp(x,y))!=f[i][j].end())
		return f[i][j][mp(x,y)];
	if(i+1==j) return 0;
	rll ans=inf;
	for(ri k=i+1;k<=j-1;++k)
		ans=min(ans,(ll)a[k]*(x+y)+dfs(i,k,x,x+y)+dfs(k,j,x+y,y));
	return f[i][j][mp(x,y)]=ans;
}
int main(){
	ri n,i;
	gi(n);
	for(i=1;i<=n;++i) gi(a[i]);
	printf("%lld\n",dfs(1,n,1,1)+a[1]+a[n]);
    return 0;
}


Measured memory_bytes: 18560
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();

        String[] str = br.readLine().split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);

        int d = a / b;
        int r = a % b;
        String f = String.format("%.6f",(double) a / b);

        sb.append(d).append(" ").append(r).append(" ").append(f).append("\n");
        System.out.println(sb);
    }
}

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

int main()
{
	string S;
	int w;
	cin >> S >> w;
	string ans;
	for (int i = 0; i < S.size(); i += w) ans += S[i];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
    	char p1,p2;cin>>p1>>p2;
    	if(p1<p2) cout<<"<"<<endl;
    	else if(p1>p2) cout<<">"<<endl;
    	else cout<<"="<<endl;
    	return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define INF 1000000000
using namespace std;
long long int n;
long long int dps[100001];
long long int dp(long long int index) {
	if (index == 0)
		return 0;
	if (dps[index] == -1) {
		dps[index] = INF;
		long long int cnter = 531441;
		for (int i = 5; i >= 0; i--) {
			if (index - cnter >= 0)
				dps[index] = min(dps[index], 1 + dp(index - cnter));
			cnter /= 9;
		}
		cnter = 279936;
		for (int j = 6; j >= 0; j--) {
			if (index - cnter >= 0)
				dps[index] = min(dps[index], 1 + dp(index - cnter));
			cnter /= 6;
		}
		dps[index] = min(dps[index], 1 + dp(index - 1));
	}
	return dps[index];
}
int main() {
	cin >> n;
	for (int i = 0; i <= 100000; i++)
		dps[i] = -1;
	cout << dp(n) << '\n';
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl;
using namespace std;

int main(){
    int ans[10005];
    int cnt=0;
    while(true){
        cin>>ans[cnt];
        if(ans[cnt]==0) break;
        cnt++;
    }

    for(int i=0; i<cnt; i++){
        cout<<"Case "<<i+1<<": "<<ans[i]<<endl;
    }
}



Measured memory_bytes: 3120
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007


ll n, k;
int a[222222], b[222222];

main(){
    scanf("%lld%lld", &n, &k);
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
        a[i]--;
        b[i] = -1;
    }
    int x=0, y=1;
    while(k){
        if(b[x] > 0){
            k %= (y - b[x]);
            if(k==0) break;
        }
        b[x] = y;
        x = a[x];
        y++;
        k--;
    }
    printf("%d\n", ++x);
    return 0;
}

Measured memory_bytes: 3304
import itertools
import math

N = int(input())

L = []
for _ in range(N):
    x,y = map(int,input().split())
    L.append([x,y])

l = [i for i in range(N)]

s = 0
for x in itertools.permutations(l):
    for i in range(N-1):
        s += math.sqrt( (L[x[i]][0]-L[x[i+1]][0])**2 + (L[x[i]][1]-L[x[i+1]][1])**2 )

print(s/math.factorial(N))

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

int main() {
  int N,x;
  cin >> N>>x;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }

sort(a.begin(),a.end());
int happy =0;
for(int i=0;i<N;i++){
  x -= a[i];
  if(x<0) break;
  happy ++ ;
}

if(x>0) happy--;
cout << happy << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int gcd(int a, int b) {
   if(a<b) swap(a, b);
   return b?gcd(b,a%b):a;
}
int lcm(int a, int b) {
   ll ret=(ll)a/gcd(a,b)*b;
   if(ret>1000000000) return INT_MAX;
   else return ret;
}

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

   bool ok=true;
   rep(i, n) if(a[i]%2==1) ok=false;

   rep(i, n) a[i]/=2;
   int l=1;
   rep(i, n) l=lcm(l, a[i]);
   rep(i, n){
      int b=l/a[i];
      if(b%2==0) ok=false;
   }
   int num=m/l - m/((ll)l*2);

   if(ok) cout<<num<<endl;
   else cout<<0<<endl;

   return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); ++i)

int main()
{
  int n, r;
  cin >> n >> r;
  if (n >= 10)
  {
    cout << r << endl;
  }
  else
  {
    r += 100 * (10 - n);
    cout << r << endl;
  }

  return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int V, E;
vector<pii> G[610];
pii bp;
bool checked[610];
double memo[610];

double dfs(int v)
{
	if (checked[v])return memo[v];
	int c = 0;
	for (auto e : G[v])
	{
		if (e == bp)continue;
		c++;
	}
	double res = 0.0;
	for (auto e : G[v])
	{
		if (e == bp)continue;
		res += (dfs(e.second)+1.0) / c;
	}
	checked[v] = true;
	memo[v] = res;
	return res;
}

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

	cin >> V >> E;
	int s, t;
	rep(i, 0, E)
	{
		cin >> s >> t;
		s--, t--;
		G[s].push_back(mp(s, t));
	}

	double ans = INF;

	ans = dfs(0);
	vector<pii> bps;

	rep(i, 0, V)
	{
		if (G[i].size() == 1)continue;
		t = -1;
		double m = -1;
		for (auto e : G[i])
		{
			if (chmax(m, memo[e.second]))
			{
				t = e.second;
			}
		}
		if (m < 0)continue;
		bps.push_back(mp(i, t));
	}

	for (auto p : bps)
	{
		bp = p;
		rep(i, 0, V)
		{
			checked[i] = false;
			memo[i] = 0.0;
		}
		chmin(ans, dfs(0));
	}

	cout << fixed << setprecision(12) << ans << endl;

	return 0;
}

Measured memory_bytes: 4608
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int length = 0;
    int res = 0;
    for (int i = 0; i < S.length(); i++){
        String s = S.substring(i, i + 1);
        if (s.equals("A") || s.equals("G") || s.equals("T") || s.equals("C")){
            length++;
        } else {
            if (res < length) {
                res = length;
            }
            length = 0;
        }
    }
    if (res < length) {
        res = length;
    }
    System.out.println(res);
  }
  
}


Measured memory_bytes: 23764
// package cp;
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	long gcd(long a,long b) {if(b==0)return a;else return gcd(b,a%b);}
	void swap(long a,long b) {long temp=a;a=b;b=temp;}
	StringBuilder sb=new StringBuilder();
	BigInteger RES=new BigInteger("0");
	//(Initialize as string) - (a.add(b)) - (array initialized with null and not 0)
	Integer[] ARR=new Integer[5];
	//Integer sort-TLE-Initialize object elements i.e a[0].
	void divisor(long n,int start) {
		int cnt=0;for(int i=start;i<=Math.sqrt(n);i++) {
		if(n%i==0) {if(i==n/i)cnt++;else cnt+=2;}}}
	static long[][] dp;
	public static void main(String[] args) throws IOException {	
		PrintWriter out = new PrintWriter(System.out);
		Readers.init(System.in);
		//Cf_three obj=new Cf_three();
		int n=Readers.nextInt();
		long[][] a=new long[n][3];
		dp=new long[n][3];long maxx=0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				a[i][j]=Readers.nextLong();
				if(i==0)dp[i][j]=a[i][j];
				else dp[i][j]=a[i][j]+Math.max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]);
				maxx=Math.max(maxx, dp[i][j]);
			}
		}
		System.out.println(maxx);
//		System.out.println(Math.max(dp[n-1][0], Math.max(dp[n-1][1], dp[n-1][2])));
		out.flush();
	}
}
class Readers {
 
    static BufferedReader reader;
 
    static StringTokenizer tokenizer;
 
 
 
    /** call this method to initialize reader for InputStream */
 
    static void init(InputStream input) {
 
        reader = new BufferedReader(
 
                     new InputStreamReader(input) );
 
        tokenizer = new StringTokenizer("");
 
    }
 
 
 
    /** get next word */
 
    static String next() throws IOException {
 
        while ( ! tokenizer.hasMoreTokens() ) {
 
            //TODO add check for eof if necessary
 
            tokenizer = new StringTokenizer(
 
                   reader.readLine() );
 
        }
 
        return tokenizer.nextToken();
 
    }
 
 
 
    static int nextInt() throws IOException {
 
        return Integer.parseInt( next() );
 
    }
 
	
 
    static double nextDouble() throws IOException {
 
        return Double.parseDouble( next() );
 
    }
    
    
    static long nextLong() throws IOException{
    	
		return Long.parseLong(next());
	}
 
}

Measured memory_bytes: 63768
def calcF(n):
    if n%2 == 0:
        if n%4 == 0:
            return n
        else:
            return n^1
    else:
        if (n+1)%4 == 0:
            return 0
        else:
            return 1
A,B = map(int,input().split())
ans_A = calcF(A-1)
#print(ans_A)
ans_B = calcF(B)
#print(ans_B)
ans = ans_A^ans_B
print(ans)

Measured memory_bytes: 3060