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

int main()
{
	int N,S,K,X,UD; double L,F,D,V;
	while(cin >> N >> S >> K, N||S||K)
	{
		double T1[1500]={0};
		double T2[1500]={0};
		double TA[1500]={0};		
		double DP[1500]={0};
		
		for(int i=0; i<N; i++)
		{
			cin >> X >> L >> F >> D >> UD;
			
			T1[X+100] = L/F;
			T2[X+100] = L/D;
			
			if(UD)
			{
				swap(T1[X+100],T2[X+100]);
				TA[X+100] = T2[X+100];
			}
		}
		
		for(int s=0; s<S; s++)
		{
			cin >> V;
			for(int p=101-s; p<K+205-s; p++)
			{
				DP[p] = max(DP[p+1]-T1[p+1],max(DP[p-1]+1.0/V,TA[p]))+T1[p];
				TA[p] = DP[p]+T2[p];
			}
		}
		printf("%.10lf\n",DP[K+100]);
	}
}

Measured memory_bytes: 0
#include<stdio.h>

int Fib(int);

int main(){
  int n, res;

  scanf("%d", &n);
  res = Fib(n);
  printf("%d\n", res);

  return 0;
}

int Fib(int n){
  int i;
  int a=1;
  int b=1;
  int res=1;
  if(n == 0)return 1;
  if(n == 1)return 1;

  for(i=1; i<n; i++){
    res = a + b;
    a = b;
    b = res;
  }
  return res;
}



Measured memory_bytes: 2112
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		long[] A = new long[N], B = new long[N];
		PriorityQueue<Pair> PQ = new PriorityQueue<Pair>();
		for(int i = 0;i < N;i++) {
			A[i] = scn.nextLong();
		}
		for(int i = 0;i < N;i++) {
			B[i] = scn.nextLong();
			if(B[i] != A[i]) {
				PQ.add(new Pair(i,B[i]));
			}
		}
		boolean can = true;
		long ans = 0;
		while(!PQ.isEmpty()) {
			Pair p = PQ.poll();
			int num = p.num;
			int numb = (num-1+N)%N;
			int numf = (num+1)%N;

			if(B[num] - A[num] < B[numb] + B[numf]) {
				can = false;
				break;
			}

			long t = (B[num] - A[num])/(B[numb] + B[numf]);

			B[num] -= (B[numb] + B[numf])*t;
			ans+=t;
			if(B[num] != A[num]) {
				PQ.add(new Pair(num,B[num]));
			}

		}
		System.out.println((can)?ans:-1);


	}

}

class Pair implements Comparable<Pair>{
	long val;
	int num;
	public Pair(int num, long val) {
		this.num = num;
		this.val = val;
	}
	@Override
	public int compareTo(Pair o) {
		if(this.val < o.val)return 1;
		if(this.val > o.val)return -1;
		return 0;
	}
}



Measured memory_bytes: 135932
import Control.Monad
import Control.Applicative

rotate :: Int -> Char -> Char
rotate i c
  | fromEnum c == 46 = c  -- c == '.'
--  | fromEnum c == 10 = c  -- c == '\n'
  | otherwise        = toEnum $ (fromEnum c - 97 + i) `mod` 26 + 97

caesar :: [String] -> Int -> [String]
caesar [] _ = []
caesar (x:xs) i = map (rotate i) x : caesar xs i


decode' :: Int -> [String] -> [String]
decode' _ [] = []
decode' 0  _ = []
decode' n xs =
  let cand = caesar xs n
      ans1 = "this" `elem` cand
      ans2 = "that" `elem` cand
      ans3 = "the"  `elem` cand
  in
      if ans1 || ans2 || ans3 then cand
      else decode' (n-1) xs

solver :: [[String]] -> [[String]]
solver = map (decode' 26)

main :: IO()
main = do
  inputs <- lines <$> getContents
  let inp' = map words inputs
  mapM_ (putStrLn . unwords)  (solver inp')

Measured memory_bytes: 3976
// eddy1021
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009ll
#define mod7 1000000007ll
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
int __ = 1 , _cs;
/*********default*********/
void build(){

}
#define N 20020
int n , p[ N ] , a[ N ] , b[ N ];
void init(){
  scanf( "%d" , &n );
  for( int i = 1 ; i <= n ; i ++ )
    scanf( "%d" , &p[ i ] );
  for( int i = 1 ; i <= n ; i ++ )
    a[ i ] = b[ i ] = i * N;
  reverse( b + 1 , b + n + 1 );
}
void solve(){
  for( int i = 1 ; i <= n ; i ++ )
    a[ p[ i ] ] -= n - i;
  for( int i = 1 ; i <= n ; i ++ )
    printf( "%d%c" , a[ i ] , " \n"[ i == n ] );
  for( int i = 1 ; i <= n ; i ++ )
    printf( "%d%c" , b[ i ] , " \n"[ i == n ] );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
  int n,m,s1,s2,s3,s4,s5;
  scanf("%d %d",&n,&m);
  s1=(n*(n-1))/2;
  s2=(m*(m-1)/2);
  s3=s1+s2;
  printf("%d",s3);
  return 0;
}


Measured memory_bytes: 128
x,y,m = map(int,input().split())
row = {}
ch = set()
column = {}
for i in range(m):
	h,k = map(int,input().split())
	ch.add((h,k))
	if h in row:
		row[h] += 1
	else:
		row[h] = 1

	if k in column:
		column[k] += 1
	else:
		column[k] = 1


r_max = 0
c_max = 0

for i in row:
	r_max = max(r_max,row[i])
for j in column:
	c_max = max(c_max,column[j])

r_inx = []
w_inx = []

for i in row:
	if row[i] == r_max:
		r_inx.append(i)
for j in column:
	if column[j] == c_max:
		w_inx.append(j)

flag = 0
for i in r_inx:
	for j in w_inx:
		if (i,j) not in ch:
			flag = 1
			break
if flag == 0:
	print(r_max+c_max-1)
else:
	print(r_max+c_max)

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

int main(){
  int n,q,i;
  int j,b[1010],e[1010],y;
  string name[1010];

  while(cin >> n >> q, n+q){
    for(i=0;i<n;i++){
      cin >> name[i] >> j >> e[i];
      b[i] = e[i]-j+1;
    }

    for(i=0;i<q;i++){
      cin >> y;
      for(j=0;j<n;j++){
	if(b[j]<= y && y<=e[j]){
	  cout << name[j] << " " << y-b[j]+1 << endl;
	  break;
	}
      }
      if(j==n)cout << "Unknown\n";
    }
  }
}

Measured memory_bytes: 1304
#include<bits/stdc++.h>
using namespace std;
using pib = pair<int,bool>;


int main(){
  pib board[3][3];
  for(int i = 0; i< 3; i++){
    for(int j= 0; j<3; j++){
      cin >> board[i][j].first;
      board[i][j].second = false;
    }
  }
  int N;
  cin >> N;
  int a;
  set<int>S;
  for(int i= 0; i<N; i++){
    cin >> a;
    S.insert(a);
  }
  
  for(int i = 0; i< 3; i++){
    for(int j= 0; j<3; j++){
      int y;
      y = board[i][j].first;
      if(S.count(y)){
        board[i][j].second = true;
      }
    }
  }
  bool ans = false;
  for(int i= 0; i<3; i++){
    if(board[i][0].second && board[i][1].second && board[i][2].second)ans = true;
  }
  for(int i= 0; i<3; i++){
    if(board[0][i].second && board[1][i].second && board[2][i].second)ans = true;
  }
  if(board[0][0].second && board[1][1].second && board[2][2].second)ans = true;
  if(board[2][0].second && board[1][1].second && board[0][2].second)ans =true;
  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

map<int, bool> mp;

int main()
{
    int n;
    cin >> n;
    int m = 0;
    int x;
    for(int i = 0; i < n; i++){
        cin >> x;
        if(!mp[x]){
            m++;
        }
        mp[x] = 1;
    }
    if(m % 2 == 1){
        cout << m;
    }
    else{
        cout << m - 1;
    }
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int main()
{
	int n,x,t;
	cin >> n >> x >> t;
	
	int i = 1;
	while(n > x * i) i ++;
	
	cout << i * t << endl;
	
	return 0;
}

Measured memory_bytes: 3172
#include<iostream>

using namespace std;

int main() {
    int n,m; cin >> n >> m;
    int t = 0;
    while (m--)
    {
        int k; cin >> k;
        t += k;
    }
    if (t>n){
        cout << -1 << endl;
    } else{
        cout << n-t << endl;
    }
    
}

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

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--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}

int Choise(int a,int b){//aは全体の数、bは選ぶ数
	int k;
	k=1;
	if((a-b)>b){
	for(int i=a;i>(a-b);i--) k=k*i;
	for(int j=1;j<=b;++j) k=k/j;
	}else{
	for(int i=a;i>(a-b);i--) k=k*i;
	for(int j=1;j<=b;++j) k=k/j;
	}
	return k;
}


 ll  a,b,c,s,t,i,j,k,x,y,z;
 ll A,B,C,S,T,X,Y,Z;

 ll count;

 long double pi=3.14159;

 string N;



signed main(){

	cin>>N;

	if(N[0]!=N[1]){
		cout<<"Yes";
		return 0;
	}else if(N[2]!=N[1]){
			cout<<"Yes";
			return 0;
		}
	else cout<<"No";


	return 0;

}


Measured memory_bytes: 3600
// Ryo Kamoi

#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>

using namespace std;

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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int INF = 1000000000;

int n, m;
int low, up;
int main(){
  cin >> n >> m;
  low = -1; up = INF;

  REP(i, m) {
    int l, r;
    cin >> l >> r;
    low = max(low, l);
    up = min(up, r);
  }

  cout << max(0, up-low+1) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define LD long double

LL MOD = 1000000007;

int main(){
    char ch;
    cin >> ch;
    cout << ('a' <= ch && ch <= 'z' ? 'a' : 'A') << endl;

    return 0;
}

Measured memory_bytes: 3508
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<stack>
#include<cassert>
#define F first
#define S second
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define mem(x,y) memset(x,y,sizeof x)
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef double db;
const int INF=2e9;
const db eps=1e-8;
template<typename T>
inline void read(T &x)                        
{
	x=0; int f=1; char ch=getchar();
	while( (ch<'0' || ch>'9') && ch!='-') ch=getchar(); if(ch=='-') {f=-1; ch=getchar();}
	while(ch>='0' && ch <='9') x=x*10+ch-'0',ch=getchar();
	x*=f;
}
//==========================head template==========================
const int N=100010;
vector<int> E[N];
int w[N],vis[N];
int bestidx,bestval;
void dfs(int x){
    vis[x]=1;
    if(w[x]<bestval){
        bestval=w[x];
        bestidx=x;
    }
    for(auto u:E[x]){
        if(!vis[u]) dfs(u);
    }
}
int main(){
    ll ans=0;
    int n,m,cnt=0;
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++) scanf("%d",&w[i]);
    for(int i=1;i<=m;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        E[x].push_back(y);
        E[y].push_back(x);
    }
    for(int i=0;i<n;i++){
        if(!vis[i]){
            bestval=2e9;
            dfs(i);
            ans+=bestval;
            w[bestidx]=2e9;
            cnt++;
        }
    }
    if(cnt==1) {printf("0\n");return 0;}
    sort(w,w+n);
    for(int i=0;i<cnt-2;i++){
        if(w[i]==2e9){
            printf("Impossible\n");
            return 0;
        }
        ans+=w[i];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print_vector(vector<T> &vec)
{
    for (auto elem : vec)
    {
        cout << elem << endl;
    }
}
int main()
{
    int n, k;
    cin >> n >> k;

    string string_n = "";
    for (int i = 0; i < k; i++)
    {
        string_n += to_string(n);
    }

    string string_k = "";
    for (int i = 0; i < n; i++)
    {
        string_k += to_string(k);
    }

    string ans;
    if (string_n == string_k || string_n < string_k)
    {
        ans = string_n;
    }
    else
    {
        ans = string_k;
    }
    cout << ans;
}


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

using namespace std;
typedef long long ll;

int N,K;
vector<vector<int>> to;

ll ans = 1;
const ll mod = 1000000007;

void dfs(int u, int v = -1){
    
    int a = K-2;
    if(u == 0) a++;
    for (int i : to[u]) {
        if(i == v) continue;
        ans*=a;
        ans%=mod;
        a--;
        dfs(i,u);
        
    }
    
    
}


int main()
{
    cin >> N >> K;
    to.resize(N);
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    
    ans = K;
    dfs(0);
    
    cout << ans << endl;
    
    
    return 0;
}



Measured memory_bytes: 10368
#include <iostream>
#include <chrono>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> n(N);
	unsigned long long int k;
	cin >> k;
	for (int i = 0; i < N; i++)	cin >> n[i].first >> n[i].second;

	sort(n.begin(), n.end(), [](pair<int, int> l, pair<int, int> r) {
		return l.first < r.first;
	});

	unsigned long long int cnt = 0;
	for (int i = 0; i < N; i++) {
		cnt += n[i].second;
		if (cnt >= k) {
			cout << n[i].first << endl;
			break;
		}
	}
}


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

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    vector<ll> sa(n-1);
    ll x=1000000000;
    rep(i,n){
        cin >> a.at(i);
    }
    sa.at(0)=a.at(n-1);
    rep(i,n-2){
        sa.at(i+1)=(a.at(n-2-i)+sa.at(i))%(x+7);
    }
    reverse(sa.begin(),sa.end());
    ll sum=0;
    for(int i=0;i<n-1;i++){
        sum+=(a.at(i)*sa.at(i))%(x+7);
    }
    sum = sum % (x+7);
    cout << sum << endl;
}

Measured memory_bytes: 6380
#include <iostream>

using namespace std;

bool Is575(const int &a, const int &b, const int &c)
{
    if (a == 7)
    {
        return (b == 5 && c == 5);
    }

    if (b == 7)
    {
        return (a == 5 && c == 5);
    }

    if (c == 7)
    {
        return (a == 5 && b == 5);
    }

    return false;
}

int main()
{
    int a, b, c;

    cin >> a;
    cin >> b;
    cin >> c;

    cout << ((Is575(a, b, c)) ? "YES" : "NO");

    return 0;
}

Measured memory_bytes: 504
N = int(input())
p = list(map(int, input().split()))
q=[]
cnt=0
for i in range(N):
  q.append(i+1)
for i in range(N):
  if p[i]==q[i]:
    cnt=cnt
  else:
    cnt=cnt+1
if cnt==2 or cnt==0:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define M 5005
#define N 55
#define X 4
using namespace std;
typedef pair<int,int> P;
int x,y,z,v[X],n,e,a;
double memo[N][M];
P d[N];
 
double dfs(int u,int sum){
  int nu=u,nsum=sum;
  if(d[u].first==1)nu=min(y,u+d[u].second);
  if(d[u].first==2)nsum+=d[u].second;
  if(d[u].first==3)nsum=max(0,nsum-d[u].second);
  if(nu==y)return nsum;
  if(memo[nu][nsum]!=-1)return memo[nu][nsum];
  double res=0;
  for(int i=0;i<x;i++){
    int nnu=min(y,nu+v[i]);
    res+=dfs(nnu,nsum);
  }
  return memo[nu][nsum]=res/x;
}
 
int main(){
  while(1){
    cin>>x>>y>>z;
    if(!x&&!y&&!z)break;
    for(int i=0;i<N;i++)
      for(int j=0;j<M;j++)memo[i][j]=-1;
    for(int i=0;i<N;i++)d[i]=P(0,0);
    for(int i=0;i<x;i++)cin>>v[i];
    for(int i=0;i<z;i++){
      cin>>n>>e>>a;
      d[n]=P(e,a);
    }
    cout<<(int)dfs(0,0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3312
//https://atcoder.jp/contests/abc179/tasks/abc179_a
#include <iostream>
using namespace std;

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

    int len = s.length();
    if ('s'==s[len-1]) {
        s += "es";
    } else {
        s += "s";
    }

    cout<<s<<"\n";

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX-1;
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };

vector<ll>G[101010];
ll V;
ll color[101010];

bool dfs(ll v, ll c) {
	color[v] = c;
	rep(i, 0, G[v].size()) {
		if (color[G[v][i]] == c)return false;
		if (color[G[v][i]] == 0 && !dfs(G[v][i],-c))return false;
	}
	return true;
}

int main(){
	cin >> V;
	ll m;
	cin >> m;
	rep(i, 0, m) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	bool check = dfs(0, 1);
	if (!check) {
		cout << V * (V - 1) / 2 - m << endl;
	}
	else if(check){
		ll bl = 0;
		ll wh = 0;
		rep(i, 0, 101010) {
			if (color[i] == 1)bl++;
			else if (color[i] == -1)wh++;
		}
		cout << bl * wh - m << endl;
	}

	return 0;
}

Measured memory_bytes: 7424
using System;

class Hello{
static void Main(){
string [] str=Console.ReadLine().Split(' ');

int a=int.Parse(str[0]);
int b=int.Parse(str[1]);
int c=int.Parse(str[2]);

if(a<b&&b<c)Console.WriteLine("Yes");
else Console.WriteLine("No");

}
}


Measured memory_bytes: 15940
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  long long N,A,B;
  cin >> N >> A >> B;

  long long ans;
  if(A > B) ans = 0;
  else if(A == B) ans = 1;
  else {
    if(N == 1) {
      cout << 0 << endl;
      return 0;
    }
    
    long long num = N-2;
    long long m = A * num,M = B * num;
    ans = M - m + 1;
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    for i in range(1,10):
        if n % i == 0 and n // i < 10:
            return "Yes"

    return "No"


print(main())





Measured memory_bytes: 5964
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;

int op(int x, int y) { return max(x, y); }
int e() { return 0; }

int main() {
    // dp[i][j] = i番目までみたとき、最後に見た値がjのときの最大値（0, ..., i）
    // dp[i][j] = max({dp[i-1][j-K], ... dp[i-1][j+K]}) + 1
    // dp[j] = max({dp[j-K], ..., dp[j+K]}) + 1
    const int MAX_A = 300005;
    int N, K; cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    atcoder::segtree<int, op, e> st(MAX_A);
    for (int i = 0; i < N; ++i) {
        st.set(A[i], st.prod(max(0, A[i] - K), min(MAX_A - 1, A[i] + K + 1)) + 1);
    }
    cout << st.all_prod() << endl;
    return 0;
}


Measured memory_bytes: 9628
#include <stdio.h>

long long DIV = 1000000007;

long long rest_div(int x, int y)
{
        int i;
        long long ret = 1;

        for (i = 0; i < y; i++)
        {
                ret = ret * x % DIV;
        }
        return (ret);
}

int main(void)
{
        int n;
        long long ans = 0;

        scanf("%d", &n);
        if (n == 1)
        {
                printf("%d\n", 0);
                return (0);
        }
        ans = rest_div(10, n) - rest_div(9, n) - rest_div(9, n) + rest_div(8, n);
        ans = ans%DIV;
        ans = (ans + DIV) % DIV;
        printf("%lld\n", ans);
        return (0);
}

Measured memory_bytes: 1732
h,w=map(int,input().split())
a=[list(input())for _ in range(h)]
b=[]
for i in range(h):
    if a[i].count('.')==w:
        continue
    else:
        b.append(a[i])
c=[]
for i in range(w):
    d=[]
    for j in range(len(b)):
        d.append(b[j][i])
    c.append(d)
e=[]
for i in range(w):
    if c[i].count('.')==len(b):
        continue
    else:
        e.append(c[i])
for i in range(len(b)):
    for j in range(len(e)):
        print(e[j][i],end='')
    print()

Measured memory_bytes: 4596
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int s = stdIn.nextInt();
    int simo = s%100;
    int ue = s/100;
    if((ue>=13&&simo<=12&&simo>=1)||(ue==0&&simo<=12&&simo>=1)) {
      System.out.println("YYMM");
    } else if((simo>=13&&ue<=12&&ue>=1)||(simo==0&&ue<=12&&ue>=1)) {
      System.out.println("MMYY");
    } else if(ue<=12&&simo<=12&&ue>=1&&simo>=1) {
      System.out.println("AMBIGUOUS");
    } else {
      System.out.println("NA");
    }
  }
}


Measured memory_bytes: 21844
from collections import deque

n = int(input())
d = deque()

for i in range(n):
    cmd = [int(i) for i in input().split()]

    if cmd[0] == 0:
        if cmd[1] == 0: d.appendleft(cmd[2])
        else: d.append(cmd[2])

    elif cmd[0] == 1:
        print(d[cmd[1]])

    elif cmd[0] == 2:
        if cmd[1] == 0: d.popleft()
        else: d.pop()



Measured memory_bytes: 21960
import collections
N=int(input())

string=list()
for i in range(N):
  c=list(input())
  c.sort()
 # print(''.join(c))
  string.append(''.join(c))
  
#print(string)

a=collections.Counter(string)
b=list(a.values())

count=0
for j in range(len(b)):
  count=count +int(b[j]*(b[j]-1)/2)
  
print(count)
  

Measured memory_bytes: 19828
#include<iostream>
using namespace std;
int main()
{
    int N;
    int A[100];
    int num = 0;
    cin >> N;
    for(int i=0; i<N; i++)
    {
        cin >> A[i];
    }
    for(int i=0; i<N-1;i++)
    {
        for(int j=N-1; j>i; j--)
        {
            if(A[j-1] > A[j])
            {
                int temp = A[j-1];
                A[j-1] = A[j];
                A[j] = temp;
                num++;
            }
        }
    }
    for(int i=0; i<N;i++)
    {
        if(i) cout<<" ";
        cout<<A[i];
    };
    cout<<endl<<num<<endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
ll mod= 1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

main(){
    string s;
    cin>>s;
    ll k;
    cin>>k;
    char p;
    while(k>0){
        rep(i,0,s.length()){
            if(k<=0)break;
            char x=s[i];
            if(x=='a')continue;
            ll g=s[i]-0;
            g+=k;
            if(g>=0x7B){s[i]='a';k-='{'-x;}
        }
        p=s[s.length()-1];
        if(k>0){
            ll g=p-0;
            g+=k;
            if(g>=0x7B){
                ll f=k-(p-0x61);
                f=k%26;
                s[s.length()-1]=0x61+f;
            }
            else s[s.length()-1]=p+k;
            k=0;
        }
    }
    cout<<s;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long M = sc.nextLong();
		long minA = 1000000;
		long minB = 1000000;

		long[] aa = new long[(int)A];
		long[] bb = new long[(int)B];
		

		for (int i = 0; i < (int)A; i++) {
			aa[i] = sc.nextLong(); 
			if (aa[i] < minA) {
				minA = aa[i];
			}
		}
		for (int i = 0; i < (int)B; i++) {
			bb[i] = sc.nextLong();
			if (bb[i] < minB) {
				minB = bb[i];
			}
		}	
		long ans = minA + minB;
		for (int i = 0; i < M; i++) {
			int x = sc.nextInt()-1;
			int y = sc.nextInt()-1;
			long c = sc.nextLong();
			if (aa[x] + bb[y] - c < ans) {
				ans = aa[x] + bb[y] - c;
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 135100
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) \
    do           \
    {            \
    } while (0)
#define dump(x) \
    do          \
    {           \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template <class T>
inline T sqr(T x) { return x * x; }

void solve()
{
    int n;
    cin >> n;
    VLL a(n);
    REP(i, 0, n)
    cin >> a[i];
    REP(i, 0, n)
    --a[i];
    int pos = 0;
    int cnt = 0;
    while (cnt <= n && pos != 1)
    {
        pos = a[pos];
        ++cnt;
    }
    if (pos == 1)
        cout << cnt << endl;
    else
        cout << -1 << endl;
}

int main()
{
    solve();

    return 0;
}

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

int main(){
  string s; cin >> s;
  int n=(int)s.size();
  vector<int> ans; ans.resize(n);
  
  int r_pos, l_pos;
  int count=1;
  for(int i=1; i<n; i++){
    if(s[i]==s[i-1]){
      if(s[i]=='R'){
        ans[i-1]=0;
      }else{
        ans[i]=0;
      }
      count++;
    }else{
      if(s[i]=='L'){
        l_pos=i;
        r_pos=i-1;
        int add=count/2;
        ans[r_pos] += add+count%2;
        ans[l_pos] += add;
        count=1;
      }else{
        int add=count/2;
        ans[r_pos] += add;
        ans[l_pos] += add+count%2;
        count=1;
      }
    }
    if(i==n-1){
      int add=count/2;
      ans[r_pos] += add;
      ans[l_pos] += add+count%2;
      count=1;
    }
  }

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long int
// #define lli llong int 
#define ld long double
#define ff first
#define ss second
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define pii pair<int, int>
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define scan(n) scanf("%lld",&n)
#define endl "\n"
ld const pi = 3.141592653589793238462;

int const mod = 1e9+7;
int const mod1 = 1e9+6;

int power(int a,int b){
    	int f=1;
    	while(b>0){
		if(b&1){
			f=f*a;
			f%=mod;
		}
		a=a*a;
		a%=mod;
		b=b/2;
	}
	return f;
}

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

int const N = 1e5+5;
vector<int> adj[N];
int h[N];


int dfs(int in,int p){
	int x = -1;
	for(auto it:adj[in]){
		if(h[it] == 0){
			h[it] = h[in] + 1;
			int z = dfs(it,in);
			if(z == 0) continue;
			if(x == -1){
				x = it;
			}
			else{
				cout<<in<<" "<<x<<endl;
				cout<<in<<" "<<it<<endl;
				x = -1;
			}
		}
		else{
			if(h[it] >= h[in] - 1) continue;
			if(x == -1){
				x = it;
			}
			else{
				cout<<in<<" "<<it<<endl;
				cout<<in<<" "<<x<<endl;
				x = -1;
			}
		}
	}
	
	if(x == -1) return 1;
	cout<<in<<" "<<p<<endl;
	cout<<in<<" "<<x<<endl;
	return 0;
}


int32_t main(){
	IOS;
	int n,m,i,j,l;
	cin>>n>>m;
	for(i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	if(m%2) {
		cout<<"-1"<<endl;
		return 0;
	}
	h[1] = 1;
	if(dfs(1,0) == 0) {
		cout<<"-1"<<endl;
	}
 	return 0;
}

/*

1 0 1 0 1




*/

Measured memory_bytes: 15488
#include <bits/stdc++.h>
using namespace std;
typedef int64_t i64;

int main()
{
  int N,K;

  cin >> N >> K ;
  
  vector<int> vec(N);
  
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  int ans = 0;
  
  for(int j = 0; j < K; j++){
  	ans = ans + vec.at(j);
  }
  
  cout << ans << endl;

}


Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int ar[5000];
int main()
{
    int n , k;
    cin>>n>>k;
    for(int i  = 0 ; i < n ; i++) cin>>ar[i];
    sort(ar ,ar+n);
    int p = n-1;
    int ans = 0;
    while(k--){
        ans += ar[p--];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
bool f[100001];
int C[100002];
int N, L, R;
int main() {
  cin>>N;
	for (int i = 2; i <= 100000; i++)if (!f[i])for (int j = i + i; j <= 100000; j += i) f[j] = true;
	for (int i = 3; i <= 100000; i+=2) {
		if (!f[i] && !f[(i + 1) / 2]) C[i]++;
	}
	for (int i = 3; i <= 100000; i++) C[i] += C[i - 1];
	while (N--) {
		cin >> L >> R;
		cout << C[R] - C[L - 1] << endl;
	}
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){ 
    int N;
    cin >> N;
    vector<int> A(N);
    map<int,int> mp;
    for(int i=0;i<N;i++){
        cin >> A[i];
        mp[A[i]]++;
    }
    int ans=0,even=0,odd=0;
    for(auto p : mp){
        int x = p.second;
        if(x%2==0){
            ans++;
            even++;
        }else{
            ans++;
            odd++;
        }
    }
    if(even%2==0){
        cout << ans << endl;
    }else{
        cout << ans - 1 << endl;
    }
}

Measured memory_bytes: 5376
import java.util.Scanner;


public class Main {

	public class Turtle {
		double x, y;
		int theta;

		public Turtle() {
			this.x = 0; this.y = 0;
			this.theta = 90;
		}

		public void move(int dist, int rotation) {
			double rad = Math.toRadians(this.theta);
			this.x += dist * Math.cos(rad);
			this.y += dist * Math.sin(rad);
			this.theta -= rotation;
		}
	}

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

		Turtle turtle = (new Main()).new Turtle();
		while (sc.hasNext()) {
			String[] s = sc.nextLine().split(",");
			int d = Integer.parseInt(s[0]),
				r = Integer.parseInt(s[1]);
			if (d == 0 && r == 0) {
				System.out.println(String.format("%d\n%d", (int) turtle.x, (int) turtle.y));
			} else {
				turtle.move(d, r);
			}
		}

	}
}

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

typedef long long ll;

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

    ll N;

    cin >> N;

    vector<ll> A(N);
    vector<ll> C(N + 1);

    for(int i = 0; i < N; i++) {
        cin >> A[i];
        C[A[i]]++;
    }

    ll base = 0;
    vector<ll> B(N + 1);

    for(int i = 0; i < N + 1; i++) {
        if(C[i] >= 2) {
            B[i] = C[i] * (C[i] - 1) / 2;
            base += B[i];
        }
    }

    for(int i = 0; i < N; i++) {
        ll x = 0;
        if(C[A[i]] - 1 >= 2) {
            x = (C[A[i]] - 1) * (C[A[i]] - 2) / 2;
        }

        cout << base - B[A[i]] + x << endl;
    }
}

Measured memory_bytes: 7296
use std::fmt::Write;
use std::io::*;

fn selection_sort<T: PartialOrd>(slice: &mut [T]) -> usize {
	let mut change = 0;

	for i in 0..slice.len() {
		let mut minj = i;

		for j in i..slice.len() {
			if slice[j] < slice[minj] {
				minj = j;
			}
		}
		if i != minj {
			slice.swap(i, minj);
			change += 1;
		}
	}

	change
}

fn main() {
	let input = {
		let mut buf = vec![];
		stdin().read_to_end(&mut buf);
		unsafe { String::from_utf8_unchecked(buf) }
	};
	let mut lines = input.split('\n');

	let n = lines.next().unwrap().parse().unwrap();

	let mut vec = Vec::with_capacity(n);
	let iter = lines.next().unwrap().split(' ').map(|s| s.parse::<u32>().unwrap());
	vec.extend(iter);

	let cnt = selection_sort(&mut vec);

	let mut res = format!("{}", vec[0]);
	for v in &vec[1..] {
		write!(res, " {}", v);
	}
	println!("{}", res);
	println!("{}", cnt);
}



Measured memory_bytes: 5032
#include<iostream>
using namespace std;
int main()
{
    int n,a,b,s[400],sum=0;
    cin>>n>>a>>b;
    int x=0,m,ans=0;
    for (int i=a;i<=b;i++)
    {
        s[x]=i;
        x++;
    }
    for (int j=a;j<=n;j++)
    {   
        m=j;
        while (m!=0)
        {
            ans+=m%10;
            m/=10;
        }
        for (int i=0;i<x;i++)
        {
            if (ans==s[i])
            {    
                sum+=j;
            }
        }
        ans=0;
    }
    cout<<sum<<endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))

typedef long long ll;

using namespace std;

int N;
char temp[15] = { 'a', };

void recursion(int idx, char last)
{
	if (idx == N)
	{
		printf("%s\n", temp);
		return;
	}
	for (char i = 'a'; i <= last; ++i)
	{
		temp[idx] = i;
		recursion(idx + 1, last);
	}
	temp[idx] = last + 1;
	recursion(idx + 1, last + 1);
}

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

	scanf("%d", &N);
	recursion(1, 'a');

	return 0;
}

Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int A, B; cin >> A >> B;

    int price;
    if (A >= 13) {
        price = B;
    } else if (A >= 6) {
        price = B/2;
    } else {
        price = 0;
    }

    cout << price << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
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; }


int main(){
    ll ans = 0;
    string s, t;
    cin >> s >> t;
    rep(i, s.length()){
        char S = s[i], T = t[i];
        if(S != T) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3928
#include <algorithm>　　
#include <cmath>
#include <iostream>
#include <iomanip>
#define pai 3.14159265358979323846264338327950288
using namespace std;
int main(){
    double a,b,h,m;
    scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
    double jiao = h*pai/6+m*pai/360-m*pai/30;
    if( jiao > pai ){
        jiao = 2*pai - jiao;
    }
    //cout<<jiao<<endl;
    //cout<<cos(jiao)<<endl;
    //cout<<a*a+b*b-2*a*b*cos(jiao)<<endl;
    cout<<fixed<<setprecision(12)<<sqrt(a*a+b*b-2*a*b*cos(jiao))<<endl;

}


Measured memory_bytes: 3656
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
//{{{ read()
inline int read(){
	register int x=0,f=1;
	register char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')	f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x*f;
}
//}}}
const double Pi=acos(-1);
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int a=read(),b=read(),h=read(),m=read();
	double t1=1.0*(h*60+m)/(12*60)*Pi*2,t2=1.0*m/60*Pi*2;
	double x1=a*cos(t1),y1=a*sin(t1),x2=b*cos(t2),y2=b*sin(t2);
	printf("%.10lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
	return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    int mm=1;
    rep(i,m){
        mm*=2;
    }


    ll ans = 0;

    ans = (100*(n-m)+1900*m)*mm;
    
    cout << ans << endl;
    return 0;
}
 
 


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

ll modpow(ll x, ll n) {
    if(n==0){
        return 1;
    }else if(n%2==0){
        ll h = modpow(x,n/2);
        return h * h % MOD;
    } else {
        return x * modpow(x,n-1) % MOD;
    }
}

int main() {
  int N, M; cin >> N >> M;
  int A[N];
  rep(i,M){
    int a; cin >> a;
    A[i] = a;
  }
  ll dp[N+1];
  dp[0] = 1;
  int j = 0;
  if(A[0]==1){
    dp[1] = 0;
    j++;
  }else{
    dp[1] = 1;
  }
  reps(i,N){
    if(i==1)  continue;
    if(A[j]!=i){
      dp[i] = (dp[i-1] + dp[i-2])%MOD;
    }else{
      dp[i] = 0;
      j++;
    }
  }
  // rep(i,N){
  //   cout << dp[i] << ' ';
  // }
  // cout << endl;

  cout << dp[N]%MOD << endl;

  return 0;
}


Measured memory_bytes: 1408
//42
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  static bool cmp[1000000]={true,true};
  static int ps[1000000]={};
  for(int i=2;i<1000000;i++){
    ps[i]=ps[i-1];
    if(!cmp[i]){
      ps[i]++;
      for(int j=2;j*i<1000000;j++){
	cmp[i*j]=true;
      }
    }
  }
  for(int n;cin>>n,n;){
    int k=0;
    for(int i=0;i<n;i++){
      int p,m;
      cin>>p>>m;
      k+=ps[min(999999,p+m)]-ps[max(p-m-1,0)]-1;
    }
    cout<<k<<endl;
  }
  return 0;
}

Measured memory_bytes: 6044
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
string s;
LL sum[303030];

int main() {
	cin >> n >> s;
	REP(i, n) {
		if (i) {
			sum[i] = sum[i - 1] + (s[i] == 'E');
		}
		else {
			if (s[i] == 'E')sum[i] = 1;
		}
	}
	sum[n] = sum[n - 1];
	LL ans = HINF;
	REP(i, n) {
		if (i == 0) {
			ans = min(ans, sum[n] - sum[i]);
		}
		else {
			ans = min(ans, i - sum[i - 1] + sum[n] - sum[i]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3076
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  string d;
  cin>>d;
  int e=0,f=0;
  rep(i,a){
  if(d[i]=='c')
    out("No");
  else if(d[i]=='a'&&e<b+c){
  e++;
    out("Yes");
  }
  else if(d[i]=='a'&&b+c<=e)
    out("No");
  else if(d[i]=='b'&&f<c&&e<b+c){
    e++;
    f++;
    out("Yes");
  }
    else 
      out("No");
  }
  
}


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

int di[]={-1,0,1,0};
int dj[]={0,-1,0,1};

int main(){
    int h,w;
    cin>>h>>w;
    vector<string>s(h);
    rep(i,h)cin>>s[i];
    queue<pair<int,int>>q;
    vector<vector<int>>dist(h,vector<int>(w,1e9));
    auto update=[&](int i,int j,int x){
        if(dist[i][j]!=1e9)return;
        dist[i][j]=x;
        q.push(make_pair(i,j));
    };
    update(0,0,0);
    while(!q.empty()){
        int i=q.front().first;
        int j=q.front().second;
        q.pop();
        rep(dir,4){
            int ni=i+di[dir];
            int nj=j+dj[dir];
            if(ni<0||ni>=h||nj<0||nj>=w)continue;
            if(s[ni][nj]=='#')continue;
            update(ni,nj,dist[i][j]+1);
        }
    }
    int ans=0;
    rep(i,h)rep(j,w){
        if(s[i][j]=='.')ans++;
    }
    ans-=dist[h-1][w-1]+1;
    if(dist[h-1][w-1]!=1e9)cout<<ans<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};

signed main()
{
    int n;
    cin >> n;
    ll p=0,k=1;
    while (n--)
    {
        ll q, x;
        cin >> q >> x;
        if (q == 1)
        {
            k *= x;
            p*=x;
        }
        else if (q == 2)
        {
            p += x;
        }
        else
        {
            p -= x;
        }
    }
    
    cout<<-p<<" "<<k<<endl;
    
}



Measured memory_bytes: 3160