akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    string str;

    cin  >> n;
    cin >>str;

    if (n % 2 != 0)
    {
        cout <<"No"<<endl;
        return 0;
    }

    int mid = n / 2 ;

    bool is_echo=true;

    for (int i = 0; i < mid;i++)
    {
        if(str[i] != str[i+mid])
        {
            is_echo =false;
            break;
        }
    }

    if(is_echo)
    {
        cout << "Yes"<<endl;
    }else
    {
        cout << "No"<<endl;
    }
    
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int main(){
    int a,b;
    in(a);in(b);
    printf("%d\n",max(max(a+b,a-b),a*b));
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  map<string,ll> cnt;
  int n;
  string s;
  ll ans=0;
  cin >> n;

  for(int i=0; i<n; i++){
    cin >> s;
    sort(s.begin(),s.end());
    if(cnt.find(s) == cnt.end()) cnt[s] = 0;
    cnt[s]++;
  }
  for(auto v : cnt){
    ans += v.second * (v.second-1) / 2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <algorithm>
using namespace std;
int a, b, k[15][10005], ans, zero, sum;
int main() {
	while (1) {
		cin >> a >> b;
		if (a == 0 && b == 0) { break; }
		for (int i = 0; i < a; ++i) {
			for (int j = 0; j < b; ++j) {
				cin >> k[i][j];
			}
		}

		//search
		for (int bit = 0; bit < (1 << a); ++bit) {//bit 0裏返さない,1裏返す
												  //calc
			sum = 0;
			for (int i = 0; i < b; ++i) {
				zero = 0;
				for (int j = 0; j < a; ++j) {
					if (k[j][i] == 1) {
						if (bit&(1 << j)) ++zero;
					}
					else {
						if (!(bit&(1 << j))) ++zero;
					}
				}
				sum += max(zero, a - zero);
			}
			ans = max(ans, sum);
		}
		cout << ans << endl;
	}
}



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

int main()
{
    string nin;
    cin >> nin;
    int jg = 0;
    for (int i = 0; i < nin.size(); i++)
    {
        jg += nin.at(i) - '0';
    }

    if (jg % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3708
N, M = list(map(int, input().split()))
a = []
for k in range(M):
  a.append(list(map(int, input().split())))

L = [] 
R = []
for i in range(M):
  L.append(a[i][0])
  R.append(a[i][1])

l = max(L)
r = min(R)
ans = 0
if r >= l:
  ans = r-l+1
  
print(ans)

Measured memory_bytes: 29080
n,m,x = map(int,input().split())
book = []
for _ in range(n):
  book.append(list(map(int,input().split())))
time = [0 for _ in range(n)]
def nex(time):
  for d in range(n):
    if time[d] == 0:
      time[d] = 1
      return time
    else:
      time[d] = 0
  else:
    return 'over'
can = []
while time != 'over':
  cnt = [0 for _ in range(m)]
  ans = 0
  for i in range(n):
    c = book[i][0]
    a = book[i][1:]
    if time[i] == 1:
      for j in range(m):
        cnt[j] += a[j]
      ans += c
  for j in range(m):
    if cnt[j] < x:
      break
  else:
    can.append(ans)
  time = nex(time)
if can:
  print(min(can))
else:
  print(-1)

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

int main() {
  int n;
  cin >> n;
  int l[2 * n];
  for (int i = 0; i < 2 * n; i++) {
    cin >> l[i];
  }
  sort(l, l + 2 * n);
  int ans = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    ans += min(l[i], l[i + 1]);
  }
  cout << ans << endl;
}


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

int main(){

  int x, y, p;

  while(cin >> x >> y >> p && (x || y || p)){

    int max = INT_MIN;
    //    int maxi, maxj;

    for(int i = 1; i <= 1000; i++){ 
      for(int j = i; j <= 1000; j++){
	if((i * (100 + x) / 100) + (j * (100 + x) / 100) == p){
	  if(max < (i * (100 + y) / 100) + (j * (100 + y) / 100)){
	    max = (i * (100 + y) / 100) + (j * (100 + y) / 100);
	    //	    maxi = i;
	    //maxj = j;
	  }
	}
      }
    }
    cout << max << endl;
    // cout << maxi << " " << maxj << endl;


  }




  return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  int prex = 0, prey = 0, pret = 0;
  bool ok = true;
  for (int i = 0; i < N; i++) {
    int x, y, t;
    cin >> t >> x >> y;
    int a = (t - pret);
    int b = abs(y - prey);
    int c = abs(x - prex);
    if (a < b + c) ok = false;

    a %= 2;
    b %= 2;
    c %= 2;
    if (a ^ b ^ c == 1) ok = false;
    x = prex;
    y = prey;
    t = pret;
  }
  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int a[] = new int [4];
		int n; n = in.nextInt();
		String s;
		for (int i = 0; i < n; i++) {
			s = in.next();
			if (s.equals("AC"))	a[0]++;
			if (s.equals("WA"))	a[1]++;
			if (s.equals("TLE"))a[2]++;
			if (s.equals("RE"))	a[3]++;
		}
		System.out.println("AC x " + a[0]);
		System.out.println("WA x " + a[1]);
		System.out.println("TLE x " + a[2]);
		System.out.println("RE x " + a[3]);
	}
}


Measured memory_bytes: 58604
#include <bits/stdc++.h>
using namespace std;
const int maxn=2000;
typedef long long ll;
const ll mod=998244353;
ll x[maxn],y[maxn],power[maxn];
/*ll power(ll a,ll b)
{
    ll ret;
    if (b==0) return 1LL;
    ret=pow(a,b/2);
    ret=ret*ret%mod;
    if (b%2) ret=ret*a%mod;
    return ret;
}*/
int main()
{
    //freopen("text.in","r",stdin);
    ll i,ans,tmp,j,k,n;
    scanf("%lld",&n);
    power[0]=1LL;
    for (i=1;i<=n;i++) {
        power[i]=power[i-1]*2LL%mod;
        scanf("%lld%lld",&x[i],&y[i]);
    }
    ans=((power[n]-n-1)%mod+mod)%mod;
    //ans=((ans-(n-1)*n/2)%mod+mod)%mod;
    for (i=1;i<=n;i++) {
        for (j=i+1;j<=n;j++) {
            tmp=0;
            for (k=j+1;k<=n;k++) {
                if ((y[j]-y[i])*(x[k]-x[j])==(y[k]-y[j])*(x[j]-x[i])) tmp++;
                //if ((y[k]-y[i])*(x[j]-x[i])==(x[k]-x[i])*(y[j]-y[i])) tmp++;
            }
            ans=((ans-/*power(2LL,tmp)*/power[tmp])%mod+mod)%mod;
        }
    }
    printf("%lld\n",(ans%mod+mod)%mod);
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

ll n, a, b[100001], ans = 0, c, d;

ll pw(int x, int n) {
	ll y = 1;
	ll p = x;
	while (n != 0) {
		if (n % 2) {
			y = y*p%mod;
		}
		p = p*p%mod;
		n = n / 2;
	}
	return y;
}
ll modinv(ll x) {
	return pw(x, mod - 2);
}

int main() {
	cin >> n;
	c = 0;
	d = 1;
	for (int i = 0; i != n; ++i) {
		c = (c*(i + 1) + d) % mod;
		d = d*(i + 1) % mod;
		b[i] = c*modinv(d) % mod;
	}
	rep(n){
		cin >> a;
		ans = (ans + a*(b[i] + b[n - 1 - i] - 1)) % mod;
	}
	rep(n)
		ans = ans*(i + 1) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long lint;

lint solve(lint n, vector<lint> &a){
    priority_queue<lint, vector<lint>, greater<lint>> queue_1;
    priority_queue<lint> queue_2;
    vector<lint> sum_fst(n+1, 0);
    vector<lint> sum_snd(n+1, 0);
    lint num, sum, ret;
    for (int i=0; i<n; ++i){
        queue_1.push(a[i]);
        sum_fst[0] += a[i];
    }
    for (int i=1; i<n+1; ++i){
        queue_1.push(a[n + i - 1]);
        sum_fst[i] = sum_fst[i-1];
        sum_fst[i] += a[n + i - 1];
        num = queue_1.top();
        queue_1.pop();
        sum_fst[i] -= num;
    }
    for (int i=0; i<n; ++i){
        queue_2.push(a[3 * n - i - 1]);
        sum_snd[n] += a[3 * n - i - 1];
    }
    for (int i=1; i<n+1; ++i){
        queue_2.push(a[2 * n - i]);
        sum_snd[n - i] = sum_snd[n - i + 1];
        sum_snd[n - i] += a[2 * n - i];
        num = queue_2.top();
        queue_2.pop();
        sum_snd[n - i] -= num;
    }
    ret = -10000000000000000;
    for (int i=0; i<=n; ++i){
        ret = max(ret, sum_fst[i] - sum_snd[i]);
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<lint> a(3 * n);
    for (int i=0; i<3 * n; ++i){
        cin >> a[i];
    }
    cout << solve(n, a) << endl;
    return 0;
}

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

int main(void){
	int n,i,j,k;
	scanf("%d",&n);
	int b, f, r, v;

	int p[1000][4];
	
	for(i=0;i<n;i++)
	{	
		scanf("%d%d%d%d",&b,&f,&r,&v);
		p[i][0]=b;
		p[i][1]=f;
		p[i][2]=r;
		p[i][3]=v;
	}
	
	int a[4][3][10] = {{{0}}};
	for(i=0;i<n;i++)
	{
		a[p[i][0]-1][p[i][1]-1][p[i][2]-1] += p[i][3];
	}

	for(j=0;j<3;j++)
	{
		for(k=0;k<10;k++)
		{
			printf(" %d",a[0][j][k]);
		}
		printf("\n");
	}
	for(i=1;i<4;i++)
	{		
		printf("####################\n");
		for(j=0;j<3;j++)
		{
			for(k=0;k<10;k++)
			{
				printf(" %d",a[i][j][k]);
			}
			printf("\n");
		}

	}


	return 0;
}

Measured memory_bytes: 620
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		final int[] table = {1, 5, 10, 50, 100, 500};
		Scanner sc = new Scanner(System.in);
		
		int[] buf = new int[6];
		for (int i = 0; i < buf.length; i++){
			buf[i] = sc.nextInt();
		}
		
		int sum = 0;
		for (int i = 0; i < buf.length; i++){
			sum += buf[i] * table[i];
		}
		
		if (sum >= 1000){
			System.out.println(1);
		}
		else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 17236
#define debug_interval ','
#define dump_interval endl
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
 
//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


//}

int n,m,ans=LLONG_MIN,tans;

main(){
	cin>>n>>m;
	int a[n][3];
	rep(i,n)rep(j,3)cin>>a[i][j];
	rep(i,8){
		tans=0;
		int t[n]={};
		rep(j,n){
			rep(k,3){
				if(i&1<<k)t[j]-=a[j][k];
				else t[j]+=a[j][k];
			}
		}
		sort(t,t+n,greater<int>());
		rep(j,m){
			tans+=t[j];
		}
		chmax(ans,tans);
	}
	dump(ans);
}

Measured memory_bytes: 256
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<i32>();
    let A = read::<i32>();

    if N % 500 <= A {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int64_t T1, T2, A1, A2, B1, B2;
  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

  int64_t P = (A1 - B1) * T1;
  int64_t Q = (A2 - B2) * T2;
  if (P > 0) {
    P *= -1;
    Q *= -1;
  }
  if ((P + Q) < 0) {
    cout << 0 << endl;
    return 0;
  } else if ((P + Q) == 0) {
    cout << "infinity" << endl;
    return 0;
  }
  // 0 < (P + Q)
  // k x (P + Q) + P < 0 : 2 times
  // k x (P + Q) + P == 0 : 1 times
  // k x (P + Q) + P > 0 : 0 times
  int64_t S = -P / (P + Q);
  int64_t T = -P % (P + Q);
  int64_t answer = S * 2;
  if (T != 0) answer++;
  cout << answer << endl;
  return 0;
}


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

#include <atcoder/math>
using namespace atcoder;

ll mpow(ll x,ll t,ll m){
   ll res=1;
   while(t){
      if(t&1)res=(__int128_t(res)*x)%m;
      x=(__int128_t(x)*x)%m; t>>=1;
   } return res;
}

bool isp(ll n){
   if(n<2 or n%2==0)return (n==2);
   ll d=n-1; while(d%2==0)d>>=1;
   for(ll x:{2,325,9375,28178,450775,9780504,1795265022}){
      if(n<=x)break;
      ll t=d,y=mpow(x,t,n);
      while(t!=n-1 and y!=1 and y!=n-1){
         y=(__int128_t(y)*y)%n; t<<=1;
      }
      if(y!=n-1 and t%2==0)return 0;
   } return 1;
}

vector<ll> pollard(ll n){
   if(n<=1)return {};
   if(isp(n))return {n};
   if(n%2==0){
      vector<ll> v=pollard(n/2); v.push_back(2);
      return v;
   }
   for(ll c=1,x=2,y=2,d;;c++){
      do{
         x=(__int128_t(x)*x+c)%n;
         y=(__int128_t(y)*y+c)%n;
         y=(__int128_t(y)*y+c)%n;
         d=__gcd(x-y+n,n);
      }while(d==1);
      if(d<n){
         vector<ll> lb=pollard(d),rb=pollard(n/d);
         lb.insert(lb.end(),ALL(rb)); return lb;
      }
   }
}

int main(){
   ll n; cin>>n;
   if(n==1){
      puts("1");
   }
   else{
      auto v=pollard(n*2);
      map<ll,ll> ps;
      for(ll x:v){
         if(ps.count(x))ps[x]*=x;
         else ps[x]=x;
      }
      vector<ll> xs;
      for(auto [tmp,x]:ps)xs.push_back(x);
      ll res=INF;
      int d=xs.size();
      rep(mask,0,(1<<d)-1){
         ll lb=1,rb=1;
         rep(i,0,d){
            if(mask>>i&1)lb*=xs[i];
            else rb*=xs[i];
         }
         assert(gcd(lb,rb)==1);
         assert(lb*rb==n*2);
         vector<ll> r={0,rb-1},m={lb,rb};
         auto [t,tmp]=atcoder::crt(r,m);
         if(t)chmin(res,t);
      }
      //assert((res*(res+1)/2)%n==0);
      cout<<res<<endl;
   }
   return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

struct Edge {
    ll from, to, weight;
    Edge() : from(0), to(0), weight(0) {}
    Edge(ll f, ll t, ll w) : from(f), to(t), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &g, ll a, ll b, ll w = 1){
    g[a].emplace_back(a, b, w);
    g[b].emplace_back(b, a, w);
}

void add_arrow(Graph &g, ll a, ll b, ll w = 1){
    g[a].emplace_back(a, b, w);
}

//ダイクストラ法
//グラフgの1点sからの最短距離をO((E + V) log V)で構築
vector<ll> dijkstra(Graph &g, ll s){
    vector<ll> dist(g.size(), INF);
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s] = 0;
    que.emplace(dist[s], s);
    
    while(!que.empty()){
        ll cost, idx;
        tie(cost, idx) = que.top();
        que.pop();
        if(dist[idx] < cost) continue;
        for(auto &e : g[idx]){
            auto next_cost = cost + e.weight;
            if(dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, M;
    cin >> N >> M;
    Graph G(N);
    rep(i, M){
        ll l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        add_arrow(G, l, r, d);
        add_arrow(G, r, l, -d);
    }

    map<ll, ll> d;
    rep(i, N){
        if(d.count(i)) continue;

        stack<P> sk;
        sk.push({i, 0});
        while(!sk.empty()){
            auto now = sk.top().first;
            auto dis = sk.top().second;
            sk.pop();
            if(d.count(now)){
                if(d[now] != dis) drop("No");
                continue;
            }
            d[now] = dis;

            for(auto e : G[now]) sk.push({e.to, dis + e.weight});
        }
    }

    print("Yes");

    return 0;
}

Measured memory_bytes: 24448
/*input
1
11 26
26 24 26 17 13 10 2 3 8 21 20

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
#define PI 3.14159265
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;
#define MAX 100001

template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(ll a, ll b) {a += b; if (a < 0) a += mod; return a;}
inline int sub(ll a, ll b) {a -= b; if (a < 0) a += mod; return a;}
inline int mul(ll a, ll b) {return (a * 1ll * b) % mod;}
inline int pwr(ll x, ll y) {
    int ans = 1 % mod;
    while (y) {
        if (y & 1) ans = mul(ans, x);
        x = mul(x, x);
        y >>= 1;
    }
    return ans;
}
inline int inv(int a) {return pwr(a, mod - 2);}

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

    int n, m, c;
    cin >> n >> m >> c;
    int ans = 0;
    vector <int> vec;
    int v;
    for (int i = 0; i < m; i++) {
        cin >> v;
        vec.pb(v);
    }
    for (int i = 0; i < n; i++) {
        int temp = c;
        for (int j = 0; j < m; j++) {
            cin >> v;
            temp += (v * vec[j]);
        }
        ans += (temp > 0);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 1;
signed main(){
  int n;
  cin >> n;
  vector<pair<char, int> > s;
  char c;
  int a;
  for(int i = 0; i < n; i++){
    cin >> c >> a;
    s.push_back(make_pair(c, a));
  }
  
  bool ok;
  string str = "SHCD";
  for(int i = 0; i < 4; i++){
    for(int j = 1; j <= 13; j++){
      ok = false;
      for(int k = 0; k < n; k++){
        if(str[i] == s[k].first && j == s[k].second){
          ok = true;
          break;
        }
      }
      if(ok)continue;
      else cout << str[i] << " " << j << endl;
    }
  }
}

Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>

using namespace std;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main()
{
    int a,b;
    cin >> a >> b;
    
    int ans = 0;
    if ((a+b)%2 == 0)
    {
        cout << ((a+b)/2) << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<pair<ll, ll>> x(n);
	vector<ll> a(n), b(n);
	rep(i, n) {
		cin >> x[i].first >> x[i].second;
		a[i] = x[i].first;
		b[i] = x[i].second;
	}
	ll ans = 0;
	sort(all(a));
	sort(all(b));
	if (n%2 == 0) {
		rep (i, n) {
			a[i] *= 2;
			b[i] *= 2;
		}
		ll am = (a[n/2] + a[n/2-1]) / 2;
		ll bm = (b[n/2] + b[n/2-1]) / 2;
		ans  = bm - am + 1;
	} else {
		ans = b[n/2] - a[n/2] + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9520
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	const double PI  =3.141592653589793238463;
	double R;
	cin >> R;
	cout << 2 * PI * R << '\n';
	return 0;
}

Measured memory_bytes: 3172
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#define pll              pair<long,long>
#define pii              pair<int,int>
#define scn(a)           scanf("%d", &a)
#define scn2(a, b)       scanf("%d%d", &a, &b)
#define scn3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pairl            pair<ll , ll >
#define scnl(a)          scanf("%lld", &a)
#define scnl2(a, b)      scanf("%lld%lld", &a, &b)
#define scnl3(a, b, c)   scanf("%lld%lld%lld", &a, &b, &c)
#define scns(s)          scanf("%s",s)
#define prts(s)          printf("%s\n",s)
#define prt(a)           printf("%d\n", a)
#define prtl(a)          printf("%lld\n", a)
#define prs(a)           printf("%d ", a)
#define prt2(a, b)       printf("%d %d\n", a, b)
#define prt3(a, b, c)    printf("%d %d %d\n", a, b, c)
#define prsl(a)          printf("%lld ", a)
#define prtl2(a, b)      printf("%lld %lld\n", a, b)
#define prtl3(a, b, c)   printf("%lld %lld %lld\n", a, b, c)
#define ptcs(a)          printf("Case %d: ", a)
#define pf               printf
#define sc               scanf
#define vi               vector<int >
#define vil              vector<ll >
#define pb               push_back
#define mem(a, b)        memset((a), (b), sizeof(a))
#define lg2(n)           (31-__builtin_clz(n))
#define N                2000010
#define inf              9999999
#define ll               long long
#define ull              unsigned long long
#define MIN              INT_MIN
#define MAX              INT_MAX
#define fast             ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<pair<ll, ll> , null_type, less<pair<ll, ll> >, rb_tree_tag, tree_order_statistics_node_update> odrst;
ll gcd(ll a, ll b){if(b==0) {return a;}return gcd(b, a % b);}
ll BigMod(ll B,ll P,ll M){     ll R=1; while(P>0)      {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
//___________________________________________________________________________________________________________________
ll dp[N],dp1[N];
map<ll,ll>mp,mp1;
vector<ll>v[27],v1[27];
//char c[100001];
int main()
{
    fast;
    odrst os;
    //freopen("fff.txt","w",stdout);
    bool ok=false,ok1;
    //os.insert({-100000000000,0});
    //v.pb(-100000000000);
    ll t,n,q,m,x,x1,y,ans=0,yy,mm,z,mx=0,my=0,z1=0,h,cn=0,p1=1,p2=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R') ans++;
        else mx++;
    }
    if(ans>mx) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
const int MAX = 1e5 + 10;
const double exps = 1e-8;
#define swap(a, b) \
    { register int tmp = a, a = b, b = tmp; }

inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a > b ? b : a; }
int a[110];
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    int sum = 0;
    for (int i = 1; i <= n; ++i) scanf("%d", a + i), sum += a[i];
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        if (4 * m * a[i] >= sum) cnt++;
    }
    if (cnt >= m)
        cout << "Yes\n";
    else
        cout << "No\n";
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		c,i,j,k,t,n,m,x,y,ans = 0;
	string	s;

	cin >> n >> s;

	for(i=0;i<n-2;i++) {
		if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
	}
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

const int maxm = 500;
const int maxn = 60;

const int mod = 1e9 + 7;

typedef long long ll;

struct Edges {
	int to, next;
} es[maxm] ;
int head[maxn] = {};

int tp = 1;
void adde(int a, int b) {
	tp++;
	es[tp].to = b;
	es[tp].next = head[a];
	head[a] = tp;
}

int dfn[maxn] = {}, low[maxn] = {};
int ti = 0;
int S[maxn] = {};
int tail = 0;
int cnt = 0;

vector<int> V[maxn];

int t1[maxm] = {}, t2[maxm] = {};

void tarjan(int now, int fa) {
	dfn[now] = low[now] = ++ti;
	S[++tail] = now;
	for (int e = head[now]; e; e = es[e].next) {
		int to = es[e].to;
		if (!dfn[to]) {
			tarjan(to, now);
			low[now] = min(low[now], low[to]);
			if (dfn[now] <= low[to]) {
				++cnt;
				int t;
				do {
					t = S[tail--];
					V[cnt].push_back(t);
				} while (t != to);
				V[cnt].push_back(now);
			}
		}
		else low[now] = min(low[now], dfn[to]);
	}
}

int d[maxn][maxn] = {};
int sum[maxn] = {};
int ans[maxn] = {};

int C[maxm][maxm] = {};

void init() {
	C[0][0] = 1;
	for (int i = 1; i < maxm; ++i) {
		C[i][0] = 1;
		for (int j = 1; j < maxm; ++j) {
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
		}
	}
}

int power(int x, int y) {
	if (!y) return 1;
	int ret = power(x, y >> 1);
	ret = 1ll * ret * ret % mod;
	if (y & 1) ret = 1ll * ret * x % mod;
	return ret;
}

int inv(int x) {
	return power(x, mod - 2);
}

int gcd(int a, int b) {
	if (!b) return a;
	return gcd(b, a % b);
}

int n, m, k;

int solve() {
	for (int i = 1; i <= m; ++i) {
		for (int j = 1; j <= cnt; ++j) {
			if (find(V[j].begin(), V[j].end(), t1[i]) != V[j].end() 
				&& find(V[j].begin(), V[j].end(), t2[i]) != V[j].end()) {
				sum[j]++;
				d[j][t1[i]]++, d[j][t2[i]]++;
			}
		}
	}
	for (int i = 1; i <= cnt; ++i) {
		if (sum[i] == 1) {
			ans[i] = k;
			continue;
		}
		bool check = 1;
		int sz = V[i].size();
		for (int j = 0; j < sz; ++j) {
			int cur = V[i][j];
			if (d[i][cur] != 2) {
				check = 0;
				break;
			}
		}
		if (check) {
			int M = sum[i];
			for (int j = 1; j <= M; ++j) {
				(ans[i] += power(k, gcd(M, j))) %= mod;
			}
			ans[i] = 1ll * ans[i] * inv(M) % mod;
		}
		else {
			ans[i] = C[sum[i] + k - 1][k - 1];
		}
	}
	int ret = 1;
	for (int i = 1; i <= cnt; ++i) {
		ret = 1ll * ret * ans[i] % mod;
	}
	return ret;
}

int main()
{
	ios::sync_with_stdio(0);
	cin >> n >> m >> k;
	for (int i = 1; i <= m; ++i) {
		cin >> t1[i] >> t2[i];
		adde(t1[i], t2[i]);
		adde(t2[i], t1[i]);
	}
	init();
	for (int i = 1; i <= n; ++i) {
		if (!dfn[i]) tarjan(i, 0);
	}
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 1280
import sys
import math

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

a, b, h, m = nm()
anm = math.pi * 2 * m / 60
anh = math.pi * 2 * (60 * h + m) / 720
f = abs(anm - anh)
f = min(f, 2 * math.pi - f)
c2 = a*a + b*b - 2*a*b*math.cos(f)
print(c2**.5)


Measured memory_bytes: 9520
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

int main() {
    int N, W;
    cin >> N >> W;
    vector<vector<int>> dp(N+1, vector<int>(W+1,0));
    vector<pair<int,int>> vw;
    REP(i,N) {
        int v, w;
        cin >> v >> w;
        vw.push_back(make_pair(v,w));
    }
    
    REP(i,N) {
        REP(j, W+1) {
            if (j < vw[i].second) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = max(dp[i][j], dp[i][j-vw[i].second] + vw[i].first);
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 6840
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef set<int> si;
typedef multiset<int> mi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;


int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	string a, b;
	cin >> a >> b;
	int ans = b.size();
	
	for(int i=0; i<a.size(); ++i) {
		int cnt=0;
		if(i+b.size()-1>=a.size()) continue;
		for(int j=0; j<b.size(); ++j) {
			if(a[j+i]!=b[j]) ++cnt;
		}
		ans=min(ans, cnt);
	}
	
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DiceinLine solver = new DiceinLine();
        solver.solve(1, in, out);
        out.close();
    }

    static class DiceinLine {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] p = new int[n];
            long[] sum = new long[n + 1];
            long max = 0;
            for (int i = 0; i < n; i++) {
                p[i] = in.nextInt() + 1;
            }

            for (int i = 0; i < n; i++) {
                sum[i + 1] = sum[i] + p[i];
            }

            for (int i = 0; i + k <= n; i++) {
                max = Math.max(max, sum[i + k] - sum[i]);
            }

            out.println((double) max / 2);

        }

    }
}



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

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if (abs(x-a) < abs(x-b)) cout << 'A' << endl;
  else cout << 'B' << endl;
}

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

int main()
{
    string S;
    cin >> S;
    
    char high[3] = {};
    S.copy(high,2);
    high[2] = '\0';


    char low[3] = {};
    S.copy(low,2,2);
    low[2] = '\0';

    int highNum = atoi(high);
    int lowNum = atoi(low); 
    // cout << "highNum = " << highNum << endl;
    // cout << "lowNum = " << lowNum << endl;

    bool isMMOKForHigh, isMMOKForLow;

    if(1 <= highNum && highNum <= 12 )
        isMMOKForHigh = true;
    else
        isMMOKForHigh = false;

    if(1 <= lowNum && lowNum <= 12 )
        isMMOKForLow = true;
    else
        isMMOKForLow = false;

    // cout << "isMMOKForHigh = " << isMMOKForHigh << endl;
    // cout << "isMMOKForLow = " << isMMOKForLow << endl;

    if(isMMOKForHigh && isMMOKForLow)
        cout << "AMBIGUOUS" << endl;
    else if(!isMMOKForHigh && isMMOKForLow)
        cout << "YYMM" << endl;
    else if(isMMOKForHigh && !isMMOKForLow)
        cout << "MMYY" << endl;
    else
        cout << "NA" << endl;
            
    return 0;
}

Measured memory_bytes: 256
def root(x):
    if(par[x]==x):
        return x
    else:
        r=root(par[x])
        diff_weight[x]+=diff_weight[par[x]]
        par[x]=r
        return r

def weight(x):
    root(x)
    return diff_weight[x]

def diff(x,y):
    return weight(y)-weight(x)

def relate(a,b,w):
    w+=weight(a);w-=weight(b)
    a=root(a)
    b=root(b)
    if(a==b):
        return False
    if rank[a]<rank[b]:
        a,b=b,a
        w=-w
    if rank[a]==rank[b]:
        rank[b]+=1
        par[b]=a
    par[b]=a
    diff_weight[b]=w
    siz[a]+=siz[b]
    return True

def size(a):
    return siz[root(a)]
    
def same(a,b):
    return root(a)==root(b)
    
N,M=map(int,input().split())
par=[i for i in range(N)]
siz=[1 for _ in range(N)]
rank=[0 for _ in range(N)]
diff_weight=[0 for _ in range(N)]

for i in range(M):
    L,R,D=map(int,input().split())
    L,R=L-1,R-1
    if same(L,R) and diff(L,R)!=D:
        print('No')
        exit()
    else:
        relate(L,R,D)
print('Yes')

Measured memory_bytes: 10656
//Md Fahad
// CSE 18

#include<bits/stdc++.h>

using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);
#define Infi                0x3f3f3f3f

const int dx[] = {+1,-1,+0,+0};                         // 4 X directions
const int dy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int dx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int dy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int           ll;
typedef unsigned long long int  llu;




int main(void)
{
  // READ_IN;
    //READ_OUT;

    int n; cin >> n;
    vector<int> a(n);

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

    sort(a.begin(),a.end());
    int maxe = a[n-1];
    int mine = a[0];

    int sum = 0;
    int ans = Infi;
    for(int i=a[0];i<=maxe;i++){


    sum = 0;
        for(int j=0;j<n;j++){

            sum += (a[j]-i)*(a[j]-i);
        }

        ans = min(ans,sum);

    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define rep(i,n) for(int i=0; i<(n); i++)
#define per(i,n) for(int i=(n)-1; i>=0; i--)
#define all(v) v.begin(), v.end()
#define debug(var) do{cout << #var << " : "; print(var); } while(0)
using namespace std;
typedef long long ll;
void print() { cout << endl; }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...); }
template <class T> void print(vector<T> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec); } }
const int INF = 1e9;
const int MOD = 1e9+7;

int dp[3010][3010];

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

	string S, T; cin >> S >> T;
	rep(i, S.size()) rep(j, T.size()) {
		char s = S[i], t = T[j];
		if (s==t) dp[i+1][j+1] = dp[i][j]+1;
		else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
	}

	// print(dp[S.size()][T.size()]);

	// rep(i, S.size()+1) {
	// 	rep(j, T.size()+1) cout << (dp[i][j]);
	// 	cout << endl;
	// }

	int cur = dp[S.size()][T.size()];
	if (cur==0) {
		cout << "" << endl;
		return 0;
	}

	int ci = 3030, cj = 3030;
	string ans;
	per(i, S.size()+1) per(j, T.size()+1) {
		if (dp[i][j] == cur && i<ci && j<cj) {
			if (S[i-1]==T[j-1]) {
				ans = S[i-1] + ans;
				cur--;
				ci = i;
				cj = j;
			}
		}
		if (cur==0) break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int64_t A,B,N,x,y,ANS;
  
  cin >> N;
  cin >> A;
  cin >> B;
  
  if(((B-A-1)%2==1))
  {
    ANS=(B-A)/2;

  }
  else
  {
    x=N-B+1+((B-A-1)/2);
    y=A+((B-A-1)/2);
    if(x>y)
    {
      ANS=y;
    }
    else
    {
      ANS=x;
    }

   }
   
  
  cout << ANS <<endl;
  return 0;

}


Measured memory_bytes: 256
S = input()
T = input()
for i in range(len(S)-len(T)+1)[::-1]:
    for j in range(len(T))[::-1]:
        if S[i+j] != T[j] and S[i+j] != "?":
            break
    else:
        S = S[:i] + T + S[i+len(T):]
        print(S.replace("?", "a"))
        exit()
print("UNRESTORABLE")


Measured memory_bytes: 3060
import math
a,b,h,m=map(int,input().split())
t1=math.radians(30*h+0.5*m)
t2=math.radians(6*m)
x1,y1=a*math.cos(t1),a*math.sin(t1)
x2,y2=b*math.cos(t2),b*math.sin(t2)
ans=math.sqrt((x2-x1)**2+(y2-y1)**2)
print(ans)

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  string s;
  cin >> s;
  cout << s.substr(0,3) << endl;
}



Measured memory_bytes: 3596
#include <iostream>
#include <cstdlib>
#include <map>
#include <vector>

using namespace std;

int main()
{
    int h, w, d, q, l, r, tmpa, distance;
    vector<vector <int>> sum;
    long long mp, ans;
    map<int, pair<int, int>> board;
    
    cin >> h >> w >> d;
    
    for (int i=0; i<h; ++i){
        for (int j=0; j<w; ++j){
            cin >> tmpa;
            // board: number -> (i, j)
            board.insert(make_pair(tmpa, make_pair(i, j)));
        }
    }
    
    // sum
    sum.resize(d);
    int num_pre, num_next;
    int pre_i, pre_j, next_i, next_j;
    pair<int, int> pre, next;
    for(int i=1; i<=d; ++i){
        mp = 0;
        num_pre = i;
        num_next = i + d;
        sum[i % d].push_back(0);
        while(num_next <= h * w){
            pre = board.at(num_pre);
            next = board.at(num_next);
            pre_i = pre.first;
            pre_j = pre.second;
            next_i = next.first;
            next_j = next.second;
            distance = abs(next_i - pre_i) + abs(next_j - pre_j);
            mp += distance;
            //cout << num_pre << ": (" << pre_i << " ," << pre_j << ") -> " << num_next << ": (" << next_i << ", " << next_j << ") -> " << distance << endl; 
            sum[i % d].push_back(mp);
            num_pre = num_next;
            num_next += d;
        }
    }
    /*
    for (int i=0; i<d; ++i){
        for (int j=0; j<sum[i].size(); ++j){
            cout << i << " " << j << ":" << sum[i][j] << endl;
        }
    }
    */
    // query
    cin >> q;
    int step1, step2, start;
    for (int i=0; i<q; ++i){
        cin >> l >> r;
        ans = 0;
        if(l == r){
            cout << 0 << endl;
            continue;
        }
        start = l % d;
        if(r % d == 0){
            step1 = r / d - 1;
            step2 = l / d - 1;
        }
        else {
            step1 = r / d;
            step2 = l / d;
        }
        // cout << start << " -> " << step1 << ":" << step2 << endl;
        ans = sum[start][step1] - sum[start][step2];
        cout << ans << endl;
    }
}


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

int main() {
  int N;
  cin >> N;
  
  vector<string> words(N);
  
  for (int i = 0; i < N; i++) cin >> words.at(i);
  
  for (int i = 0; i < N - 1; i++) {
    char a = words.at(i).at(words.at(i).size() - 1);
    char b = words.at(i + 1).at(0);
    
    if(!(a == b)) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  sort(words.begin(), words.end());
  
  for (int i = 0; i < N - 1; i++) {
    if(words.at(i) == words.at(i + 1)) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

namespace Test
{
    class MainClass
    {
        static void Main()
        {
            Console.ReadLine();
            var numsS = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Console.ReadLine();
            var strs = Console.ReadLine().Split();
            int ans = 0;
            foreach (var item in strs)
            {
                if (BinarySearch(numsS, int.Parse(item))) ans++;
            }
            Console.WriteLine(ans);

        }
        static bool BinarySearch(int[] array, int key)
        {
            var right = array.Length;
            var left = 0;
            var mid = 0;

            while (left < right)
            {
                mid = (left + right) / 2;
                if (key == array[mid])
                {
                    return true;
                }
                else if (key < array[mid])
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }
            return false;
        }
    }
}

Measured memory_bytes: 16140
#include <bits/stdc++.h>
using namespace std;
#define N 500010
#define mo 1000000007
#define ll long long
ll i,j,k,ans,m,n,x,y,t[N],a[N],b[N],c[N],cnt,f[N];
inline ll ask(ll x) {
    ll ans = 0;
    for (; x; x -= x & -x)(ans += t[x]) %= mo;
    return ans;
}
inline void add(ll x,ll d) {
    for (; x <= cnt; x += x & -x)(t[x] += d) %= mo;
}
struct dist {
    ll x, y;

    inline bool operator<(const dist &b) const {
        if (x == b.x)return y > b.y;
        return x < b.x;
    }

    inline bool operator==(const dist &b) const {
        return x == b.x && y == b.y;
    }
}e[N];
int main() {
    cin >> n >> m;
    for (i = 1; i <= n; ++i)cin >> a[i];
    for (i = 1; i <= m; ++i)cin >> b[i];
    for (i = j = 1; i < m && j <= n; ++i) {
        for (; j <= n && a[j] <= b[i]; ++j);
        if (j > n)break;
        for (; j <= n && a[j] < b[i + 1]; ++j)c[++*c] = a[j] - b[i], e[++cnt] = (dist) {b[i + 1] - a[j], c[*c]};
    }
    sort(c + 1, c + *c + 1);
    for (i = 1; i <= cnt; ++i)e[i].y = lower_bound(c + 1, c + *c + 1, e[i].y) - c;
    sort(e + 1, e + cnt + 1);
    for (ans = i = 1; i <= cnt; ++i) {
        if (e[i] == e[i - 1])continue;
        f[i] = (ask(e[i].y - 1) + 1) % mo;
        (ans += f[i]) %= mo, add(e[i].y, f[i]);
    }
    cout << ans;
}

Measured memory_bytes: 18176
n,m=map(int,input().split())
l_n=[list(map(int,input().split())) for _ in range(n)]
l_m=[list(map(int,input().split())) for _ in range(m)]
# print(l_n,l_m)


for i,j in l_n:
    distance=0
    cnt = 0
    ans = float ( "inf" )
    for k,l in enumerate(l_m,1):
        a,b=l
        distance=abs(i-a)+abs(j-b)
        if ans>distance:
            ans=min(ans,distance)
            cnt=k
    print(cnt)


Measured memory_bytes: 9156
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int MAXN = 1e5 + 10;
LL dist[MAXN], val[MAXN], tmp1[MAXN], tmp2[MAXN];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    LL n, c;
    cin >> n >> c;
    for (int i = 0; i < n; i++) {
        cin >> dist[i] >> val[i];
    }
    LL tot = 0;
    for (int i = 0; i < n; i++) {
        tot += val[i];
        tmp1[i] = max(0LL, tot - dist[i]);
        tmp2[i] = max(0LL, tot - 2 * dist[i]);
        if (i > 0) {
            tmp1[i] = max(tmp1[i - 1], tmp1[i]);
            tmp2[i] = max(tmp2[i - 1], tmp2[i]);
        }
    }
    LL ret = tmp1[n - 1], tmp;
    tot = 0;
    for (int i = n - 1; i >= 1; i--) {
        tot += val[i];
        tmp = max(tot - (c - dist[i]), 0LL);
        ret = max(ret, tmp + tmp2[i - 1]);
        tmp = max(tot - 2 * (c - dist[i]), 0LL);
        ret = max(ret, tmp + tmp1[i - 1]);
    }
    tot += val[0];
    ret = max(ret, tot - (c - dist[0]));
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3328
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
Dk = list(map(int, input().split()))

all = [i for i in range(10)]

for Di in Dk:
    if Di in all:
        all.remove(Di)

# print(all)
ans = 0
for i in range(N,100000):
    tmp_list = map(int, list(str(i)))
    # print(tmp_list)
    all_ok = True
    for c in tmp_list:
        if c in all:
            pass
        else:
            all_ok = False
            continue
    if all_ok == True:
        ans = i
        break

print(ans)


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

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

	int r;
	cin >> r;
	cout << 2*r*3.1415926;

	return 0;
}


Measured memory_bytes: 3804