akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repe(i, n) for(int i = 0; i <= (n); i++)
#define fo(i, a, b) for(int i = (a); i < (b); i++)
#define foe(i, a, b) for(int i = (a); i <= (b); i++)
#define NL << endl

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;

int main() {
	int t, n;

	cin >> n >> t;

	vector<int> c;
	rep(i, n) {
		int cc, tt;
		cin >> cc >> tt;
		if (tt <= t) c.push_back(cc);
	}
	sort(c.begin(), c.end());

	if (c.size() == 0) cout << "TLE" NL;
	else cout << c[0] NL;

	return 0;

}



Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10


def main():
	N = INT()
	S = input()

	s1 = []
	dic_s2 = defaultdict(int)

	for x in product([0, 1], repeat=N):
		s1_red = ""
		s1_blue = ""
		s2_red = ""
		s2_blue = ""
		for i in range(N):
			if x[i]:
				s1_red += S[i]
				s2_red += S[N+i]
			else:
				s1_blue += S[i]
				s2_blue += S[N+i]

		s1.append((s1_red, s1_blue))
		dic_s2[(s2_blue[::-1], s2_red[::-1])] += 1

	ans = 0
	for x in s1:
		ans += dic_s2[x]

	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 142908
import java.util.*;

class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		
		char[] ary = new char[str.length()];
		for(int i = 0; i < str.length(); ++i) {
		    ary[i] = str.charAt(i);
		}
		
		Arrays.sort(ary);
		
		boolean flag =false;
		
		for(int i = 0; i < str.length() - 1; ++i) {
		    if(ary[i] == ary[i+1]) {
		        flag = false;
		        break;
		    }
		    else {
		        flag = true;
		        continue;
		    }
		}
		
		if(flag) System.out.println("yes");
		else System.out.println("no");
		
	}
}

Measured memory_bytes: 21972
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    int a[30][30]={{0}};
    char str;
    int cnt=0,m;
    int ans=0;
    int x,y,z;
    while(scanf("%d%c%d%c%d",&x,&str,&y,&str,&z)!=EOF){
        x+=10,y+=10;
        if(z==1){
            a[x][y]++;
            a[x+1][y]++;
            a[x-1][y]++;
            a[x][y+1]++;
            a[x][y-1]++;
 
        }
        else if(z==2){
            a[x][y]++;
            a[x+1][y+1]++;
            a[x+1][y-1]++;
            a[x+1][y]++;
            a[x-1][y+1]++;
            a[x-1][y-1]++;
            a[x-1][y]++;
            a[x][y+1]++;
            a[x][y-1]++;
 
 
        }
        else if(z==3){
            a[x+1][y]++;
            a[x+2][y]++;
            a[x][y+1]++;
            a[x][y+2]++;
            a[x-1][y]++;
            a[x-2][y]++;
            a[x][y-1]++;
            a[x][y-2]++;
            a[x+1][y+1]++;
            a[x-1][y-1]++;
            a[x+1][y-1]++;
            a[x-1][y+1]++;
            a[x][y]++;
 
 
 
 
        }
 
 
    }
    for(int i=10;i<20;i++){
            for(int j=10;j<20;j++){
                if(a[i][j]==0)cnt++;
                ans=max(ans,a[i][j]);
            }
        }
        cout<<cnt<<endl<<ans<<endl;
 
 
 
    return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORit(it,a) for(auto it=a.begin();it!=a.end();it++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<int>
#define vll vector<ll>
#define vec vector
#define pb push_back
#define pop pop_back
#define all(x) x.begin(),x.end()
#define testcases ll t;cin>>t;while(t--)
#define mem(a,k) memset(a,k,sizeof(a))
#define FF first
#define SS second
#define MP(x,y) make_pair(x,y)
#define rt return
#define br break
#define ct continue
#define elif else if
#define ii pair<ll,ll>
#define vecin(a,n,index) for(int i=index;i<n;i++)cin>>a[i]
#define vecout(a,n,index) for(int i=index;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define FASTio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod = 1000000007;
ll fact[2001] = {0};
ll power(ll a, ll b) {
	if (b < 0)rt 0;
	ll res = 1;
	while (b != 0) {
		if (b % 2) {res = (res % mod * a % mod) % mod; b--;}
		else {a = (a % mod * a % mod) % mod; b /= 2;}
	}
	rt res % mod;
}
void factorial() {
	fact[0] = 1; fact[1] = 1;
	FOR(i, 2, 2001)fact[i] = (i % mod * fact[i - 1] % mod) % mod;
}
ll modIN(ll n) {
	rt power(n, mod - 2) % mod;
}
ll C(ll n, ll r) {
	rt (fact[n] % mod * modIN((fact[r] % mod * fact[n - r] % mod) % mod) % mod) % mod;
}
void solve() {
	ll s;
	cin >> s;
	ll maxr = s / 3;
	ll ans = 0;
	FOR(r, 1, maxr + 1) {
		ans = (ans % mod + C(s - 2 * r - 1, r - 1) % mod) % mod;
	}

	cout << ans << endl;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	FASTio
	// START FROM HERE :)
	factorial();
	solve();
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define maxn 20
#define ll long long int 
using namespace std;

const int inf = 2000000020;

int n;
int v[maxn][2];

bool vis[1 << maxn][maxn];
int dp[1 << maxn][maxn];
int DP(int op, int last){
	if (op == ((1 << n) - 1)) return 0;
	if (vis[op][last]) return dp[op][last];
	vis[op][last] = 1;
	int& ans = dp[op][last];
	ans = inf;
	int now = 0, sum = 0;
	rep(i, 1, n) if (op & (1 << (i - 1))) sum++;
	per(i, n, 1){
		if (op & (1 << (i - 1))) {now++; continue;}
		if (v[i][((sum + 1) & 1) ^ (i & 1)] < v[last][(sum & 1) ^ (last & 1)]) continue;
		ans = min(ans, DP(op | (1 << (i - 1)), i) + now);
	} 
	return ans;
} 
int main(){
	
		//freopen("D.in", "r", stdin);
	
	cin >> n;
	rep(i, 1, n) cin >> v[i][0];
	rep(i, 1, n) cin >> v[i][1];
	
	int ans = DP(0, 0);
	if (ans == inf) printf("-1");
	else printf("%d", ans);
	return 0;
}

Measured memory_bytes: 28928
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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


void solve(long double A, long double B){
    ll b = B*100 + 0.5;
    ll ans = A * b;
    ans /= 100;
    cout << ans << endl;
}

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


Measured memory_bytes: 3840
def main():
    from builtins import int, str, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    a = str(input())
    if a.islower():
        print("a")
    else:
        print("A")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9064
#include <bits/stdc++.h> //ライブラリ全読み込み
using namespace std; //std:を省略できる

int main(){
    int x,h,m,s;
    cin >> x;
    h = x/3600;
    m = x%3600/60;
    s = x%60;
    cout << h <<":" << m <<":" << s << endl;
    return 0;
}


Measured memory_bytes: 3116
def read_input(trans=int):
    return list(map(trans, input().split()))


X, N = read_input()
if N == 0:
    print(X)
else:
    list_p = read_input()

    for i in range(100):
        if X-i in list_p:
            if X+i in list_p:
                continue
            else:
                print(X+i)
                break
        else:
            print(X-i)
            break


Measured memory_bytes: 9176
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        fozubaoyou    pass System Test!
        quoted from "https://codeforces.com/contest/472/submission/7996840"
*/
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void){

	string s;
	int k;
	cin>>s>>k;
	for(int i=0;i<s.size();i++){
		if(s[i]!='a'&&'z'-s[i]+1<=k){
			k-='z'-s[i]+1;
			s[i]='a';
		}
	}
	k%=26;
	s[s.size()-1]=(s[s.size()-1]-'a'+k)%26+'a';

	fin(s);


}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353 ;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;
   
   while(test--)
   solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

void solve(){
    string s;
    cin>>s;
    int cnt[2]={0};
    for(int i=0;i<3;i++)
    cnt[s[i]-'A']++;
    
    if(cnt[0]>0 and cnt[1]>0){
        cout<<"Yes";
    }    
    else{
        cout<<"No";
    }
}    


///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}





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

int main() {
  int n,a,b,c,d;
  cin>>n;
  
  a=n/1000;
  b=(n-a*1000)/100;
  c=(n-a*1000-b*100)/10;
  d=(n-a*1000-b*100-c*10);
  
  if((a==b&&b==c)||(b==c&&c==d)){
  	cout<<"Yes"<<endl;
  }else{
  	cout<<"No"<<endl;
  }
  
 }

Measured memory_bytes: 256
N=int(input())
H=list(map(int,input().split()))
x=int(0)
y=int(0)

for i in range(N):
    for j in range(i):
      if H[i]>=H[j]:
        y+=1
    if y>=i:
        x+=1
    y=int(0)

print(x)

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

typedef long long int ll;

using namespace std;

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

    int n;
    cin >> n;
    
    vector<int> d(n);
    for (int i = 0; i < n; ++i)
        cin >> d[i];
    
    sort(d.begin(), d.end());
    int mid = n / 2;
    
    cout << d[mid] - d[mid - 1] << "\n";

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

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

    string ans = "No";
    if(s == t){
        ans = "Yes";
    }else{
        for(int i = 1; i < s.length(); i++){
            s.insert(s.begin(), s[s.length() - 1]);
            s.pop_back();

            if(s == t){
                ans = "Yes";
                break;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = sc.nextLong();
        long ax = a / x;
        long bx = b / x;
        long ans = bx - ax;
        if (a % x == 0) {
            ans++;
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 23124
#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> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int c[26];

int main(){
    string s;
    cin >> s;
    rep(i,s.size()) c[s[i]-'a'] ++;
    rep(i,26){
        if(c[i]==0){
            cout << (char)('a'+i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
const int Mod = 1e9 + 7, Nmax = 1e5 + 5;

ll fact[Nmax], ifact[Nmax];
int ap[Nmax], n, i, x, rest;

ll comb(int n, int k)
{
    if(n < k) return 0;
    return fact[n] * ifact[k] % Mod * ifact[n-k] % Mod;
}

ll power(ll a, int b)
{
    if(!b) return 1;
    if(b&1) return a * power(a*a%Mod, b/2) % Mod;
    return power(a*a%Mod, b/2);
}

int main()
{
   // freopen("input", "r", stdin);
   // freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    fact[0] = ifact[0] = 1;
    cin >> n;
    for(i=1; i<=n+1; ++i)
    {
        cin >> x;
        if(ap[x]) rest = n + 1 - (i - ap[x] + 1);
            else ap[x] = i;
        fact[i] = fact[i-1] * i % Mod;
    }

    ifact[n+1] = power(fact[n+1], Mod-2);
    for(i=n; i; --i) ifact[i] = ifact[i+1] * (i+1) % Mod;

    for(i=1; i<=n+1; ++i)
        cout << (comb(n+1, i) - comb(rest, i-1) + Mod) % Mod << '\n';

    return 0;
}


Measured memory_bytes: 3200
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    cin >> n;
    auto s = new char[n + 1];
    cin >> s >> k;
    char c = s[k-1];

    for (int i = 0; i < n; ++i)
        if (s[i] != c)
            s[i] = '*';

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define mod 1000000007
typedef long long ll;
using namespace std;


#define MAX 100050
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2;i<MAX;i++){
    fac[i] = fac[i-1] * i % mod;
    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}

ll COM(int n, int k){
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[n-k] * finv[k] % mod) % mod;
}

int main(){
  int n,k; cin >> n >> k;
  vector<ll> A(n);
  for(int i=0;i<n;i++) cin >> A[i];
  sort(A.begin(),A.end());

  COMinit();
  ll ans = 0;

  for(int i=k-1;i<n;i++){
    ans = (ans + COM(i,k-1) * A[i]) % mod;
  }
  
  for(int i=0;i<n-k+1;i++){
    ans = (ans - ((COM(n-i-1,k-1) * A[i]))) % mod;
  }
  ans = (ans + mod) % mod;

  cout << ans << endl;
  return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> L(N);
  
  int num = -1e9;
  int num2 = 0;
  
  for(int i = 0;i < N;++i){
    cin >> L[i];
  }
  
  for(int i = 0;i < N;++i){
    num = max(L[i],num);
  }
  
  for(int i = 0;i < N;++i){
    num2 = L[i] + num2;
  }
  
  int num3 = num2 -num;
  
  if(num < num3){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}




Measured memory_bytes: 256
include(Math)

n = gets.to_i

def koch(x0,y0, x1,y1, m)
  if m == 0
    [[x0,y0]]
  else
    # n = sqrt((y0-y1)**2+(x1-x0)**2)
    s = [(2*x0+x1)/3.0,(2*y0+y1)/3.0]
    t = [(x0+2*x1)/3.0,(y0+2*y1)/3.0]
    u = [(x0+x1)/2.0-(y1-y0)*sqrt(3)/6.0,(y0+y1)/2.0+(x1-x0)*sqrt(3)/6.0]
    return koch(x0,y0, s[0],s[1], m-1) + koch(s[0],s[1], u[0],u[1], m-1) +
           koch(u[0],u[1], t[0],t[1], m-1) + koch(t[0],t[1], x1,y1, m-1)
  end
end

a = koch(0,0,100,0,n) + [[100.0,0.0]]

a.each do |e|
  print e[0].to_f, " ", e[1].to_f, "\n"
end

Measured memory_bytes: 8952
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <ctime>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, m, p;
vector<int> et[2500];
vector<int> ec[2500];
vector<int> rEt[2500];
bool visitG[2500];
int dist[2500];
queue<int> que;

signed main() {
	int i, j, k;
	
	cin >> n >> m >> p;
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		et[a].push_back(b);
		ec[a].push_back(p - c);
		rEt[b].push_back(a);
	}
	
	que.push(n - 1);
	visitG[n - 1] = true;
	while (!que.empty()) {
		int v = que.front(); que.pop();
		rep(i, rEt[v].size()) {
			int nv = rEt[v][i];
			if (visitG[nv] == false) {
				que.push(nv);
				visitG[nv] = true;
			}
		}
	}
	if (visitG[0] == false) { cout << -1 << endl; return 0; }	//ゲームを終了できない
	
	int INF = 1e+16;
	rep(i, n) dist[i] = INF;
	
	dist[0] = 0;
	
	for (i = 0; i <= 5 * n; i++) {
		for (j = 0; j < n; j++) {
			if (dist[j] >= INF) continue;
			for (k = 0; k < et[j].size(); k++) {
				int v = j;
				int nv = et[j][k];
				if (visitG[nv] == false) continue;
				if (dist[nv] > dist[v] + ec[j][k]) {
					dist[nv] = dist[v] + ec[j][k];
					//cout << "i = " << i << ", v = " << v << ", nv = " << nv << ", dist[nv] = " << dist[nv] << endl;
					if (i == n) { cout << -1 << endl; return 0; }
				}
			}
		}
	}
	
	int ans = max(0LL, -dist[n - 1]);
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int h[n];
    rep(i, n) cin >> h[i];

    vector<int> dp(n, INF);
    dp[0] = 0;
    rep(i, n) {
        for (int j = 1; j <= k; j++) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 4016
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC131A
{
    class Program
    {
        static void Main(string[] args)
        {
            var abcd = Console.ReadLine().Split(' ');
            var a = ulong.Parse(abcd[0]);
            var b = ulong.Parse(abcd[1]);
            var c = ulong.Parse(abcd[2]);
            var d = ulong.Parse(abcd[3]);
            var cdlcm = Lcm(c, d);
            var tmp = b / c - (a - 1) / c + b / d - (a - 1) / d - (b / cdlcm - (a - 1) / cdlcm);
            var result = b - a + 1 - tmp;
            Console.WriteLine(result);

        }
        public static  ulong Lcm( ulong a,  ulong b)
        {
            return a * b / Gcd(a, b);
        }

        // ユークリッドの互除法 
        public static  ulong Gcd( ulong a,  ulong b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int>
#define rep(a,n) for(int i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int n,vin &a){
    rep(0,n){
        cin>>a.at(i);
    }
}

signed main(){
    typedef pair<int,int> P;
    int A,B;
    string S,T,U;
    cin>>S>>T;
    cin>>A>>B;
    cin>>U;
    if(S==U) A--;
    else B--;
    cout<<A<<" "<<B<<endl;
    return 0;
}

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

using namespace std;

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	int ans;
	ans = a+ b + c;
	if(ans <= 21){
		cout << "win"<<endl;
	}
	else{
		cout<<"bust"<<endl;
	}
	
	
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<P> ans;
  if(n%2==0) {
    for(ll x=1;x<n;++x) {
      for(ll y=x+1;y<=n;++y) {
        if(x+y==n+1) continue;
        else ans.emplace_back(P(x,y));
      }
    }
  }
  else {
    for(ll x=1;x<n-1;++x) {
      for(ll y=x+1;y<n;++y) {
        if(x+y==n) continue;
        else ans.emplace_back(P(x,y));
      }
    }
    for(ll x=1;x<=n-1;++x) ans.emplace_back(P(x,n));
  }
  print(ans.size());
  for(P p:ans) cout<<p.first<<' '<<p.second<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;

int main(){
	string a,b;
	cin>>a>>b;
	if(a.length()>b.length()){
		cout<<"GREATER"<<endl;
	}
	else if(a.length()<b.length()){
		cout<<"LESS"<<endl;
	}
	else if(a.length()==b.length()&&a>b){
		cout<<"GREATER"<<endl;
	}
	else if(a.length()==b.length()&&a<b){
		cout<<"LESS"<<endl;
	}
	else if(a.length()==b.length()&&a==b){
		cout<<"EQUAL"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PII pair<int,int>
const int INF = (1<<30);
const int MX = 1e5+5;
bool vis[MX];
int cnt[MX];

void solve(){

}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n,t,ac=0,wa=0;
    string str;
    cin>>n>>t;

    while(t--){
        cin>>n>>str;
        if(str=="AC"){
            if(!vis[n]){
                vis[n]=1;
                ac++;
                wa+=cnt[n];
            }
        }
        else{
           cnt[n]++;
        }
    }

    cout<<ac<<" "<<wa<<"\n";
    return 0;
}





Measured memory_bytes: 768
using System;

namespace ATCODER123
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            var A = new long[n];
            var X = new long[n];
            String[] S = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                A[i] = long.Parse(S[i]);
            }
            for (int i = 0; i < n; i++)
            {
                if(i%2 == 0)
                {
                    X[0] += A[i];
                }
                else
                {
                    X[0] -= A[i];
                }
                //Console.WriteLine(X[1]);
            }
            for (int i = 0; i < n; i++)
            {
                if(i > 0)
                {
                    X[i] = 2 * (A[i - 1] - (X[i - 1] / 2));
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (i < n - 1)
                {
                    Console.Write("{0} ", X[i]);
                }
                else
                {
                    Console.Write("{0}\r\n", X[i]);
                }
            }



        }

    }
}


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

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using cd = complex<ld>;

template<typename T>
struct max_queue {
  struct node {
    T val;
    T mx;

    node(T val, T mx)
        : val(val),
          mx(mx) {}
  };

  stack<node> forw, backw;

  size_t size() const {
    return forw.size() + backw.size();
  }

  void push(T value) {
    backw.emplace(value, backw.empty() ? value : max(value, backw.top().mx));
  }

  void pop() {
    if (forw.empty()) {
      while (!backw.empty()) {
        node const& n = backw.top();
        forw.emplace(n.val, forw.empty() ? n.val : max(n.val, forw.top().mx));
        backw.pop();
      }
    }
    forw.pop();
  }

  T get_max() {
    if (forw.empty()) {
      return backw.top().mx;
    } else if (backw.empty()) {
      return forw.top().mx;
    } else {
      return max(forw.top().mx, backw.top().mx);
    }
  }
};

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

  int n, m, k;
  cin >> n >> m >> k;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  const ll INF = 1'000'000'000'000'000'000;
  vector<vector<ll>> dp(k + 1, vector<ll>(n, -INF));
  copy(a.begin(), a.end(), dp[0].begin());
  for (int i = 1; i < k; i++) {
    max_queue<ll> pq;
    for (int j = 0; j < n; j++) {
      if (j >= i) {
        dp[i][j] = (i + 1LL) * a[j] + pq.get_max();
      }
      if (pq.size() == m) {
        pq.pop();
      }
      pq.push(dp[i - 1][j]);
    }
    fill(dp[i + 1].begin(), dp[i + 1].end(), -INF);
  }
  cout << *max_element(dp[k - 1].begin(), dp[k - 1].end());
  return 0;
}


Measured memory_bytes: 241580
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
    int a,b,c,d,ans,tmp;
  	cin >> a;
  	if(a >= 2800)cout << "AGC";
  	else if(a >= 1200)cout << "ARC";
  	else cout << "ABC";

}


Measured memory_bytes: 3548
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int m;
  cin >> m;
  vector<bool> visit(m);
  int cur = 0, ret = -1;
  for (int k = 0; ; ++k) {
    cur = (cur * 10 + 7) % m;
    if (visit[cur]) break;
    visit[cur] = true;
    if (cur == 0) {
      ret = k + 1;
      break;
    }
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 3384
#include <stdio.h>

int main(void){
  int n;
  scanf("%d", &n);
  int i, j;
  int count = 0;
  int ans = 0;
  
  for(i = 1; i <= n; i += 2){
    count = 0;
    for(j = 1; j <= i; j++){
      if(i % j == 0) count++;
    }
    if(count == 8) ans++;
  }
  
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
// Parasparopagraho Jīvānām

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std ;
using namespace  __gnu_pbds ;
using namespace __gnu_cxx ;

typedef long long ll ;
typedef long double ld ;

typedef pair<int, int> pii ;
typedef pair<int, ll> pil ;
typedef pair<ll,ll> pll ;

typedef vector<int> vi ;
typedef vector<ll> vll ;
typedef vector<pii> vpi ;
typedef vector<pll> vpl ;
typedef vector<int,pil> edges ;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

#define mp make_pair
#define eb emplace_back
#define pb push_back
#define fi first
#define se second

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int mod1 = 1000000007 ;
const int mod2 = 998244353 ;
const ll  infl = 2e18 ;
const int infi = 2e9 ;
const int maxn = 100005 ;
const int block = 500 ;
const int logn = 30 ;
const int alpha = 27 ;
const ld pi = 3.141592653589793238462643383279 ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) ;

/* Careful when using long long
__builtin_clz(int x) {} //: the number of zeros at the beginning of the number
__builtin_ctz(int x) {} //: the number of zeros at the end of the number
__builtin_popcount(int x) {} //: the number of ones in the number
__builtin_parity(int x) {} //: the parity (even or odd) of the number of ones*/
ll modpow(ll a, ll b, int MOD) { ll res = 1 ; while(b) { if(b&1) { res = res*a ; res %= MOD ; } a *= a ; a %= MOD ; b >>= 1 ; } return res%MOD ; }
void upmin(int &a, int b) { if(a < b) { a = b ; } }
void relax(int &a, int b) { if(a > b) { a = b ; } }
ll add(ll a, ll b, int MOD) { a += b ; if(a >= MOD) { a -= MOD ; } return  a ; }
ll sub(ll a, ll b, int MOD) { a -= b ; if(a < 0) { a += MOD ; } return a ; }
ll mul(ll a, ll b, int MOD) { b %= MOD ; a *= b ; a %= MOD ; return a ; }
ll inverse(ll a, ll MOD) { a = modpow(a, MOD - 2, MOD) ; return a ; }
ll lcm(ll a, ll b) { ll ret ; ll g = __gcd(a, b) ; ret = a/g ; ret = ret*b ; return ret ; }

int main()
{
    ios::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    int h1, m1, h2, m2, k ;
    cin >> h1 >> m1 >> h2 >> m2 >> k ;
    int m ;
    if(h1 == h2)
    {
        m = (m2 - m1) ;
    }
    else
    {
        m = (60 - m1) ;
        h1 = (h1 + 1)%24 ;
        m += (h2 - h1)*60 ;
        m += (m2) ;
    }

    m -= k ;
    cout << m << endl ;
    return 0 ;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

int main(){
  int N;cin>>N;
  vector<int> P(N);
  REP(i,0,N)cin>>P[i];
  vector<int> P_c=P;
  int pre=-1,cnt=0;
  sort(P_c.begin(),P_c.end());
  REP(i,0,N){
    if(P[i]!=P_c[i]){
      cnt++;
      if(pre==-1){
        pre=P[i];
      }
      else if(pre!=P_c[i]){
        print("NO")
        return 0;
      }
    }
  }
  print(((cnt==2)||(cnt==0)?"YES":"NO"))
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  int mn = A[0] , mx = A[0];
	for(int i = 1; i < N; i++){
		if(mn > A[i])
			mn = A[i];
		if(mx < A[i])
			mx = A[i];
	}
	
	cout << mx - mn << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_A&lang=jp

struct Node {
    int l, r , p;
};


#define MAX 100005
#define NIL -1

Node T[MAX];
int D[MAX];

static void print(int u) {
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].p);
    printf("depth = %d, ", D[u]);

    if (T[u].p == NIL) cout << "root, ";
    else if (T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";
    for (int i = 0, c = T[u].l; c != NIL; i++, c=T[c].r) {
        if (i) cout << ", ";
        cout << c;
    }
    cout << "]" << "\n";
}

static void setDepth(int u, int d) {
    if (u==NIL) return;
    D[u] = d;
    setDepth(T[u].l, d+1);
    setDepth(T[u].r, d);
}

int main() {
    int N; cin >> N;
    REP(i, N) T[i].l = T[i].r = T[i].p = NIL;
    REP(i, N) {
        int id, c; cin >> id >> c;
        int l = 0;
        REP(j, c) {
            int a; cin >> a;
            if (j==0) T[id].l = a;
            else T[l].r = a;
            l = a;
            T[a].p = id;
        }
    }

    int root = 0;
    REP(i, N) if (T[i].p == NIL) root = i;
    setDepth(root, 0);
    REP(i, N) print(i);


    return 0;
}


Measured memory_bytes: 4788
#include<cstdio>
#include<cstdlib>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cassert>
#include<queue>
#include<iostream>
#include<climits>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define rep(i,a,b) for(register int i=(a);i<(b);++i)
#define pb push_back
#define mp make_pair
#define mx(a,b) (a>b?a:b)
#define mn(a,b) (a<b?a:b)
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef long long ll;
using namespace std;

namespace IO
{
    const uint32 Buffsize=1<<15,Output=1<<24;
    static char Ch[Buffsize],*S=Ch,*T=Ch;
    inline char getc()
    {
        return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
    }
    static char Out[Output],*nowps=Out;
    
    inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

    template<typename T>inline void read(T&x)
    {
        x=0;static char ch;T f=1;
        for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
        for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
        x*=f;
    }

    template<typename T>inline void write(T x,char ch='\n')
    {
        if(!x)*nowps++='0';
        if(x<0)*nowps++='-',x=-x;
        static uint32 sta[111],tp;
        for(tp=0;x;x/=10)sta[++tp]=x%10;
        for(;tp;*nowps++=sta[tp--]^48);
        *nowps++=ch;
        if(nowps-Out>=1<<23)flush();
    }

    inline void getstr(char*q)
	{
		register char ch;
		for(ch=getc();!isupper(ch);ch=getc());
		for(;isupper(ch);ch=getc())*q++=ch;
		*q='\0';
	}

	inline void getwd(char&x){for(x=getc();!isupper(x);x=getc());}
}
using namespace IO;

void file()
{
#ifndef ONLINE_JUDGE
    FILE*DSD=freopen("water.in","r",stdin);
    FILE*CSC=freopen("water.out","w",stdout);
#endif
}

inline void Chkmin(int&u,int v){u>v?u=v:0;}

inline void Chkmax(int&u,int v){u<v?u=v:0;}

inline void Chkmax(ll&u,ll v){u<v?u=v:0;}

inline void Chkmin(ll&u,ll v){u>v?u=v:0;}

const int MAXN=2e5+7;

static int n,Q;

static char s[MAXN];

static struct opt{char bl,dr;}q[MAXN];

inline void init()
{
	read(n),read(Q);
	getstr(s+1);
	Rep(i,1,Q)getwd(q[i].bl),getwd(q[i].dr);
}

static int ans;

inline int getps(int cr)
{
	Rep(i,1,Q)if(q[i].bl==s[cr])q[i].dr=='L'?--cr:++cr;
	return cr;
}

inline void solve()
{
	ans=n;
	int l=1,r=n;
	while(l<=r)
	{
		int md=(l+r)>>1;
		if(getps(md)==0)l=md+1;
		else r=md-1;
	}
	ans-=r;
	l=r+1,r=n;
	while(l<=r)
	{
		int md=(l+r)>>1;
		if(getps(md)==n+1)r=md-1;
		else l=md+1;
	}
	ans-=n+1-l;
	cout<<ans<<endl;
}

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

Measured memory_bytes: 896
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
const int MAX=1000001;

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

    bool ok=false;
    for(int i=0;i<s.size();i++){
        if(s==t){
            ok=true;
            break;
        }
        s=s.back()+s.substr(0,s.size()-1);
    }

    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
from collections import Counter

S = input()

x = [0]
dec = 1
for s in S[::-1] :
  x.append((x[-1] + dec * int(s)) % 2019)
  dec *= 10
  dec %= 2019

ret = 0
for v in Counter(x).values() :
  ret += v * (v - 1) // 2
print(ret)

Measured memory_bytes: 76632
#include <vector>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;


int main(void){
  
  int S,W;

  
  
  cin >> S >> W;

  if( W >= S){
    cout << "unsafe" << endl; 
  }else{
    cout << "safe" << endl;
  }
  

  return 0;
}




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

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

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

int main(){
    long long a,b,c,d,ans=0,llccmm=0;
    cin >> a >> b >> c >> d;
    ans=b-a+1;
    ans-=b/c;
    ans+=(a-1)/c;
    ans-=b/d;
    ans+=(a-1)/d;
    llccmm=lcm(c,d);
    ans+=b/llccmm;
    ans-=(a-1)/llccmm;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int x,n; cin >> x >> n;
	set<int> s;
	forn(i,0,n){
		int y; cin >> y;
		s.insert(y);
	}
	int i = 0;
	while(true){
		int num1 = x-i;
		int num2 = x+i;
		if(s.find(num1) == s.end()){
			cout << num1;
			break;
		}
		if(s.find(num2) == s.end()){
			cout << num2;
			break;
		}
		++i;
	}
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
	int a, b;
	cin >> a >> b;
	if(a + b < 24) {
	cout << a + b << endl;
	}
	else cout << a + b -24 << endl;
	return 0;
}

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

int main() {
  int result=0;
  int drop_a=0, drop_b=0;
  int loop_count = 0;
  int g = 0, w =0, p=0, y=0;
  int drop_count=0;
  cin >> loop_count;

  for(int i=0;i < loop_count;i++){
    for(int j=0;j < 3; j++){
      if(j==0){
        cin >> drop_a;
      }else if(j==1){
        cin >> drop_b;
      }else{
        result = result + drop_b - drop_a + 1;
      }
    }
  }
  cout << result;
}


Measured memory_bytes: 256
///God help me.

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n,d,x;
    int a[1001];
    cin >> n >> d >> x;
    for(int i = 0; i<n; i++)
        cin >> a[i];
    int ans = 0;
    for(int i = 0; i<n; i++){
        int k = 0;
        for(int j = 1; j<=d; j = k*a[i]+1){
            ans++;
            k++;
        }
    }
    cout << ans+x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){


  int a,b,x; cin>>a>>b>>x;

  cout<< ( x-a>=0 and a+b-x>0 ? "YES" : "NO" )<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N = Scanner.int()
    memo = [[0 for _ in range(10)] for _ in range(10)]
    for i in range(1, N + 1):
        s = str(i)
        memo[int(s[0])][int(s[-1])] += 1

    ans = 0
    for i in range(1, N + 1):
        s = str(i)
        t = memo[int(s[-1])][int(s[0])]
        ans += t
    print(ans)


def main():
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10728