akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long int64;

const int MOD = 1000000007;

class Combination {
public:
    const int MAX = 510000;
    vector<long long> fac, finv, inv;
    Combination();
    long long COM(int n, int k);
};

inline Combination::Combination() {
    fac.resize(MAX);
    finv.resize(MAX);
    inv.resize(MAX);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

inline long long Combination::COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

Combination C;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    int64 ans = 0;
    rep(i, N) {
        int64 add = C.COM(i, K - 1) * A[i] % MOD;
        int64 sub = C.COM(N - i - 1, K - 1) * A[i] % MOD;
        ans = (ans + add - sub) % MOD;
        ans = (ans + MOD) % MOD;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 12544
from collections import Counter
n=int(input())
a=list(map(int, input().split()))
q=int(input())
cou=Counter(a)
arr=list(cou.items())
dic={}
for item in arr:
    dic[item[0]]=item[1]
ans=sum(a)
for _ in range(q):
    b,c=map(int,input().split())
    if not b in dic.keys():
      print(ans)
      continue
    if not c in dic.keys():
      dic[c]=0
    tmpb=dic.pop(b)
    tmpc=dic.pop(c)
    ans+=(c-b)*tmpb
    dic[c]=tmpb+tmpc
    print(ans)

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

using ll = long long;
using namespace std;

int main() {
    ll x;

    cin >> x;

    if(x == 2){
        cout << x << endl;
        return 0;
    }

    for (;;)
    {
        ll devided = 0;
        for (ll k = 2; k*k < x; k++)
        {
            if(x%k==0){
                devided = 1;
                break;
            }
        }

        if (devided == 0){
            break;
        }
        x++;
    }
    

    cout << setprecision(20) << x << endl;

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toLong)
    val ans = combination(N + M, 2) - N * M
    println(ans)
}

fun combination(n: Long, k: Long): Long {
    var a = 1L
    var b = 1L
    val min = k.coerceAtMost(n - k)
    for (i in n - min + 1..n) {
        a *= i
    }
    for (i in 1..min) {
        b *= i
    }
    return a / b
}

Measured memory_bytes: 37600
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
int ar[200002] ;
vector<int>ps,ne,tup ;
bool cmp(int a , int b) {return a>b ; }
int32_t main()
{
    int n,k ; cin>>n>>k ;
    int an=1 ;
    for(int i = 0 ; i < n ; i++) {cin>>ar[i] ; if(ar[i]>=0) an=0 ;}
    if(k==n)
    {
        int ans=1 ;
        for(int i = 0 ; i < n ; i++)
        {
            int x=ar[i] ;
            x=(x+mod)%mod ;
            ans=(ans*x)%mod ;
        }
        cout<<ans<<endl ;
    }
    else
    {
        if(an)
        {
           // cout<<"jkl "<<k<<endl ;
            if(k&1ll) sort(ar,ar+n,cmp) ;
            else sort(ar,ar+n) ;
            int ans=1 ;
            for(int i = 0 ; i < k ; i++)
            {
                int x=ar[i] ;
                x=(x+mod)%mod ;
                ans=(ans*x)%mod ;
            }
            cout<<ans<<endl ;
        }
        else
        {
           // cout<<"oo"<<endl ;
            int ans=1 ;
            for(int i = 0 ; i < n ; i++)
            {
                if(ar[i]>=0) ps.push_back(ar[i]) ;
                else ne.push_back(ar[i]) ;
            }
            sort(ps.begin(),ps.end()) ;
            sort(ne.rbegin(),ne.rend()) ;
          //  for(int i = 0 ; i < ps.size() ; i++) cout<<ps[i]<<" " ; cout<<endl ;
          //  for(int i = 0 ; i < ne.size() ; i++) cout<<ne[i]<<" " ; cout<<endl ;
            if(k&1)
            {
                int x=ps.back() ; ps.pop_back() ;
                ans=(ans*x*1ll)%mod ;
            }
            while((int)ps.size()>1)
            {
                int x=ps.back() ; ps.pop_back() ;
                int y=ps.back() ; ps.pop_back() ;
                int h=(x*y) ;
                // h%=mod ;
                tup.push_back(h) ;
            }
            while((int)ne.size()>1)
            {
                int x=ne.back() ; ne.pop_back() ;
                int y=ne.back() ; ne.pop_back() ;
                int h=(x*y) ;
                // h%=mod ;
                tup.push_back(h) ;
            }
            sort(tup.rbegin(),tup.rend()) ;
            //for(int i = 0 ; i < (int)tup.size() ; i++) cout<<tup[i]<<" " ; cout<<endl ;
            for(int i = 0 ; i < k/2 ; i++)
            {
                ans%=mod ; tup[i]%=mod ;
                ans=(ans*tup[i])%mod ;
            }
            cout<<ans%mod<<endl ;

        }
    }

}
// -1000000000 -1 -1000000000 -1000000000 -1000000000


Measured memory_bytes: 8116
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int n;int m;
int dp[100005];
map<int,int>mp;
void solve()
{
	for(int i=3;i<=n;i++)
	{
		if(mp[i]>0)
		 dp[i]=0;
		else
		 dp[i]=(dp[i-1]+dp[i-2])%mod; 
	}
}

int main() 
{
    ios;
    cin>>n>>m;
     f(i,0,m)
     {
     	int x;cin>>x;
     	mp[x]++;
	 }
	  dp[0]=0;
	  if(mp[1]==0)
	   dp[1]=1;
	   if(mp[2]==0&&mp[1]==0)dp[2]=2;
	   else if(mp[2]==0)dp[2]=1;
	  solve(); 
	 cout<<dp[n]; 
}



Measured memory_bytes: 5376
#include <stdio.h>
#include <string.h>

int main(void)
{
	//int i;
	char s[100];
	char p[100];
	char sp[200];

	/*for(i = 0; i < 100; i++)
	{
		s[i] = '\0';
		p[i] = '\0';
	}
	
	for(i = 0; i < 200; i++)
	{
		sp[i] = '\0';
	}*/
	
	scanf("%s", s);
	scanf("%s", p);
    strcat(sp, s);
	strcat(sp, s);
	
	if(strstr(sp, p))
	{
	    printf("Yes\n");
	}
	else
	{
	    printf("No\n");
	}
}

Measured memory_bytes: 2672
import numpy as np

n = int(input())
p = list(map(int,input().split(" ")))

def check_condition(l):
  if (l[0] < l[1] < l[2]) or  (l[0] > l[1] > l[2]):
    return 1
  else:
  	return 0

is_satisfied = [check_condition(p[i:i+3]) for i in range(n-2)]
  
print(np.sum(is_satisfied))

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

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

const long long INF = 1LL << 60;

int N;
double p[3100];
double dp[3100][3100];

int main(){
  cin >> N;
  p[0] = 0;
  REP(i, 1, N) cin >> p[i];

  dp[0][0] = 1;
  REP(i, 1, N){
    REP(j, 0, i){
      if(j > 0) dp[i][j] += dp[i-1][j-1] * p[i];
      dp[i][j] += dp[i-1][j] * (1 - p[i]);
    }
  }

  double ans = 0;
  REP(j, (N+1)/2, N) ans += dp[N][j];
  
  cout << fixed << setprecision(10) << ans << endl;

  return 0;
}


Measured memory_bytes: 72320
#include<stdio.h>
#include<iostream>
#include<algorithm>
#define MAX 1000000
using namespace std;

class P{
public:
  int id, value;
  P(){}
  P(int id, int value):id(id), value(value){}

  bool operator > ( const P &p ) const{
    if ( value == p.value ){
      return id < p.id;
    } else {
      return value > p.value;
    }
  }

};

P A[MAX+1];
int size;
int I[MAX+1]; // index of heap

void downHeap(int i){

  int l, r, largest;
  l = 2*i;
  r = 2*i+1;
  if ( l <= size && A[l] > A[i] ) largest = l;
  else largest = i;

  if ( r <= size && A[r] > A[largest] ) largest = r;

  if ( largest != i ){
    I[A[i].id] = largest;
    I[A[largest].id] = i;
    swap(A[i], A[largest]);
    downHeap(largest);
  }
}

void upHeap(int i){
  while ( i > 1 && A[i] > A[i/2]){
    I[A[i].id] = i/2;
    I[A[i/2].id] = i;
    swap(A[i], A[i/2]);

    i = i/2;
  }
}

main(){
  int id, value;
  int n, q;

  size = MAX;
  for ( int i = 1; i <= MAX; i++ ){
    A[i].value = 0;
    A[i].id = i;
    I[i] = i;
  }

  cin >> n >> q;

  int total = 0;
  for ( int i = 0; i < q; i++ ){
    scanf("%d %d", &id, &value);
    total += value;
    A[I[id]].value += value;
    if ( value > 0 ){
      upHeap(I[id]);
    } else if ( value < 0 ){
      downHeap(I[id]);
    }
    cout << A[1].id << " " << A[1].value << endl;
  }
  
  return 0;
}

Measured memory_bytes: 12964
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(i, e) cerr << #i << ' ' << i << e
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 300010, p = 1e9+7;
ll bin_pow(ll v, ll t) {
	ll res = 1;
	for (;t;t>>=1, v = v * v % p)
		if (t&1) res = res * v % p;
	return res;
}
ll inv(int i) {
	if (i <= 1) return 1;
	return (p - p/i) * inv(p % i) % p;
}
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n;
	cin >> n;
	ll res = 0;
	ll cni = n;
	for (int i = 1;i <= n;++i) {
		res = (res + cni * (bin_pow(2, i) + p - 2) % p * bin_pow(8, n-i)) % p;
		//cout << "C " << n << ' ' << i << " : " << cni << endl;
		cni = (cni * (n-i) % p * bin_pow(i+1, p-2)) % p;
//		if (inv(i+1) != bin_pow(i+1, p-2)) {
//			cerr << i+1 << '\n';
//			cerr << inv(i+1) << ' ' << bin_pow(i+1, p-2) << '\n';
//		}
//		assert(inv(i+1) == bin_pow(i+1, p-2));
	}
	cout << res << '\n';
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;



const long long int mod=1000000007;
const long long int INF=99999999999999999;
long long int n;
string str;
int main() {
	cout << fixed << setprecision(18);
    cin>>n>>str;
    for(int i=0;i<str.length();i++){
        str[i]=(str[i]-'A'+n)%26+'A';
    }
    cout<<str;
} 


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
double pi = 3.14159265358979323846;
double l = 0, r = pi / 2, m;
double a, b, x;
double S(double t) {
	if (a * tan(t) < b)return(a * b - 0.5 * a * a * tan(t));
	else return 0.5 * b * b / tan(t);
}
int main() {
	scanf("%lf%lf%lf", &a, &b, &x);
	x /= a;
	while ((l + 0.0000000001) < r) {
		m = (r + l) / 2;
		if (S(m) <= x)r = m;
		else l = m;
	}
	printf("%.10lf\n", r * 180 / pi);
}


Measured memory_bytes: 2632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

ll fnk[2000][2000];

// 魔法はすべてのスライムの色を変える

void solve() {
    int n, x;
    cin >> n >> x;
    
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    // make f(n, k) : 魔法k回使える n番目のスライムは何番のスライムから作るか(最小の)
    rep(i, n) fnk[i][0] = a[i];
    rep3(k, 1, n) { // 魔法を使う回数
        rep(i, n) {
            fnk[i][k] = min(fnk[i][k - 1], a[(i - k + n) % n]);
        }
    }
    
    // rep(k, n) { rep(i, n) cout << fnk[i][k] << " "; cout << endl; }
    
    ll ans = 1e18;
    rep(k, n) {
        ll tmp = 0;
        rep(i, n) {
            tmp += fnk[i][k];
        }
        // out(k << " " << tmp);
        chmin(ans, (ll)k * x + tmp);
    }
    
    out(ans);
}

int main() {
    solve();
}



Measured memory_bytes: 31616
import java.util.Scanner;

public class Main {
// Mainに書き換え！

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        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;

        if (x == 1 && y == 1) ans += 400000;
        // 出力
        System.out.println(Integer.toString(ans));

    }
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

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

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ll N; cin >> N;
    map<string, ll> m;
    ll ans = 0;
    REP(i, N) {
        string s; cin >> s;
        sort(s.begin(), s.end());
        m[s]++;
    }
    for(auto x : m) {
        ans += x.second * (x.second - 1) / 2;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 11340
from math import isinf

N, Ma, Mb = map(int, input().split())
a,b,c = [],[],[]
aappend = a.append
bappend = b.append
cappend = c.append
for i in range(N):
    ai,bi,ci = map(int, input().split())
    aappend(ai)
    bappend(bi)
    cappend(ci)

W_MAX = 40*10
dp = [[float('inf')]*(W_MAX+1) for _ in range(W_MAX+1)]
dp[0][0] = 0

for i in range(N):
    for wa in reversed(range(W_MAX+1)):
        for wb in reversed(range(W_MAX+1)):
            if isinf(dp[wa][wb]): continue
            if wa+a[i]<=W_MAX and wb+b[i]<=W_MAX:
                dp[wa+a[i]][wb+b[i]] = min(dp[wa+a[i]][wb+b[i]],
                                           dp[wa][wb]+c[i])

ans = float('inf')
for wa in range(1, W_MAX+1):
    for wb in range(1, W_MAX+1):
        if wa*Mb == wb*Ma:
            ans = min(ans, dp[wa][wb])

if isinf(ans): ans = -1
print(ans)

Measured memory_bytes: 48860
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll unsigned long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll spf[10000007]; 
#define MAXN 10000007
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (ll j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	ll ans=0;
	sieve();
	for(ll i=1;i<=n;i++){
		ll c=0;
		ll x=i;
		ll prev=-1;
		ll fact=1;
		while(x!=1){
			if(spf[x]!=prev&&prev!=-1){
				fact*=(c+1);
				c=1;
			}
			else
				c++;
			prev=spf[x];
			x=x/spf[x];
		}
		fact*=(c+1);
		ans+=i*(fact);
	}
	
	cout<<ans<<"\n";
	
}


Measured memory_bytes: 81772
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

string S;

int main(){
  cin >> S;
  if(S[0] == S[1] && S[1] == S[2] && S[2] == S[3]) {
    cout << "No" << endl;
  } else if(S[0] == S[1] && S[2] == S[3]) {
    cout << "Yes" << endl;
  } else if (S[0] == S[2] && S[1] == S[3]) {
    cout << "Yes" << endl;
  } else if (S[0] == S[3] && S[1] == S[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define EPS 1e-7

int main(void) {
    int n, i;
    double x1, y1, x2, y2, x3, y3, x4, y4, dx1, dx2;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",
              &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
        dx1 = x2 - x1;
        dx2 = x4 - x3;
        if (fabs(dx1) < EPS || fabs(dx2) < EPS) {
            if (fabs(dx2 - dx1) < EPS) puts("YES");
            else puts("NO");
        }
        else if (fabs((y2-y1)/dx1 - (y4-y3)/dx2) < EPS) {
            puts("YES");
        }
        else {
            puts("NO");
        }
    }
    return 0;
}

Measured memory_bytes: 620
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  string ans;
  rep(i,s.size()){
    if(i==0) {
      ans = s[i];
      ans += t[i];
    }
    else {
      ans += s[i];
      if(t.size()==i) break;
      ans += t[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

ans = 100000
for i in range(len(S)-2):
	ans = min(ans, abs(753-int(S[i:i+3])))
print(ans)


Measured memory_bytes: 5400
import math
N, K = list(map(int, input().split()))

func = [0] * 2001
g = 10 ** 9 + 7
w = 1
for i in range(1, 2001):
    w = w * i
    func[i] = w
func[0] = 1

for i in range(1, K+1):
    #print((N-K+1, N-K+1-i, i, K, K-i, i))
    print((func[N-K+1] // func[N-K+1-i] // func[i]) * (func[K-1] // func[K-i] // func[i-1]) % g)


Measured memory_bytes: 5748
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    vector<int> a(n+1);
    repf(i,1,n+1) cin >> a[i];
    vector<int> b(n+1);
    int m = 0;
    for (int i = n; i >= 1; i--) {
        int sum = a[i];
        for (int j = i+i; j <= n; j += i) {
            sum += b[j];
        }
        b[i] = sum%2;
        if (b[i]) m++;
    }
    cout << m << endl;
    if (m) {
        repf(i,1,n+1) {
            if (b[i]) cout << i << endl;
        }
    }
    return 0;
}

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

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

	int n, k; cin >> n >> k;
	vector<int> has(n+1);
	for (int i = 0; i < k; i++) {
		int x; cin >> x;
		while (x--) {
			int y; cin >> y;
			has[y] = 1;
		}
	}

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += (has[i] == 0);
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const LL INF=1e9;

int main(){
    int Q;
    cin>>Q;
    vector<LL>res;
    REP(i,Q){
        LL A,B;
        cin>>A>>B;
        if (A>B)swap(A,B);
        if(B-A<=1LL){
            res.PB(2LL*(A-1LL));
        }else{
            LL C=sqrt(A*B);
            if(C*C==A*B)C--;
            if(C*(C+1LL)>=A*B){
                res.PB(2LL*C-2LL);
            }else{
                res.PB(2LL*C-1LL);
            }

        }
    }
    REP(i,Q)cout<<res[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

ll fact[maxn];

ll C(ll n, ll k) {
	ll ret = 1;
	for (ll i = n - k + 1; i <= n; i++) {
		ret = mul(ret, i);
	}
	ll kek = 1;
	for (ll i = 1; i <= k; i++) {
		kek = mul(kek, i);
	}
	return mul(ret, inv(kek));
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	fact[0] = 1;
	for (ll i = 1; i < maxn; i++) {
		fact[i] = mul(fact[i - 1], i);
	}

	ll n, a, b; cin >> n >> a >> b;
	ll ans = poww(2LL, n) - 1;
	ans %= mod; if (ans < 0) ans += mod;
	ll kek1 = C(n, a);
	ll kek2 = C(n, b);
	ans -= kek1 + kek2;
	ans %= mod;
	if (ans < 0) ans += mod;
	cout << ans << endl;

	return 0;
}

/*
3
0 1
3 0
1 0
*/

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, K, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    vector<vector<vector<ll>>> DP;
    DP.resize(51);
    for(int i=0;i<51;i++) {
        DP[i].resize(51);
        for(int j=0;j<51;j++) {            
            DP[i][j].resize(2500, 0);
        }
    }
    DP[0][0][0]++;
    for(int i=0;i<N;i++) {
        for(int j=0;j<N;j++) {
            for(int l=0;l<=50*50;l++) {
                DP[i+1][j][l] += DP[i][j][l];
                DP[i+1][j+1][l+A[i]] += DP[i][j][l];
            }
        }
    }
    /*
    for(int i=0;i<N+1;i++) {
        for(int j=0;j<N+1;j++) {
            cout << endl;
            for(int l=0;l<=35;l++) {
                cout << " " << DP[i][j][l];
            }
        }
    }
    */
    for(int i=1;i<N+1;i++) {
        ans += DP[N][i][K*i];
        //cout << DP[N][i][K*i] << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 54516
#include<stdio.h>

int main()
{
    int a,b,c,d,bi,end;
    scanf("%d%d%d%d",&a,&b,&c,&d);

    if(a<=c)
     bi=c;
     else bi=a;
    if(b<=d)
     end=b;
     else end=d;
     if((end-bi)<=0)
     printf("%d",0);
     else
      printf("%d",end-bi);


     return 0;
}


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

n, m = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

###具体例###
for _ in range(m):
    a, b = [int(x) for x in input().split()]
    unite(a - 1, b - 1)

ans = 0

for i, j in enumerate(p):
    if same(i, j - 1):
        ans += 1

print(ans)

Measured memory_bytes: 87312
if __name__ == '__main__':
    N, M, C = map(int, input().split())
    B = list(map(int, input().split()))
    A = [list(map(int, input().split())) for _ in range(N)]
    count = 0
    
    for i in range(N):
        S = 0
        for j in range(M):
            S += A[i][j]*B[j]
        if S + C > 0:
            count += 1
    
    print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;

int h, w;
char a[8][10];

int main() {
	int i, j;
	
	cin >> h >> w;
	for (i = 0; i < h; i++) cin >> a[i];
	
	for (i = 1; i < h; i++) {
		for (j = 0; j < w; j++) { if (a[i][j] == '#') break; } int l = j;
		for (j = w - 1; j >= 0; j--) { if (a[i-1][j] == '#') break; } int r = j;
		if (l < r) { cout << "Impossible" << endl; return 0; }
	}
	cout << "Possible" << endl;
	return 0;
}

Measured memory_bytes: 764
parseInt(x) = parse(Int,x)

function main()
  N = parseInt(readline())
  c = 0
  for l = 1:N
    k = 1
    for i = 1:5
      l >= 10^i ? k = i+1 : tmp = 0
    end
    k%2 == 1 ? c+=1 : tmp = 0 
  end
  println(c) 
end

main()

Measured memory_bytes: 165220
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, S: "List[str]"):
    print(len(set(S)))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)


if __name__ == '__main__':
    main()


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

using Pi = pair < int , int >;

int main()
{
	int N, M;
	int ans[100005];
	int P[100005], Y[100005];	
	vector < Pi > dat[100006];

	cin >> N >> M;

	for ( int i = 0; i < M; i++ ) {
		cin >> P[i] >> Y[i];
		dat[P[i]].emplace_back(Y[i], i);
	}
	
	for ( int i = 1; i <= N; i++ ) {
		sort(begin(dat[i]), end(dat[i]));
		for ( size_t j = 0; j < dat[i].size(); j++ ) {
			auto &x = dat[i][j];
			ans[x.second] = j + 1;
		}
	}

	for ( int i = 0; i < M; i++ ) {
		printf("%06d%06d\n", P[i], ans[i]);
	}

	return ( 0 );
}


Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <set>
#include <math.h>
using namespace std;

int main(){

    string s;
    set<char> backet;

    cin >> s;

    for(int i = 0; i < s.size(); ++i){
        if(backet.count(s[i]) == 1){
            cout << "no" << endl;
            return 0;
        }
        backet.insert(s[i]);
    }

    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String S = "";
        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;

        for (int i = 0; i < N; i++) {
            S = sc.next();
            if (S.equals("AC")) {
                ac++;
            } else if (S.equals("WA")) {
                wa++;
            } else if (S.equals("TLE")) {
                tle++;
            } else {
                re++;
            }
        }
        PrintWriter out = new PrintWriter(System.out);
        out.println("AC x " + ac);
        out.flush();

        out.println("WA x " + wa);
        out.flush();

        out.println("TLE x " + tle);
        out.flush();

        out.println("RE x " + re);
        out.flush();

        sc.close();

    }
}

Measured memory_bytes: 59532
k, a, b = map(int, input().split())
bis = 1
if b - a < 3 or k < a + 1:
    print (k+1)
else:
    k -= (a-1)
    bis += (a-1)
    n = k // 2
    bis += (b-a) * n
    bis += k % 2
    print (bis)

Measured memory_bytes: 3060
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"

int main()
{
	ll n,x;
	cin>>n;
	for(ll i=1 ; i*i<=n ; i++){
		if(n%i==0) x = i;
		}
	cout<<x+(n/x)-2 <<nw;
	return 0;
}

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

bool isKaibun(int n){
    int A[5];
    for(int i =0; i < 5; i++){
        A[i] = n%10;
        n /=10;
    }
    bool flag = true;
    for(int i =0; i < 2; i++){
        if(A[i] != A[4-i]){
            flag = false;
            break;
        }
    }
    return flag;
}

int main(){
    int A, B;
    cin >> A >> B;
    int res = 0;
    for(int i = A; i <= B; i++){
        if(isKaibun(i)){
            res ++;
        }
    }
    cout << res << endl;
}

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

#define int long long
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; }

template <class Monoid> struct SegmentTree{
    using Func = function<Monoid(Monoid, Monoid)>;

    int size;
    vector<Monoid> seg;
    const Func merge;
    const Monoid def;

    SegmentTree(int n, Monoid d, const Func f): merge(f), def(d){
        for(size = 1; size <= n; size <<= 1);
        seg.assign(size*2, def);
    }

    Monoid& operator[] (int i) { return seg[i+size]; };
    void build(){ for(int i = size-1;i >= 0;i--) seg[i] = merge(seg[i*2], seg[i*2+1]); } 

    void update(int i, Monoid val){
        seg[i += size] = val;
        while(i >>= 1) seg[i] = merge(seg[i*2], seg[i*2+1]);
    }

    void add(int i, Monoid val){ update(i, val+seg[i+size]); }

    Monoid get(int a, int b){
        Monoid l = def, r = def;
        for(a += size, b += size; a < b; a >>= 1, b >>= 1){
            if(a & 1) l = merge(l, seg[a++]);
            if(b & 1) r = merge(seg[--b], r);
        }
        return merge(l, r);
    }
};

int solve(int n);

struct Data{
	int l;
	int r;
	int sum;
	int ma;
	bool t;
	Data(): l(0), r(0), sum(0), ma(0), t(true){}
	Data(int a){
		l = a;
		r = a;
		sum = a;
		ma = a;
		t = false;
	}

};


signed main(){
	int n;

	while(cin >> n, n != 0){
		solve(n);
	}

	return 0;
}

int solve(int n){

	auto merge = [](Data a, Data b){
		if(b.t) return a;
		if(a.t) return b;
		Data c;
		c.l = max(a.l, a.sum + b.l);
		c.r = max(b.r, b.sum + a.r);
		c.sum = a.sum + b.sum;
		c.ma = max({a.ma, b.ma, a.r + b.l});
		c.t = false;
		return c;
	};

	SegmentTree<Data> seg(n, Data(), merge);

	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		seg[i] = Data(a);
	}
	seg.build();
	cout << seg.get(0, n).ma << endl; 

	return 0;
}



Measured memory_bytes: 3264
#include<stdio.h>

int A,B;
int CA[5000],CB[5000];
int ken(int b){
	int i,corsole = b;
	for(i = 0;i < A;i++){
		if(corsole-b >= B)
			return B;
		if(CA[i] == CB[corsole])
			corsole++;
	}
	return corsole-b;
}
int main(){
	int i,num,max = 0;
	scanf("%d%d",&A,&B);
	for(i = 0;i < A;i++){
		scanf("%d",CA+i);
	}
	for(i = 0;i < B;i++){
		scanf("%d",CB+i);
	}
	for(i = 0;i < B-1;i++){
		//ブルーノの手持ちを上からi番目から検索
		num = ken(i);
		if(max < num)
			max = num;
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 1064
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

int main()
{
    //i文字目までに'AC'が含まれる数
    int ac[100001];

    int n, q;
    string s;
    cin >> n >> q;
    cin >> s;

    s = '0' + s;
    ac[0] = 0;

    for (int i = 2; i <= n; i++)
    {
        if (s[i - 1] == 'A' && s[i] == 'C')
        {
            ac[i] = ac[i - 1] + 1;
        }
        else
        {
            ac[i] = ac[i - 1];
        }
    }

    for (int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << ac[r] - ac[l] << endl;
    }

    return 0;
}

Measured memory_bytes: 1404
import bisect
while True:
  n,w,d=map(int,input().split())
  if n==w==d==0:break
  A=[w*d]
  B=[[0,w,w+d,2*w+d,2*w+2*d]]
  for _ in range(n):
    p,s=map(int,input().split())
    b=B.pop(p-1)
    S=A.pop(p-1)
    s%=b[-1]
    w=b[1]
    d=b[2]-w
    if bisect.bisect_left(b,s)%2:
      w1=s-b[bisect.bisect_left(b,s)-1]
      w2=w-w1
      d1,d2=d,d
    else:
      d1=s-b[bisect.bisect_left(b,s)-1]
      d2=d-d1
      w1,w2=w,w
    if w1*d1>w2*d2:
      A.append(w2*d2)
      A.append(w1*d1)
      B.append([0,w2,w2+d2,2*w2+d2,2*w2+2*d2])
      B.append([0,w1,w1+d1,2*w1+d1,2*w1+2*d1])
    else:
      A.append(w1*d1)
      A.append(w2*d2)
      B.append([0,w1,w1+d1,2*w1+d1,2*w1+2*d1])
      B.append([0,w2,w2+d2,2*w2+d2,2*w2+2*d2])
  print(*sorted(A))
  


Measured memory_bytes: 5672
#include <algorithm>
#include <iostream>
#include <list>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

int n;
int S[1000000];

bool binarySearch(int v) {
	int left = 0;
	int right = n;
	while (left < right) {
		int mid = (left + right) / 2;
		if (S[mid] == v) {
			return true;
		}

		if (v < S[mid]) right = mid;
		else left = mid + 1;
	}

	return false;
}

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

	int  q, cnt = 0;
	cin >> q;
	int T[50000];
	for (int i = 0; i < q; i++) cin >> T[i];

	for (int i = 0; i < q; i++) {
		if (binarySearch(T[i])) cnt++;
	}

	cout << cnt << endl;
}



Measured memory_bytes: 3608
import bisect

n, h = [int(item) for item in input().split()]

a_s, b_s = [], []
for i in range(n):
    a, b = [int(item) for item in input().split()]
    a_s.append(a)
    b_s.append(b)
    
a_s.sort()
b_s.sort()
throwable = bisect.bisect(b_s, a_s[-1])
throw_sum = sum(b_s[throwable:])

ans = 0
for item in b_s[throwable:][::-1]:
    h -= item
    ans += 1
    if h <= 0:
        print(ans)
        exit()

ans += h // a_s[-1]
if h % a_s[-1] != 0:
    ans += 1
if ans <= 0:
    ans = 1
print(ans)

Measured memory_bytes: 12416
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	string str;
	cin >> str;
	int len = str.length();

	if (str[(len-1)/2] != str[len/2]){
		printf("%d\n", len/2);
		return 0;
	}
	int cnt_l = 0, cnt_r = 0;
	for (int i = (len-1)/2; i >=0; i--){
		if (str[i] != str[(len-1)/2])
			break;
		cnt_l++;
	}
	for (int i = len/2; i < len; i++){
		if (str[i] != str[len/2])
			break;
		cnt_r++;
	}
	int cnt = 2 * min(cnt_l, cnt_r) - len%2;
	printf("%d\n", len - (len - cnt) / 2);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   if((a+b+c)==17)
   {
       cout<<"YES"<<endl;
   }

   else
   {
       cout<<"NO"<<endl;
   }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair



int main() {
    string S; cin >> S;
    if (S == "SSS") PRINT(0);
    else if (S == "RRR") PRINT(3);
    else if (S == "SRR" || S == "RRS") PRINT(2);
    else PRINT(1);
    return 0;
}

Measured memory_bytes: 3616
s=input()
n=s.split()
s=input()
p=s.split()
a=[]
a.append(int(p[0]))
now=a[0]
for i in range(1,int(n[0])):
	now+=int(p[i])
	a.append(now)
k=int(n[1])
m=a[k-1]
for i in range(k,int(n[0])):
	if m<a[i]-a[i-k] :
		m=a[i]-a[i-k]
print('{:.8f}'.format(m/2+k/2))


Measured memory_bytes: 25656
/*
AizuOnline A1010
Title Domino Arrangement
WA
*/
#include <stdio.h>
#include <setjmp.h>

int domino[28];
int flag[28];
int N;
jmp_buf env;
int State;
//
int can_connect(int s1,int n)
{
  int i,t1,t2;
#ifdef DEBUG
	printf("(%d)\n",n);
#endif
  if(n==0)
    {
      State=-1;
      longjmp(env,1);
    }

  for(i=0;i<28;i++)
    if(flag[i])
      {
	t1=domino[i] / 10;t2=domino[i] % 10;
#ifdef DEBUG
	printf("t1s1s2=%d %d %d(%d)\n",t1,t2,s1,n);
#endif
	if(s1 == -1)
	  {
	    flag[i]=0;
	    can_connect(t1,n-1);
	    can_connect(t2,n-1);
	    flag[i]=-1;
	   }
	else if(s1 == t1)
	  {
	    flag[i]=0;
	    can_connect(t2,n-1);
	    flag[i]=-1;
	   }
	else if(s1 == t2)
	  {
	    flag[i]=0;
	    can_connect(t1,n-1);
	    flag[i]=-1;
	   }

      }
  return;
}
void clearflag()
{
  int i;
  for(i=0;i<28;i++)
    flag[i]=0;
  for(i=0;i<N;i++)
    flag[i]=-1;
}
main()
{
  int i;
  while(EOF!=scanf("%d",&N) && N)
    {
      for(i=0;i<N;i++)
	scanf("%d ",&domino[i]);
      clearflag();
      State=0;
      if(setjmp(env)==0)
	{
	  can_connect(-1,N);
	}
      printf("%s\n",State?"Yes":"No");
    }
return(0);
}

Measured memory_bytes: 588
import math

N=int(input())

ANS=[0,1, 3, 2, 7, 4, 3, 6, 15, 8, 4, 10, 8, 12, 7, 5, 31, 16, 8, 18, 15, 6, 11, 22, 15, 24, 12, 26, 7, 28, 15, 30, 63, 11, 16, 14, 8, 36, 19, 12, 15, 40, 20, 42, 32, 9, 23, 46, 32, 48, 24, 17, 39, 52, 27, 10, 48, 18, 28, 58, 15, 60, 31, 27, 127, 25, 11, 66, 16, 23, 20, 70, 63, 72, 36, 24, 56, 21, 12, 78, 64, 80, 40, 82, 48, 34, 43, 29, 32, 88, 35, 13, 23, 30, 47, 19, 63, 96, 48, 44, 24]


if N<=100:
    print(ANS[N])
    exit()


def ff(x):
    L=int(math.sqrt(x))

    FACT=dict()

    for i in range(2,L+2):
        while x%i==0:
            FACT[i]=FACT.get(i,0)+1
            x=x//i

    if x!=1:
        FACT[x]=FACT.get(x,0)+1

    return FACT

# 拡張ユークリッドの互除法.ax+by=gcd(a,b)となる(x,y)を一つ求め、(x,y)とgcd(x,y)を返す.
def Ext_Euc(a,b,axy=(1,0),bxy=(0,1)): # axy=a*1+b*0,bxy=a*0+b*1なので,a,bに対応する係数の初期値は(1,0),(0,1)
    # print(a,b,axy,bxy)
    q,r=divmod(a,b)

    if r==0:
        return bxy,b # a*bxy[0]+b*bxy[1]=b
   
    rxy=(axy[0]-bxy[0]*q,axy[1]-bxy[1]*q) # rに対応する係数を求める.
    return Ext_Euc(b,r,bxy,rxy)

FACT=ff(N*2)
LIST=[]
for f in FACT:
    LIST.append(f**FACT[f])
    
L=len(LIST)

LANS=1<<60

for i in range(1,(1<<L)-1):
    A=1
    B=1
    for j in range(L):
        if i & (1<<j)!=0:
            A*=LIST[j]
        else:
            B*=LIST[j]
    #print(A,B)
    #print(Ext_Euc(A,-B))
    x,_=Ext_Euc(A,-B)
    x,y=x[0],x[1]
    # ANS=x+B*k

    if x<0:
        x+=(1+abs(x)//B)*B
    #k=(B+x-1)//x
    #ANS=x+B*k
    #print(x,B,k,ANS)
    LANS=min(LANS,x*A)

print(LANS)
    


Measured memory_bytes: 71780
// header file section
#include <iostream>
#include <cstdio>
#include <cfloat>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <numeric>
#include <algorithm>

using namespace std;
using llong = long long;

// library section
// ===

vector<llong> v;
llong a[10];

llong num() {
    llong s = 0;
    for (int i = 0; i < 10; i++) {
        s *= 10;
        s += a[i];
    }
    return s;
}

void lunlun(llong led, llong dig) {
    if (dig >= 10) {
        v.push_back(num());
        return;
    }

    if (led == 9) {
        a[dig] = 9;
        lunlun(9, dig + 1);
        a[dig] = 8;
        lunlun(8, dig + 1);
    }
    else if (led == 0) {
        a[dig] = 0;
        lunlun(0, dig + 1);
        a[dig] = 1;
        lunlun(1, dig + 1);
    }
    else {
        a[dig] = led + 1;
        lunlun(led + 1, dig + 1);
        a[dig] = led;
        lunlun(led, dig + 1);
        a[dig] = led - 1;
        lunlun(led - 1, dig + 1);
    }
    a[dig] = 0;
    return;
}

int main() {
    llong k;
    cin >> k;

    for (int i = 0; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            a[i] = j;
            lunlun(j, i + 1);
            a[i] = 0;
        }
    }

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

    cout << v[k - 1] << endl;

    return 0;
};



Measured memory_bytes: 2420
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
class UnionFind {
private:
	int size_; vector<int> g; vector<vector<int> > v;
public:
	UnionFind() : size_(0), g(vector<int>()), v(vector<vector<int> >()) {};
	UnionFind(int size__) : size_(size__) { g.resize(size_), v.resize(size_); for (int i = 0; i < size_; i++) g[i] = i, v[i] = { i }; };
	int size() { return size_; }
	int root(int x) { return g[x]; }
	int size(int x) { return v[x].size(); }
	bool same(int x, int y) { return g[x] == g[y]; }
	void unite(int x, int y) {
		x = g[x], y = g[y];
		if (x == y) return;
		if (v[x].size() < v[y].size()) swap(x, y);
		v[x].insert(v[x].end(), v[y].begin(), v[y].end());
		for (auto &e : v[y]) g[e] = x;
		v[y].clear();
	}
	bool operator==(const UnionFind& u) { return g == u.g; }
	bool operator!=(const UnionFind& u) { return g != u.g; }
	int operator[](int x) { return g[x]; }
};
struct edge { int s, to, cost; };
bool operator<(const edge& e1, const edge& e2) { return e1.cost < e2.cost; }
int V, E, x[10009], y[10009], s, t; edge e[99999];
int main() {
	scanf("%d%d", &V, &E);
	for (int i = 0; i < V; i++) scanf("%d%d", x + i, y + i);
	for (int i = 0; i < E; i++) {
		scanf("%d%d", &s, &t); s--, t--;
		int dist = (x[s] - x[t]) * (x[s] - x[t]) + (y[s] - y[t]) * (y[s] - y[t]);
		e[i] = edge{ s, t, dist };
	}
	sort(e, e + E);
	reverse(e, e + E);
	UnionFind u(V);
	double ret = 0;
	for (auto &v: e) {
		if (u.same(v.s, v.to)) ret += sqrt(v.cost);
		else u.unite(v.s, v.to);
	}
	printf("%.9f\n", ret);
	return 0;
}

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

int main() {
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	printf("%.10f\n", sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
}



Measured memory_bytes: 3288
#1_5_c
while True:
    H , W = map(int,input().split())
    if W == 0 and H == 0:
        break
    for i in range(1,H+1):
        if i%2 == 0:
            for k in range(1,W+1):
                if k%2 == 0:
                    print("#" , end="") 
                else:
                    print("." , end="")
            print()
        else:
            for k in range(1,W+1):
                if k%2 == 0:
                    print("." , end="")
                else:
                    print("#",end="")
            print()
    print()


Measured memory_bytes: 7008
n = int(input())
aaa = list(map(int, input().split()))

sum_a = 0
sum_aa = 0
for a in aaa:
  sum_a += a
  sum_aa += a ** 2
  
print(((sum_a ** 2 - sum_aa) // 2) % (10 ** 9 + 7))

Measured memory_bytes: 31576
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll N;
	cin >> N;
	if (N % 2 == 0){
			cout << N << endl;
	}
	else{
	cout << N * 2 <<endl;
	}
	return 0;
}

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

int main(void)
{
	string n;
	cin >> n;

	long long ans = 0;

	for (auto e : n)
	{
		ans += (int)e - 48;
	}

	if (ans % 9 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3748
def main():
	# import sys
	# input = sys.stdin.readline
	S, T = list(map(str, input().split()))
	A, B = list(map(int, input().split()))
	U = input()
	# print(U)
	if U == S:
		print(A-1, B)
	else:
		print(A, B-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060