akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
 
int main(void){
  int N, R;
  cin >> N >> R;
  if(N >= 10){
    cout << R;
  }
  else{
    cout << R + 100 * (10 - N);
  }
    
  return 0;
}

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

using namespace std;

string s;

int main(){
	while(getline(cin,s)){
		for (int i=0;i<s.length();i++){
			if (s[i]!=' ' && s[i]!='.'){
				s[i]+='A'-'a';
			}
		}
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  ll ans=0;
  FOR(i,1,n+1){
    if(0<i&&i<10){
      ans++;
    }
    else if(99<i&&i<1000){
      ans++;
    }
    else if(9999<i&&i<100000){
      ans++;
    }
  }
  co(ans)
}

Measured memory_bytes: 1024
#include <stdio.h>

int min(int a, int b){ return a < b ? a : b; }
int max(int a, int b){ return a > b ? a : b; }

int main() {
  int N, x, y, b, p, i;
  scanf("%d", &N);
  for(int i = 0; i < N; ++i) {
    scanf("%d %d %d %d", &x, &y, &b, &p);
    printf("%d\n", min(x*b+y*p, (x*max(b,5)+y*max(p,2))*4/5) );
  }
  return 0;
}



Measured memory_bytes: 2112
import java.io.*;
import java.util.*;

public class Main {

    static MyScanner sc;
    private static PrintWriter out;
    static long M = 1000000007;

    public static void main(String[] s) throws Exception {
        StringBuilder stringBuilder = new StringBuilder();


        if (stringBuilder.length() == 0) {
            sc = new MyScanner(System.in);
        } else {
            sc = new MyScanner(new BufferedReader(new StringReader(stringBuilder.toString())));
        }


        out = new PrintWriter(new OutputStreamWriter(System.out));
        long t = System.currentTimeMillis();


        solve();
        out.flush();
    }

    private static void solve() {
        int s1 = sc.nextInt();
        int s2 = sc.nextInt();
        int s3 = sc.nextInt();
        for (int i = 0 ; i <= s1 ; i++) {
            for (int j = 0 ; j <= s2 ; j++) {
                if (i * s2 + j * s1 - 2 * i * j == s3) {
                    out.println("Yes");
                    return;
                }
            }
        }
        out.println("No");
    }


    private static void solveT() {
        int t = sc.nextInt();
        while (t-- > 0) {
            solve();
        }
    }

    private static long gcd(long l, long l1) {
        if (l > l1) return gcd(l1, l);
        if (l == 0) return l1;
        return gcd(l1 % l, l);
    }

    private static long pow(long a, long b, long m) {
        if (b == 0) return 1;
        if (b == 1) return a;
        long pp = pow(a, b / 2, m);
        pp *= pp;
        pp %= m;
        return (pp * (b % 2 == 0 ? 1 : a)) % m;
    }


    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        MyScanner(BufferedReader br) {
            this.br = br;
        }

        public MyScanner(InputStream in) {
            this(new BufferedReader(new InputStreamReader(in)));
        }

        void findToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }

        String next() {
            findToken();
            return st.nextToken();
        }

        int[] na(int n) {
            int[] k = new int[n];
            for (int i = 0; i < n; i++) {
                k[i] = sc.nextInt();
            }
            return k;
        }

        long[] nl(int n) {
            long[] k = new long[n];
            for (int i = 0; i < n; i++) {
                k[i] = sc.nextLong();
            }
            return k;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }


}

Measured memory_bytes: 23124
#include<iostream>
using namespace std;
main()
{
  string s;cin>>s;bool ans[26]={0};int f=0;
  for(int i=0;s[i];i++)
  {
    ans[s[i]-'a']=true;
  }
  for(int i=0;i<26;i++)
  {
     if(ans[i]==false){f=1;cout<<(char)(97+i)<<"\n";break;}
  }
  if(f==0)cout<<"None\n";
}


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

int n,x,a[100010];
signed main() {
	cin>>n>>x;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	int ans=0;
	rep(i,n-1){
		if(x>=a[i]){
			x-=a[i];
			ans++;
		}
	}
	if(a[n-1]==x)ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036854775807ll;

void solve()
  {
   int n,k;
   cin>>n>>k;
   vector<int> v(n);
   loop(i,0,n)
    cin>>v[i];
  sort(v.begin(), v.end());
  int sum = 0;
  loop(i,0,k)
   sum += v[i];
   cout<<sum;
  } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 

     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

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

int n, m, temp;
deque<int> d, t;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> temp;
        d.push_back(temp);
    }
    cin >> m;
    for(int i=0; i<m; i++) {
        cin >> temp;
        t.push_back(temp);
    }
    sort(d.begin(), d.end());
    sort(t.begin(), t.end());

    while(!t.empty()) {
        if(d.empty()) {
            cout << "NO" << endl;
            return 0;
        }
        if(t[0]!=d[0]) d.pop_front();
        else {
            d.pop_front();
            t.pop_front();
        }
    }
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int n;
	cin>>n;
	int a[n];
	rep(i,n){
		cin>>a[i];
	} 
	int cnt=1;
	rep(i,n){
		if(a[i]==cnt){
			cnt++;
		}
	}
	if(cnt==1){
		cout<<-1;
	}
	else{
		cout<<n-cnt+1;
	}
	re 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int tile[k][2];
  int i;
  for (i = 0; i < k; i++) {
    cin >> tile[i][0] >> tile[i][1];
  }
  for (i = 0; i < k; i++) {
    int con = min(min(tile[i][0], n - (tile[i][0] - 1)), min(tile[i][1], n - (tile[i][1] - 1)));
    if (con % 3 == 0) {
      cout << 3 << endl;
    } else if (con % 3 == 1) {
      cout << 1 << endl;
    } else {
      cout << 2 << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3100
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int H = scan.nextInt();
		int W = scan.nextInt();

		int [][]A = new int[H + 2][W + 2];
		String []S = new String[H];
		for(int i = 0; i < H; i++) {
			S[i] = scan.next();
		}
		scan.close();
		for(int i = 0; i < H + 2; i++) {
			for(int j = 0; j < W + 2; j++) {
				A[i][j] = 0;
			}
		}
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(S[i].substring(j, j + 1).equals("#")) {
					A[i + 1][j + 1] = 1;
				}
			}
		}

		for(int i = 1; i < H + 1; i++) {
			for(int j = 1; j < W + 1; j++) {
				if(A[i][j] == 1) {
					if(!(A[i - 1][j] == 1 || A[i + 1][j] == 1
							|| A[i][j - 1] == 1 || A[i][j + 1] == 1)) {
						System.out.println("No");
						System.exit(0);
					}
				}
			}
		}

		System.out.println("Yes");

	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (int) (1e9+7)
#define INF (int) 2e9

bool memo[405][405];
ll dp[405][405];
ll s[405];

ll f(int l, int r){
    if(memo[l][r]) return dp[l][r];
    memo[l][r] = true;

    if(l==r) return 0;

    ll fans = (ll)2e18;
    for (int i = l; i < r; i++){
        fans = min(fans, f(l, i)+f(i+1, r));
    }
    dp[l][r] = fans + s[r]-s[l-1];   
    return dp[l][r];
}

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    rep(i, n){
        s[i+1] = s[i] + a[i];
    }
    cout << f(1, n) << endl;
    // printf("%d\n", N);
    return 0;
}

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

int main(){
    int a,b,tmp;
    scanf("%d %d",&a,&b);
    if (a>b) {
        tmp=a;
        a=b;
        b=tmp;
    }
    for (int i=0; i<b; i++) {
        printf("%d",a);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(){
  int i,n,a[100];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=n-1;i>=0;i--){
    if(i==0){
      printf("%d",a[0]);
      break;
    }
    printf("%d ",a[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, m; cin >> n >> m;
    vector<P> key(m);
    rep(i, m) {
        int a, b; cin >> a >> b;
        int s = 0; //開けれる宝箱の集合
        rep(j, b) {
            int c; cin >> c;
            c--;
            s |= 1<<c; //宝箱cのビットを立てる
        }
        key[i] = P(s, a);
    }
    vector<int> dp(1<<n, INF); //各宝箱の集合全てを開けられる鍵の買い方の最小コスト
    dp[0] = 0;
    //各宝箱の集合に対して, 鍵を1つずつ全種類試して遷移先のコストを更新
    //すでに買ってる鍵については,集合が変化せず更新されないので考慮しなくていい
    rep(s, 1<<n) {
        rep(i, m) {
            int t = s | key[i].first; //遷移先
            int cost = dp[s]+key[i].second;
            chmin(dp[t], cost);
        }
    }
    int ans = dp.back();
    if (ans == INF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 256
// ITP1_2_A: Small, Large, or Equal
#include <cstdio>
int main()
{
    int a,b;
    scanf("%d %d", &a, &b);
    if (a<b) {
        printf("a < b\n");
    } else if (a>b) {
        printf("a > b\n");
    } else {
        printf("a == b\n");
    }
} 



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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  vi s(n + 1, 0);
  vi b(n + 1, 0);
  int ans = 0;
  for (int i = n; i > 0; i--) {
    int sum = 0;
    for (int j = i; j <= n; j += i) {
      sum += b[j];
    }
    if (sum % 2 == a[i]) {
      b[i] = 0;
    } else {
      b[i] = 1;
      ans++;
      // s[i] += 1;
    }
    // if (s[i] % 2 == a[i]) {
    //   b[i] = 0;
    // } else {
    //   b[i] = 1;
    //   ans++;
    //   // s[i] += 1;
    // }
    // for (int j = 0; j < i; j++) {
    //   if ((i + 1) % (j + 1) == 0) {
    //     s[j] += b[i];
    //   }
    // }

    // debug
    // printf("i=%d, b: ", i);
    // for (int j = 0; j < n; j++) {
    //   printf("%d ", b[j]);
    // }
    // printf("\n");
    // printf("i=%d, s: ", i);
    // for (int j = 0; j < n; j++) {
    //   printf("%d ", s[j]);
    // }
    // printf("\n");
  }
  cout << ans << endl;
  if (ans != 0) {
    for (int i = 1; i <= n; i++) {
      if (b[i] == 1) {
        printf("%d ", i);
      }
    }
    printf("\n");
  }
  return 0;
}


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

int main(){
	int m,n,s;
	cin >> m;
	for(int i=0;i<m;i++){
        cin >> n;
		int max = 0;
		int min = 0;
		vector<int> b(n);
		for(int j=0;j<n;j++){
			cin >> b[j];
		}
		for(int j=1;j<n;j++){
			if((b[j] - b[j-1]) > 0){
				if(max <= (b[j] - b[j-1])){
					max = b[j] - b[j-1];
				}
			}else if((b[j] - b[j-1]) < 0){
				if(min <= (b[j-1] - b[j])){
					min = b[j-1] - b[j];
				}
			}
			
		}
		cout << max << " " << min << endl;
	}	
		return 0;
}
	

Measured memory_bytes: 1196
#include <iostream>
#include <cstring>
#include <cmath>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x

int main(){

  int N;
  int d[100];
  int sum = 0;
  int j;

  cin >> N;
  REP(i, N){
    cin >> d[i];
  }

  REP(i, N-1){
    for( j = i+1; j < N; j++){
      sum += d[i] * d[j];
    }
  }
  cout << sum << endl;

  return 0;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import defaultdict
n = int(input())
e = defaultdict(lambda: [])

for _ in range(n-1):
    v,u,w = map(int, input().split())
    v -= 1
    u -= 1
    e[v].append((u,w))
    e[u].append((v,w))

col = [-1]*n
q = [0]
col[0] = 0
while len(q)>0:
    v = q.pop()
    for u,w in e[v]:
        if col[u]<0:
            if w%2==1:
                col[u] = (col[v]+1)%2
            else:
                col[u] = col[v]
            q.append(u)

print(*col)

Measured memory_bytes: 45976
#include <iostream>
#include <stack>
using namespace std;
int main (void) {
    string X;

    cin >> X;

    stack<char> s;
    for (int i = 0, len = X.length(); i < len; i++) {
        if (X[i] == 'S') {
            s.push(X[i]);
        } else if (X[i] == 'T' && (s.size() == 0 || s.top() == 'T')) {
            s.push(X[i]);
        } else if (X[i] == 'T' && s.top() == 'S') {
            s.pop();
        }
    }

    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 644
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;



int main(){
    
    ll N;
    cin >> N;
    if(N==0){
        cout << 0 << endl;
        return 0;
    }
    int p = ( log2(abs(N)) + 1 )* 2;
    
//    cout << p << endl;
    
    string S(p,'0');
    ll v;
    for(int i=0;i<p;i++){
//        cout << N << endl;
        v = pow(-2,i);
        if(abs(N) % (2*abs(v)) != 0) {
            S[p-i-1]='1';
            N -= v;
        }
//        cout << v << endl << N << endl << endl;
    }
//    cout << N << endl;
    int flag=0;
    for(int i=0;i<p;i++){
        if(S[i]=='1') flag=1;
        if(flag) cout << S[i];
    }
    cout << endl;
    
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  string S;
  cin >> S;
  int mn = INF;
  REP(i, S.size() - 2) {
    int num = (S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + S[i + 2]-'0';
    mn = min(mn, abs(753-num));
  }
  cout << mn << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n,m;cin>>n>>m;
    ll a[n+1]={0};
    bool ok=0;
    while(m--){
        ll x,y;cin>>x>>y;
        if((a[x] && a[x]!=y) || (x>n)){ok=1;break;}
        if(x==1 && y==0 && n>1){ok=1;break;}
        else a[x]=y;
    }
    if(a[1]==0 && n>1)a[1]=1;
    if(ok)cout<<-1;
    else{
        f(i,1,n+1)cout<<a[i];
    }
    return 0;  
} 





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main(){
   string s;
   cin>>s;
   if(s[5]-'0'>0){
      cout<<"TBD"<<endl;
   }
   else if(s[6]-'0'>4){
      cout<<"TBD"<<endl;
   }   
   else cout<<"Heisei"<<endl;
   
}

Measured memory_bytes: 256
N, A, B, C, D = map(int, input().split())
S = '.' + input()


def solve():
    if '##' in S[A:C + 1] or '##' in S[B:D + 1]:
        return 'No'

    if C > D:
        if '...' not in S[B - 1:D + 2]:
            return 'No'

    return 'Yes'


print(solve())


Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[100010];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    ll ans = INF2;
    for (int k = 0; k < 2; k++) {
        ll tmp = 0;
        ll sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a[i];
            if ((k + i) % 2 == 0 && sum <= 0) {
                tmp += abs(1 - sum);
                sum = 1;
                
            } else if ((k + i) % 2 == 1 && sum >= 0) {
                tmp += abs(-1 - sum);
                sum = -1;
            }
            //cout << sum << " " << tmp << endl;
        }
        //cout << endl;
        ans = min(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    """
    二部グラフに変換，x,yそれぞれのグループにわけ，座標の値を点で，点の情報を辺で表す．
    連結成分の中で全部辺を繋ぐ
    """
    ################
    class UnionFind():
        """
        parents : 親要素(findしない場合は根ではないことの注意)，根の場合は"-(要素数）"
        find(x):要素xの属するグループの根を返す
        size(x):要素xの属するグループの要素数を返す
        same(x,y):x,yが同じグループに属しているか返す
        重いかも！　　members(x):要素xが属するグループに属する要素をリストで返す
        roots:全ての根の要素を返す
        group_count():グループの数を返す
        重いかも！　all_group_members():{根要素：[そのグループに含まれる要素のリスト]}の辞書を返す
        """
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        def find(self, x):
            #根を探す&つなぎかえる
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)

            if x == y:
                return

            if self.parents[x] > self.parents[y]:
                x, y = y, x

            self.parents[x] += self.parents[y]
            self.parents[y] = x

        def size(self, x):
            return -self.parents[self.find(x)]

        def same(self, x, y):
            return self.find(x) == self.find(y)

        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]

        def group_count(self):
            return len(self.roots())

        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}

        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    ################
    
    M=10**5
    N=I()
    
    uf=UnionFind(2*M)
    for i in range(N):
        x,y=MI()
        x-=1
        y-=1
        y+=M
        uf.union(x,y)#辺を張る
        
    from collections import defaultdict
    ddx = defaultdict(int)
    ddy = defaultdict(int)
    
    for i in range(M):
        root=uf.find(i)
        ddx[root]+=1
        
        root=uf.find(i+M)
        ddy[root]+=1
        
    ans=-N
    
    roots=uf.roots()

    
    for v in roots:
        x=ddx[v]
        y=ddy[v]
        ans+=x*y
        
    print(max(ans,0))
    
    
    

main()


Measured memory_bytes: 151676
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll w,h,p,q;
    cin>>w>>h;
    vector<pair<int,int>> A;
    rep(i,w) cin>>p,A.push_back(make_pair(p,0));
    rep(i,h) cin>>q,A.push_back(make_pair(q,1));
    sort(A.begin(),A.end());
    ll ans=0,W=w+1,H=h+1;
    rep(i,w+h){
        if(A[i].second==0) ans+=A[i].first*H,W--;
        else ans+=A[i].first*W,H--;
    }
    cout<<ans;
}

Measured memory_bytes: 2420
import collections as col

A = str(input())
B = str(input())
C = str(input())

A_queue = col.deque()
B_queue = col.deque()
C_queue = col.deque()

for i in range (0, len(A)):
	A_queue.append(A[i])
for i in range (0, len(B)):
	B_queue.append(B[i])
for i in range (0, len(C)):
	C_queue.append(C[i])

D = ['a','b','c']
  
start = 0  
for i in range (0, 300):
	if start == 0:
		if len(A_queue) == 0:
			print('A')
			exit()
		else:
			V = A_queue.popleft()
			start = D.index(V)
	elif start == 1:
		if len(B_queue) == 0:
			print('B')
			exit()
		else:
			V = B_queue.popleft()
			start = D.index(V)     
	else:
		if len(C_queue) == 0:
			print('C')
			exit()
		else:
			V = C_queue.popleft()
			start = D.index(V) 

Measured memory_bytes: 9344
import java.io.*;
import java.util.*;
import java.util.Map.*;

public class Main {
	static int H, W, N;
	static long[] score = new long[10];
	static int[] va = { -1, -1, -1, 0, 0, 0, 1, 1, 1 };
	static int[] vb = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] item;
		HashMap<Integer, Map<Integer, Integer>> map = new HashMap<Integer, Map<Integer, Integer>>();
		line = br.readLine();
		item = line.split(" ");
		H = Integer.parseInt(item[0]);
		W = Integer.parseInt(item[1]);
		N = Integer.parseInt(item[2]);
		int h, w;
		h = H - 1;
		w = W - 1;
		Arrays.fill(score, 0);
		score[0] = (long) (H - 2) * (W - 2);
		for (int i = 0; i < N; i++) {
			line = br.readLine();
			item = line.split(" ");
			int a = Integer.parseInt(item[0]), b = Integer.parseInt(item[1]);
			for (int k = 0; k < va.length; k++) {
				int adja = a + va[k];
				int adjb = b + vb[k];
				if (!(2 <= adja && adja <= h && 2 <= adjb && adjb <= w))
					continue;
				if (!map.containsKey(adja)) {
					map.put(adja, new HashMap<Integer, Integer>());
				}
				if (!map.get(adja).containsKey(adjb)) {
					map.get(adja).put(adjb, 0);
				}
				map.get(adja).put(adjb, map.get(adja).get(adjb) + 1);
			}
		}

		for (Entry<Integer, Map<Integer, Integer>> e1 : map.entrySet()) {
			int a = e1.getKey();
			for (Entry<Integer, Integer> e2 : map.get(a).entrySet()) {
				// int b = e2.getKey();
				int sc = e2.getValue();
				if (sc != 0) {
					score[sc]++;
					score[0]--;
				}
			}
		}
		for (int i = 0; i < score.length; i++)
			System.out.println(score[i]);
	}
}


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

int main() {
  int N, x;
  cin >> N >> x;
  vector<int> happynumber(N);
  for (int i = 0; i < N; i++) {
    cin >> happynumber.at(i);
  }
  
  sort(happynumber.begin(), happynumber.end());
  int sum = 0;
  int count = 0;
  for (int i = 0; i < N; i++) {
    sum += happynumber.at(i);
    if (sum > x) {
      break;
    }
    else if (i == N-1 && sum < x){
      break;
    }
    else {
      count ++;
    }
  }
  
  cout << count << endl;
  
}



Measured memory_bytes: 256
//  Darker and Darker

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>

using namespace std;

struct Point
{
    int x;
    int y;
    int number;
};

int H,W;

int move(int met[1000][1000], Point p, queue<Point> &q, int x1, int y1, int count)
{
    int x2 = x1 + p.x;
    int y2 = y1 + p.y;
    if (x2 >= W || y2 >= H || x2 < 0 || y2 < 0) {
        return count;
    }
    if (met[y2][x2] > -1) {
        return count;
    }
    int number = p.number + 1;
    met[y2][x2] = number;
    p.x = x2;
    p.y = y2;
    p.number = number;
    q.push(p);
    count = count < number ? number : count;
    return count;
}

int main()
{
    int met[1000][1000];
    cin >> H >> W;
    int number = 0;
    queue<Point> q;

    // 初期化
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < W; j++) {
            if (s[j] == '#') {
                number++;
                met[i][j] = 0;
                Point p;
                p.x = j;
                p.y = i;
                p.number = 0;
                q.push(p);
            }
            else {
                met[i][j] = -1;
            }
        }
    }

    int count = 0;
    while (!q.empty()) {
        Point p = q.front();
        q.pop();
        // 隣接するセルをキューに追加する
        count = move(met, p, q, 0, -1, count);
        count = move(met, p, q, -1, 0, count);
        count = move(met, p, q, 1, 0, count);
        count = move(met, p, q, 0, 1, count);
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 16272
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <stdio.h>
#include <cmath>
#include <string.h>
#include <vector>

#define ll long long
using namespace std;

int main()
{
   // freopen("C:\\Users\\23733\\Desktop\\in.txt","r",stdin);
    int a, b, ans;
    cin >> a >> b;
    if((a+b) % 2 == 0)
    {
        ans = min(a, b) + abs(a - b) / 2;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> r(N);
  for(int i=0;i<N-1;i++){
    int t;
    cin >> t;
    r[t-1]++;
  }
  for(auto&& x:r)cout << x << endl;
  
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
int main() {
  int arr[6];
  int idx = 1;
  for (int i = 1; i <= 5; i++) {
    cin >> arr[i];
    if (arr[i] == 0)
      idx = i;
  }
  cout << idx;
}

Measured memory_bytes: 3576
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const ll INF=100000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
int main() {
	string a,b,c;
	cin>>a>>b>>c;
	cout<<a[0]<<b[0]<<c[0]<<endl;
	
	return 0;
}


Measured memory_bytes: 256
import math


inf = 10**12

def main():
    N = int(input())
    print(solve(N))

def get_count(k):
    for i in range(inf):
        k -= i
        if k < 0:
            return i-1

def solve(N):
    result = 0
    
    current_count = 0
    while N % 2 == 0:
        current_count += 1
        N //= 2
    result += get_count(current_count)

        
    d = 3
    sqrt = math.sqrt(N)
    while N > 1:
        current_count = 0
        # print(f'd: {d}')
        # print(f'N: {N}')
        if d > sqrt:
            # print("hello")
            if N > 1:
                result += 1
                N = 1
        while N % d == 0:
            current_count += 1
            N //= d
            # print(N)
        if current_count:
            result += get_count(current_count)
            sqrt = math.sqrt(N)
        # print(f'N: {N}')
        d += 2

    return result


if __name__ == '__main__':
    main()


Measured memory_bytes: 9224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int q, n;
int co;
set<int> si;

int solve(int n){
	int res = -1;
	int k = 10;
	while (n / k >= 1){
		int a = n / k, b = n%k;
		res = max(res, a*b);
		k *= 10;
	}
	return res;
}

int main(){
	cin >> q;
	REP(i, q){
		si.clear();
		co = 0;
		cin >> n;
		while (n / 10 > 0){
			if (!si.insert(n).second){
				co = -1;
				break;
			}
			co++;
			n = solve(n);
		}
		cout << co << endl;
	}
}

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

int main() {
    int n, m;
    cin >> n >> m;
    cout << (n * (n - 1) / 2) + (m * (m - 1) / 2) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
using namespace std;

long long N;

/*bool nine(long long n){

}*/

int main(){
	cin >> N;
	string S = to_string(N);
	long long ans = 0,ans2 = 0;
	long long i = 1;
	char c = S[0];
	int a = atoi(&c);
	for(int j=0;j<S.size();j++){
		ans += 9*i;
		i *= 10;
	}
	//cout << ans << endl;
	if(ans==N) cout << 9*S.size() << endl;
	else if(ans/10 == N%(i/10)) cout << 9*(S.size()-1)+a << endl;
	else if(ans/10<N) cout << max(9*(S.size()-1),9*(S.size()-1)+a-1) << endl;
	else cout << 9*S.size()+a-1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

  public static boolean search(String ring, String pattern, int i) {
    int j = 1;
    i = (i + 1) % ring.length();
    while (j < pattern.length()) {
      if (ring.charAt(i) != pattern.charAt(j))
        return false;
      i = (i + 1) % ring.length();
      j++;
    }
    return true;
  }

  public static String patternInRing(String ring, String pattern) {
    int i = 0;
    boolean found = false;
    while (i < ring.length()) {
      if (ring.charAt(i) == pattern.charAt(0)) {
        if(search(ring, pattern, i))
          return "Yes";
      }
      i++;
    }
    return "No";
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String ring = s.next();
    String pattern = s.next();
    System.out.println(patternInRing(ring, pattern));
    s.close();
  }
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();

  map<string, int> count;
  REP(i, N) {
    string s;
    cin >> s;
    sort(ALL(s));
    count[s]++;
  }
  ll ans = 0;
  for (auto it = count.begin(); it != count.end(); ++it) {
    int c = it->second;
    ans += (ll)c*(c-1) / 2;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

int main(void){
    char s[1005];
    scanf("%s",s);
    if(s[strlen(s)-1]=='s'){printf("%ses",s);}
    else{printf("%ss",s);}

}

Measured memory_bytes: 1736
n = int(input())
s = input()
dp = [[0 for i in range(5001)] for j in range(5001)]

for i in range(n-1,-1,-1):
	for j in range(n-1,-1,-1):
		if s[i] != s[j]:
			dp[i][j] = 0
		else:
			dp[i][j] = dp[i+1][j+1] + 1

res = 0
for i in range(n):
	for j in range(n):
		if i >= j:
			continue
		x = min(dp[i][j], j-i)
		res = max(x,res)
print (res)

Measured memory_bytes: 247560
X = int(input())
flag = 0
for i in range(1,int(X**0.5)+1):
    if X%i==0:
        x = i
        y = X//i
        for b in range(-int(10**(9/5))-1,int(10**(9/4))+1):
            a = b+x
            if a**4+a**3*b+a**2*b**2+a*b**3+b**4==y:
                A = a
                B = b
                flag = 1
                break
        if flag==1:break
print(A,B)

Measured memory_bytes: 65404
import sys
input = sys.stdin.readline
N = int(input())
s = []
for _ in range(N):
  s.append(int(input()))
res = sum(s)
s.sort()
if res % 10 == 0:
  for i in range(N):
    if s[i] % 10:
      res -= s[i]
      print(res)
      exit(0)
  print(0)
else: print(res)

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

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int d;
    cin>>d;
    if(abs(a-c)<=d){
        puts("Yes");
        return 0;
    }
    if(abs(a-b)<=d&&abs(c-b)<=d){
        puts("Yes");
        return 0;
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main() {

    int n, j, key;
    int arr[1000+5];
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d",&arr[i]);
    for ( int i = 0; i < n; i++ ) {
        j = i - 1;
        key = arr[i];

        while( j >= 0 && arr[j] > key) {
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = key;

        for(int k = 0; k < n; k++) {
            if( k > 0 ) printf(" ");
            printf("%d", arr[k]);
        }
        printf("\n");
    }
    return 0;
}




Measured memory_bytes: 2080
# 入力
H,W=map(int,input().split())

l=[]
for i in range(H):
  x=input()
  # 白いマスのみからなる場合は追加しない
  if x!='.'*W:
    l.append(x)

rm=[]
for i in range(W):
  # フラグ
  f=True
  for j in range(len(l)):
    if l[j][i]=='#':
      f=False

  # 取り除く列の添字を保存しておく
  if f:
    rm.append(i)

a=[]
for x in l:
  for i in rm[::-1]:
    x=x[:i]+x[i+1:]
  a.append(''.join(x))

# 出力
for i in range(len(a)):
  print(''.join(a[i]))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = (long) Math.floor(Math.sqrt(n));

		long ans = Long.MAX_VALUE;
		for (long i = m; i > 0; i--) {
			if (n%i==0) {
				long r = n/i;
				ans = Math.min(ans, i + r -2);
			}
		}
		System.out.println(ans);

	}
}


Measured memory_bytes: 23252
[N,K] = list(map(int, input().split()))
S = str(input())        
#[N,K] = [3,1]
#S = "ABC"
ans = ""
for i in range(N):
    if i == K - 1:
        ans = ans +S[i].lower()
    else:
        ans = ans + S[i]
print(ans)
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N,A;
  cin>>N>>A;
  N%=500;
  if(A<N) {
cout<<"No"<<endl;
  }
  else {
cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int longestIncreaseSequence(int a[], int n) {
	vector<int> A(n, INF);
	for (int i = 0; i < n; i ++)
		*lower_bound(A.begin(), A.end(), a[i]) = a[i];
	return find(A.begin(), A.end(), INF) - A.begin();
}

int main() {
	const double weight = 4.292036732051034;
	const double weight2 = 11.415926535897931;
	int x1; int y1; int x2; int y2;
	while (~scanf("%d%d%d%d", &x1, &y1, &x2, &y2)) {
		int W = abs(x2 - x1), H = abs(y2 - y1);
		bool flipx = x1 > x2, flipy = y1 > y2;
		int N;
		scanf("%d", &N);
		vpii points;
		rep(i, N) {
			int X; int Y;
			scanf("%d%d", &X, &Y);
			X -= x1, Y -= y1;
			if (flipx) X = -X;
			if (flipy) Y = -Y;
			if (0 <= X && X <= W && 0 <= Y && Y <= H)
				points.emplace_back(X, Y);
		}
		sort(points.begin(), points.end());
		vi ys;
		for (auto p : points)
			ys.push_back(p.second);
		int num = ys.empty() ? 0 : longestIncreaseSequence(ys.data(), (int)ys.size());
		double ans = (W + H) * 100.;
		if (num < min(W, H) + 1) {
			ans -= num * weight;
		} else {
			ans -= (num - 1) * weight;
			ans += weight2;
		}
		printf("%.10f\n", ans);
	}
	return 0;
}


Measured memory_bytes: 4080
#include <bits/stdc++.h>
        using namespace std;
        typedef long long ll;
        int main ()
        {
            ios::sync_with_stdio(0);
            cin.tie(0);
            string s;
            cin>>s;
            int k;
            cin>>k;
            set<string> st;
            for(int i=0;i<s.size();i++)
            {
                string p;
                for(int j=i;j<=i+k;j++)
                {
                    if(j>=s.size())break;
                    p+=s[j];
                    st.insert(p);
                }
            }
            vector<string> ans(st.begin(),st.end());
            sort(ans.begin(),ans.end());
            cout<<ans[k-1];
        	return 0;
        }

Measured memory_bytes: 2304
class PERM_COMB_MOD():
    # http://drken1215.hatenablog.com/entry/2018/06/08/210000
    def __init__(self, max_n=510000, mod=10**9+7):
        self.fac = [0]*max_n
        self.finv = [0]*max_n
        self.inv = [0]*max_n
        self.fac[0] = self.fac[1] = 1
        self.finv[0] = self.finv[1] = 1
        self.inv[1] = 1
        self.max = max_n
        self.mod = mod
        self._maesyori()

    def _maesyori(self):
        for i in range(2,self.max):
            self.fac[i] = self.fac[i-1] * i % self.mod
            self.inv[i] = self.mod - self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.finv[i] = self.finv[i-1] * self.inv[i] % self.mod

    def perm(self, n, k):
        if n < k : return 0
        if n < 0 or k < 0:return 0
        return self.fac[n] * self.finv[n-k] % self.mod % self.mod

    def comb(self, n, k):
        if n < k : return 0
        if n < 0 or k < 0:return 0
        return self.fac[n] * (self.finv[k] * self.finv[n-k] % self.mod) % self.mod

n,m,k = map(int, input().split())
mod = 10**9+7
p = PERM_COMB_MOD()
ans = 0

# xについて
for i in range(1,n):
    ans += i*(n-i)*m*m % mod
    ans %= mod
# yについて
for i in range(1,m):
    ans += i*(m-i)*n*n % mod
    ans %= mod
ans *= p.comb(n*m-2,k-2)
ans %= mod
print(ans)

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  string s;cin>>s;
  int n=s.size();
  bool e=false;
  int sc=0,tc=0;
  int count=0;
  rep(i,0,n){
    if(s[i]=='S'){
      sc++;
    }
    else{
      if(sc!=0){
        sc--;
        count++;
      }
    }
  }
  out(n-2*count);


  return 0;
}


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

void testCase(){
    long long val, count = 0;
    cin>>val;
    if(val == 2) cout<<1<<endl;
    else{
        for(long long i = 2; i*i <= val; i++){
            if(val%i == 0){
                long long temp = val;
                while(temp%i == 0) temp = temp/i;
                if(temp%i == 1){
                    // cout<<i<<endl;
                    count++;
                }

                if(i != val/i){
                    temp = val;
                    long long j = val/i;
                    while(temp%j == 0) temp = temp/j;
                    if(temp%j == 1){
                        // cout<<val/j<<endl;
                        count++;
                    }
                }
                // count += 2;
            }
        }
        val--;
        count++;
        for(long long i = 2; i*i <= val; i++){
            if(val%i == 0){
                if(i*i == val){
                    // cout<<i<<endl;
                    count++;
                }
                else{
                    // cout<<i<<endl;
                    // cout<<val/i<<endl;
                    count += 2;
                }
            }
        }
        count++;
        cout<<count<<endl;
    }
}

int main(){
    int t;
    t = 1;
    // cin>>t;
    while(t--){
        testCase();
    }
}



Measured memory_bytes: 3608
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
const ll MAX_N = 1e5;
ll N;
ll a[MAX_N],b[MAX_N],c[MAX_N];
ll dp[MAX_N+1][3]; // メモ化テーブル
 
// i番目以降の品物から重さの総和がj以下になるように選ぶ
void rec(ll i){
	if (i==0){
		dp[i][0] = a[0];
		dp[i][1] = b[0];
		dp[i][2] = c[0];
	}
	else{
		dp[i][0] = a[i]+max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = b[i]+max(dp[i-1][2], dp[i-1][0]);
		dp[i][2] = c[i]+max(dp[i-1][0], dp[i-1][1]);
	} 
	return;
}

int main() {
	// 入力
	cin >> N;
	for (ll i = 0; i < N; ++i) cin >> a[i]>>b[i]>>c[i];
 
	
	// 解法
	// まだ調べていないことを表す-1でメモ化テーブルを初期化
	memset(dp, -1, sizeof(dp));
	
	REP(i,N) rec(i);
	
	// REP(i,N){
	// 	printf("%lld %lld %lld\n", dp[i][0],dp[i][1],dp[i][2]);
	// }
	ll ans = max(dp[N-1][0],dp[N-1][1]);
	ans    = max(ans, dp[N-1][2]);
	printf("%d\n", ans);
}


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

int main(void)
{
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> city(m);
    vector<vector<int>> a(n);
    for (int i=0;i<m;i++){
        int p,y;
        cin >> p >> y;
        city[i].first = p;
        city[i].second = y;
        a[p-1].push_back(y);
    }
    for (int i=0;i<a.size();i++){
        sort(a[i].begin(),a[i].end());
    }
    for (int i=0;i<m;i++){
        int now_f = city[i].first-1; //探す場所
        int now_s = city[i].second; //探したいもの
        auto Iter1 = upper_bound(a[now_f].begin(),a[now_f].end(),now_s);
        city[i].second = Iter1 - a[now_f].begin();
        // for(int j=0;j<a[city[i].first-1].size();j++){
        //     //ここを2分にする?
        //     if(city[i].second==a[city[i].first-1][j]){
        //         city[i].second = j+1;
        //     }
        // }
    }
    //6桁にする
    vector<string> ans(m);
    for(int i=0;i<m;i++){
        ans[i] = "000000000000";
        int at = city[i].first;
        string s_at = to_string(at);
        int year = city[i].second;
        string s_year = to_string(year);
        ans[i].replace(6-s_at.size(),s_at.size(),s_at);
        ans[i].replace(12-s_year.size(),s_year.size(),s_year);
        cout << ans[i] << endl;;
    }

    return 0;
}

Measured memory_bytes: 13184