akhauriyash/Code-Regression huggingface dataset:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## const ##
MOD=10**9+7
## libs ##
import itertools as it
import functools as ft
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
    n = II()
    aa = MII()
    aa.sort()
    bb = []
    for i in range(n%2+1,n,2):
        bb += [i, i]
    if n%2==1:
        bb = [0] + bb
    if aa != bb:
        print(0)
        return None
    print((2**(n//2))%MOD)


if __name__ == '__main__':
    main()

Measured memory_bytes: 14424
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,d,cnt,x,y,i;
	long long d2,z;
	scanf("%d %d",&n,&d);
	cnt=0;
	d2=(long long)d*d;
	for(i=0;i<n;i++)	{
		scanf("%d %d",&x,&y);
		z=(long long)x*x+(long long)y*y;
		if(d2>=z)	cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 1732
while True:
	L = int(raw_input())
	if L == 0: break
	M = [map(int, raw_input().split()) for i in range(12)]
	for i in range(12):
		L -= M[i][0] - M[i][1]
		if L <= 0:
			print i+1
			break
	else:
		print "NA"

Measured memory_bytes: 4208
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n,c,k;
  cin >> n >> c >> k;
  
  vector<int> t(n);
  rep(i,n) cin >> t[i];
  sort( t.begin(), t.end() );
  
  int cnt = 0;
  int num = 0, t_max = -1;
  rep(i,n){
    if(t[i] > t_max || num == c){
      cnt++; 
      num = 1; t_max = t[i] + k;
    }else{
      num++;
    }
  }
  
  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 1152
n = 10**5
e = [True]*(n+1)
e[0] = False
e[1] = False
for i in range(2, int(n**0.5)+1):
    if not e[i]:
        continue
    for j in range(i*2, n+1, i):
        e[j] = False

c = [0]*(n+2)
for i in range(3, n+1, 2):
    if e[i] and e[(i+1)//2]:
        c[i] += 1

for i in range(3, n+1):
    c[i] += c[i-1]

q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(c[r]-c[l-1])


Measured memory_bytes: 7156
c=[list(map(int,input().split())) for i in range(3)]

sa_a=[c[0][0]-c[1][0], c[1][0]-c[2][0]]
sa_b=[c[0][0]-c[0][1], c[0][1]-c[0][2]]
for i in range(2):
    if sa_a[i]!=c[i][i+1]-c[i+1][i+1]:
        print("No")
        quit()
for i in range(2):
    if sa_b[i]!=c[i+1][i]-c[i+1][i+1]:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 38256
import java.util.*;
public class Main {
 public static void main (String [] args) {
  Scanner it = new Scanner (System.in); 
   int a = it.nextInt();
   if (a == 1) {
    System.out.println("0");
   }
   else if (a == 0){
    System.out.println("1"); 
   }
 }
  
}

Measured memory_bytes: 35696
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll H, W;
  cin >> H >> W;
  string s;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> s;
      if (s == "snuke") {
        cout << ((char)('A' + j)) << i + 1 << endl;
        return 0;
      }
    }
  }
  return 0;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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 int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, m; cin >> n >> m;
    vector<int> dist(n, INF);
    vector<vector<int>> graph(n);

    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    queue<int> que;
    que.push(0);
    dist[0] = 0;

    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(auto nv: graph[v]){
            if(dist[nv] != INF) continue;
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }

    if(dist[n-1] == 2) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    
    return 0;
}


Measured memory_bytes: 13168
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var X = cin.ReadLong;
            var Y = cin.ReadLong;
            if(Abs(X - Y) <= 1)
            {
                WriteLine("Brown");
            }
            else
            {
                WriteLine("Alice");
            }
        }



        public long C(int X, int Y)
        {

            if (Y == 0 || Y == X)
            {
                return 1;
            }
            if (X < Y)
            {
                return 0;
            }
            var Pascal = new long[X + 1, X + 1];
            for (int i = 0; i <= X; i++)
            {
                Pascal[i, 0] = 1L;
                Pascal[i, i] = 1L;
            }
            for (int i = 2; i <= X; i++)
            {
                for (int j = 1; j < i; j++)
                {
                    Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
                }
            }
            return Pascal[X, Y];
        }

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

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


int main() {
    int x;
    cin >> x;
    if(x>=30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
int main(){
    int a,b,i,ok=1;
    cin >> a >> b;
    string s;
    cin >> s;
    for(i=0;i<a+b+1;i++){
        if(i==a){
            if(s.at(i)!='-')ok=0;
        }else{
            if(s.at(i)<'0'||s.at(i)>'9')ok=0;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

const int mxN=1e5+1;

void solve(){
    int n,x,m,f=INT_MIN,curr;
    cin>>n>>x>>m;
    int pr=x;
    int ans=x;
    int res;
    map<int,int>mp;
    mp[x]=1;
    for(int i=2;i<=n;i++){
        res=(pr%m*pr%m)%m;
        if(mp[res]){
           int pr_pos=mp[res];
           int len=i-mp[res];
           int rem=n-(i-1);
           int c=rem/len;
           vector<int>cy,pre;
           for(int j=pr_pos;j<i;j++){
               int v=res;
               cy.push_back(v);
               res=(res*res)%m;
           }
           int pp=0;
           for(int j=0;j<cy.size();j++){
               pp+=cy[j];
               pre.push_back(pp);
           }
           ans+=c*pre[len-1];
           int rr=rem%len;
           if(rr){
               ans+=pre[rr-1];
           }
           break;
        }
        if(res==0){
            f=0;
            break;
        }
        if(res==1){
            f=1;
            curr=i;
            break;
        }
        ans+=res;
        pr=res;
        mp[res]=i;
    }
    if(f==1){
        ans+=n-curr+1;
        cout<<ans<<endl;
    }
    else
        cout<<ans<<endl;
}

signed main(){
    int t;
//    cin>>t;
//    while(t--){
        solve();
//    }
}

Measured memory_bytes: 7300
s = '0'
s += input()


def isPara(string, l, r):
    while l <= r:
        if s[l] != s[r]:
            return False
        l += 1
        r -= 1
    return True


def solve():
    N = len(s)-1
    if s[N] == '1' or s[1] == '0':
        print(-1)
        return
    if isPara(s, 1, N-1) == False:
        print(-1)
        return
    root = 1
    for i in range(2, N+1):
        print(str(root) + ' ' + str(i))
        if s[i-1] == '1':
            root = i


solve()


Measured memory_bytes: 4432
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  ll ans = 0;
  REP1(i, n - 1) {
    ans += max(0LL, a[i - 1] - a[i]);
    a[i] = max(a[i - 1], a[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4820
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int x[50];
ll dp[51][51][2501];
int main() {
  int n, a;
  cin >> n >> a;
  reps(i,n)
    cin >> x[i];
  dp[0][0][0] =1;
  reps(i,n)
    rep(j,i+1)
      rep(k,n*a+1){
        if(i > 0 && k < x[i]){
          dp[i][j][k] = dp[i-1][j][k];
	} else if(i > 0 && j > 0 && k >= x[i]){
          dp[i][j][k] = dp[i-1][j][k]+dp[i-1][j-1][k - x[i]];
        }else{
          dp[i][j][k] = 0;
        }
      }
  ll ans = 0;
  reps(j,n)
	if(dp[n][j][j*a]) ans+=dp[n][j][j*a];
  cout << ans << endl;
  return 0;
}


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

int main () {
    int N;
    cin >> N;
    int cnt=0;
    for (int i=N; i>=1; i/=10) {
        cnt+=i%10;
    }
    if (N%cnt==0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
        
    


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))
#define clr(x) memset(x, 0, sizeof(x))
#define pb push_back
#define eb emplace_back

template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (b < a)
	{
		a = b;
		return 1;
	}
	return 0;
}

using ll = long long;
using namespace std;

int main()
{
	ll N, K;
	cin >> N >> K;

	int i = 1;
	while (pow(K, i) <= N)
	{
		++i;
	}

	cout << i << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e13;
int main() {
    ll n, i, j, k, cnt = 0;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n + 1, 0), ret(n + 1, 0);
    for(i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(i = n - 1; i >= 0; i--) {
        if(a[i] != b[i + 1] % 2) {
            for(j = 1; j * j <= i + 1; j++) {
                if((i + 1) % j == 0) {
                    b[j]++;
                    if(j!=(i+1)/j)b[(i + 1) / j]++;
                }
            }
            ret[i + 1]++;
            cnt++;
        }
    }
    bool ch = false;
    for(i = 1; i <= n; i++) {
        if(b[i] % 2 != a[i - 1]) ch = true;
    }
    if(ch) {
        cout << -1 << endl;
    } else {
        cout << cnt << endl;
        for(i = 0; i <= n; i++) {
            if(ret[i] == 1) {
                cout << i << " ";
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define pb push_back
#define vii vector<int>
#define task "dddd"
#define pll pair<ll, ll>
#define pii pair< ll, pair< ll, ll > >
#define fi first
#define se second

using ll = long long;
using ld = long double;
using ull = unsigned long long;
const ll mod = 1e9 + 7;
using namespace std;
const int N = 2002;
const int M = 1e6;
ll tong, m, n, k, t, T, ntest, ans, a[M], dp[N][N], b[M], c[M];

struct dang
{
    ll id;
    vector<int> vc;
};
string s;
vector<ll> adj[N], adt[N];
vector<ll> pre;
list<pll> ds;

inline void sol()
{
    cin >> n;
    a[0] = 1;
    for(int i = 3; i <= n; i ++)
    {
        for(int j = 3; j <= i; j ++)a[i] = (a[i] + a[i-j]) % mod;
    }
    cout << a[n];
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".inp", "r"))
    {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    sol();
}



Measured memory_bytes: 3760
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,j,k,N,cnt,ans=1;
  cin>>N;
  vec v(3,0);
  rep(i,N){
    cin>>k;
    cnt=0;
    rep(j,3){
      if(v[j]==k){
        cnt++;
        if(cnt==1)v[j]++;
      }
    }
    ans=ans*cnt%mod;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    char s[10];
    scanf("%s", s);
    int a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
    for(int i = 0; i < 2; ++i) {
        for(int j = 0; j < 2; ++j) {
            for(int k = 0; k < 2; ++k) {
                int temp = a;
                if(i == 0) temp -= b;
                else temp += b;
                if(j == 0) temp -= c;
                else temp += c;
                if(k == 0) temp -= d;
                else temp += d;
                if(temp == 7) {
                    printf("%d%c%d%c%d%c%d=7\n", a, (i == 0 ? '-' : '+'), b, (j == 0 ? '-' : '+'), c, (k == 0 ? '-' : '+'), d);
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 256
# 解法　XORの性質が大事になる．XORを同じものに２回繰り返すと000000になり次の数はそのままになる.
# a ^ b ^ b

N = int(input())
A = list(map(int,input().split()))

xor_all = 0
for a in A:
    xor_all = xor_all ^ a

X=[]
for a in A:
    X.append(str(xor_all^a))

print(' '.join(X))


Measured memory_bytes: 35556
N = int(input())
a = list(map(int, input().split()))
frag = 0
ans = 0
while True:
    for i in range(N):
        if a[i] % 2 == 1:
            frag = 1
            break
    if frag == 0:
        for i in range(N):
            a[i] /= 2
        ans += 1
    else:
        break
print(ans)


Measured memory_bytes: 9240
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str1 = br.readLine();
        String str2 = br.readLine();
 
        Loop:{
            for (int i = 0; i < str1.length(); i++) {
                StringBuilder sb = new StringBuilder(str2.length());
                for (int j = 0; j < str2.length(); j++) {
                    sb.append(str1.charAt((i + j) % str1.length()));
                }
                if (sb.toString().equals(str2)) {
                    System.out.println("Yes");
                    break Loop;
                }
            }
            System.out.println("No");
        }
    }
}

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

void shuffle(vector<int>& stock);
void cut(int k, vector<int>& stock);
int main() {
  int n, m, k;
  cin >> n;
  cin >> m;
  int size = 2 * n;
  vector<int> stock;
  for (int i = 0; i < size; i++) stock.push_back(i + 1);
  for (int i = 0; i < m; i++) {
    cin >> k;
    if (k == 0) shuffle(stock);
    else cut(k, stock);
  }
  for (int i = 0; i < size; i++) cout << stock[i] << endl;
  return 0;
}
void shuffle(vector<int>& stock) {
  int size = stock.size();
  vector<int> res;
  for (int i = 0; i < size / 2; i++) {
    res.push_back(stock[i]);
    res.push_back(stock[i + size / 2]);
  }
  for (int i = 0; i < size; i++) stock[i] = res[i];
}
void cut(int k, vector<int>& stock) {
  int size = stock.size();
  vector<int> res;
  for (int i = k; i < size; i++) res.push_back(stock[i]);
  for (int i = 0; i < k; i++) res.push_back(stock[i]);
  for (int i = 0; i < size; i++) stock[i] = res[i];
}

Measured memory_bytes: 3072
def main(board)
  board.each_with_index do |line, idxi|
    line.each_with_index do |box, idxj|
      next if box == '.'

      paintable = false
      pairs = [
        [idxi - 1, idxj],
        [idxi + 1, idxj],
        [idxi, idxj - 1],
        [idxi, idxj + 1]
      ]
      pairs.each do |i, j|
        next if i < 0 || j < 0
        break paintable = true if board.fetch(i, []).fetch(j, "") == '#'
      end
      return false unless paintable
    end
  end

  true
end

h, _ = gets.split(' ').map(&:to_i)
s = []
h.times do
  s.push gets.chomp.split('')
end
puts main(s) ? "Yes" : "No"

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
  ll n;cin>>n;
  vector<ll>a(n);
  vector<ll>b(n);
    for (int i = 0; i <n; ++i) {
        cin>>a[i]>>b[i];
    }
    reverse(all(a));
    reverse(all(b));
    ll ans=0;
    ll now=0;
    for (int i = 0; i < n; ++i) {
        a[i]+=now;
        a[i]%=b[i];
        if(a[i]!=0){
            ans+=b[i]-a[i];
            now+=b[i]-a[i];
        }
    }
    cout <<ans<<endl;
  return 0;
}



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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

string s[3];

signed main(){
    rep(i,0,3)cin>>s[i];
    cout<<"A"<<s[1][0]<<"C"<<endl;
    
    
    
    
    
    
    
    
    
    
    return 0;
}

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

typedef long long ll;
const ll INF = 1LL << 60;
 
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define Rep(i,n,m) for(int i = (int)(n); i < (int)(m);i++)
#define rrep(i,n) for(int i = (int)(n - 1); i > -1;i--)
#define RRep(i,n,m) for(int i = (int)(n - 1); i > (int)(m);i--)
#define trav(a, x) for(auto& a : x)
 
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))
#define REVERSE(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REVERSE(V)
 
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define yes(n) cout << ((n) ? "yes" : "no") << endl;

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

int main()
{
    int N;
    cin >> N;
    ll dp[100001];
    ll list[100001];
    rep(i,N)
    {
        dp[i] = INF;
        cin >> list[i];
    }
    dp[0] = 0;
    rep(i,N)
    {
        chmin(dp[i], dp[i - 1] + abs(list[i] - list[i - 1]));
        if(i>1)
        {
            chmin(dp[i], dp[i - 2] + abs(list[i] - list[i - 2]));
        }
    }
    cout << dp[N - 1] << endl;
}

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

typedef long long int ll;

int main(){
    int n;
    scanf("%d",&n);
    int arr[n];
    for(int i=0;i<n;i++) scanf("%d",&arr[i]);
    int sum[n];
    sum[0]=arr[0];
    for(int i=1;i<n;i++) sum[i]=arr[i]+sum[i-1];
    int ans = INT_MAX;
    for(int i=0;i<n-1;i++){
        int s1=sum[i];
        int s2 = sum[n-1]-sum[i];
        ans = min(ans,abs(s1-s2));
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict

def f(s):
    d = defaultdict(int)
    for c in s:
        d[c] += 1
    return d

def g(d1, d2):
    new_d = {}
    ks = set(d1.keys()).intersection(set(d2.keys()))
    for k in ks:
        new_d[k] = min(d1[k], d2[k])
    return new_d

sys.stdin.readline()
d2 = None
for line in sys.stdin.readlines():
    d = f(line.strip())
    if d2 is None:
        d2 = d
    else:
        d2 = g(d, d2)
for c in sorted(d2.keys()):
    print(c * d2[c], end='')
print()


Measured memory_bytes: 3444
import java.util.*;

class Main {
	static int N;
	static char[] s;
	static int[] sum;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		sum = new int[N];
		s = sc.next().toCharArray();
		for (int i = 0; i < N; ++i) {
			if (s[i] == 'o') {
				sum[i] = 0;
			} else {
				sum[i] = 1;
			}
		}
		for (int i = 0; i < 2; ++i) {
			for (int j = 0; j < 2; ++j) {
				int[] arr = new int[N];
				arr[0] = i;
				arr[1] = j;
				for (int k = 2; k < N; ++k) {
					arr[k] = (sum[k - 1] - arr[k - 1] - arr[k - 2] + 2) % 2;
				}
				if (sum[0] == (arr[0] + arr[1] + arr[N - 1]) % 2
						&& sum[N - 1] == (arr[N - 1] + arr[N - 2] + arr[0]) % 2) {
					for (int k = 0; k < N; ++k) {
						System.out.print(arr[k] == 0 ? 'S' : 'W');
					}
					System.out.println();
					return;
				}
			}
		}
		System.out.println(-1);
		return;
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 36336
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C ++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()

//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 998244353
#define INF 0x3f3f3f3f
#define MAXN (int)(20)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
//DEBUG
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
ll dp[1<<MAXN];
vll pre;
ll a[MAXN][MAXN];
void solve(int i,vi &not_cons,int mask,ll score,int curr_grp)
{
	if(i==not_cons.size())
	{
		dp[mask]=max(dp[mask],score+pre[curr_grp]);
		return;
	}
	int curr_bit=(1<<not_cons[i]);
	solve(i+1,not_cons,mask,score,curr_grp);
	solve(i+1,not_cons,mask^(curr_bit),score,curr_grp^(curr_bit));
}
//dp[mask]-max score if we have grouped rabbits in mask 
//this can be obtained from considering masks st
//some of bits of mask are turned off dp[mask'] and we group the remaining bits
//since mask' is less than mask we would have its answer 
int main()
{
	fastio;
	int n;cin>>n;
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<n;++j)
		{
			cin>>a[i][j];
		}
	}
	pre.resize(1<<n);
	//O(2^n * n^2)
	for(int i=0;i<(1<<n);++i)//i is the mask
	{
		for(int j=0;j<n;++j)
		{	
			if(i&(1<<j))
			for(int k=j+1;k<n;++k)
			{
				if((i&(1<<k)))
					pre[i]+=a[j][k];
			}
		}
	}
	dp[0]=0;
	vi not_cons;
	//O(2^n*n + 3^n)
	for(int mask=0;mask<(1<<n);++mask)
	{
		not_cons.clear();
		for(int i=0;i<n;i++)
		{
			if(!(mask & (1<<i)))
				not_cons.pb(i);
		}
		solve(0,not_cons,mask,dp[mask],0);
	}
	cout<<dp[(1<<n)-1]<<endl;


}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
using namespace std;
using ll=long long;
using R=double;

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

	int b[26] = {1000};
	int count = 0;

	for(int i = 0; i < 26; i++){
		for(int j = 0; j < s.length(); j++){
			if(s[j] == i + 'a'){
				if(b[i] == 1000){
					b[i] = count;
				}else if(b[i] < count){
					b[i] = count;
				}
				count = 0;
			}else if(j == s.length()-1 and b[i] != 1000){
				if(b[i] < count+1){
					b[i] = count+1;
				}
				count = 0;
				continue;
			}else{
				count++;
			}
		}
		//printf("b[%d] : %d\n", i, b[i]);
	}

	sort(b,b+26);

	cout << b[0] << endl;
	return 0;

}


Measured memory_bytes: 256
# input here
_INPUT = """\
4 5
1 2
2 5
#.###
####.
#..##
#..##
"""

def main():
    H, W = map(int, input().split())
    c = tuple(map(int, input().split()))
    d = tuple(map(int, input().split()))
    d_y = d[0]-1
    d_x = d[1]-1
    s = [list(input()) for i in range(H)]

    visited = [[-1]*W for j in range(H)]
    visited[c[0]-1][c[1]-1] = 0

    main_q = deque()
    main_q.append((c[0]-1,c[1]-1))
    magic_q = deque()
    direction = [(0,1),(1,0),(-1,0),(0,-1)]

    #魔法使わないbfs
    while main_q:
        y, x = main_q.popleft()
        magic_q.append((y,x))

        for i in range(4):
            moved_y = y + direction[i][0]
            moved_x = x + direction[i][1]

            if moved_y < 0 or H -1 < moved_y or moved_x < 0 or W -1 < moved_x:
                continue
            if s[moved_y][moved_x] == '#':
                continue
            if s[moved_y][moved_x] == '.' and visited[moved_y][moved_x] == -1:
                main_q.append((moved_y, moved_x))
                visited[moved_y][moved_x] = visited[y][x]

        if not main_q:
            while magic_q:
                y, x = magic_q.popleft()

                for k in range(-2,3):
                    for l in range(-2,3):
                        moved_y = y + k
                        moved_x = x + l

                        if moved_y < 0 or H -1 < moved_y or moved_x < 0 or W -1 < moved_x:
                            continue
                        if s[moved_y][moved_x] == '#':
                            continue
                        if s[moved_y][moved_x] == '.' and visited[moved_y][moved_x] == -1:
                            main_q.append((moved_y, moved_x))
                            visited[moved_y][moved_x] = visited[y][x] + 1
    print(visited[d_y][d_x])


if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools
    from collections import deque

    # sys.stdin = io.StringIO(_INPUT)
    main()



Measured memory_bytes: 135864
n, m, q = map(int, input().split())
lr = []
for _ in range(m):
    l, r = map(int, input().split())
    lr.append((l, r))
query = []
for _ in range(q):
    p, q = map(int, input().split())
    query.append((p, q))
accu = [[0]*(n+1) for _ in range(n+1)]
for l, r in lr:
    accu[l][r] += 1
for i in range(n):
    for j in range(n):
        accu[i+1][j+1] += accu[i+1][j]
for j in range(n):
    for i in range(n):
        accu[i+1][j+1] += accu[i][j+1]
ans = []
for p, q in query:
    ans.append(accu[q][q]-accu[q][p-1]-accu[p-1][q]+accu[p-1][p-1])
print(*ans, sep='\n')

Measured memory_bytes: 109884
//TINY_OUNCE911666
// You are not prepared!

#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

const int N = 5e5 + 7;

ll n, sum;
bool used[N];
ll cnt[N];

int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n; vector<ll> a(n);
	
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	
	for (int i = 0; i < n; ++i) {
		if (used[a[i]]) continue;
		//cout << cnt[a[i]] << ' ';
		sum += (cnt[a[i]] * (cnt[a[i]]-1)) / 2;
		used[a[i]] = true;
	}
	//cout << sum;
	
	for (int i = 0; i < n; ++i) {
		sum -= (cnt[a[i]] * (cnt[a[i]]-1)) / 2;
		cnt[a[i]]--;
		
		if (cnt[a[i]] - 1 < 0) {
			cout << sum << "\n";
			cnt[a[i]]++;
			sum += (cnt[a[i]] * (cnt[a[i]]-1)) / 2;
			continue;
		}
		
		//cout << cnt[a[i]] << ' ';
		sum += (cnt[a[i]] * (cnt[a[i] ]-1)) / 2;
		
		cout << sum << "\n";
		
		sum -= (cnt[a[i]] * (cnt[a[i]]-1)) / 2;
		
		cnt[a[i]]++;
		sum += (cnt[a[i]] * (cnt[a[i]]-1)) / 2;
	}
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define all(x) (x).begin(), (x).end()
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

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

  ll n, k;
  cin >> n >> k;
  vector<ll> p(n), c(n);
  for (int i = 0; i < n; i++) {
    //cin >> p[i];
    ll pt;
    cin >> pt;
    p[i] = pt-1;
  }
  for (int i = 0; i < n; i++) cin >> c[i];

  vector<ll> looppoint(n), looplen(n);
  vector<bool> isdone(n, false);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) isdone[j] = false;
    ll place = i;
    while (!isdone[place]) {
      isdone[place] = true;
      place = p[place];
      looppoint[i] += c[place];
      looplen[i]++;
    }
  }

  /*
  for (int i = 0; i < n; i++) cout << looppoint[i] << " ";
  cout << endl;
  for (int i = 0; i < n; i++) cout << looplen[i] << " ";
  cout << endl;
  */

  ll ans = -1000000000000000001;
  for (int i = 0; i < n; i++) {
    ll temp = 0, anstemp = -1000000000000000001;
    if (looppoint[i] > 0) {
      if (k < looplen[i]) {
        ll place = i;
        temp = 0;
        for(int j = 0; j < k; j++) {
          place = p[place];
          temp += c[place];
          anstemp = max(anstemp, temp);
        }
      }
      else {
        temp = ((k / looplen[i]) - 1) * looppoint[i];
        ll place = i;
        for (int j = 0; j < (looplen[i] + (k % looplen[i])); j++) {
          place = p[place];
          temp += c[place];
          anstemp = max(anstemp, temp);
        }
      }
    }
    else {
      ll place = i;
      temp = 0;
      for (int j = 0; j < looplen[i]; j++) {
        place = p[place];
        temp += c[place];
        anstemp = max(anstemp, temp);
      }
    }
    ans = max(ans, anstemp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3800
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val n = sc.nextInt()
    val m = sc.nextInt()

    val a = mutableListOf<Int>()
    (0 until m).forEach {
        a.add(sc.nextInt())
    }

    if (n >= a.sum()) {
        println(n - a.sum())
    } else {
        println(-1)
    }
}

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


def main():
    X, Y = [int(x) for x in input().split()]
    ans = 0
    if X == 3:
        ans += 100000
    if X == 2:
        ans += 200000
    if X == 1:
        ans += 300000
    if Y == 3:
        ans += 100000
    if Y == 2:
        ans += 200000
    if Y == 1:
        ans += 300000
    if X == 1 and Y == 1:
        ans += 400000
    
    print(ans)

    



if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
import sys
A1=map(int, sys.stdin.readline().split())
A2=map(int, sys.stdin.readline().split())
A3=map(int, sys.stdin.readline().split())
A=A1+A2+A3
N=input()

def isbingo():
    if A[0]==A[1]==A[2]==0: return True
    elif A[3]==A[4]==A[5]==0: return True
    elif A[6]==A[7]==A[8]==0: return True
    elif A[0]==A[3]==A[6]==0: return True
    elif A[1]==A[4]==A[7]==0: return True
    elif A[2]==A[5]==A[8]==0: return True
    elif A[0]==A[4]==A[8]==0: return True
    elif A[2]==A[4]==A[6]==0: return True
    else: return False

for _ in range(N):
    b=int(sys.stdin.readline().strip())
    for i,a in enumerate(A):
        if b==a:
            A[i]=0

if isbingo():
    print "Yes"
else:
    print "No"

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

using namespace std;

int main()
{
    long long int n,d,i,mini,j,coun;
    cin>>n>>d;
    long long int A[n],dp[n];
    for(i=0;i<n;i++)
    {
        cin>>A[i];
    }
    dp[0]=0;
    dp[1]=abs(A[1]-A[0]);

    for(i=2;i<n;i++)
    {coun=0;
     mini=dp[i-1]+abs(A[i]-A[i-1]);
        for(j=i-1;j>=0&&coun!=d;j--)
        {coun++;
            if(dp[j]+abs(A[i]-A[j])<mini)
            {
                mini=dp[j]+abs(A[i]-A[j]);
                dp[i]=mini;
            }
            else
                dp[i]=mini;
        }
    }
    cout<<dp[n-1];

    return(0);
}


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

#define rep(i, n) for(int i=0; i<n; i++)
#define INF 2000000001

int V, E;
int d[100][100];//d[i][j]:=i??????j????????????????????¢

void warshall(){
  rep(k, V) rep(i, V) rep(j, V)
    if(d[i][k]!=INF && d[k][j]!=INF)d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
}

int main(){
  cin>>V>>E;
  rep(i, V)rep(j, V)
    if(i==j)d[i][j]=0;
    else d[i][j]=INF;
  rep(i, E){
    int s, t, cost;
    cin>>s>>t>>cost;
    d[s][t]=cost;
  }

  warshall();

  bool NC=false;
  rep(i, V)if(d[i][i]<0)NC=true;
  if(NC)cout<<"NEGATIVE CYCLE"<<endl;
  else{
    rep(i, V)rep(j, V){
      if(d[i][j]==INF)cout<<"INF";
      else cout<<d[i][j];
      if(j<V-1)cout<<" ";
      else cout<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1200
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//符号反転
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(ll n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
     mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
mint dp[3005][3005];
int main(){
int n;
cin>>n;
string s;
cin>>s;
for(int i=0;i<n;i++)dp[0][i]=1;
for(int i=1;i<n;i++){
    for(int j=1;j<n;j++)dp[i-1][j]+=dp[i-1][j-1];
    if(s[i-1]=='<'){
        for(int j=0;j<n-i;j++)dp[i][j]+=dp[i-1][n-i]-dp[i-1][j];
    }else{
        for(int j=0;j<n-i;j++)dp[i][j]+=dp[i-1][j];
    }
}
cout<<dp[n-1][0]<<"\n";
}

Measured memory_bytes: 70784
S = input()
U = int(S[0:2])
L = int(S[2:4])
if 0<U<=12 and 0<L<=12:
  print("AMBIGUOUS")
elif 0<U<=12:
  print("MMYY")
elif 0<L<=12:
  print("YYMM")
else:
  print("NA")

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

typedef vector<int> vi;
typedef bitset<16> MASK;
#define ll long long
#define PI 3.14159265359
//#define x first
//#define y second
#define point pair<double,double>
#define clr(x, val)	memset((x), (val), sizeof(x))

//you don't know math, unless you can do math!
int main(){
    //freopen("output.txt" , "w" , stdout) ;

    cin.tie(0);
    cin.sync_with_stdio(0);

    int n; cin>>n;
    int ac = 0, wa = 0, tle = 0, re = 0;
    for(int i = 0; i < n; i++){
        string ver;
        cin>>ver;

        ac += (ver == "AC");
        wa += (ver == "WA");
        tle += (ver == "TLE");
        re += (ver == "RE");
    }

    cout<<"AC x "<<ac<<'\n';
    cout<<"WA x "<<wa<<'\n';
     cout<<"TLE x "<<tle<<'\n';
      cout<<"RE x "<<re<<'\n';
}


Measured memory_bytes: 3616
#include <iostream>
#include <math.h>
#include <string>
#include <string.h> 
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s<t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

string s;

void solve(){
    cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

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

Measured memory_bytes: 3648
def main():
    mod = 1e9 + 7
    n, k = list(map(int, input().split()))
    ans = 0
    for i in range(k, n + 2):
        ans += ((n + (n - i + 1)) * i // 2) - ((0 + (i - 1)) * i // 2) + 1
        ans = int(ans % mod)
    print(ans)
    return


if __name__ == "__main__":
    main()


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

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

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	if (2 * k - 1 <= n)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		String[] cut = input.split(" ");
		int a = Integer.parseInt(cut[0]);
		int b = Integer.parseInt(cut[1]);
		int c = Integer.parseInt(cut[2]);
		if (a<b && b<c) {
			System.out.println("Yes");
		} else{
			System.out.println("No");
			
		}

	}
}

Measured memory_bytes: 24220
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		int sum, count = 0;
		int n, x;
		boolean flg = true;
		
		while(true) {
			n = scan.nextInt();
			x = scan.nextInt();
			
			if(n == 0 && x == 0)break;
			
			count = 0;
			
			for(int i = 1; i <= n; i++) {
				sum = i;
				for(int j = 1 + i; j <= n; j++) {
					sum = i;
					if( j != i) {
						sum += j;
						flg = true;
					}else {
						flg = false;
					}
					for(int k = 1 + j; k <= n; k++) {
						if( flg == true) {
							sum = i + j;
							if( i != j && i != k && j != k) {
								sum += k;
								
								if( x == sum) {
									count++;
								}
							}
						}
						
						
					}
				}
			}
			
			System.out.println(count);
			
		}
		
	}
}


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

int main() {
  int N;
  cin >> N;
  int M =0;
  for(int i=0; i<N; i++){
    int l;
    int r;
    cin>>l>>r;
    int X = r-l+1;
    M = M + X;
  }
  cout<<M<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {    
    
    static int MOD = (int) (Math.pow(10,9) + 7);
    
    public static void main(String[] args){

       Scanner sc = new Scanner(System.in);
       
       int N = sc.nextInt();
       int M = sc.nextInt();
       
       if(N > M + 1 || M > N + 1){
           System.out.println(0);
       }else if(N == M + 1 || M == N + 1){
           System.out.println(((Fact(M,MOD)%MOD)*(Fact(N,MOD)%MOD))%MOD);
       }else if(N == M){
           System.out.println((long)((2*(Fact(M,MOD)%MOD)*(Fact(N,MOD)%MOD))%MOD));
       }
              
    }  
    
    static long Fact(int n,int mod){
        long fact = 1;        
        for(int i = 1;i <= n;i++){
            fact *= i;
            fact %= MOD;
        }        
        return fact;
    }
    
}        
        
        

Measured memory_bytes: 21844