akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define int long long
#define double long double
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

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

	int cnt = 0, pre = 0;
	rep (i, n) {
		cnt += s[i] == '(' ? 1 : -1;
		if(cnt < 0)
			pre = max(pre, -cnt);
	}

	rep (i, pre) {
		s = '(' + s;
	}

	n += pre;
	cnt = 0;
	rep (i, n) {
		cnt += s[i] == '(' ? 1 : -1;
	}

	rep (i, abs(cnt)) {
		s += ')';
	}

	cout << s << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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; }
template<class T> inline bool change(T& a, T b) { if (a != b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    map<ll,ll> m;
    for(ll i=0;i<n;i++){
        ll a; cin >> a;
        m[a]++;
    }
    ll q; cin >> q;
    ll ans=0;
    for (auto i=m.begin();i!=m.end();i++){
        ans+=(i->first)*(i->second);
    }
    for(ll i=0;i<q;i++){
        ll b,c; cin >> b >> c;
        ans-=m[b]*b;
        ans+=m[b]*c;
        cout << ans << endl;
        m[c]+=m[b];
        m.erase(b);
    }
    return 0;
}

Measured memory_bytes: 8008
#include <stdio.h>

int n, s, cnt;

void dfs(int i, int sum, int n){
    if(sum==s&&!n){
        cnt++;
        return;
    }
    if(i==10||!n) return;
    dfs(i+1,sum,n);
    dfs(i+1,sum+i,n-1);
}

int main(){
	while(1){
		scanf("%d%d",&n,&s);
		if(n==0&&s==0){
			break;
		}
		cnt=0;
		dfs(0,0,n);
		printf("%d\n",cnt);
	}

    return 0;
}

Measured memory_bytes: 2544
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int gcd(int x, int y) {
    return x % y == 0? y: gcd(y, x % y);
}

int g[201][201];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int i, j;
    xrep(i, 1, 201) xrep(j, 1, 201) {
        g[i][j] = gcd(i, j);
    }
    int n;
    cin >> n;
    ll ans(0);
    int k;
    xrep(i, 1, n + 1) xrep(j, 1, n + 1) xrep(k, 1, n + 1) {
        ans += g[i][g[j][k]];
    }
    cout << ans << endl;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
  string t = "AKIHABARA";
  string s;
  cin >> s;
  if (s == t) {
    cout << "YES" << endl;
    return;
  }

  int N = s.size();
  int M = t.size();

  vector<vector<int>> dp(N + 1, vector<int>(M + 1));
  dp[0][0] = 1;

  for(int i = 0; i <= N; i++) {
    for (int j = 0; j < M; j++) {
      if (!dp[i][j]) continue;
      if (i != N && s[i] == t[j]) dp[i + 1][j + 1] = 1;
      if (t[j] == 'A') dp[i][j + 1] = 1;
    }
  }


  if (dp.back().back()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	double d;
	int ans=0;
	cin >>n>>d;
	int x,y;
	rep(i,n){
		cin>>x>>y;
		if(hypot(x,y)<=d){ans++;}
	}
	cout<<ans<<endl;
}

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


public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> Mylist = new ArrayList<Integer>();
        int N = sc.nextInt(), K = sc.nextInt();
        for(int i = 0;i<N;i++){
          	int S = sc.nextInt();
            Mylist.add(S);
        }
      
        for(int j = K+1;j<=N;j++){
          	int A = Mylist.get(j-(K+1)); 
          	int B = Mylist.get(j-1);         	
            if (A < B){
                System.out.println("Yes");
            }
            else{
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 64340
#include <iostream>

bool f(int n){
    int fn = 0;
    int tmp = n;
    while(n > 0){
        fn += n % 10;
        n /= 10;
    }
    return tmp % fn == 0;
}

int main(){
    int n;
    std::cin >> n;
    std::cout << (f(n) ? "Yes" : "No") << std::endl;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

void solve(){
    string S;
    cin >> S;

    int ans = 10000;
    for (int i = 0; i <= (int)S.size() - 3; i++) {
        ans = min(ans, abs(753 - stoi(S.substr(i,3))));

    }
    cout << ans << endl;
    // cout << stoi(S.substr(0,3)) + 1 << endl;
    
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[50];
int main(){
	int n,w=0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	for(int i=2;i<n;++i)if(a[i]>a[i-1]&&a[i]<a[i+1]||a[i]<a[i-1]&&a[i]>a[i+1])++w;
	printf("%d",w);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main ()
{
  long long int a,b,c,k;
  cin>>a>>b>>c>>k;
  long long int shuma=0;
  if(k>=a)
  {
    shuma=a;
    k-=a;
  }
  else
  {
      cout<<k<<endl;
      return 0;
  }
  if(k>=b)
  {
      k-=b;
  }
  if(k>0)
  {
      shuma-=k;
  }
  cout<<shuma<<endl;
  return 0;
}



Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
int n,k,a[10010],h;
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=k;i++)
	{
		h+=a[i];
	}
	cout<<h;
	return 0;
}


Measured memory_bytes: 256
(async () => {
  process.stdin.setEncoding('utf8');
  let text = '';
  for await (const chunk of process.stdin) text += chunk;

  const lines = text.toString().split('\n');
  const tmpArray = lines[1].split(' ');
  const count = lines[0];
  let result = 0;

  for (let i = 0; i < tmpArray.length; i++) {
    if (i % 2 === 0) {
      if (tmpArray[i] % 2 === 1) {
        result ++;
      }
    }
  }

  console.log(result);
})();



Measured memory_bytes: 29948
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int ar[200005]={0},dr[200005]={0};
ll L,R,mod=1e9+7;
int main(){
  ll n;
  cin>>n;
  for(int i=1;i<=2*n;i++){
    char a;
    cin>>a;
    if(a=='B') ar[i]=1;
    else ar[i]=0;
  }
  if(ar[1]==0) {
    cout<<0<<endl;
    return 0;
  }
  dr[0]=0;
  dr[1]=0;
  for(int i=2;i<=2*n;i++){
    if(ar[i-1]==ar[i]) {
      dr[i]=(dr[i-1]+1)%2;
    }
    else{
      dr[i]=dr[i-1];
    }
  }
  for(int i=1;i<=2*n;i++){
    if(dr[i]==0) L++;
    else R++;
  }
  if(L!=R) {
    cout<<0<<endl;
    return 0;
  }
  ll ans=1;
  ll lnum=0;
  for(int i=1;i<=2*n;i++){
    if(dr[i]==0) lnum++;
    else{
      ans*=lnum;
      lnum--;
      ans%=mod;
    }
  }
  for(ll i=1;i<=n;i++) {
    ans*=i;
    ans%=mod;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    int N;
    int a,b,c;
  	scanf("%d", &N);
	a=N/100;
	b=N%100/10;
	c=N%10;
	if(99<N&&N<1000){
	    if(a==7||b==7||c==7){
	        printf("Yes");
	    }else{
	        printf("No");
	    }
	}else{
	    printf("No");
	}
	
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

int n,m,k,arr[N];

void solve()
{
    cin>>n>>m;
    string s1,s2;
    forn(i,1,n)s1+=to_string(m);
    forn(i,1,m)s2+=to_string(n);
    cout<<min(s1,s2);

}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       clang++ c.cpp ; ./a.out < a.txt ;  

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

int main(){
    long long N,K;
    cin >> N >> K;
    vector<int> A(N+1);
    for(int i = 1; i <= N; i++){
        cin >> A[i];
    }
    map<int,int> m;
    m[1] = 0;
    vector<int> v;
    int c = 1; // 現在地
    m[c] = 0;
    long long right, left;
    v.push_back(c);
    for(int i = 1; i < N + 10; i++){
        c = A[c];
        v.push_back(c);
        if(c == 1 || m[c]!=0){
            right = i;
            break;
        }
        m[c] = i;
    }
    left = m[c];
    if(K < v.size()) cout << v[K] << endl;
    else cout << v[left + (K - right)%(left - right)] << endl;    

}

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

using namespace std;

int n;
int v[200010];

map<int,int> mp;

int main() {
    
    cin >> n;

    for (int i = 1; i <= n; ++i) {
        cin >> v[i];
        mp[i - v[i]]++;
    }

    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
        int val = v[i] + 1;
        int id = i + val;
        ans += mp[id - 1];
    }

    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 21224
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    n = getN()
    lis = getList()
    xo, su = 0, 0
    ans = 0
    l, r = 0, 0
    forward = True
    while True:
        # print(l, r, ans, xo, su)
        if r == n:
            print(ans)
            return
        if forward:
            xo = xo^lis[r]
            su += lis[r]
            if xo == su:

                ans += r - l + 1
                r += 1
            else:
                forward = False
        else:
            xo = xo^lis[l]
            su -= lis[l]
            if xo == su:
                forward = True
                ans += r - l
                r += 1
                l += 1
            else:
                l += 1

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 103740
#include<bits/stdc++.h>
using namespace std;
const double PI=3.14159265358979323846;
#define int long long int
signed main(){
    int x,n;cin>>x;
    n=100;
    int cnt=0;
    while(1){
        if(n>=x)break;
        n*=1.01;
        cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3636
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int a = Character.getNumericValue(s.charAt(0));
        int b = Character.getNumericValue(s.charAt(1));
        int c = Character.getNumericValue(s.charAt(2));
        int d = Character.getNumericValue(s.charAt(3));
        char[] kigou = {'+', '-'};
        int sum = 0;
        String result = "";

        for (char aKigou : kigou) {
            for (char aKigou1 : kigou) {
                for (char aKigou2 : kigou) {

                    if (aKigou == '+') {
                        sum = a + b;

                    } else {
                        sum = a - b;
                    }

                    if (aKigou1 == '+') {
                        sum = sum + c;

                    } else {
                        sum = sum - c;
                    }

                    if (aKigou2 == '+') {
                        sum = sum + d;

                    } else {
                        sum = sum - d;
                    }

                    if (sum == 7) {
                        result = String.valueOf(a) + aKigou + String.valueOf(b) + aKigou1 + String.valueOf(c) + aKigou2 + String.valueOf(d);
                        break;
                    }

                }
                if (sum == 7) {
                    break;
                }
            }
            if (sum == 7) {
                break;
            }
        }

        result += "=7";
        System.out.println(result);

    }
}

Measured memory_bytes: 23380
def cmb(n, r):
    return fact[n] * inv_fact[r] * inv_fact[n - r] % MOD


MOD = 10 ** 9 + 7

N, M, K = map(int, input().split())

fact = [1]
for i in range(1, N * M - 2 + 1):
    fact.append(fact[-1] * i % MOD)

inv_fact = [-1] * (N * M - 1)
inv_fact[-1] = pow(fact[-1], MOD - 2, MOD)
for i in range(N * M - 3, -1, -1):
    inv_fact[i] = inv_fact[i + 1] * (i + 1) % MOD

pat = cmb(N * M - 2, K - 2)

ans = 0

for i in range(M):
    ans += i * (M - i) * N ** 2

for i in range(N):
    ans += i * (N - i) * M ** 2

ans = (ans * pat) % MOD

print(ans)


Measured memory_bytes: 18960
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	string S; cin >> S;
	if (S[0] != 'A') S = "A" + S;
	if (S.size() > 4 && S[4] != 'A') S = S.substr(0, 4) + "A" + S.substr(4, 50);
	if (S.size() > 6 && S[6] != 'A') S = S.substr(0, 6) + "A" + S.substr(6, 50);
	if (S[S.size()-1] != 'A') S = S + "A";
	YN(S == "AKIHABARA");

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	vector<vector<int>> X;
	int N, D;
	int ans = 0;
	
	cin>>N>>D;
	
	X.resize(N, vector<int>(D));
	for(int i = 0; i < N; i++){
		for(int j = 0; j < D; j++){
			cin>>X[i][j];
		}
	}
	
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			int sum = 0;
			for(int k = 0; k < D; k++){
				sum += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
			}
			
			for(int k = 0; k*k <= sum; k++){
				if(k*k == sum){
					ans++;
					break;
				}
			}
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cctype>
#include <cassert>
#include <string>
#include <vector>
#include <algorithm>

class Permutation {
  size_t n;
  std::vector<std::vector<size_t>> body;

public:
  Permutation(size_t n): n(n), body(n, std::vector<size_t>(n)) {
    size_t k=0;
    for (size_t i=0; i<n; ++i)
      for (size_t j=0; j<n; ++j)
        body[i][j] = k++;
  }
  Permutation(size_t n, char shift, size_t k): Permutation(n) {
    if (shift == 'L') {
      size_t tmp=body[k][0];
      for (size_t j=1; j<n; ++j)
        body[k][j-1] = body[k][j];
      body[k][n-1] = tmp;
    } else if (shift == 'R') {
      size_t tmp=body[k][n-1];
      for (size_t j=n-1; j--;)
        body[k][j+1] = body[k][j];
      body[k][0] = tmp;
    } else if (shift == 'U') {
      size_t tmp=body[0][k];
      for (size_t i=1; i<n; ++i)
        body[i-1][k] = body[i][k];
      body[n-1][k] = tmp;
    } else if (shift == 'D') {
      size_t tmp=body[n-1][k];
      for (size_t i=n-1; i--;)
        body[i+1][k] = body[i][k];
      body[0][k] = tmp;
    }
  }

  Permutation& operator *=(const Permutation& other) {
    Permutation tmp(n);
    for (size_t i=0; i<n; ++i)
      for (size_t j=0; j<n; ++j) {
        size_t ii=other[i][j]/n;
        size_t jj=other[i][j]%n;
        tmp[i][j] = (*this)[ii][jj];
      }

    body = std::move(tmp.body);
    return *this;
  }

  Permutation& operator ^=(uintmax_t iexp) {
    Permutation tmp(n);
    for (Permutation dbl=*this; iexp; iexp>>=1) {
      if (iexp & 1) tmp *= dbl;
      dbl *= dbl;
    }
    body = std::move(tmp.body);
    return *this;
  }

  const std::vector<size_t>& operator [](size_t i) const {
    return body[i];
  }

  std::vector<size_t>& operator [](size_t i) {
    return body[i];
  }

  void print() const {
    for (size_t i=0; i<n; ++i)
      for (size_t j=0; j<n; ++j)
        printf("%zu%c", body[i][j]+1, j+1<n? ' ':'\n');
  }
};

uintmax_t parse_int(const std::string& s, size_t& i) {
  uintmax_t res=s[i]-'0';
  while (++i < s.length() && isdigit(s[i]))
    res = res*10+s[i]-'0';
  return res;
}

Permutation parse(const std::string& s, size_t& i, size_t n) {
  Permutation res(n);
  while (i < s.length() && s[i] != ')') {
    if (s[i] == '(') {
      Permutation tmp=parse(s, ++i, n);
      assert(s[i] == ')');
      tmp ^= parse_int(s, ++i);
      res *= tmp;
    } else {
      char shift=s[i];
      size_t number=parse_int(s, ++i);
      Permutation tmp(n, shift, number-1);
      res *= tmp;
    }
  }
  return res;
}

int main() {
  size_t N, L;
  char buf[1024];
  scanf("%zu %zu %s", &N, &L, buf);
  std::string S=buf;

  size_t i=0;
  parse(S, i, N).print();
}


Measured memory_bytes: 30196
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	cout << s[0] << s.length() - 2 << s[s.length() - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
n,m,x = input().split()
N = int(n)
M = int(m)
X = int(x)
left = []
right = []

A = input().split()
A = list(map(int,A))
for i in range(len(A)):
	if(A[i]<X):
		left.append(A[i])
	elif(A[i]>X):
		right.append(A[i])

print(min(len(left),len(right)))

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef pair<ll, ll> lpair;
typedef tuple<int, int, int> ituple;

// const int INF = INT_MAX;
// const ll INF = LLONG_MAX;
// const int MOD = ((int)1e9 + 7);
// const ld EPS = (1e-10);
#define PI acosl(-1)
#define MAX_N (100000 + 2)

void exec(){
  string s, t;
  cin >> s >> t;
  bool isOK = true;
  for (int i = 0; i < s.length(); i++){
    if (s[i] != t[i]) {
      isOK = false;
      break;
    }
  }

  cout << (isOK ? "Yes" : "No") << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3600
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;
vector<bool> a(100005, false);
	int n;
bool isSame(int pos)
{
	if (pos==0)
		return a[n-1] == a[1];
	if (pos==n-1)
		return a[n-2] == a[0];
	return a[pos-1] == a[pos+1];
}

int main()
{
	ios::sync_with_stdio(false);


	cin >> n;
	string s;
	cin >> s;
	
	bool t[2] = {true, false};

	REP(j,2)
	{
		REP(k,2)
		{
			a[0] = t[j];
			a[1] = t[k];

			for(int i = 2; i < n; i++)
			{
				if(s[i-1] == 'o')
					if (a[i-1])
					{
						a[i] = a[i-2];
					}
					else
					{
						a[i] = !a[i-2];
					}
				else
					if (a[i-1])
					{
						a[i] = !a[i-2];
					}
					else
					{
						a[i] = a[i-2];
					}
			}
			REP(i, n)
			{
				dbg(a[i]);
			}
			dbg("=--");
			bool ok = true;
			for (int i = 0; i < n; i++)
			{
				if (a[i])
					if ((isSame(i) && (s[i] == 'o')) ||
					((!isSame(i) && (s[i] == 'x'))))
					{
						continue;
					}
					else
					{
						ok = false;
						break;
					}
				else
					if ((!isSame(i) && (s[i] == 'o')) ||
					((isSame(i) && (s[i] == 'x'))))
					{
						continue;
					}
					else
					{
						ok = false;
						break;
					}
				
			}
			if (ok)
			{
				REP(i,n)
				{
					cout << (a[i] ? 'S' : 'W');
				}
				cout << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 592
// A

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int s;
  cin>>s;
  int a[1000001] = {0};
  int cnt(1);
  a[s]++;
  int x = s;
  while(true){
    cnt++;
    if(x%2==0){
      x /= 2;
    }else{
      x = 3*x + 1;
    }
    a[x]++;
    if (a[x] == 2){
      cout << cnt << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 4096
#include <algorithm>
#include <iostream>
#include <vector>
int main(int argc, char const* argv[]) {
    int n;
    std::string s;
    std::cin >> n >> s;
    std::vector<int> cs(n);
    int w = 0;
    int e = std::count(s.begin(), s.end(), 'E');
    // ewe
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'E') {
            e--;
        }
        if (i && s[i - 1] == 'W') {
            w++;
        }
        cs[i] = e + w;
    }
    std::cout << *std::min_element(cs.begin(), cs.end()) << std::endl;
    return 0;
}


Measured memory_bytes: 1796
def linerSearch(A, key):
    for i in A:
        if i == key:
            return 1
    return 0

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
c=0
for j in T:
    if linerSearch(S, j) != 0:
        c += 1
print(c)


Measured memory_bytes: 6552
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define MOD 1e+7
#define inf 1e9
#define fi first
#define se second
using namespace std;

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

  int k;
  string s;
  cin >> k >> s;
  int l = s.size();
  if(k >= l) cout << s << endl;
  else cout << s.substr(0,k) << "..." << endl;
  return 0;
}

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

int main() {
	long n, k, ans = 1;
	cin >> n >> k;
	if (k < n) ans = 0;
	else {
		for (long i = 0, j = k; i < n; i++, j--) {
			ans *= j;
			ans %= 1000000007;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3108
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int MAXN = 2e5 + 5;
int n;
vector<pair<int, int> > a, b;
int dp[105][105];
bool graph[105][105];
bool visited[105];
int matchR[105];
bool bpm(int node, bool vis[]){
    for(int i = 0; i < n; i ++){
        if(!graph[node][i] || vis[i])continue;
        vis[i] = true;
        if(matchR[i] < 0 || bpm(matchR[i], vis)){
            matchR[i] = node;
            
            return true;
        }
        
    }
    return false;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> n;
    int a2, b2;
    for(int i =0 ; i < n; i ++){
        cin >> a2 >> b2;
        a.push_back(make_pair(a2, b2));
    }
    for(int i = 0; i < n; i ++){
        cin >> a2 >> b2;
        b.push_back(make_pair(a2, b2));
    }
    memset(graph, false, sizeof graph);
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < n; j ++){
            if(a[i].first < b[j].first && a[i].second < b[j].second){
                graph[i][j] = true;
            }
        }
    }
    int ret = 0;
    memset(matchR, -1, sizeof matchR);
    for(int i = 0; i < n; i ++){
        memset(visited, false, sizeof visited);
        if(bpm(i, visited)){
            ret ++;
        }
    }
    cout << ret << endl;
    return 0;
}


/*
 5 2
 aabb
 abbz
 */


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    string s; cin >> s;
    vector<string> pat = {"Sunny", "Cloudy", "Rainy"};
    int c = -1;
    for(int i=0; i<3; i++) {
        if(pat[i] == s) {
            c = i;
            break;
        }
    }
    cout << pat[(c + 1) % 3] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast_input ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef long long int ll;
long long int gcd(long long int a,long long int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
   
int main()
{
    fast_input;
   long long  int a,b;
    cin>>a>>b;
    long long int x = a*b;
    long long int ans = x/gcd(a,b);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int flagC;
int main()
{
	char st[128];int i,l;
	scanf("%s",st);
	l=strlen(st);
	for(i=0;i<l;++i)
	{
		if(st[i]=='C')
			flagC=1;
		else if(st[i]=='F'&&flagC)
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}



Measured memory_bytes: 256
// ---------- begin fenwick tree ----------
pub struct Fenwick<T> {
    zero: T,
    a: Box<[T]>,
}

impl<T> Fenwick<T>
where
    T: Copy + std::ops::Add<Output = T>,
{
    pub fn new(size: usize, zero: T) -> Fenwick<T> {
        Fenwick {
            zero: zero,
            a: vec![zero; size + 1].into_boxed_slice(),
        }
    }
    pub fn add(&mut self, mut x: usize, v: T) {
        assert!(x > 0);
        while let Some(a) = self.a.get_mut(x) {
            *a = *a + v;
            x += x & (!x + 1);
        }
    }
    pub fn sum(&self, mut x: usize) -> T {
        assert!(x < self.a.len());
        let mut res = self.zero;
        while x > 0 {
            res = res + self.a[x];
            x -= x & (!x + 1);
        }
        res
    }
}

impl<T> Fenwick<T>
where
    T: Copy + std::ops::Add<Output = T> + PartialOrd,
{
    pub fn search(&self, s: T) -> usize {
        debug_assert!(self.sum(self.a.len() - 1) >= s);
        let mut k = 1;
        while 2 * k < self.a.len() {
            k *= 2;
        }
        let mut x = 0;
        let mut w = self.zero;
        while k > 0 {
            self.a.get(x + k).map(|a| {
                if w + *a < s {
                    w = w + *a;
                    x += k;
                }
            });
            k >>= 1;
        }
        x + 1
    }
}
// ---------- end fenwick tree ----------

use proconio::*;
use proconio::marker::*;

#[fastout]
fn run() {
    input! {
        n: usize,
        q: usize,
        c: [Usize1; n],
        ask: [(Usize1, usize); q],
    }
    let mut a = vec![vec![]; n];
    for (i, c) in c.iter().enumerate() {
        a[*c].push(i);
    }
    let mut query = vec![vec![]; n];
    for (i, (l, r)) in ask.into_iter().enumerate() {
        query[l].push((r, i));
    }
    let mut bit = Fenwick::new(n, 0i32);
    for a in a.iter_mut() {
        a.reverse();
        if let Some(k) = a.pop() {
            bit.add(k + 1, 1);
        }
    }
    let mut ans = vec![0; q];
    for (l, (query, c)) in query.into_iter().zip(c.into_iter()).enumerate() {
        for (r, k) in query.into_iter() {
            ans[k] = bit.sum(r);
        }
        bit.add(l + 1, -1);
        if let Some(k) = a[c].pop() {
            bit.add(k + 1, 1);
        }
    }
    for a in ans {
        println!("{}", a);
    }
}

fn main() {
    run();
}


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

int main(){
    int n;
    while(cin >> n, n){
        int ans = 0;
        for(int i=0; i < n*(n-1)/2; i++){
            int m;
            cin >> m;
            ans += m;
        }
        cout << ans/(n-1) << endl;
    }
}

Measured memory_bytes: 1160
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 *
 * AND WATCH OUT FOR OFF BY ONE!!!
 */

#include <bits/stdc++.h>
const bool unsyncedio=std::ios::sync_with_stdio(false);
using namespace std;
typedef unsigned int uint;
typedef long long ll;

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll (i)=0; (i)<(n); (i)++)

class DSU {
public:
    vector<int> p;
/* initializes each (0..size-1) to single set */
    DSU(int size) {
        p.resize(size);
        for(int i=0; i<size; i++)
            p[i]=i;
    }

/* finds set representative for member v */
    int find_set(int v) {
        if (v == p[v])
            return v;
        return p[v] = find_set(p[v]);
    }

/* makes v a single set, removes it from other set if contained there. */
    void make_set(int v) {
        p[v] = v;
    }

/* combines the sets of two members.
 *  * Use the bigger set as a for optimized performance.  */
    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b)
            p[b] = a;
    }
};

int main() {
    int n, m;
    cin>>n>>m;
    DSU dsu(n+1);
    fori(m) {
        int x, y, z;
        cin>>x>>y>>z;
        dsu.union_sets(x, y);
    }

    set<int> c;
    for(int i=1; i<=n; i++)
        c.insert(dsu.find_set(i));

    cout<<c.size()<<endl;
}



Measured memory_bytes: 5376
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

//long int ar[90013],br[100013];
//long int gcd(long int a, long int b)
//{
//    if(b==0)
//        return a;
//    return gcd(b,a%b);
//}
//long int sieve(long long int a)
//{
//    //long long int i,j,k = 0;
//    memset(ar,0,sizeof(ar));
//    ar[1] = 1;
//    for(i=2; i<=90013; i++)
//    {
//        if(ar[i]==0)
//        {
//            k++;
//            br[k] = i;
//            for(j=i+i; j<=90013; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//    return br[a];
//}

void Ok()
{
    long int a,b,c,d,h,t,i = 0,j = 0,k = 0,l,m,n;
    long int ans_1,ans_2,ans_3,cnt = 0,Max,Min,flag = 1,temp,sum = 0;
    double aa,bb,cc,dd,ee,ff,gg;
    //char aaa[10013],bbb[10013],ccc[113],ddd;
    string spc,in;

    scanf("%ld",&a);
    aa = a;
    bb = 2 * 3.1416 * aa;
    printf("%0.2lf",bb);

    return;
}

int main()
{
    Ok();

    return 0;
}


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



int main(void)
{
    int n;
    cin >> n;
    vector<int> p(n), q(n);

    rep(i, n)
    {
        cin >> p.at(i);
    }
    
    rep(i, n)
    {
        cin >> q.at(i);
    }

    vector<int> y(n);
    rep(i, n) y[i] = i + 1;
    int cnt = 1;
    int a, b;

    do{
        if(p == y) a = cnt;
        if(q == y) b = cnt;
        cnt++;
    }while(next_permutation(y.begin(), y.end()));

    cout << abs(a - b) << endl;

    
    return 0;
}

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

using namespace std;
typedef long long ll;

#define ZERO_IQ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x, y) cerr << (#x) << " " << (#y) <<" is " << (x) <<" "<< (y) << endl
#define debug2(x, y, z) cerr << (#x) << " " <<(#y) << " " << (#z) << " is " << (x) << " " << (y) << " " << (z) << endl
#define watch(x) cerr << (#x) << " is " << (x) << endl
const ll mod = 1e9 + 7;
vector<ll> fact(1e6+10), inv(1e6+10);

ll fp(ll base, ll exp) {
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n) {
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++) {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r) {
    if(n<r)return 0;
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

int main() {
    ll n, k;
    cin >> n >> k;
    calcFacAndInv(1e5);
    for (int i = 1; i <= k; ++i) {
        cout << 1LL*((ncr(n - k + 1, i) * ncr(k - 1, i - 1)) % mod) << endl;
    }
    return 0;
}

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

const ll MOD = 1e9+7;

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  ll a, b, x;
  cin >> a >> b >> x;
  
  ll adiv = a/x;
  ll bdiv = b/x;
  ll ans = bdiv - adiv;
  if(a%x == 0) ++ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/irange.hpp>
#include <cmath>
#include <map>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define decn int n = 0; cin >> n

using namespace std;
namespace mp = boost::multiprecision;
typedef long long ll;
const ll M = 1000000007;

int main(){
	decn;
	map<string, int> mp;

	int max = 0;
	rep(i, n) {
		string s;
		cin >> s;
		mp[s]++;
		if (max < mp[s]) {
			max = mp[s];
		}
	}

	vector<string> st;
	for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
		if (itr->second == max) {
			st.push_back(itr->first);
		}
	}

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

	rep(i, st.size()) {
		cout << st[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 23916
a, b, n = map(int, input().split())

cnt = 1
buf = []
if n < b:
    buf.append(int(a * n / b) - a * (int(n / b)))
else:
    buf.append(int(a * (b - 1) / b) - a * (int((b - 1) / b)))
    

while True:
    if n / b > 10 ** 6:
        break
    x = cnt * b - 1
    if n < x :
        break
    calc = int(a * x / b) - a * (int(x / b))
    if calc > max(buf):
        buf.append(calc)
    cnt += 1
    
if n / b > 10 ** 6 and n >= b:
    buf.append(int(a * (b - 1) / b) - a * (int((b - 1) / b)))

ans = max(buf)
print(ans)

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

using namespace std;

int main(){
 string s;
  cin >> s;
    
  if(s[0]==s[s.length()-1]&&s.length()%2==0) cout << "First" << endl;
  else if(s[0]!=s[s.length()-1]&&s.length()%2) cout << "First" << endl;
  else cout << "Second" << endl;
  
  
  
}

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

const int MOD = 1000000007;
const int INF = 1001001001;

int main(){
    int a,b;
    cin>>a>>b;
    cout <<(a-1)*(b-1)<< endl;
    return 0;
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

int calc_memo(vi& dp, int n) {
    if (n <= 1) { return 1; }
    if (dp[n] != 0) { return dp[n]; }
    return dp[n] = calc_memo(dp, n - 2) + calc_memo(dp, n - 1);
}

int calc_dp(vi& dp, int n) {
    dp[0] = dp[1] = 1;
    int i = 2;
    while(i <= n) {
        dp[i] = dp[i - 1] + dp[i - 2];
        ++i;
    }
    return dp[i - 1];
}

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

    int n;
    cin >> n;

    vi dp(n + 1, 0);
    cout << calc_dp(dp, n) << endl;

    return 0;
}


Measured memory_bytes: 3140
/**
 * 
 */
import java.util.*;
/**
 * @author akira
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a, b;
		boolean first = true;
		while(scan.hasNextInt()){
			a = scan.nextInt();
			b = scan.nextInt();
			if(a == 0 && b == 0){
				break;
			}
			if(!first){
				System.out.println("");
			}
			first = false;
			boolean bl = true;
			for(int i = a;i <= b;i++){
				if(i % 400 == 0 || (i % 4 == 0 && i % 100 != 0)){
					System.out.println("" + i);
					bl = false;
				}
			}
			if(bl){
				System.out.println("NA");
			}
		}
	}

}

Measured memory_bytes: 20904
n=int(input())
a=input()
b=input()
c=input()
ans=0

for i in range(n):
    cnt=0
    if a[i]!=b[i] and b[i]!=c[i] and c[i]!=a[i]:
        cnt+=2
    elif a[i]==b[i] and b[i]!=c[i] and c[i]!=a[i]:
        cnt+=1
    elif a[i]!=b[i] and b[i]==c[i] and c[i]!=a[i]:
        cnt+=1
    elif a[i]!=b[i] and b[i]!=c[i] and c[i]==a[i]:
        cnt+=1
    ans+=cnt
print(ans)

Measured memory_bytes: 3064
using System;
using System.Linq;

namespace AtCoder.BC083
{
    public class B
    {
        public static void Main()
        {
            var nums = Console.ReadLine().Split(" ").Select(n => int.Parse(n)).ToArray();
            int sum = 0;

            for (int i = 1; i <= nums[0]; i++)
            {
                int d = DigitSum(i);
                if (nums[1] <= d && d <= nums[2]) sum += i;
            }

            Console.WriteLine(sum);
        }

        public static int DigitSum(int i)
        {
            int tmp = 0;

            while (i > 0)
            {
                tmp += i % 10;
                i /= 10;
            }

            return tmp;
        }
    }
}

Measured memory_bytes: 18872
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cmath> 
#include <cctype>

using namespace std;

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

    if ((s[2] == s[3]) && (s[4] == s[5])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

vector<int> graph[200000];
long long cnt[200000];
long long ans[200000];

void dfs(int cur, int parent, long long tmp_cnt) {
  ans[cur] = tmp_cnt + cnt[cur];
  for (int to: graph[cur]) {
    if (to == parent) {
      continue;
    }
    dfs(to, cur, ans[cur]);
  }
}
int main() {
  int n, q;
  cin>>n>>q;
  for (int i=0; i<n-1; i++) {
    int a, b;
    cin>>a>>b;
    --a; --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  for (int i=0; i<200000; i++) {
    cnt[i] = 0;
    ans[i] = 0;
  }
  for (int i=0; i<q; i++) {
    int p, x;
    cin>>p>>x;
    --p;
    cnt[p] += x;
  }
  dfs(0, -1, 0);
  cout<<ans[0];
  for (int i=1; i<n; i++) {
    cout<<" "<<ans[i];
  }
  cout<<endl;
}


Measured memory_bytes: 25856
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;
#define lowbit(x) ((x)&(-x))
#define pi acos(-1.0)
#define eps 1e-8
#define LL long long
#define INF 0x3f3f3f3f
inline int Scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
#define MOD 1000000007
#define MX 1005
//Code
int h,w,n;
int clo[MX*MX];
int mp[MX][MX];

int main()
{
    scanf("%d%d%d",&h,&w,&n);
    for (int i=1;i<=n;i++)
        clo[i]=Scan();
    int pos = 1;
    int c=1;
    for (int i=1;i<=h;i++)
    {
        while (1)
        {
            if (clo[c]==0) c++;
            mp[i][pos]=c;
            clo[c]--;

            if (i&1) pos++;
            else pos--;
            if (pos>w||pos<1) break;
        }
        if (pos==0) pos++;
        if (pos==w+1) pos--;
    }
    for (int i=1;i<=h;i++)
    {
        for (int j=1;j<w;j++)
            printf("%d ",mp[i][j]);
        printf("%d\n",mp[i][w]);
    }
    return 0;
}


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

int main(void)
{
    int n, k; cin >> n >> k;
    int d, a;
    vector<int> cnt(n, 0);

    for (int i = 0; i < k; i++)
    {
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            cin >> a;
            cnt[a-1]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (cnt[i] == 0) ans++;
    }
    cout << ans << endl;    
}

Measured memory_bytes: 3632
//Grid Repainting 2

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) int n;cin>>n;vector<int>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18
vector<string> pictureframe(vector<string> md,char fm){
    int w=md[0].size();
    int h=md.size();
    string s(w+2,fm);
    vector<string>picfm(h+2,s);
    rep(i,1,h+1)rep(j,1,w+1)picfm[i][j]=md[i-1][j-1];
    return picfm;
}

int main (){
    int h,w;cin>>h>>w;
    vector<string>s(h);
    rep(i,0,h)cin>>s[i];
    s=pictureframe(s,'.');
    bool flag = true;
    rep(i,1,h+1){
        rep(j,1,w+1){
            if(s[i][j]=='#'){
                if(s[i+1][j]!='#'&&s[i-1][j]!='#'&&s[i][j+1]!='#'&&s[i][j-1]!='#'){
                    flag=false;
                }
            }
        }
    }
    cout<<(flag?"Yes":"No")<<nnn;
    return 0;
}

Measured memory_bytes: 256