akhauriyash/Code-Regression huggingface dataset:
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;

int main(){
ll N;
cin>>N;
ll A[N],sum=0;
rep(i,N){
  cin>>A[i];
  sum+=A[i];
}
ll diff[N];
rep(i,N){
if(i==N-1){
  diff[i]=A[0]-A[i];
}
else{
  diff[i]=A[i+1]-A[i];
}
}
if(sum%(N*(N+1)/2)!=0){
  cout<<"NO"<<endl;
  return 0;
}
ll num=sum/(N*(N+1)/2);
ll sumdiff=0;
rep(i,N){
  if((diff[i]-num>0)||((diff[i]-num)%N!=0)){
    cout<<"NO"<<endl;
    return 0;
  }
  sumdiff+=diff[i]-num;
  
}
if(sumdiff==-N*num){
  cout<<"YES"<<endl;
}
else{
  cout<<"NO"<<endl;
}
}

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

using namespace std;

long long n , a[222222] , ans;

int main() {
	scanf("%lld" , &n);
	for (int i = 0; i < n; i++) scanf("%lld" , &a[i]);
	for (int i = 1; i < n; i++) {
		if (a[i] > a[i-1]) continue;
		ans += a[i-1]-a[i];
		a[i] = a[i-1];
	}
	printf("%lld" , ans);
	
	return 0;
}

Measured memory_bytes: 5372
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<iterator>

using namespace std;
bool sortit(pair<long int,int>&a, pair<long int,int>&b){
	return (a.first < b.first);
}
int main(){
	int n,m;
	cin >> n >> m;
  	// insertion into two arrays
  	long int arr1[n], arr2[n];
  vector<pair<long int,int>> vec;
  	for (int i = 0 ; i < n; i++)
    {
      cin >> arr1[i] >> arr2[i];
      vec.push_back(make_pair(arr1[i],arr2[i]));
    }
  	// sorting vector on basis of first element
  	sort(vec.begin(), vec.end(), sortit);
  // main code
  long long int res =0;
  int i = 0;
  while (m != 0){
  	if(vec[i].second < m) {
    	res += (vec[i].first)*(vec[i].second);
      m = m - vec[i].second;
    }
    else {
    	res += (vec[i].first)*m;
      	m = 0;
    }
    ++i;
  }
  cout << res<<'\n';
  return 0;
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
template <typename T>
void print(std::vector<T>& v, std::string s = " ") {}
template <class T>
void print(T& x){ cout << x << '\n';}


const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long A){
  if(N%500>A)print(NO);
  else print(YES);

}

int main(){
  long long N;
  scanf("%lld",&N);
  long long A;
  scanf("%lld",&A);
  solve(N, A);
  return 0;
}


Measured memory_bytes: 256
#A問題
H,W,A,B = map(int,input().split())

ans = []
for i in range(H):
    hlist = []
    if i < B:
        for j in range(W):
            if j < A:
                hlist.append("0")
            else:
                hlist.append("1")
    else:
        for j in range(W):
            if j < A:
                hlist.append("1")
            else:
                hlist.append("0")
    ans.append(hlist)
    
for hlist in ans:
    for h in hlist:
        print(h,end="")
    print()


Measured memory_bytes: 15732
#include <iostream>
using namespace std;
int main(){
    int x; cin >> x;
    bool c[x + 1] = {false};
    c[1] = true;
    for (int i = 2; i * i <= x; i++) {
        for (int j = i; j <= x; j *= i) {
            if (i != j) c[j] = true;
        }
    }
    for (int i = x; i > 0; i--) {
        if (c[i]) {cout << i << endl; return 0;}
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int n,k;
long long pow(long long a)
{
	return a*a*a;
}
long long ans()
{
	long long ret=pow(n/k);
	if(k&1) return ret;
	if(n%k<k/2) return ret*2;
	return ret+pow(n/k+1); 
}
int main()
{
	cin>>n>>k;
	cout<<ans()<<endl;
	return 0;
} 



Measured memory_bytes: 256
n = int(input())
s = input()
for c in ['SS','SW','WS','WW']:
    for d in range(1,n-1):
        if c[d] == 'S':
            if s[d] == 'o':
                c += c[d-1]
            elif c[d-1] == 'S':
                c += 'W'
            else:
                c += 'S'
        else:
            if s[d] == 'x':
                c += c[d-1]
            elif c[d-1] == 'S':
                c += 'W'
            else:
                c += 'S'
    res = ''
    for i in range(len(c)):
        if c[i-1] == c[(i+1)-len(c)]:
            if c[i] == 'S':
                res += 'o'
            else:
                res += 'x'
        else:
            if c[i] == 'S':
                res += 'x'
            else:
                res += 'o'
    if res == s:
        print(c)
        exit()
print(-1)


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define int long long
#define ld long double
#define sb __builtin_popcount
#define vi vector<int>
#define vc vector<char>
#define ii pair<int, int>
#define pq priority_queue<ii, vector<ii>, greater<ii>>
#define vii vector<ii>
#define sz(a) int((a).size())
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <=n; i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define in(a, b) (b.find(a) != string::npos)
#define minin(a) *min_element(all(a))
#define maxin(a) *max_element(all(a))
#define X first
#define Y second
#define fill(a, x) memset(a, x, sizeof(a))
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define rall(v) reverse(v.begin(), v.end())
#define el "\n"
#define mx3(a, b, c) max(max(a, b), c)
#define mn3(a, b, c) min(min(a, b), c)
#define S(v) accumulate(all(v), (ll)0)
#define SP(n) cout.precision(n)
#define PI = atan(1.0) * 4.0;
#define MOD = 1e9 + 7;
void start() {
    fio;
    SP(10);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
    start();
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)cin >> a[i];
    int xr = a[0];
    for (int i = 1; i < n; i++)xr ^= a[i];
    for (int i = 0; i < n; i++) {
        cout << (xr ^ a[i]) << " ";
    }
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  if(s == "Sunny"){
    cout << "Cloudy" << endl;
  }
  if(s == "Cloudy"){
    cout << "Rainy" << endl;
  }
  if(s == "Rainy"){
    cout << "Sunny" << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
a = []
b = []
if n == 1:
    print(0)
    exit()
if True:
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
kosuu = 1
mae = a[0]
for i in range(1,len(a)):
    if mae == a[i]:
        kosuu += 1
    else:
        mae = a[i]
        b.append(kosuu)
        kosuu = 1
b.append(kosuu)
ans = 0
for i in range(len(b)):
    for j in range(2,100):
        if b[i] < j*(j+1)//2:
            ans += j-1
            break
print(ans)

Measured memory_bytes: 9248
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <unordered_map>
#include <iterator>
#include <functional>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000009;


int T, n, m;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	vector<set<int>> g(n);
	vi deg(n);
	REP(i, m){
		int u, v;
		cin >> u >> v; u--; v--;
		g[u].insert(v); g[v].insert(u);
	}
	set<pii> s;
	REP(i, n) s.insert(pii(g[i].size(), i));
	int c = 0;
	ll ans = 1;
	while(!s.empty()){
		int u = s.rbegin()->second;
		int deg = g[u].size();
		s.erase(pii(deg, u));
		if([&](){
			for(int v : g[u]) if(g[v].size() != deg) return 0;
			return 1;
		}()){
			ans = ans * (deg + 1) % MOD;
			for(int v : g[u]) s.erase(pii(deg, v));
			c ++;
		}else{
			for(int v : g[u]){
				s.erase(pii(g[v].size(), v));
				g[v].erase(u);
				s.insert(pii(g[v].size(), v));
			}
		}
	}
	cout << c << endl;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 29704
#include<bits/stdc++.h>
using namespace std;
signed main()
{
 int a,b,c;
  cin>>a>>b>>c;
  if(c<=b){
    cout<<"delicious\n";
  }else{
    if(c-b>a){
     cout<<"dangerous\n";
   }else{
     cout<<"safe\n"; 
   }
  }
}

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

int main(){
  string a;
  cin>>a;
int r,x,D;
  r=a.size();
  x=0;
  for(int i=0;i<r;i++){
    if(a[i]=='o'){
      x++;
    }
  }
  x+=15-r;
  if(x>7){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

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

struct edge{
  int to, cost;
};

vector<edge> G[2000010];
bool vis[100010];
int d[100010];

bool dfs(int v,int dist){
  if(vis[v]){
    if(d[v] != dist){
        return true;
    }
    else{
        return false;
    }
  }
  vis[v] = true;
  d[v] = dist;
  for(int i=0;i<(int)G[v].size();i++){
    if(dfs(G[v][i].to,d[v]+G[v][i].cost)) return true;
  }
  return false;
}

int main(){
  int n,m;cin >> n >> m;
  for(int i=0;i<m;i++){
    int l,r,d;cin >> l >> r >> d;
    l--;r--;
    G[l].push_back({r,d});
    G[r].push_back({l,-d});
  }
  for(int i=0;i<n;i++){
    if(!vis[i]&&dfs(i,0)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 56576
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;


int main(){
   int N,M; cin >> N >> M;
   int m = M/N;
   int ans = 0;
   for(int i = m; i >= 1; i--){
      if(M % i == 0){
         ans = i;
         break;
      }
   }
   cout << ans << endl;
}



Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

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

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...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n, k; cin >> n >> k;
	vector<int> p(n); for (int i = 0; i <= n - 1; i++) cin >> p[i];
	sort(p.begin(), p.end());

	int ans = 0;
	for (int i = 0; i <= k - 1; i++) ans += p[i];
	cout << ans;

	return 0;
}

Measured memory_bytes: 3620
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define pause system("pause")


signed main() {
	int s, s1, s2, s3;
	cin >> s;
	s3 = s % 10;
	s2 = (s % 100 - s3) / 10;
	s1 = (s - s2 - s3) / 100;
	s = s1 + s2 + s3;
	cout << s << endl;

	pause;
}

Measured memory_bytes: 504
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect

n,m=map(int,input().split())
k=2**n
inf=10**7
d=[[inf]*k for _ in range(m+1)]
for i in range(m+1):
  d[i][0]=0
for i in range(m):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    res=0
    for x in c:
        res+=2**(x-1)
    for j in range(2**n):
        jx=j|res
        d[i+1][j]=min(d[i+1][j],d[i][j])
        d[i+1][jx]=min(d[i][jx],d[i][j]+a,d[i+1][jx])
if d[-1][-1]==10**7:
  print(-1)
else:
  print(d[-1][-1])


Measured memory_bytes: 111920
#include<iostream>
#define LE(x) (2*(x))
#define RI(x) (2*(x)+1)
#define PA(x) ((x)/2)
using namespace std;
const int N_MAX = 500005;
int H[N_MAX];
int n;

/*void test(int flag){
    cout<<"///////////NOW TEST//////////"<<endl;
    for(int i=1;i<=n;i++){
        cout<<H[i]<<' ';
    }
    cout<<endl<<"///////////flag = "<<flag<<"//////////"<<endl;
    getchar();
}*/

void maxHeapify(int flag){
    if(flag>PA(n)){
        return;
    }
    int l = LE(flag);
    int r = RI(flag);
    if(r<=n){
        if(H[r]>H[l]){
            if(H[r]>H[flag]){
                H[r]^=H[flag];
                H[flag]^=H[r];
                H[r]^=H[flag];
                //test(flag);
                maxHeapify(r);
            }else{
                return;
            }
        }else{
            if(H[l]>H[flag]){
                H[l]^=H[flag];
                H[flag]^=H[l];
                H[l]^=H[flag];
                //test(flag);
                maxHeapify(l);
            }else{
                return;
            }
        }
    }else{
        if(H[l]>H[flag]){
                H[l]^=H[flag];
                H[flag]^=H[l];
                H[l]^=H[flag];
                //test(flag);
        }else{
            return;
        }
    }
}

void buildMaxHeap(){
    for(int i=PA(n); i>0; i--){
        maxHeapify(i);
    }
}

int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>H[i];
    }
    buildMaxHeap();
    for(int i=1;i<=n;i++){
        cout<<' '<<H[i];
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 4964
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int n,w,v,size;
double maxm;
double t[11];

int main(){
  while(1){
    cin>>n>>w;
    if(n==0&&w==0)break;
    for(int i=0;i<11;i++)t[i]=0;
    size=maxm=0;
    for(int i=0;i<n;i++){
      cin>>v;
      t[v/w]+=1.0;
      maxm=max(maxm,t[v/w]);
      size=max(size,v/w);
    }
    double ans=0.0;
    for(int i=0;i<=size;i++){
      ans+=(double)(size-i)*t[i];
    }
    printf("%.8f\n",ans/maxm/(double)size+0.01);
  }
  return 0;
}

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

int N,M;
int a,b;

int main(){
	cin >> N >> M;
	bool first[200001];
	bool last[200001];
	for(int i=0;i<=N;i++){
		first[i] = false;
		last[i] = false;
	}

	for(int i=0;i<M;i++){
		cin >> a >> b;
		if(a==1) first[b] = true;
		else if(b==N) last[a] = true;
	}
	int f = 0;
	for(int i=1;i<N;i++){
		if(first[i]==true){
			if(last[i]==true){
				cout << "POSSIBLE\n";
				f = 1;
				break;
			}
		}
	}
	if(f==0) cout <<"IMPOSSIBLE\n";
	return 0;	
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;


int main(){
	int N,M;
	while(cin>>N>>M&&N){
		int P[11]={0};
		int d,p;
                long long int ans=0;
		REP(i,0,N){
			cin>>d>>p;
			P[p]+=d;
		}
		for(int i=10;i>=0;i--){
			if(P[i]>=M){
				P[i]-=M;
				break;
			}else{
				M-=P[i];
				P[i]=0;
			}
		}
		REP(i,1,11){
			ans+=i*P[i];
		}
		p(ans);
	}

	return 0;
}

Measured memory_bytes: 2988
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.nextLine());

        if (N < 100) {
            System.out.println(0);
            return;
        }
        if (5 * (N / 100) >= N % 100) {
            System.out.println(1);
        } else {
            System.out.println(0);
        }
    }

}


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

int n,a,maxx,minn=1010;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) {
		cin>>a;
		if(a>maxx) maxx=a;
		if(a<minn) minn=a;
	}
	cout<<maxx-minn<<endl;
	return 0;
}

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

int main(){
	int H[300], W[300];
	int s = 0;
	for (;;){
		cin >> H[s] >> W[s];
		if (H[s] == 0 && W[s] == 0)break;
		s++;
	}
	for (int t = 0; t < s; t++){
		for (int i1 = 0; i1 < H[t];i1++){
			for (int i2 = 0; i2 < W[t];i2++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <queue>

using namespace std;
#define ll long long
#define pb push_back

int cnt, h, w, xy[110][110]={-1};
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
pair<int,int> p;
char c[110][110];
queue<pair<int,int> > q;
 
int bfs(int x,int y){
  // チェック済みかどうかの配列
	for(int i =0; i < h; i++){
		for(int j =0; j < w; j++){
			xy[i][j]=-1;
		}
	}
	q.push(pair<int,int>(x, y));
	xy[x][y]=0;
	while(q.size()){
		p=q.front(); //先頭の要素をqに入れる
		q.pop(); // 先頭の要素を取り出す
		for(int i = 0; i < 4; i ++){ // 1ノードで辿れるものを順番に見ていくことにより幅優先
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if(0 <= nx && nx <h  && 0 <= ny && ny < w && c[nx][ny] != '#' && xy[nx][ny]==-1){
				q.push(pair<int, int>(nx, ny));
				xy[nx][ny] = xy[p.first][p.second]+1;
			}
		}
	}
	return xy[p.first][p.second];
}
int32_t main()
{
	cin>>h>>w;
	for(int i =0; i<h; i++)
		for(int j =0; j<w; j++)
			cin>>c[i][j];
	for(int i =0; i<h; i++)
		for(int j =0; j<w; j++)
			if(c[i][j]=='.')
				cnt = max(cnt, bfs(i,j));
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s;
    cin >> s;
    bool a=false;
    bool b=false;
    for(int i=0;i<3;i++){
        if(s.at(i)=='A')a=true;
        if(s.at(i)=='B')b=true;
    }
    if(a&&b) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	while(sc.hasNext()) {
		int m=sc.nextInt();
		int f=sc.nextInt();
		int r=sc.nextInt();
		if(m==-1 && f==-1 && r==-1) {
			break;
		}else {
			int x;
			x=m+f;
			if(m==-1 || f==-1) {
				System.out.println("F");
			}
			if(x>=80 && m!=-1 && f!=-1 ) {
				System.out.println("A");
			}
			if(x<80 && x>=65 && m!=-1 && f!=-1 ) {
				System.out.println("B");
			}
			if(x<65 && x>=50 && m!=-1 && f!=-1 ) {
				System.out.println("C");
			}
			if(x<50 && x>=30 && m!=-1 && f!=-1 && r>=50) {
				System.out.println("C");
			}if(x>=30 && x<50 && m!=-1 && f!=-1 && r<50) {
				System.out.println("D");
			}
			if(x<30 && m!=-1 && f!=-1 ) {
				System.out.println("F");
			}
		}
	}
}
}



Measured memory_bytes: 26132
#include <bits/stdc++.h>
#define inf INFINITY
#define file freopen( "input.txt" , "r" , stdin) ; freopen( "output.txt" , "w" , stdout) ;
#define Gamed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define _3102_ main()
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
const int N = 1e5 + 100;
const ll MX = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-9 ;

ll n, h[N], dp[N] ;
ll solve( int i ){
	if ( i < 0 ) return 0 ;
	ll &ret = dp[i] ;
	if ( ~ret ) return ret ;
	if ( i == 0 ) return ret = 0 ;
	if ( i == 1 ) return ret = abs( h[1] - h[0]) ; 
	return ret = min ( solve(i - 1 ) + abs(h[i] - h[i-1]) , solve ( i - 2 ) + abs ( h[i] - h[i-2])) ;
}

int _3102_{
	Gamed
	cin >> n ;
	for ( int i = 0 ; i < n ; i ++ ){
		cin >> h[i] ;
	}
	memset ( dp , -1 , sizeof dp ) ;
	cout << solve ( n - 1 ) ;

	return 0;
}


Measured memory_bytes: 7532
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const long long LINF = 1000000000000000018ll;
const int INF = 1000000009;
const int mod = 1000000007;

int v;
struct Edge {
  int dst;
  long long cost;
  Edge() {}
  Edge(int x, int y) : dst(x), cost(y) {}
};

vector<vector<Edge> > graph;
vector<long long> dijkstra(int start_v) {
  vector<long long> dist(v, 1000000000000000018ll);
  dist[start_v] = 0;
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
    greater<pair<long long, int> > > q;

  q.push(make_pair(0, start_v));

  while (!q.empty()) {
    pair<long long, int> t = q.top(); q.pop();
    int cur_v = t.second;
    for (int i = 0; i < graph[cur_v].size(); i++) {
      int next_v = graph[cur_v][i].dst;
      long long cost = graph[cur_v][i].cost;
      if (dist[next_v] > dist[cur_v] + cost) {
        dist[next_v] = dist[cur_v] + cost;
        q.push(make_pair(dist[next_v], next_v));
      }
    }
  }
  return dist;
}

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

  cin >> v;
  graph.assign(v, vector<Edge>());
  for (int i = 0; i < v-1; i++) {
    int src, dst, cost;
    cin >> src >> dst >> cost;
    src--; dst--;
    graph[src].push_back(Edge(dst, cost));
    graph[dst].push_back(Edge(src, cost));
  }
  int q, k;
  cin >> q >> k;
  vector<long long> dist = dijkstra(k-1);
  for (int i = 0; i < q; i++) {
    int x, y; cin >> x >> y;
    cout << dist[x-1] + dist[y-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 11120
"""
100/C 回1回の施行にかかる

Aが克orBの場合を愚直に計算

N,b 回でaが勝つ確率(b < N)
nCr(N+b-1,b) * (b/100)^b * (a/100)^N

↑これはもう求めちゃっておく
"""

#modの掛け算

def modmal(a,b,mod): #a*bをmodを法にして求める

    return a * b % mod


#modの割り算

def moddiv(a,b,mod): #a/bをmodを法にして求める

    return (a * pow(b,mod-2,mod)) % mod


#逆元

def inverse(a,mod): #aのmodを法にした逆元を返す
    return pow(a,mod-2,mod)



#modのn!と、n!の逆元を格納したリストを返す(拾いもの)
#factorialsには[1, 1!%mod , 2!%mod , 6!%mod… , n!%mod] が入っている
#invsには↑の逆元が入っている

def modfac(n, MOD):
 
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return factorials, invs


def modnCr(n,r,mod,fac,inv): #上で求めたfacとinvsを引数に入れるべし(上の関数で与えたnが計算できる最大のnになる)

    return fac[n] * inv[n-r] * inv[r] % mod


mod = 10**9+7
N,A,B,C = map(int,input().split())
fac,inv = modfac(2*N,mod)

inv100 = inverse(100,mod)
invAB = inverse(A+B,mod)

ans = 0
for b in range(N):

    ans += modnCr(N+b-1,b,mod,fac,inv) * pow(B*invAB,b,mod) * pow(A*invAB,N,mod) * (N+b)
    ans %= mod
    #print (ans)

for a in range(N):

    ans += modnCr(N+a-1,a,mod,fac,inv) * pow(A*invAB,a,mod) * pow(B*invAB,N,mod) * (N+a)
    ans %= mod
    #print (ans)
#print (ans)
print (ans * 100 * inverse(100-C,mod) % mod)


Measured memory_bytes: 54128
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率

def input(): return sys.stdin.readline()[:-1]
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    #N, K = map(int, input().split())
    A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列


    for i,a in enumerate(A):
        if a==0:
            print(i+1)
            break



if __name__ == "__main__":
    main()

Measured memory_bytes: 68088
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long int;
using namespace std;
ll mod=1e9+7;


int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  int a=s.size();
  if(a<=k){cout << s << endl;}
  else{
    rep(i,k){cout << s[i];}
    cout << "..." << endl;
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <iomanip>
#define FI first
#define SE second
#define EB emplace_back
#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 1100000000
#define LLINF 1100000000000000000LL
#define Decimal fixed << setprecision(20)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v, sz) for(int i = 0; i < sz; i++) cerr << v[i] << ' '; cerr << endl;
#define SHOWX(x) cerr << #x << ": " << x << endl;
#define SHOWP(p) cerr << "[" << p.first << ',' << p.second << "]";

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main()
{
  ll N; cin >> N;
  vector<ll> L(N); REP(i, N) cin >> L[i];
  sort(ALL(L));
  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    for (ll j = i + 1; j < N; j++) {
      ll a = L[i], b = L[j];
      // |a - b| < c < a + b
      // (|a-b|, a+b)[a+b, ...)
      auto itr1 = upper_bound(ALL(L), abs(a - b));
      auto itr2 = lower_bound(ALL(L), a + b);
      ll tmp = itr2 - itr1;

      if (*lower_bound(itr1, itr2, a) == a) tmp--;
      if (*lower_bound(itr1, itr2, b) == b) tmp--;

      ans += tmp;
    }
  }
  cout << ans/3 << endl;
  return 0;
}


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

#define N 2000000
#define AMAX 10000

int main()
{
  int n,i,j;
  int *A,*B;
  int C[AMAX+1]; /* Aに入力,Bで出力,Cに記録*/

  scanf("%d",&n);

  A = malloc(sizeof(int)*n+1);
  B = malloc(sizeof(int)*n+1);  /* A,Bのメモリ確保 */

  for(i=0;i<=AMAX;i++)
    C[i] = 0;

  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=AMAX;i++)
    C[i] = C[i] + C[i-1];

  for(j=1;j<=n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i > 1){
      printf(" ");
    }
    printf("%d",B[i]);
      }

  printf("\n");

  return 0;
}

  



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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
	string s,t;
	cin>>s>>t;
	sort(all(s));
	sort(all(t),greater<char>());
	cout<<(s<t?"Yes":"No")<<en;
}

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

    solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


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

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


Measured memory_bytes: 3064
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=1000000007;
const ll INF=1000000000000000001;
int main(){
    int n,q;cin >> n >> q;
    string s;cin>>s;
    int sum[n];
    int l[n],r[n];
    sum[0]=0;
    for(int i=1;i<n;i++){
    if(s[i-1]=='A'&&s[i]=='C')sum[i]=sum[i-1]+1;
    else sum[i]=sum[i-1];
    }
    rep(i,q){
        cin>>l[i]>>r[i];
    }
    rep(i,q){
        int ans=0;
        if(l[i]>=2){
        ans=sum[r[i]-1]-sum[l[i]-1];
        cout << ans << endl;
        }
        if(l[i]==1){
        ans=sum[r[i]-1];
        cout << ans << endl;
        }
    }
 return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var abhm = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        var a = abhm[0];
        var b = abhm[1];
        var h = abhm[2];
        var m = abhm[3];

        //double hTheta = h * Math.PI * (1d / 6d);
        //double mTheta = m * Math.PI * (1d / 30d);
        double hTheta = ToRadian(h * 30d + (0.5d * m));
        double mTheta = ToRadian(m * 6d);

        // 曲座標表示
        var hx = a * Math.Cos(hTheta);
        var hy = a * Math.Sin(hTheta);

        var mx = b * Math.Cos(mTheta);
        var my = b * Math.Sin(mTheta);

        Console.WriteLine(Math.Sqrt(Math.Pow(my - hy, 2) + Math.Pow(mx - hx, 2)));
    }

    public static double ToRadian(double angle)
    {
        return (double)(angle * Math.PI / 180);
    }
    
}


Measured memory_bytes: 28632
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

long long solve(int n, long long x)
{
    vector<long long> burger(n, 1);
    vector<long long> patty(n, 1);
    for(int i=1; i<n; ++i){
        burger[i] = burger[i-1] * 2 + 3;
        patty[i] = patty[i-1] * 2 + 1;
    }

    long long ans = 0;
    for(int i=n-1; i>=0 && x > 0; --i){
        if(x <= burger[i] + 1){
            -- x;
        }
        else if(x <= burger[i] * 2 + 2){
            x -= burger[i] + 2;
            ans += patty[i] + 1;
        }
        else{
            ans += patty[i] * 2 + 1;
            x = 0;
        }
    }
    ans += x;

    return ans;
}

int main()
{
    int n;
    long long x;
    cin >> n >> x;

    cout << solve(n, x) << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
import math

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    s = 0
    for i in range(N):
        a = (int(input_raw[i]))
        while 1:
            if a % 2 == 0:
                s += 1
                a /= 2
            else:
                break
    print s



if __name__ == '__main__':
    main()

Measured memory_bytes: 3704
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
using namespace std;

int n,m,i,j,k,l,r;
int f[305][305][305];
char s[100005];

int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	scanf("%d",&m);
	for(i=1;i<=n;++i)
	for(j=0;j<=m;++j)
	f[i][i][j]=1;
	for(i=1;i<n;++i)
	for(l=1;l+i<=n;++l)
	{
		r=l+i;
		for(j=0;j<=m;++j)
		{
			f[l][r][j]=max(f[l+1][r][j],f[l][r-1][j]);
			if(s[l]==s[r])f[l][r][j]=max(f[l][r][j],f[l+1][r-1][j]+2);
			else if(j)f[l][r][j]=max(f[l][r][j],f[l+1][r-1][j-1]+2);
		}
	}
	printf("%d\n",f[1][n][m]);
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;

    ll ok = false;
    rep(i, n){
        char s;
        cin >> s;
        if(s == 'Y') ok = true;
    }

    if(ok){
        cout << "Four" << endl;
    }else{
        cout << "Three" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
S = input()
lS, ans = len(S), [0] * len(S)

for i in range(lS):
    if S[i:i + 2] == 'RL':
        r = i
    if S[i] == 'L':
        ans[r + ((i - r) % 2)] += 1
    if S[(lS - i - 2):(lS - i)] == 'RL':
        l = (lS - i - 1)
    if S[(lS - i - 1)] == 'R':
        ans[l - ((lS - i - 1 - l) % 2)] += 1

print(' '.join(map(str, ans)))


Measured memory_bytes: 10612
import itertools
n = int(input())
p = tuple(map(lambda x: int(x),input().split()))
q = tuple(map(lambda x: int(x),input().split()))

list = list(itertools.permutations([i+1 for i in range(n)]))
a = 0
b = 0
for i in range(len(list)) :
    if list[i] == p:
        a = i + 1
    if list[i] == q:
        b = i + 1


print(abs(a-b))


Measured memory_bytes: 8052
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <set>
using namespace std;
typedef long long int LL;

const int MAX = 1e5+24;
const int INF = 0x3f3f3f3f;

int d[MAX];
int main(){
    int n,k;
    while(~scanf("%d%d",&n,&k)){
        for(int i = 0; i < n; i++){
            scanf("%d\n",&d[i]);
        }
        int result = INF, l = 0, r = k-1;
        for(;r<n;l++,r++){
            if(d[r]>=0&&d[l]>=0){
                result = min(result, d[r]);
            }
            else if(d[r] <=0 && d[l] <= 0){
                result = min(result, abs(d[l]));
            }
            else{
                result = min(result, min(abs(d[l]) * 2 + d[r], abs(d[l]) + d[r] * 2));
            }
        }
        printf("%d\n", result);
    }
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
typedef long long int ll;

vector<long long int>a,dp;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,k;cin>>n>>k;
    ll m = (ll)10e9;
    a.resize(n);
    dp.resize(n,1e9);
    for (int i=0;i<n;i++){
        cin>>a[i];
    }
    dp[0]=0;
    for (int i=1;i<=k;i++){
        for (int j=0;j<i;j++){
            m= min(m,abs(a[i]-a[j])+dp[j]);
        }
        dp[i]=m;
        m= 10e9;
    }
    m= 10e9;
    for (int i = k+1; i < n; i++){
        for (int j = i-k; j < i; j++){  // [i-k,.....,i-1] -> i
            m= min(m, abs(a[i]-a[j]) + dp[j]);
        }
        dp [i]=m;
        m=10e9;
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
 
int gcd(int*, int*);
 
int main(void) {
    int x, y, result;
    scanf("%d%d",&x,&y);
     
    if(x>=y) result = gcd(&x, &y);
    else result = gcd(&y, &x);
     
    printf("%d\n", result);
    return 0;
}
 
int gcd(int *x, int *y) {
    int ret, mod;
     
    if(*y==0) ret= *x;
    else {
        mod = *x % *y;
        ret = gcd(y, &mod);
    }
    return ret;
}


Measured memory_bytes: 1992
import sys
from collections import deque


def read():
    return sys.stdin.readline().rstrip()


def main():
    n, m = map(int, read().split())
    al = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, read().split())
        al[a - 1].append(b - 1)
        al[b - 1].append(a - 1)
    ne = deque([(0, 0)])
    s = set()
    t = [(0, 10**6) for _ in range(n)]
    t[0] = (0, 0)
    while ne:
        p, f = ne.popleft()
        if p in s:
            continue
        s.add(p)
        if t[f][1] + 1 < t[p][1]:
            t[p] = (f, t[f][1] + 1)
        for ni in al[p]:
            ne.append((ni, p))
    print("Yes")
    for ti, _ in t[1:]:
        print(ti + 1)


if __name__ == '__main__':
    main()

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

int main() {
  string s, t;
  cin >> s >> t;
  cout << t + s << endl;
}

Measured memory_bytes: 256
from collections import namedtuple
from itertools import compress, product

Testimony = namedtuple('Testimony', 'honest_persons unkind_persons')

def bin_iter(num, width=1):
    assert width > 0
    while num > 0 or width > 0:
        yield num & 1
        num >>= 1
        width -= 1

def pop_count(num):
    return sum(bin_iter(num))

def solve(testimonies):
    def is_not_contradicted(honest_persons):
        for testimony in compress(testimonies, bin_iter(honest_persons, len(testimonies))):
            if (testimony.honest_persons | honest_persons) > honest_persons:
                return False
            if testimony.unkind_persons & honest_persons:
                return False
        return True
    return max(map(pop_count, filter(is_not_contradicted, range(1 << len(testimonies)))), default=0)

def main():
    N = int(input())
    testimonies = []
    for _ in range(N):
        honest_persons, unkind_persons = 0, 0
        for _ in range(int(input())):
            x, y = list(map(int, input().split()))
            if y == 1:
                honest_persons |= (1 << (x - 1))
            else:
                unkind_persons |= (1 << (x - 1))
        testimonies.append(Testimony(honest_persons, unkind_persons))
    print(solve(testimonies))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3436
#pragma GCC optimize(3)
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set> 
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#define ll long long
#define db double
#define inf 262145
#define INF (int)2e9 
#define pi acos(-1)
#define mxbit 30
#define rd(n) {n=0;char ch;int f=0;do{ch=getchar();if(ch=='-'){f=1;}}while(ch<'0'||ch>'9');while('0'<=ch&&ch<='9'){n=(n<<1)+(n<<3)+ch-48;ch=getchar();}if(f)n=-n;}
using namespace std;
int n,m,S,T;

struct edge{
	int x,y,nxt;
	int mxf;
	int flow;
	edge(){}
	edge(int xx,int yy,int nn,int ff){
		x=xx,y=yy,nxt=nn;
		mxf=ff;
		flow=0;
	}
}e[100009];
int head[10009],ecnt=1;

void addedge(int x,int y,int flow){
	ecnt++;
	e[ecnt]=edge(x,y,head[x],flow);
	head[x]=ecnt;
	return;
}

void ae(int x,int y,int fl){
	addedge(x,y,fl);
	addedge(y,x,0);
	return;
}

int dep[10009];
queue <int> q;

bool bfs(void){
	while (!q.empty()){
		q.pop();
	}
	memset(dep,-1,sizeof(dep));
	dep[S]=1;
	q.push(S);
	while (!q.empty()){
		int u=q.front();
		q.pop();
		for (int i=head[u];i;i=e[i].nxt){
			int v=e[i].y;
			if (dep[v]==-1 && e[i].mxf-e[i].flow>0){
				dep[v]=dep[u]+1;
				q.push(v);
			}
		}
	}
	if (dep[T]==-1){
		return 0;
	}
	return 1;
}

int dfs(int u,int flow){
	if (flow==0){
		return 0;
	}
	if (u==T){
		return flow;
	}
	int ans=0;
	for (int i=head[u];i;i=e[i].nxt){
		int v=e[i].y,now;
		if (dep[v]==dep[u]+1){
			now=dfs(v,min(flow,e[i].mxf-e[i].flow));
			if (now){
				e[i].flow+=now;
				e[i^1].flow-=now;
				flow-=now;
				ans+=now;
			}
		}
	}
	return ans;
}

int dinic(void){
	int ans=0;
	while (bfs()){
		ans+=dfs(S,INF);
	}
	if (ans>=INF){
		ans=-1;
	}
	return ans;
}

int main(){
	rd(n) rd(m)
	char ch;
	S=0,T=n+m+1;
	int sx,sy,tx,ty;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			ch=getchar();
			while (ch!='.' && ch!='o' && ch!='T' && ch!='S'){
				ch=getchar();
			}
			if (ch=='o'){
				ae(i,j+n,1);
				ae(j+n,i,1);
			}
			else if (ch=='S'){
				ae(S,i,INF);
				ae(S,j+n,INF);
				sx=i,sy=j;
			}
			else if (ch=='T'){
				ae(i,T,INF);
				ae(j+n,T,INF);
				tx=i,ty=j;
			}
		}
	}
	if (sx==tx || sy==ty){
		puts("-1");
		return 0;
	}
	int ans=dinic();
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    static int[][] AB;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int  X = sc.nextInt();


        int ans = 1;
        double x =0;
        double y =0;
        double deg = 0;
        while(true){
//            int rad = (90-X*(ans-1));
            int rad = X*ans;
            if(rad %360==0){
                break;
            }
//            deg = rad* Math.PI/180;
//            x =x -  Math.cos(deg);
//            y =y + Math.sin(deg);
//            if(x==0 && y ==0){
//                break;
//            }
            ans++;
        }
        System.out.println(ans);

    }


}


Measured memory_bytes: 35692
N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = 0
tmp = 0
for i in range(N - 1):
    if t[i] + T < t[i + 1]:
        ans += T
    else:
        ans += t[i + 1] - t[i]



print (ans + T)


Measured memory_bytes: 26708
n = int(input())
A = list(map(int,input().split()))
A.sort()

ac = A.count(1)
if ac == 1:
    print(1)
    exit()
if ac >= 2:
    print(0)
    exit()

num = [0]*1000005
for a in A:
    num[a] += 1

b = [False]*1000005
seen = [False]*1000005
cnt = 0
A = list(set(A))
A.sort()
for a in A:
    if seen[a]:
        continue

    seen[a] = True
    if b[a] == False:
        cnt += 1
        if num[a] > 1:
            cnt -= 1

    for i in range(a, 1000005, a):
        b[i] = True
print(cnt)


Measured memory_bytes: 53840