akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map> 
#define INF 0x3f3f3f3f
#define int long long
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int maxn=2e5+6;
const int mod=1e9+7;
const double pi=acos(-1.0);
int n,m;
int read(){        
    int s = 0, f = 1;        
    char ch = getchar();        
    while(!isdigit(ch)) {        
        if(ch == '-') f = -1;        
        ch = getchar();        
    }        
    while(isdigit(ch)) {        
        s = s * 10 + ch - '0';        
        ch = getchar();        
    }        
    return s * f;        
}        
void write(int x){        
    if(x < 0) {        
        putchar('-');        
        x = -x;        
    }        
    if(x > 9)        
        write(x/10);        
    putchar(x % 10 + '0');        
    return;        
}   
signed main(){
	cin>>n;
	n=n%10;
	if(n==2||n==4||n==5||n==7||n==9)
	   cout<<"hon"<<endl;
	if(n==0||n==1||n==6||n==8)
	   cout<<"pon"<<endl;
	if(n==3)
	   cout<<"bon"<<endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int a[100010];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    ans += a[i] - 1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import itertools

def main(L):
    ans = 0
    for pair in itertools.combinations(L, 3):
        if len(set(pair)) < 3:
            continue
        lines = list(pair)
        a = max(lines)
        lines.remove(a)
        b, c = lines
        if a < b + c:
            ans += 1
    return ans

if __name__ == '__main__':
    N = int(input())
    L = list(map(int, input().split()))
    ans = main(L)
    print(ans)



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

int main() {
	int n;
	cin >> n;
	string s[n];
	for (int i = 0;i<n;i++)cin >> s[i];
	for (int i = 0;i<n;i++) {
		for (int j = 0;j<i;j++) {
			if (s[i] == s[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
		if (i + 1 < n) {
			if (s[i][s[i].size() - 1] != s[i + 1][0]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)

int n;
int mat[100][100];
int d[100];

void solve()
{
    fill(begin(d), end(d), -1);

    queue<int> q;
    q.push(0);
    d[0] = 0;

    while(!q.empty()) {
        int i = q.front(); q.pop();
        REP(j, n) {
            if(!mat[i][j]) continue;
            if(d[j] != -1) continue;

            d[j] = d[i] + 1;
            q.push(j);
        }
    }
}

int main()
{
    cin >> n;

    REP(i, n) {
        REP(j, n) {
            mat[i][j] = 0;
        }
    }

    REP(_, n) {
        int u, k;
        cin >> u >> k;

        REP(_, k) {
            int v;
            cin >> v;
            mat[u-1][v-1] = 1;
        }
    }

    solve();

    REP(i, n) {
        cout << i+1 << " " << d[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
bool isPrime(int x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int const INF = 1001001001;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> to[100005];
    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a;    --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int> d(n,INF);
    vector<int> pre(n,-1);
    queue<int> q;
    d[0] = 0;
    q.push(0);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int u : to[v]){
            if(d[u]!=INF)
                continue;
            d[u]++;
            pre[u] = v;
            q.push(u);
        }
    }
    puts("Yes");
    for(int i=1;i<n;i++){
        cout << pre[i]+1 << endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

ll ppow(ll a,ll b){
	a %= MOD;
	ll res = 1;
	while(b){
		if(b & 1)res = (res*a)%MOD;
		a = (a*a)%MOD;
		b >>= 1;
	}
	return res;
}

map<ll,int>prime_factor(ll n){
	map<ll,int> res;
	for(ll i = 2;i*i <= n;i++){
		while(n%i == 0){
			res[i]++;
			n /= i;
		}
	}
	if(n != 1)res[n]++;
	return res;
}

int main(){


  
	int n;
  cin >> n;
  vector<ll> v(n);
	map<int,int> mp;
	rep(i,n){
		cin >> v[i];
		auto mpp = prime_factor(v[i]);
		for(auto &p : mpp)mp[p.first] = max(mp[p.first],p.second);
	}
	ll A=1;
	for(auto &p : mp){
		(A*=ppow(p.first,p.second))%=MOD;
	}
	ll ans = 0;
	rep(i,n){
		(ans+=A*ppow(v[i],MOD-2))%=MOD;
	}
	cout << ans << endl;
  

  
  



  

  return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<sstream>
#include<stack>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define req(i,n) for(int i = 1;i <= n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define fix  fixed << setprecision(10)
const int MOD = 1000000007;
const ll INF = (1LL << 60);
string s; ll n, m, k =0, q = 0, ans, sum;
ll r = 0, g = 0; int a[26];
int main() {
    string s; cin >> s; char c = s[0];
    req(i, s.size() -1) {
        if (c != s[i]) {
            c = s[i];
            k++;
        }
    }
    cout << k << endl;
}

Measured memory_bytes: 512
def solve():
    N = int(input())
    A = [int(i) for i in input().split()]

    InsertionSort(N, A)

def InsertionSort(N, A):
    print(*A)
    for i in range(1, N):
        v = A[i]
        for j in range(i - 1, -1, -1):
            if A[j] > v:
                A[j + 1] = A[j]
            else:
                A[j + 1] = v
                break
        else:
            A[0] = v

        print(*A)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 8048
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define got(container,num) get<num-1>(container)
using namespace std;
const int INF=LLONG_MAX/2;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+10;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;
umap<int,int>f[maxn],vis[maxn],tt[maxn];
main()
{
    IOS
    int k;
    cin>>n>>m>>k;
//    int f[n+5][m+5]={0};
//    int vis[n+5][m+5]={0};
    fu(i,1,4)cin>>a[i];
    ans=-1;
    queue<tuple<int,int,int>>Que;
    Que.push(mk(a[1],a[2],0));
    fun(i)
    {
        fum(j)
        {
            char x;
            cin>>x;
            if(x=='@')f[i][j]=1;
        }
    }
//    if(f[a[3]][a[4]]){
//        out(-1)
//        return 0;
//    }
    while(!Que.empty())
    {
        auto now=Que.front();
        int X=got(now,1),Y=got(now,2),Time=got(now,3);
        Que.pop();
        if(X==a[3] && Y==a[4]){
            ans=Time;
            break;
        }
        fu(i,0,3)
        {
            fu(j,1,k)
            {
                int x=X+dx[i]*j,y=Y+dy[i]*j;
                if(f[x][y] or x<=0 or x>n or y<=0 or y>m or (vis[x][y] && Time+1>tt[x][y]))break;
                if(!vis[x][y])
                {
                    Que.push(mk(x,y,Time+1));
                    tt[x][y]=Time+1;
                    vis[x][y]=1;
                }
            }
        }
    }
    out(ans)
    return 0;
}


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

int main(){
  int n,m,t=0;
  cin >> n >> m;
  
  int mc[31] = {};
  
  for(int i=0,tmp,fo; i<n; i++){
    cin >> tmp;
    for(int j=0; j<tmp; j++){
      cin >> fo;
      mc[fo-1]++;
    }
  }
  for(int i=0; i<m; i++){
    if(mc[i] == n){
      t++;
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
const int inf = 1000000000; // 10^9
int main()
{
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, N) cin >> X[i];
    int ans = inf;
    for (int i = 1; i <= 100; i++)
    { // L やR の計算が不要
        int cost = 0;
        rep(j, N) cost += (X[j] - i) * (X[j] - i);
        ans = min(ans, cost);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int main(void) {
    int N;
    cin>>N;

    vector<Int> A(N);
    Int sum = 0;
    Int minA = INT_MAX;
    int eo = 0;
    bool flag = false;
    for(int i = 0;i < N;i++) {
        cin>>A[i];
        if(A[i] < 0) {
            eo++;
        } else if(A[i] == 0) {
            flag = true;
        }
        minA = min(minA,abs(A[i]));
        sum += abs(A[i]);
    }

    if(eo % 2 == 0 || flag) {
        cout<<sum<<endl;
    } else {
        cout<<sum-2*minA<<endl;
    }

    return 0;
}




Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[][] A = new Integer[N][2];
		for (int i = 0; i < A.length; i++) {
			A[i][0] = sc.nextInt();
			A[i][1] = i;
		}
		Arrays.sort(A, (x, y) -> {
			if (x[0].compareTo(y[0]) > 0) {
				return 1;
			} else if (x[0].compareTo(y[0]) < 0) {
				return -1;
			} else {
				return 0;
			}
		});
		StringBuilder sb = new StringBuilder();
		int first = A[A.length - 1][0];
		int second = A[A.length - 2][0];
		for (int i = 0; i < A.length; i++) {
			if (i != A[A.length - 1][1]) {
				sb.append(first);
			} else {
				sb.append(second);
			}
			sb.append("\n");
		}
		System.out.println(sb.toString());
		sc.close();
	}
}

Measured memory_bytes: 103228
#include<cstdio>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
using namespace std;
const int N=1e5+11;
int n,k,tot,ans;
int a[N],nxt[N],las[N],to[N],dis[N];
inline void add(int x,int y){
	nxt[++tot]=las[x];
	las[x]=tot;
	to[tot]=y;
}
inline void dfs(int x){
	dis[x]=1;
	for(register int e=las[x];e;e=nxt[e]){
		dfs(to[e]);
		dis[x]=max(dis[x],dis[to[e]]+1);
	}
	if(dis[x]>=k&&a[x]>1)
		++ans,dis[x]=0;
}
int main(){
	scanf("%d%d",&n,&k);
	rep(i,1,n)
		scanf("%d",a+i);
	if(a[1]!=1)++ans,a[1]=1;
	rep(i,2,n)
		add(a[i],i);
	dfs(1);
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

#define fileInput(problemName) freopen ((string(problemName) + ".inp").c_str(), "r", stdin);freopen ((string(problemName) + ".out").c_str(), "w", stdout);
#define ll long long

const ll inf = 1e9 + 7;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 7;

int n, a[N], f[N];

main() {
    //fileInput("frog-1");
    cin >> n;
    for (int i = 1; i <= n; i++) {
    	cin >> a[i];
    }
    f[1] = 0;
    f[2] = abs(a[2] - a[1]) + f[1];
    for (int i = 3; i <= n; i++) {
    	f[i] = min(f[i - 2] + abs(a[i] - a[i - 2]), f[i - 1] + abs(a[i] - a[i - 1]));
    }
    cout << f[n] << endl;
}

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

int main(){
    int N; cin >> N;
    vector<int> v;
    for(int i=0; i<N; ++i){
        int a; cin >> a;
        v.push_back(a);
    }
    
    if(N%2==0){
        for(int i=N-1; i>=1; i-=2){
            if(i!=N-1) cout << ' ';
            cout << v[i];
        }
        for(int i=0; i<N; i+=2){
            cout << ' ' << v[i];
        }
        cout << endl;
    }else{
        for(int i=N-1; i>=0; i-=2){
            if(i!=N-1) cout << ' ';
            cout << v[i];
        }
        for(int i=1; i<N; i+=2){
            cout << ' ' << v[i];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3060
#include <stdio.h>
#define DEBUG

int main(void){
	int n;
	scanf("%d", &n);
	int a[n];
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	int b[n];
	for(int i = 0; i < n; i++){
		b[i] = 0;
	}
	b[0] = 1;
	int i = 1;
	int ans = 0;
	while(1){
		ans++;
		i = a[i-1];
		if(i == 2){
			break;
		}
		if(b[i-1] > 1){
			printf("-1\n");
			return 0;
		}
		b[i-1]++; 
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String b = sc.next();

        String result = "A";
        if ("A".equals(b)) {
            result = "T";
        } else if ("C".equals(b)) {
            result = "G";
        } else if ("G".equals(b)) {
            result = "C";
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;

//gcd(int)
int gcd(int a, int b) {
    return b ? gcd(b, a%b) : a;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    B[0] = A[0];
    C[N - 1] = A[N - 1];
    for (int i = 1; i < N; i++)
    {
        B[i] = gcd(B[i - 1], A[i]);
        C[N - i - 1] = gcd(C[N - i], A[N - i - 1]);
    }
    int M = 0;
    for (int i = 0; i < N; i++)
    {
        if (i == 0) {
            M = max(M, C[1]);
        }
        else if (i == N - 1) {
            M = max(M, B[N - 2]);
        }
        else {
            M = max(M, gcd(B[i - 1], C[i + 1]));
        }
    }
    cout << M << endl;
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	deque<int>qwe;
	cin >> n;
	int tmp;
	cin >> tmp;
	qwe.push_back ( tmp );
	for ( int j = 1; j < n; j++ ) {
		cin >> tmp;
		if ( j % 2 == 0 )
			qwe.push_back ( tmp );
		else qwe.push_front ( tmp );
	}
	if ( n % 2 == 0 ) {
		while ( !qwe.empty() ) {
			tmp = qwe.front();
			qwe.pop_front();
			cout << tmp << " ";
		}
	}
	else{
		while ( !qwe.empty() ) {
			tmp = qwe.back();
			qwe.pop_back();
			cout << tmp << " ";
		}
	}
	return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>
int main(void)
{
    int minute, hour, second, sec;
    scanf("%d", &second);

    hour = second / 3600;
    minute = second % 3600 /60;
    sec = second % 3600 % 60;

    printf("%d:%d:%d\n", hour, minute, sec);

    return 0;
}


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

int main(){
   int A, B, C, X, Y;
   cin >> A >> B >> C >> X >> Y;
    int ans = 1000000000;
   for(int i = 0; i <= 2 * max(X, Y); i += 2) {
       int a = i / 2;
       int b = i / 2;
       int a1 = X - a;
       int a2 = Y - b;
       if(a1 < 0) a1 = 0;
       if(a2 < 0) a2 = 0;
    if(ans > C * i + a1 * A + a2 * B) ans = C * i + a1 * A + a2 * B;
       }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

  string str;
  cin>>str;
  int n=str.length();
  int mod=2019;
  int mm[2020]={0};
  mm[0]=1;
  int ans=0;
  int rem=0;
  int x=1;
  for(int i=n-1;i>=0;i--)
  {
    rem=(rem+(str[i]-'0')*x)%mod;
    x=(x*10)%mod;
    ans+=mm[rem];
    mm[rem]++;
  }
  cout<<ans;

// -------------------------------------Code ends here------------------------------------------------------------------
    clock_t clk;
  clk = clock();

    clk = clock() - clk;
  cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
  return 0;
}


Measured memory_bytes: 3980
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<stdio.h>
#include<sys/time.h>
#define ck 26

unsigned long long seed;

unsigned long long xorshift(){
  seed=seed^(seed<<13);
  seed=seed^(seed>>7);
  seed=seed^(seed<<17);
  return seed;
}

int d;
int c[32];
int s[512][32];
int res[512];

int eval(){
  int i,j,lc[32],r=0;
  for(i=1;i<=ck;i++){lc[i]=-1;}
  for(i=0;i<d;i++){
    r+=s[i][res[i]];
    lc[res[i]]=i;
    for(j=1;j<=ck;j++){
      r-=c[j]*(i-lc[j]);
    }
  }
  return r;
}

int sum(int x){
  return (x*(x+1))/2;
}

int delq(int tg,int x){
  if(res[tg]==x){return 0;}
  int r,i;
  int bfb=-1,bff=d,afb=-1,aff=d;
  r=s[tg][x]-s[tg][res[tg]];

  for(i=tg-1;i>=0;i--){
    if(res[i]==res[tg]){bfb=i;break;}
  }
  for(i=tg+1;i<d;i++){
    if(res[i]==res[tg]){bff=i;break;}
  }

  for(i=tg-1;i>=0;i--){
    if(res[i]==x){afb=i;break;}
  }
  for(i=tg+1;i<d;i++){
    if(res[i]==x){aff=i;break;}
  }
  
  r+=c[res[tg]]*sum((tg-bfb)-1);
  r+=c[res[tg]]*sum((bff-tg)-1);
  r-=c[res[tg]]*sum((bff-bfb)-1);

  r-=c[x]*sum((tg-afb)-1);
  r-=c[x]*sum((aff-tg)-1);
  r+=c[x]*sum((aff-afb)-1);
  return r;
}

void getperm(int n,int p[]){
  int i,tg,mem;
  for(i=0;i<n;i++){
    p[i]=i;
  }
  for(i=n-1;i>=1;i--){
    tg=(xorshift()%(i+1));
    mem=p[tg];
    p[tg]=p[i];
    p[i]=mem;
  }
}

int main(){
  long long stt,nt;
  struct timeval tv;
  gettimeofday(&tv, NULL);
  seed=(tv.tv_sec*1000000+tv.tv_usec);
  stt=seed;
  int i,j,q,r,tg,x,p[32],dv[32];
  int tgpm[512];
  scanf("%d",&d);
  for(i=1;i<=ck;i++){scanf("%d",&c[i]);}
  for(i=0;i<d;i++){
    for(j=1;j<=ck;j++){
      scanf("%d",&s[i][j]);
    }
  }
  for(i=0;i<d;i++){
    res[i]=(i%ck)+1;
  }
  r=eval();
  q=0;
  getperm(d,tgpm);
  while(1){
    tg=tgpm[q];
    for(i=1;i<=ck;i++){dv[i]=delq(tg,i);}
    getperm(ck,p);
    for(i=0;i<ck;i++){
      if(dv[res[tg]]<=dv[p[i]+1]){res[tg]=p[i]+1;}
    }
    q++;
    if(q==d){
      getperm(d,tgpm);
      q=0;
      gettimeofday(&tv, NULL);
      nt=(tv.tv_sec*1000000+tv.tv_usec);
      if((nt-stt)>=1990000){break;}
    }
  }
  for(tg=0;tg<d;tg++){
    for(i=1;i<=ck;i++){dv[i]=delq(tg,i);}
    getperm(ck,p);
    for(i=0;i<ck;i++){
      if(dv[res[tg]]<=dv[p[i]+1]){res[tg]=p[i]+1;}
    }
  }
  for(i=0;i<d;i++){
    printf("%d\n",res[i]);
  }
  return 0;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long 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;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        ll num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    int N,M,R;
    cin >> N >> M >> R;

    vector<int> r(R);
    REP(i,R) {
        cin >> r[i];
        r[i]--;
    }
    sort(all(r));

    auto g = make_vec<int>(N,N);
    fill_v(g,inf);
    REP(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        g[a][b] = g[b][a] = c;
    }
    REP(i,R) g[r[i]][r[i]] = 0;

    REP(k,N) REP(i,N) REP(j,N) chmin(g[i][j],g[i][k]+g[k][j]);

    ll ans = longinf;
    do {
        ll ans_tmp = 0;
        REP(i,r.size()-1) ans_tmp += g[r[i]][r[i+1]];
        chmin(ans,ans_tmp);
    } while(next_permutation(all(r)));

    pl(ans)

    return 0;
}


Measured memory_bytes: 512
data = []

begin
  while line = $stdin.gets.chomp
    break if line == ""
    data.push(line.split(" "))
  end
rescue
end

data.each{|d|
  puts d.map{|word| word.gsub(",", "").gsub(".","") }.select{|word| word.length > 2 && word.length < 7 }.join(" ")
}

Measured memory_bytes: 8580
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
#include <string>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
vector<int> v;
class Calc
{
    // 宣言
    long long a;

    public:
        // 素因数分解
        void decompositPrime(long long a);
};

/*
 * 素因数分解
 */
void Calc::decompositPrime(long long n)
{
    // 割る数の初期値
    a = 2;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (n >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            //printf("%d * ", a);
             v.push_back(a);
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
    v.push_back(n);
    //printf("%d\n", n);
}

int main(){
    //std::stack<int> stack;
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int cnt = min(k, (int)log(200000)+1);
    for(int i = 0; i < k; i++){
        vector<int> b(n,0);
        for(int j = 0; j < n; j++){
            int left = max(0, j-a[j]);
            int right = min(n-1, j+a[j]);
            b[left] ++;
            if(right < n-1){
                b[right+1] --;
            }
        }
        for(int j = 1; j < n; j++){
            b[j] += b[j-1];
        }
        if(a == b){
            break;
        }
        a=b;
    }
    for(int i = 0; i < n-1; i++){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    //cout << ans << endl;
    return 0;
}





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

using namespace std;
using ll = long long int;

int main()
{
	int n, m;
	cin >> n >> m;

	vector<int> count(n);
	vector<bool> aced(n);
	int ac = 0, ng = 0;
	for (int i = 0; i < m; i++)
	{
		int p;
		string s;
		cin >> p >> s;
		p--;

		if (s == "AC" && !aced[p])
		{
			ac++;
			ng += count[p];
			aced[p] = true;
		}
		else
		{
			count[p]++;
		}
	}

	cout << ac << " " << ng << endl;
}

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

using ll = long long;
using P = pair<int, int>;
#define rep1(i,n) for (int i=1; i<=n; i++)
#define rep0(i,n) for (int i=0; i<n; i++)
#define zarray(x,n) x[n+1]; rep1(i,n) {x[i]=0;} 

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    string ans = "No";
    for (;;) {
        c -= b;
        if (c <= 0) {
            ans = "Yes";
            break;
        }
        a -= d;
        if (a <= 0) {
            break;
        }
    }
    cout << ans << endl;
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a < b) cout << "a" << " < " << "b" << endl;
    if (a > b) cout << "a" << " > " << "b" << endl;
    if (a == b) cout << "a" << " == " << "b" << endl; 
    return 0;
}


Measured memory_bytes: 3060
"use strict"

const main =(input)=>{
  const array =input.split(" ")
  const N = array[0]-0
  const A = array[1]-0
  const B = array[2]-0
  
  let result = 0;
  for (let i=0; i<=N; i++){
   const sum= i.toString().split("").reduce( (a,b)=>(a-0)+(b-0) )
    if (A<=sum && B>=sum) result+=i ;
  }
  console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 9744
import functools
import os
import sys

sys.setrecursionlimit(10000)
INF = float('inf')


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        ret = fn(*args, **kwargs)
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        print(ret)
        return ret

    return wrapper


# @debug
# @functools.lru_cache(maxsize=None)
# def solve(idx, abc=3):
#     """
#     S[0:idx+1] の ABC 数の数
#     abc=2 なら AB 数、abc=1 なら A 数、abc=0 なら今までのパターン数
#     :param idx:
#     :param abc:
#     :return:
#     """
#     if idx < 0:
#         return 1 if abc == 0 else 0
#     c = S[idx]
#     if 1 <= abc <= 3:
#         if c == '0ABC'[abc]:
#             return (solve(idx - 1, abc=abc) + solve(idx - 1, abc=abc - 1)) % MOD
#         elif c == '?':
#             return (solve(idx - 1, abc=abc) * 3 + solve(idx - 1, abc=abc - 1)) % MOD
#         else:
#             return (solve(idx - 1, abc=abc)) % MOD
#     elif abc == 0:
#         if c == '?':
#             return (solve(idx - 1, abc=0) * 3) % MOD
#         else:
#             return (solve(idx - 1, abc=0)) % MOD


S = input()
MOD = 10 ** 9 + 7
# print(solve(len(S) - 1) % MOD)

# ↑の DP 版
# dp[i][3]: S[0:i] の ABC 数
# dp[i][2]: S[0:i] の AB 数
# dp[i][1]: S[0:i] の A 数
# dp[i][0]: S[0:i] の組み合わせ数
# dp = np.empty((len(S) + 1, 4))
# dp[0][0] = 1
# for i in range(len(S)):
#     c = S[i]
#     if c == '?':
#         dp[i + 1][0] = dp[i][0] * 3 % MOD
#     else:
#         dp[i + 1][0] = dp[i][0] % MOD
#     for abc in [1, 2, 3]:
#         if c == '0ABC'[abc]:
#             dp[i + 1][abc] = (dp[i][abc] + dp[i][abc - 1]) % MOD
#         elif c == '?':
#             dp[i + 1][abc] = (dp[i][abc] * 3 + dp[i][abc - 1]) % MOD
#         else:
#             dp[i + 1][abc] = dp[i][abc] % MOD
#     # dp[i + 1, :] %= MOD
# print(int(dp[len(S), 3]))


# ↑の配列再利用版
dp = [0] * 4
dp[0] = 1
for i in range(len(S)):
    c = S[i]
    for abc in [3, 2, 1]:
        if c == '0ABC'[abc]:
            dp[abc] = (dp[abc] + dp[abc - 1]) % MOD
        elif c == '?':
            dp[abc] = (dp[abc] * 3 + dp[abc - 1]) % MOD
    if c == '?':
        dp[0] = dp[0] * 3 % MOD
print(int(dp[3]))


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  vi32 indices(n);
  iota(all(indices), 0);
  vi32 ord(n);
  iota(all(ord), 0);
  sort(all(ord), [&](int i, int j) {
    if (a[i] != a[j]) return a[i] < a[j];
    return indices[i] < indices[j];
  });
  pqdesc<pair<int, int>> q;
  rep(i, n) {
    q.emplace(a[i], i);
  }
  vi64 ans(n);
  int cnt = 0;
  int ma = q.top().first;
  do {
    int idx;
    while (sz(q) && q.top().first == ma) {
      cnt += 1;
      idx = q.top().second;
      q.pop();
    }
    int next = 0;
    if (sz(q)) {
      next = q.top().first;
    }
    ans[idx] += (i64) (ma - next) * cnt;
    if (sz(q)) {
      ma = q.top().first;
      cnt -= 1;
      q.emplace(ma, idx);
    }
  } while (sz(q));
  rep(i, n) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
char a;
ll h,w,k=0,ans=0;
ll  kumi[160000][2];
int masu[4000][4000];
bool visited[4000][4000];
void bfs(int i,int j,int k){
    if(masu[i][j]==1)kumi[k][1]++;
    else kumi[k][0]++;
    visited[i][j]=true;
 
    if(i>0&&!visited[i-1][j]&&masu[i][j]+masu[i-1][j]==1)bfs(i-1,j,k);
    if(j>0&&!visited[i][j-1]&&masu[i][j]+masu[i][j-1]==1)bfs(i,j-1,k);
    if(i<h-1&&!visited[i+1][j]&&masu[i][j]+masu[i+1][j]==1)bfs(i+1,j,k);
    if(j<w-1&&!visited[i][j+1]&&masu[i][j]+masu[i][j+1]==1)bfs(i,j+1,k);
}
main(){
    cin>>h>>w;
    for(int i=0;i<160000;i++){
        kumi[i][0]=0;
        kumi[i][1]=0;
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a;
            if(a=='.')masu[i][j]=0;
            else masu[i][j]=1;
            visited[i][j]=false;
        }
    }
 
 
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(!visited[i][j])bfs(i,j,k);
            k++;
        }
    }
 
 
    for(int i=0;i<k;i++){
        //cout<<kumi[i][0]<<" "<<kumi[i][1]<<endl;
        ans+=kumi[i][0]*kumi[i][1];
    }
 
    cout<<ans;
}

Measured memory_bytes: 27776
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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;}
ll mod= 1e9 + 7;


int main(){
  int n,x,t;
  cin >> n >>x >>t;
  int g=(n+x-1)/x;
  cout << t*g << endl;
}


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

string st;

int main(){
    cin >> st;
    for(int i=0; i<st.size(); i++)
        for(int j=i+1; j<st.size(); j++)
            if(st[i] == st[j]){
                cout << "no\n";
                return 0;
            }
    cout << "yes\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define Max 100000
#define NIL -1

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

Node T[Max];
int n, D[Max];

void print(int u){
  int i, c;

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

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

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

int rec(int u, int p){
  D[u] = p;

  if(T[u].r != NIL) rec(T[u].r, p);
  if(T[u].l != NIL) rec(T[u].l, p + 1);
}

int main(){
  int i, j, d, v, c, l, r;

  scanf("%d", &n);

  for(i = 0 ; i < n ; i++){
    T[i].p = T[i].l = T[i].r = NIL;
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d %d", &v, &d);
    for(j = 0 ; j < d ; j++){
      scanf("%d", &c);
      if(j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }

  for(i = 0 ; i < n ; i++){
    if(T[i].p == NIL) r = i;
  }

  rec(r, 0);

  for(i = 0 ; i < n ; i++) print(i);

  return 0;
}


Measured memory_bytes: 6384
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sys/types.h>
#include <unistd.h>
#include <vector>

#pragma region macros
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) _range(i, 0, n)
#define _range(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(...) _overload(__VA_ARGS__, _range, _rep, )(__VA_ARGS__)
#define _rrep(i, n) _rrange(i, n, 0)
#define _rrange(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)
#define rrep(...) _overload(__VA_ARGS__, _rrange, _rrep, )(__VA_ARGS__)
#pragma endregion macros

using namespace std;

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

using ll    = long long;
using R     = long double;
const R EPS = 1e-9L;  // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R &r) {
    return (r > EPS) - (r < -EPS);
}
inline R sq(R x) {
    return sqrt(max(x, 0.0L));
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

using pll = pair<ll, ll>;
map<ll, vector<pll>> memo;

inline ll sum(ll l, ll r, ll d) {
    const ll n = r - l;
    return 1LL * d * (l + r - 1) * n / 2LL;
}


int main(void) {
    ll n, x, d;
    cin >> n >> x >> d;
    const ll pd = abs(2LL * d);

    if (d == 0) {
        set<ll> val;
        rep(i, n + 1) val.insert(1LL * (n - i) * x - 1LL * i * x);
        cout << val.size() << endl;
        return 0;
    }


    rep(i, n + 1) {
        const ll xfix = 1LL * (n - i) * x - 1LL * i * x;
        const ll dmax = sum(i, n, d) - sum(0, i, d);
        const ll dmin = sum(0, n - i, d) - sum(n - i, n, d);

        const ll vmax   = xfix + dmax;
        const ll vmin   = xfix + dmin;
        const ll offset = (vmax % pd + pd) % pd;

        const ll imax = (vmax - offset) / pd;
        const ll imin = (vmin - offset) / pd;

        memo[offset].push_back(pll(min(imin, imax), 1));
        memo[offset].push_back(pll(max(imin, imax) + 1, -1));
    }
    

    ll ans = 0LL;
    for (auto &it: memo) {
        vector<pll> ary = it.second;
        sort(begin(ary), end(ary));

        ll cnt = 0, prv = -1;
        for (auto &elem: ary) {
            if (cnt > 0) {
                ans += elem.first - prv;
            }
            prv = elem.first;
            cnt += elem.second;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 28156
#include <iostream>

using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;

  int count5 = 0;
  int count7 = 0;

  if(a == 5)count5++;
  if(a == 7)count7++;
  if(b == 5)count5++;
  if(b == 7)count7++;
  if(c == 5)count5++;
  if(c == 7)count7++;

  if(count5 == 2 && count7 == 1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

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



Measured memory_bytes: 21716
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <map>
using namespace std;
#define pb push_back
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (n); ++i)

map<string, int> names;
pair<int, string> tree[1010];
char buf[1024], X[1024], Y[1024], R[1024];
int main()
{
	while (true) {
		char* p = strtok(fgets(buf, 1024, stdin), " ");
		int n = atoi(p);
		p = strtok(NULL, " ");
		int m = atoi(p);

		if (n == 0 && m == 0) break;

		rep(i, n) {
			fgets(buf, 1024, stdin); buf[strlen(buf)-1] = '\0';
			int c = 0;
			rep(j, strlen(buf)) { if (buf[j] != ' ') break; c++; }
			string name = string(buf).substr(c);
			tree[i] = mp(c, name);
			names[name] = i;
		}
		rep(i, m) {
			fgets(buf, 1024, stdin); buf[strlen(buf)-2] = '\0';
			sscanf(buf, "%s %*s %*s %s of %s", X, R, Y);
			string x(X), y(Y);
			int nx = tree[names[x]].first;
			int ny = tree[names[y]].first;
			if (!strcmp(R, "child")) {
				if (nx != ny + 1) puts("False");
				else {
					bool ok = false;
					for (int j = names[x] - 1; j >= 0; --j) {
						if (tree[j].second != y && tree[j].first + 1 == nx)
							break;
						if (tree[j].second == y) { ok = true; break; }
					}
					if (ok) puts("True"); else puts("False");
				}
			}
			else if (!strcmp(R, "parent")) {
				if (nx != ny - 1) puts("False");
				else {
					bool ok = false;
					for (int j = names[y] - 1; j >= 0; --j) {
						if (tree[j].second != x && tree[j].first + 1 == ny)
							break;
						if (tree[j].second == x) { ok = true; break; }
					}
					if (ok) puts("True"); else puts("False");
				}
			}
			else if (!strcmp(R, "ancestor")) {
				if (nx >= ny) puts("False");
				else {
					bool ok = false;
					for (int j = names[x] + 1; j < n; ++j) {
						if (tree[j].first <= nx) break;
						if (tree[j].second == y) { ok = true; break; }
					}
					if (ok) puts("True"); else puts("False");
				}
			}
			else if (!strcmp(R, "descendant")) {
				if (nx <= ny) puts("False");
				else {
					bool ok = false;
					for (int j = names[y] + 1; j < n; ++j) {
						if (tree[j].first <= ny) break;
						if (tree[j].second == x) { ok = true; break; }
					}
					if (ok) puts("True"); else puts("False");
				}
			}
			else if (!strcmp(R, "sibling")) {
				if (nx != ny) puts("False");
				else {
					bool ok = false;
					for (int j = names[x] - 1; j >= 0; --j) {
						if (tree[j].first < nx) break;
						if (tree[j].second == y) { ok = true; break; }
					}
					if (!ok) for (int j = names[x] + 1; j < n; ++j) {
						if (tree[j].first < nx) break;
						if (tree[j].second == y) { ok = true; break; }
					}
					if (ok) puts("True"); else puts("False");
				}
			}

		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 0
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(map(str, input()))
res = []

def point(i):
	if T[i] == "r":
		return P
	elif T[i] == "s":
		return R
	elif T[i] == "p":
		return S

for i in range(N):
	if i < K:
		res.append(point(i))
	else:
		if T[i - K] != T[i]:
			res.append(point(i))
		elif res[-K] == 0:
			res.append(point(i))
		else:
			res.append(0)
			
print(sum(res))


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

int n,a[2100000],ans;

int main()
{
    cin>>n;
  
    for(int i=1; i<=n; i++)
    {
        int x;
      
        cin>>x;
      
        a[x]++;
    }
    for(int i=1;i<=1000000;i++)
    {
        if(a[i]==1)
        {
          ans++;
        }
      
        if(a[i]>0)
        {
            for(int j=i; j<=1000000; j+=i)
            {
                a[j]=0;
            }
        }
    }
  
    cout<<ans<<endl;
  
  return 0;
}

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

int n;
int a[200];

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int cnt = 0;
  while (true) {
    bool odd_exists = false;
    for (int j = 0; j < n; j++) {
      if (a[j] % 2 != 0) odd_exists = true;
    }
    if (odd_exists) break;
    for (int j = 0; j < n; j++) a[j] /= 2;
    cnt += 1;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;

int main()
{
int n;
int a,b;
int ren=0;
int flag=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d %d",&a,&b);
if(a==b){ren++;}
else{ren=0;}
if(ren==3){flag=1;}
}
if(flag==1){printf("Yes");}
else{printf("No");}
}


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

int asciiS[26] = {};
int asciiT[26] = {};
string S;
string T;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> S >> T;
    bool ok = true;
    for(int i=0; i<26; i++){
        asciiT[i] = -1;
        asciiS[i] = -1;
    }
    for(long i=0; i<(int)S.size(); i++){
        if(asciiS[S[i]-'a']==-1 && asciiT[T[i]-'a']==-1) {
            asciiS[S[i]-'a'] = T[i]-'a';
            asciiT[T[i]-'a'] = S[i]-'a';
        }
        else{
            if(asciiS[S[i]-'a'] != T[i]-'a' || asciiT[T[i]-'a'] != S[i]-'a'){
                ok = false;
                break;
            }
        }
    }
    if(ok) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 916
N, M, X = map(int, input().split())
l = []

for _ in range(N):
    l.append(list(map(int, input().split())))

ans = 10 ** 10

for i in range(2**N):
    tmp = [0]*M
    tmp2 = 0
    for j in range(N):
        if i >> j & 1:
            for k in range(M):
                tmp[k] += l[j][k+1]
            tmp2 += l[j][0]
    flag = True
    for k in range(M):
        if tmp[k] < X:
            flag = False
    if flag:
        ans = min(ans, tmp2)
if ans != 10**10:
    print(ans)
else:
    print(-1)

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

int main() {
  int N,A,B;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  A=0;
  B=0;
  for (int i=0;i<N;i++){
    if (i%2==0){A+=vec.at(i);}
    if (i%2==1){B+=vec.at(i);}
  }
  cout<<A-B<<endl;
}



Measured memory_bytes: 256
/*
 * NoobM
 * File Name : A.cpp
 * Date : 17.05.2020 01:14:16 +06
 * Version : 1.0
 * 
 * Copyright 2020 Mehedi <imehedi357@gmail.com>
 * Shahjalal University of Science & Technology 
 * 
 * Geany 1.36
 * 
 */

#include <bits/stdc++.h>

#define rep(i, a, b) \
    for (int i = int(a); i < int(b); i++)
#define rr(i, b) \
    for (int i = 0; i < int(b); i++)
#define vina vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl

using namespace std;
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    string s, t;
    cin >> s >> t;
    
    for(int i = 0; i < s.size(); i++) {
		if(s[i] != t[i]){
			cout << "No" << endl;
			return 0;
		}
	}
    
    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define int long long
#define rep1(i,a,b) for(int i=a;i<b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000009
#define garou99 ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
signed main() {
  string s,t;
  cin>>s>>t;
  int m=s.length();
  int n=t.length();
  if(n>m){
	  cout<<0;
	  return 0;
  }
  int mn=INT_MAX,j=0;
  for(int i=0;i<m;i++){
	  int x=i,z=0;
	for(int j=0;j<n;j++){
		if(i+j>=m){
			z=INT_MAX;
			break;
		}
   if(s[i+j]!=t[j])
   z++;
   x++;
	} 
	mn=min(mn,z);
  }
  if(mn==INT_MAX)
  mn=n;
  cout<<mn;
	}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 9000000000000;
#define LX 100010
    struct edge{ll from,to,cost;};
    edge es[2010];
    ll N,M;
    ll d[1010];


int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>M;
    REP(i,N)d[i]=INF;
    d[0]=0;
    ll count=0;
    REP(i,M){
        ll a,b,c;
        cin>>a>>b>>c;
        es[i].from = a-1;
        es[i].to   = b-1;
        es[i].cost = -1*c;
    }
bool inf=false;
    while(true){
        bool up=false;

        REP(i,M){
            edge e=es[i];
            DEB(i)DEB(count)DEB(d[e.from])DEB(d[e.to])DEB(e.cost)DEB(d[N-1])END
            if(d[e.to]>d[e.from]+e.cost){
                d[e.to]=(d[e.from]+e.cost);
                if(count>=N&&e.to==N-1)inf=true;
                up=true;

            }
        }
        if(!up||count>=2*N+1){
            if(inf)cout<<"inf";
            else cout<<d[N-1]*-1;
            break;
        }
        count++;
    }
END
DEB(d[0])DEB(d[1])DEB(d[2])
}
//ABC061 D - Score Attack


Measured memory_bytes: 256