akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

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


int main(){
    int A,B;
    cin >> A >> B;
    string A_s = to_string(A);
    string B_s = to_string(B);
    int A_sub = ctoi(A_s[1]) * 10 + ctoi(A_s[0]) - A % 100;
    int B_sub = B % 100 - ctoi(B_s[1]) * 10 - ctoi(B_s[0]);
    if (A_sub >= 0 && B_sub >= 0){
        cout << B / 100 - A / 100 + 1 << endl;
    }
    else if((A_sub >= 0 && B_sub < 0) || (A_sub < 0 && B_sub >= 0)){
        cout << B / 100 - A / 100 << endl;
    }
    else{
        cout << B / 100 - A / 100 - 1 << endl;
    }
    
}



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

int main() {
	string s;
	cin >> s;
	int pos = 1;
	for(int i = 0; i < s.size(); ++i) {
		if(i&1) {
			if(s[i] == 'R') pos = 0;
		}
		else {
			if(s[i] == 'L') pos = 0;
		}
	}
	if(pos) cout << "Yes";
	else cout << "No";
	return 0;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    while (cin >> N >> M, N + M) {
        vector<ll> maxPoint(N, 0);
        vector<ll> forcePoint(N, 0);
        REP(i, 0, M) {
            int S, k;
            cin >> S >> k;
            if (k == 1) {
                int c;
                cin >> c;
                forcePoint[c - 1] += S;
                maxPoint[c - 1] += S;
            } else {
                REP(j, 0, k) {
                    int c;
                    cin >> c;
                    maxPoint[c - 1] += S;
                }
            }
        }
        vector<int> ind1(N), ind2(N);
        REP(i, 0, N) {
            ind1[i] = ind2[i] = i;
        }
        sort(begin(ind1), end(ind1), [&](int a, int b) -> bool {
            return forcePoint[a] < forcePoint[b];
        });
        sort(begin(ind2), end(ind2), [&](int a, int b) -> bool {
            return maxPoint[a] > maxPoint[b];
        });

        ll ans = 0;
        if (ind1[0] == ind2[0]) {
            ans = max(maxPoint[ind2[1]] - forcePoint[ind1[0]], maxPoint[ind2[0]] - forcePoint[ind1[1]]);
        } else {
            ans = maxPoint[ind2[0]] - forcePoint[ind1[0]];
        }
        cout << ans + 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 3228
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)1e5+20
#define INF 1e9+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int,int> pii;
const int delta=(int)1e9+7;
string s;
bool ac(){
	for(int i=0;i<s.size()-1;++i){
		if(s[i]=='A'&&s[i+1]=='C') return 1;
	}
	return 0;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin>>s;
	if(ac()) cout<<"Yes";
	else cout<<"No";
	return cout<<endl,0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n,s[10000],q,t[500],cnt=0,idx=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>s[i];
  sort(s,s+n);

  
  cin>>q;
  for(int i=0;i<q;i++)cin>>t[i];
  sort(t,t+q);

  for(int i=0;i<q;i++)
    for(int j=idx;j<n;j++)
      if(t[i]==s[j]){idx=j;cnt++;break;}


  
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3200
#include <stdio.h>
int main(){
int a;
scanf("%d",&a);
int temp = 0;
for (int i=0;i<=9;i++){
	for(int j=0;j<=9;j++){
		if(i*j==a){
			temp = 1;
			break;
		}
	}
}
if(temp==1){
	printf("Yes");
}
else{
	printf("No");
}
return 0;
}


Measured memory_bytes: 1696
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int a,b,h,m; cin >> a >> b >> h >> m;
  double theta = (h+ (double) m/60)*30;
  double phi = (m%60)*6;
  double x = abs(theta-phi);
  x = min(x, 360-x);
  x = (double) x * M_PI * 2/360.0; 
  // cout<<x<<endl;
  double c_sq = (double) a*a+b*b - 2*a*b*cos(x);
  // cout << cos(x) << endl;
  printf("%.20f\n", sqrt(c_sq));

  return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

#define M 1000000007

int n,k;
ll a[111];
ll dp[111][111][1<<8];

ll fuc[111];

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>k;
	rep(i,n)cin>>a[i];
	dp[0][0][0]=1;
	rep(l,n)rep(i,n)rep(S,1<<8){
		dp[l][i+1][S]=(dp[l][i+1][S]+dp[l][i][S])%M;
		dp[l+1][i+1][S^a[i]]=(dp[l+1][i+1][S^a[i]]+dp[l][i][S])%M;
	}
	fuc[0]=1;
	rep(i,n+1)fuc[i+1]=(fuc[i]*(i+1))%M;
	ll res=0;
	repl(l,1,n+1){
		res=(res+(dp[l][n][k]*fuc[l]))%M;
	}
	cout<<res<<endl;
	return 0;
}


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

bool f(int n)
{
  return 1 <= n && n <= 12;
}

int main()
{
  int n;
  cin >> n;
  int i = f(n / 100) * 2 + f(n % 100);
  string s[] {"NA", "YYMM", "MMYY", "AMBIGUOUS"};
  cout << s[i] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;
const int mod=1000000007;
int main(){
  string s;
  cin>>s;
  long long dp[100010][14]={};
  dp[0][0]=1;
  int buf=0;
  long long n;
  n=(int)(s.length());
  for(int i=1;i<=n;i++){
    buf=s[i-1]-'0';
    if(s[i-1]=='?') buf=-1;
    int sum=0;
    if(buf!=-1){
    for(int j=0;j<13;j++){
      dp[i][(j*10+buf)%13]=dp[i-1][j];
      dp[i][(j*10+buf)%13]%=mod;
    }
    }
    else {
      for(int j=0;j<13;j++){
	for(int k=0;k<10;k++){
	  dp[i][(j*10+k)%13]+=dp[i-1][j];
	  dp[i][(j*10+k)%13]%=mod;
	}
      }
    }
  }
  cout<<dp[n][5]<<endl;
  //  cout<<n<<endl;
  return 0;
}


Measured memory_bytes: 11392
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int , int>
#define fast ios_base::sync_with_stdio(0)
#define mod 1000000007
int arr[22][22], n;
ll dp[(1<<21)+5];
ll fun(int mask)
{
    if(mask == (1<<n)-1) return 1;
    int men = __builtin_popcount(mask);
    if(men==n) return 0;
    ll& ret = dp[mask];
    if(ret!=-1) return ret;
    ret = 0;
    for(int i=0; i<n; i++){
        if(mask&(1<<i));
        else if(arr[men][i]==1){
            ret+=fun(mask|(1<<i));
            ret%=mod;
        }
    }
    return ret;
}
int main()
{
    fast;
    cin>>n;
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin>>arr[i][j];
    memset(dp, -1, sizeof dp);
    cout<<fun(0)<<endl;
}


Measured memory_bytes: 16640
from math import sqrt


def IsPrime(num):
    if num < 2:
        return True
    elif num == 2:
        return True
    elif num % 2 == 0:
        return False

    sqrtNum = sqrt(num)
    for i in range(3, int(sqrtNum) + 1, 2):
        if num % i == 0:
            return False

    return True


def make_divisors(num):
    divisors = []
    for i in range(1, int(num**0.5)+1):
        if num % i == 0:
            divisors.append(i)
            if i != num // i:
                divisors.append(num//i)

    # divisors.sort()
    return divisors


if __name__ == "__main__":
    A, B = map(int, input().split())

    A_list = make_divisors(A)
    B_list = make_divisors(B)

    AB_list = set(A_list) & set(B_list)

    ans = list()
    for i in AB_list:
        if IsPrime(i):
            ans.append(i)

    print(len(ans))


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

#define int long long
#define INF numeric_limits<int>::max()

int dp[109][100009];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, w;
    cin >> n >> w;
    vector< pair<int, int> > ve(n+1);
    for(int i = 1; i<= n; i++){
        int a, b;
        cin >> a >> b;
        ve[i] = make_pair(a,b);
    }
    for(int i = 0; i<= n; i++){
        for(int j = 0; j <= 100000; j++){
            dp[i][j] = INF/2;
        }
    }
    for(int i = 1; i <= n; i++){
        dp[i][ve[i].second] = ve[i].first;
        for(int j = 0; j <= 100000; j++){
            if(j-ve[i].second >= 0)dp[i][j] = min(dp[i][j],min(dp[i-1][j], dp[i-1][j-ve[i].second]+ve[i].first));
            else dp[i][j] = min(dp[i-1][j], dp[i][j]);
        }
    }
    for(int i = 100000; i >= 0; i--){
        if(dp[n][i] <= w){
            cout << i << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
#define mk make_pair
using namespace std;
map<int,pair<int,int> >max_p,min_p;
map<char,int>mc;
int h,w,c,vis[101];
string s[51];
void mae(){
  r(i,h)r(j,w)
   if(s[i][j]=='.')s[i][j]='0';
   else{
    if(mc[s[i][j]])s[i][j]=mc[s[i][j]];
    else{
      mc[s[i][j]]=(c++)+'0';
      s[i][j]=(c-1)+'0';
    }
   }
}
void in(){
  for(int k=1;k<c;k++){
    int px=0,py=0,mx=1000,my=1000;
    r(i,h)r(j,w)
      if(s[i][j]-'0'==k){
        px=max(px,j);
        py=max(py,i);
        mx=min(mx,j);
        my=min(my,i);
      }
    max_p[k]=mk(px,py);
    min_p[k]=mk(mx,my);
  }
}
bool chb(){
  for(int k=1;k<c;k++){
    pair<int,int>p1=min_p[k],p2=max_p[k];
    for(int i=p1.se;i<=p2.se;i++)
      for(int j=p1.fi;j<=p2.fi;j++)
        if(s[i][j]=='0')return 1;
  }
  return 0;
}
bool dfs(int d,int x){
  if(d){
    pair<int,int>p1=min_p[x],p2=max_p[x];
    for(int i=p1.se;i<=p2.se;i++)
      for(int j=p1.fi;j<=p2.fi;j++)
        if(!vis[s[i][j]-'0'])return 0;
  }
  if(d==c-1)return 1;
  for(int i=1;i<c;i++)
    if(!vis[i]){
      vis[i]=1;
      if(dfs(d+1,i))return 1;
      vis[i]=0;
    }
  return 0;
}
int main(){
  int n;
  cin>>n;
  while(n--){
    memset(vis,0,sizeof(vis));
    max_p.clear();
    min_p.clear();
    mc.clear();c=1;
    cin>>h>>w;
    r(i,h)cin>>s[i];
    mae();
    in();
    if(chb())cout<<"SUSPICIOUS"<<endl;
    else{
      if(dfs(0,0))cout<<"SAFE"<<endl;
      else cout<<"SUSPICIOUS"<<endl;
    }
  }
}

Measured memory_bytes: 3140
d=int(input()) #365
c=list(map(int,input().split()))
s=[]
for i in range(d):
  s.append(list(map(int,input().split())))

ll=[0 for i in range(26)]
l=[]
ans=[]
for i in range(d):
  for j in range(26):
    ll[j]+=1
  m=-(10**10)
  for j in range(26):
    t=s[i][j]+ll[j]*c[j]
    if m<t:
      m=t
      tt=j
  l.append(ll[tt])
  ans.append(tt)
  ll[tt]=0
print("\n".join(map(lambda x:str(x+1),ans)))

Measured memory_bytes: 74140
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cassert>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {

  int N; cin >> N;
  vector<int> x(N), y(N), h(N);
  
  for (int i=0; i<N; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }
  
  int hmax, hmaxindex;
  hmaxindex = int(max_element(h.begin(), h.end()) - h.begin());
  hmax = h[hmaxindex];
  
  int cxans=-1, cyans=-1, Hans=-1;
  for (int H=hmax; H<=hmax+200; H++) {
    int cx, cy;
    int diffmax = H-h[hmaxindex];
    for (int diffx=0; diffx<=diffmax; diffx++) {
      for (int i=0; i<4; i++) {
        switch (i) {
          case 0:
            cx = x[hmaxindex] + diffx;
            cy = y[hmaxindex] + (diffmax - diffx);
            break;
          case 1:
            cx = x[hmaxindex] - diffx;
            cy = y[hmaxindex] + (diffmax - diffx);
            break;
          case 2:
            cx = x[hmaxindex] + diffx;
            cy = y[hmaxindex] - (diffmax - diffx);
            break;
          case 3:
            cx = x[hmaxindex] - diffx;
            cy = y[hmaxindex] - (diffmax - diffx);
            break;
        }
        
        if (cx<0 || cy<0 || cx>100 || cy>100)
          continue;
        
        for (int j=0; j<N; j++) {
          if (h[j] != max(H - abs(x[j]-cx) - abs(y[j]-cy), 0))
            break;
          if (j == N-1){
            cxans = cx;
            cyans = cy;
            Hans = H;
          }
        }
      }
    }
  }
  
  assert(cxans != -1);
  cout << cxans << " " << cyans << " " << Hans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y){
	if(y==0)
		return 1;
	ll res=power(x,y/2);
	res=(res*res);
	if(y&1)
		res=(res*x);
	return res;
}
 
ll powermod(ll x,ll y,ll mod){
	if(y==0)
		return 1;
	ll res=powermod(x,y/2,mod);
	res=(res*res)%mod;
	if(y&1)
		res=(res*x)%mod;
	return res;
}
/*ll binarysearch(ll va)
{
	ll n=1;
	ll l=va+1,u=n;
	ll st=num.order_of_key(va);
	while(l+1<u)
	{
		m=(l+u)/2;
		ll in=num.order_of_key(m);
		if(in-st==m-va)
		{
			l=m;
		}
		else
		{
            u=m;
		}
	}
	if(num1.find(l)==num1.end())
		return l;
	return u;
}*/
void solve(){
	int n;
	cin>>n;
	int a[n+1],b[n+1];
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	int c[n];
	for(int i=1;i<n;i++) cin>>c[i];
	int ans=0;
	for(int i=1;i<=n;i++){
      ans +=b[a[i]];
	  if(i>1 && a[i]-a[i-1]==1) ans += c[a[i-1]];
	}
	cout<<ans<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
 
    for(int i=1;i<=t;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}

Measured memory_bytes: 3612
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {
	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long D = sc.nextLong();
		long E = sc.nextLong();

		long[] a = new long[] { A, B, C, D, E };
		long min = Arrays.stream(a).min().getAsLong();
		debug(min);

		System.out.println(N / min + (N % min == 0 ? -1 : 0) + 5);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	private static class Tuple {
		boolean hasLeft;
		boolean hasRight;
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public char nextChar() throws IOException {
			return (char) skip();
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

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

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

int main () {
  int n;
    cin >> n;
  ll a[n];
  REP(i, n) {
    cin >> a[i];
  }
 
  
  int cnt = 0;
  int cnt4 = 0;
  REP(i ,n) {
    if (a[i] % 4 == 0) {
      cnt++;
      cnt4++;
    }
    else if (a[i] % 2 ==1) cnt--;
  }
  
  if (cnt >= 0) cout << "Yes";
  else if (cnt == -1 and cnt4 >= n/2) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
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 ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
map<string,int>ma;
int n;
cin >> n;
vector<string>a(n);
for(int i=0;i<n;i++){
    string s;
    cin >> s;
    a.at(i)=s;
    if(ma.count(s))ma.at(s)++;
    else ma[s]=1;
}
sort(a.begin(),a.end());
int che = -1;
for(int i=0;i<n;i++){
    che = max(che,ma.at(a.at(i)));
}
for(int i=0;i<n;i++){
    if(che==ma.at(a.at(i))){
        cout<< a.at(i)<<endl;
        ma.at(a.at(i))=-1;
    }
}
}



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

public class Main {

	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
         String s = in.readString();
         String t = in.readString(); 
         for(int i = 0; i<s.length(); i++) {
        	 if(s.equals(t)) {
        		 System.out.println("Yes"); 
        		 return; 
        	 }
        	 s = s.charAt(s.length()-1) + s.substring(0,s.length()-1);
         }
         System.out.println("No"); 
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


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

typedef long long ll;

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

    int n;
    cin >> n;
    vector<string> s(n);
    string ans;
    for(int i=0;i<n;i++) cin >> s[i];
    char now = 'a';
    for(char c=now;c<='z';c++){
        int cnt = 0;
        for(int i=0;i<n;i++){
            for(int j=0;j<s[i].size();j++){
                if(s[i][j]==c){
                    s[i].erase(s[i].begin()+j);
                    cnt++;
                    break;
                }
            }
        }
        if(cnt==n){
            ans += c;
            now = c--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//-----------------------
// author : xyqkoala
// time : 2020-08-10
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


void solve(){
	int MX = 100;
	vector<vector<int>> dp(MX,vector<int>(MX,0));
	int n = 0;
	cin>>n;
	vector<LL> nums;
	for(int i=0;i<n;i++){
		// long double x;
		string s;

		cin>>s;
		LL x = 0;
		int cnt = -1;
		for(int j=0;j< int(s.size());j++){
			if(s[j]=='.') {
				cnt = j;
				continue;
			}
			x = 10ll * x+s[j]-'0';
		}
		if(cnt==-1) cnt=0;
		else cnt = s.size()-1-cnt;
		while(cnt<10){
			x = 10ll * x;
			cnt++;
		}
		nums.push_back(x);
		// cout<<x<<endl;
	}
	LL res = 0;
	for(auto item:nums){
		// cout<<item<<endl;
		int cnt2 = 0;
		while(item%2 == 0){
			cnt2++;
			item = item/2;
		}
		int cnt5 = 0;
		while(item%5 == 0){
			cnt5++;
			item = item/5;
		}
		// cout<<cnt2<<" "<<cnt5<<endl;
		for(int i=0;i<MX;i++){
			int tcnt = cnt2+i;
			if(tcnt<20) continue;
			tcnt = max(0,20-cnt5);
			res+=dp[i][MX-1]-dp[i][tcnt];
			// if(item == 160000000000) cout<<dp[i][MX-1]-dp[i][tcnt]<<endl;
		}
		cnt5++;
		for(int j=cnt5;j<MX;j++){
			dp[cnt2][j]++;
		}
		// cout<<res<<endl;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 5292
#include<stdio.h>
#define MAX 100000
#define INFINITY 1000000000
#define TRUE 1
#define FALSE 0
typedef struct{
  char mark;
  int num;
}trump;
int partition(trump *, int, int);
void quicksort(trump *, int, int);
void merge(trump *, int, int, int);
void mergeSort(trump *, int, int);
int isStable(trump *, trump *, int);

int main(){
  int i,n;
  trump card[MAX],data[MAX];

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf(" %c%d",&card[i].mark,&card[i].num);
    data[i] = card[i];
  }
  mergeSort(data,0,n);
  quicksort(card, 0, n-1);
  if(isStable(data, card, n) == TRUE) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0; i<n; i++){
    printf("%c %d\n",card[i].mark,card[i].num);
  }
  return 0;
}

int partition(trump *card, int p, int r){
  int i,j,x;
  trump temp;
  x = card[r].num;
  i = p-1;
  for(j=p; j<r; j++){
    if(card[j].num <= x){
      i = i+1;
      temp = card[i];
      card[i] = card[j];
      card[j] = temp;

    }
  }
  temp = card[i+1];
  card[i+1] = card[r];
  card[r] = temp;

  return i+1;
}

void quicksort(trump *card, int p, int r){
  int q;
  if(p<r){
    q = partition(card, p, r);
    quicksort(card, p, q-1);
    quicksort(card, q+1, r);
  }
}

void merge(trump *S, int left, int mid, int right){
  int i,j,k;
  trump L[MAX],R[MAX];
  int n1 = mid-left;
  int n2 = right-mid;

  for(i=0; i<n1; i++){
    L[i] = S[left+i];
  }
  for(i=0; i<n2; i++){
    R[i] = S[mid+i];
  }
  L[n1].num = INFINITY;
  R[n2].num = INFINITY;
  i = 0;
  j = 0;
  for(k=left; k<right; k++){
    if(L[i].num <= R[j].num){
      S[k] = L[i];
      i = i+1;
    }
    else{
      S[k] = R[j];
      j = j+1;
    }
  }  
  
}

void mergeSort(trump *S, int left, int right){
  int mid;
  if(left+1 < right){
    mid = (left+right)/2;
    mergeSort(S, left, mid);
    mergeSort(S, mid, right);
    merge(S,left,mid,right);
  }

}

int isStable(trump *data, trump *card, int n){
  int i;
    for(i=0; i<n; i++){
        if(data[i].num != card[i].num || data[i].mark != card[i].mark) return FALSE;
    }
    return TRUE;
}



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

int main(){
    string s, sub;
    int n, ans;
    cin >> s;
    n=s.size();
    ans=0;

    for(int i=0; i<n; ++i){
        for(int j=(n-i); j>=1; --j){
            sub = s.substr(i, j);
            bool result1 = all_of(sub.begin(), sub.end(), [](char c){ return c=='A'||c=='C'||c=='G'||c=='T';});
            if(result1){
                auto count = count_if(sub.begin(), sub.end(), [](char c){ return c=='A'||c=='C'||c=='G'||c=='T';});
                if(ans<count) ans = count;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	static bool isprime[300000];
	fill(isprime, isprime + 300000, true);
	isprime[0] = isprime[1] = false;
	for(int i = 2; i * i < 300000; i++)
		if(isprime[i])
			for(int j = i * 2; j < 300000; j += i)
				isprime[j] = false;


	static int sums[300000];
	memset(sums, 0, sizeof sums);
	for(int i = 1; i < 300000; i++) {
		sums[i] = sums[i - 1] + (isprime[i] ? 1 : 0);
	}
	for(int n; cin >> n, n;) {
		cout << sums[2 * n] - sums[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
double be(double a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod)); else return (be(a,b/2,mod)*be(a,b/2,mod));}
const int mod = 1e9 + 7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
const int siz = 2*(1e5 + 10);
const int logi = 21;
const double epsilon = 1e-6;
int prime[siz];
int has[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}

vector<int> vt[siz];


signed main()
{
	#ifndef ONLINE_JUDGE
 	freopen("in.txt", "r", stdin);
 	freopen("out.txt", "w", stdout);
 	#else
// // online submission
 	#endif 
	speedrap
	int t;
	t = 1;
	//cin>>t;
	while(t--)
	{	
		int x;
		cin>>x;

		for(int i = -1e3 ; i <= 1e3 ; i++)
		{
			for(int j = -1e3 ; j <= 1e3 ; j++)
			{
				int v = i*i*i*i*i;
				int u = j*j*j*j*j;

				if(v - u == x)
				{
					cout<<i<<" "<<j;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 8288
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();
        if(a <= k){
            k -= a;
            a = 0;
            b -= k;
            if(b < 0)
                b = 0;
        }else{
            a -= k;
        }
        System.out.println(a+" "+b);
    }
}

Measured memory_bytes: 21844
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader(); 
        int n = r.i();
        int[][] count = new int[n][26];
        for(int i = 0; i < n; i++){
            String s = r.s();
            int len = s.length();
            for(int j = 0; j < len; j++)
                count[i][s.charAt(j)-'a']++;
        }
        char[] ans = new char[60];
        int end = 0;
        for(char c = 'a'; c < 'z'+1; c++){
            int num = count[0][c-'a'];
            for(int i = 1; i < n ; i++)
                num = Math.min(num, count[i][c-'a']);
            for(int i = 0; i < num; i++)
                ans[end++] = c;
        }
        println(String.valueOf(ans, 0, end));
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 21332
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;	
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,M;
  cin >>N>>M;
  vector<bool> bad(N+1);
  vector<int> vec(N+2);
  
  for(int i=0;i<M;i++){
    int a;cin>>a;
    bad[a]= true;
  }
  const int mod = 1000000007;
  vec[N]=1;
  for(int i=N-1;i>=0;i--){
    if(bad[i]) {
      vec[i]=0;
      continue;
    }
    vec[i] = (vec [i+1]+vec[i+2])%mod;
  }
    cout << vec[0]<<endl;
}


Measured memory_bytes: 640
from collections import deque

N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]

graph = [[] for _ in range(N * N)]
inserted = [0] * (N * N)
for i, nodes in enumerate(X):
    for j1, j2 in zip(nodes[:-1], nodes[1:]):
        n1 = max(i, j1 - 1) * N + min(i, j1 - 1)
        n2 = max(i, j2 - 1) * N + min(i, j2 - 1)
        graph[n1].append(n2)
        inserted[n2] += 1

dist = [0] * (N * N)
visited = [False] * (N * N)
for i in range(N):
    visited[i * N + i] = True

q = deque()
for i, v in enumerate(inserted):
    if v == 0:
        q.append(i)
        visited[i] = True
        dist[i] = 1

while q:
    u = q.popleft()
    for v in graph[u]:
        if visited[v]:
            continue

        inserted[v] -= 1
        if inserted[v] == 0:
            visited[v] = True
            dist[v] = dist[u] + 1
            q.append(v)

print(max(dist) if all(visited) else -1)


Measured memory_bytes: 197656
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = Integer.valueOf(scan.next());
        int[] ns = new int[n];
        for(int i=0;i<n;i++) {
        	ns[i] = Integer.valueOf(scan.next());
        }
        int change = 0;
        int minj=0;
        int cnt=0;
        for(int i=0;i<n;i++) {
        	minj = i; 
        	for(int j=i;j<n;j++) {
        		if(ns[j]<ns[minj]) {
        			minj = j;
        		}
        	}
        	if(minj!=i) {
	        	change = ns[minj];
	        	ns[minj] = ns[i];
	        	ns[i] = change;
	        	cnt++;
        	}
        }
        for(int i=0;i<n-1;i++) {
        	System.out.print(ns[i]+" ");
        }
        System.out.println(ns[n-1]);
        System.out.println(cnt);
        scan.close();
    }
}


Measured memory_bytes: 26356
def main():
    r,g,b=map(int,input().split())
    k=int(input())
    while(k>0):
        if(g<=r):
            g=g<<1
            k-=1
        elif(b<=g):
            b=b<<1
            k-=1
        else:
            break;
    if(r<g and g<b):
        print('Yes')
    else:
        print('No')
    
main()


Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,W,V,w[101],v[101],dp[101][100001];
signed main(){
	cin>>n>>W;
	for(int i=1;i<=n;i++)	cin>>w[i]>>v[i],V+=v[i];
	memset(dp,0x3f3f3f3f,sizeof(dp));
	for(int i=0;i<=n;i++)	dp[i][0]=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=V;j++){
			dp[i][j]=dp[i-1][j];
			if(j-v[i]>=0)
				dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
		}
	for(int i=V;i>=0;i--)
		if(dp[n][i]<=W){
			cout<<i<<endl;
			return 0;
		}
}

Measured memory_bytes: 79104
n, m = map(int, input().split())
x = list(map(int, input().split()))
if m <= n:
  print(0)
  exit()
x.sort()
diff = []
for i in range(m-1):
  diff.append(x[i+1] - x[i] - 1)
diff.sort(reverse=True)
print(x[-1] - x[0] + 1 - sum(diff[:n-1]) - n)

Measured memory_bytes: 13968
// @ts-ignore
const main = (input: string) => {
  const list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];

  console.log(list[Number(input) - 1]);
}

// *この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

const double PI = 3.141592653589;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A,B,H,M; cin >> A >> B >> H >> M;
  double lang, sang;
  ll now = H * 60 + M;
  lang = (double)(now * PI / 360);  
  sang = (double)(M*PI/30);
  double ang = abs(lang-sang);
  double ans = sqrt((A*A+B*B-2*A*B*cos(ang)));
  cout << setprecision(12) << ans;
  return 0;
}


Measured memory_bytes: 4208
#include <stdio.h>
int gcd(int a, int b);
int main()
{
    long long a, b,g, lcd;
    while(scanf("%lld %lld",&a, &b)==2)
    {
    g =gcd(a,b);
    lcd= (a*b)/g;
    printf("%lld %lld\n", g, lcd);
    }
    return 0;
}
int gcd(int x, int y)
{
    int r;
    while(x!=0)
    {
        r=y%x;
        y=x;
        x=r;
        gcd(x,y);
    }


    return y;
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define MAX_N 2005
#define INF 1000000000

using namespace std;

int n,K,q,ans=INF;
int a[MAX_N];
int t[MAX_N];
int w[MAX_N];

int main()
{
	scanf("%d%d%d",&n,&K,&q);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		int cnt=0,tot=0;
		for(int j=1;j<=n+1;j++)
		{
			if(a[j]<a[i])
			{
				if(cnt>=K)
				{
					nth_element(t+1,t+cnt-K+1,t+1+cnt);
					for(int k=1;k<=cnt-K+1;k++) w[++tot]=t[k];
				}
				cnt=0;
			}
			else t[++cnt]=a[j];
		}
		if(tot>=q)
		{
			nth_element(w+1,w+q,w+1+tot);
			ans=min(ans,w[q]-a[i]);
		}
	}
	printf("%d\n",ans);
}


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

int main(){
    ll n;
    cin >> n;
    ll ans = n*(n+1)*(n+2)/6;
    rep(i, n-1) {
        ll u, v;
        cin >> u >> v;
        if (u>v) swap(u, v);
        ans -= (u)*(n-v+1);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
#include <string.h>
#include<algorithm>
using namespace std;

int main(void){
int A,B;
  scanf("%d %d",&A,&B);
if((A<1 || A>9) || (B<1 || B>9) ){
printf("-1");

}
else{
printf("%d",A*B);
	
}
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    int n;
    int a[];

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = new int[n];
        for (int i = 0; i < n-1; i++) {
            a[i] = sc.nextInt();
        }
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        int[] s = new int[n];
        Arrays.fill(s, 0);
        for (int i = 0; i < a.length-1; i++) {
            s[a[i] - 1]++;
        }
        for (int i = 0; i < s.length; i++) {
            System.out.println(s[i]);            
        }
    }
}

Measured memory_bytes: 70228
n=int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]

zoro=0
aru=0
for i in range(n):
    if x[i]==y[i]:
        zoro+=1
        if zoro==3:
            aru=1
    else:
        zoro=0

if aru==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9192
s = input()

def f():
    p0, p1 = ' ', s[0]
    for i, p2 in enumerate(s[1:] + '_'):
        if p1 == p2:
            print(i + 1, i + 2)
            return
        if p0 == p2:
            print(i, i + 2)
            return
        p0, p1 = p1, p2
    print(-1, -1)
    return
f()

Measured memory_bytes: 3188
($A, $B) = split(/\s+/, <>);

# A=>K and B=>K ==> A-K = B-K ==> A = B
# A=>K and B<K  ==> A-K = K-B ==> A+B = 2K
# A<K  and B=>K ==> K-A = B-K ==> A+B = 2K
# A<K  and B<K  ==> K-A = K-B ==> A = B

if ($A == $B) {
    $K = 0;
} elsif (($A + $B) % 2 != 0) {
    $K = "IMPOSSIBLE";
} else {
    $K = ($A + $B) / 2;
}
print "$K\n";


Measured memory_bytes: 640
s = gets.chomp

#LまたはR
pre = ""

result = []

ss = s.split("LR")
last = ss.size - 1
ss.each_with_index do |si,i|
  if i == 0 && i == last
    si = si
  elsif i == 0 && i != last
    si = si + "L"
  elsif i == last
    si = "R" + si
  else
    si = "R" + si + "L"
  end

  size = si.size
  flug = 0
  si.chars.each_with_index do |c,i|
    if i == 0
      next
    end

    if c == "L" && flug < 2
      flug += 1
      result << (size + (i % 2)) / 2
    else
      result << 0
    end
  end
  if flug == 1
    result << size.+(1) / 2
  else
    result << 0
  end
end

puts result*" "





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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    for(int i = a; i <= b; ++i) {
        if (!(c % i)) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>

int a[105];

int main(){

	int N;
	scanf("%d",&N);

	int i,j;

	for(i=0;i<N;i++){
	scanf(" %d",&a[i]);
	}

	int ans=1<<30;

	for(i=-100;i<=100;i++){
		int cost=0;
		for(j=0;j<N;j++){
		cost+=(i-a[j])*(i-a[j]);
		}
		if(ans>cost){ans=cost;}
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize(2)
#include <cstdio>
using namespace std;

int a[10],sum;

inline void read(int& sum)
{
    char ch; sum=0;
    bool f=true;
    ch=getchar();
    while((ch>'9'||ch<'0')&&ch!='-') ch=getchar();
    if(ch=='-') f=false,ch=getchar();
    while(ch<='9'&&ch>='0')
        sum=(sum<<3)+(sum<<1)+ch-'0',ch=getchar();
    sum=(f?sum:-sum);
}

int main()
{
	for(int i=1;i<=9;i++) {
		read(a[i]);
		sum+=a[i];
	}
	if(sum==(a[1]+a[5]+a[9])*3) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
import sys
inputs = sys.stdin.readlines()

from heapq import heappush, heappop
N, M = map(int, inputs[0].split())
A = sorted(list(map(int, inputs[1].split())))

queue = []
for a in A:
    heappush(queue, -a)

for _ in range(M):
    heappush(queue, -(-heappop(queue) // 2))
print(-sum(queue))

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

int n;
string s;
map<string, int> v;

bool check(int x) {
    v.clear();
    for(int i = 1; i <= n - x; i++) {
        string a = s.substr(i, x);
        if(v[a]) {
            if(i - v[a] >= x) return true;
        }
        else v[a] = i;
    }
    return false;
}

int main() {
    cin >> n >> s;
    s = " " + s;
    n++;
    int l = 0, r = n / 2;
    while(l <= r) {
        int m = (l + r) >> 1;
        if(check(m)) l = m + 1;
        else r = m - 1;
    }
    cout << r << endl;
}

Measured memory_bytes: 6668
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, v[21], c[21], ans;

int main(){
	cin >> n;
	ans = 0;
	for(ll i = 1; i <= n; i++){cin >> v[i];}
	for(ll i = 1; i <= n; i++){cin >> c[i];}
	
	for(ll i = 1; i <= n; i++){
		if(v[i]-c[i] >= 0){
			ans += (v[i]-c[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int l = sc.nextInt();
		UnionFindTree kTree = new UnionFindTree(n);
		for (int i = 0; i < k; i++) {
		    kTree.unite(sc.nextInt() - 1, sc.nextInt() - 1);
		}
		UnionFindTree lTree = new UnionFindTree(n);
		for (int i = 0; i < l; i++) {
		    lTree.unite(sc.nextInt() - 1, sc.nextInt() - 1);
		}
		HashMap<Long, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
		    long key = kTree.find(i) * (long)n + lTree.find(i);
		    if (map.containsKey(key)) {
		        map.put(key, map.get(key) + 1);
		    } else {
		        map.put(key, 1);
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
		    if (i != 0) {
		        sb.append(" ");
		    }
		    long key = kTree.find(i) * (long)n + lTree.find(i);
		    sb.append(map.get(key));
		}
		System.out.print(sb);
   }
   
   static class UnionFindTree {
       int[] parents;
       
       public UnionFindTree(int size) {
           parents = new int[size];
           for (int i = 0; i < size; i++) {
               parents[i] = i;
           }
       }
       
       public int find(int x) {
           if (parents[x] == x) {
               return x;
           } else {
               return parents[x] = find(parents[x]);
           }
       }
       
       public void unite(int x, int y) {
           int xx = find(x);
           int yy = find(y);
           if (xx == yy) {
               return;
           }
           parents[xx] = yy;
       }
   }
}




Measured memory_bytes: 110920
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;

ll INF = 10000000000007;

int main() {
	int n;
	ll w;
	cin >> n >> w;
	vector<ll> W(n);
	vector<int> V(n);
	rep(i, n) cin >> W[i] >> V[i];
	vector<vector<ll>> dp(n+1, vector<ll>(1005 * n+1,INF));
	dp[0][0] = 0;
	rep(i, n) {
		for (int j = 1005 * n; j >= 0; j--) {
            if(j>=V[i]){
			   dp[i + 1][j] = min(dp[i][j], dp[i][j - V[i]] + W[i]);
            }
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
		}
	}
	int ans=0;
    for(int i=1005*n;i>=0;i--){
      if(dp[n][i]<=w){
        cout<<i<<endl;
        return 0;
      }
    }
  cout<<0<<endl;
}

Measured memory_bytes: 80640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    ll a=0;
    ll b=0;
    ll c=0;
    ll d=0;
    ll e=0;
    rep(i,n){
        string s;
        cin >> s;
        if(s[0]=='M'){a++;}
        if(s[0]=='A'){b++;}
        if(s[0]=='R'){c++;}
        if(s[0]=='C'){d++;}
        if(s[0]=='H'){e++;}
    }
    ll ans = 0;
    ans += a*b*c;
    ans += a*b*d;
    ans += a*b*e;
    ans += a*c*d;
    ans += a*c*e;
    ans += a*d*e;
    ans += b*c*d;
    ans += b*c*e;
    ans += b*d*e;
    ans += c*d*e;
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll);
ll mod_fact(ll, ll);
ll mod_inv(ll, ll);
ll gcd(ll, ll);
//
int main(){
    int n;
    cin >> n;
    int a[n + 1];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    vector<bool> flag(n + 1);
    int total = 0;
    for(int i = n; i >= 1; i--){
        int cnt = 0;
        for(int j = 2; j <= n / i; j++){
            if(flag[i * j]) cnt++;
        }
        flag[i] = (a[i] - cnt) % 2;
        if(flag[i]) total++;
    }
    cout << total << " ";
    for(int i = 1; i <= n; i++){
        if(flag[i]) cout << i << " ";
    }
}

Measured memory_bytes: 1792