akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int>pi;

const ll inf = 1e18;
const ll mod = 1e9+7;
int n,m,i;
int t;
long long x,y;
int main()
{
    cin >> x >> y;
    if(x>=y) cout << "10";
    else cout << "0";
}



Measured memory_bytes: 256
//鉄道旅行
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<utility>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
#define MP make_pair
#define PB push_back
#define F_d first
#define S_d second
#define LARGE 100000000
#define MOD 100000
#define LL long long

LL N, M, P[100009], midc[100009], ans = 0;
//middlecount[i] = i~i+1の区間を通る回数
//A,B,C,midc >> mid  N,M,P >> edge
int main() {
	cin >> N >> M;
	for (int i = 0; i <= N; i++)midc[i] = 0;
	for (int i = 0; i < M; i++) {
		cin >> P[i];
		if (i != 0) {
			midc[min(P[i], P[i - 1])]++;
			midc[max(P[i], P[i - 1])]--;
		}
	}
	for (int i = 0; i < N; i++) midc[i + 1] += midc[i];
	for (int i = 1; i < N; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		ans += min(a * midc[i], c + b * midc[i]);
	}
	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 4660
<?php
  
while($line = fgets(STDIN)) {
	$tmp[] = trim($line);
}

foreach($tmp as $key => $value) {
	$array[] = explode(" ", $value);
}

$operateCnt = 0;
$existOdd = false;
while (!$existOdd) {
  for ($i = 0; $i < $array[0][0]; $i++) {
      if ($array[1][$i] % 2 == 0) {
          $array[1][$i] = $array[1][$i] / 2;
      } else {
      	$existOdd = true;
        break;
      }
    }
    $operateCnt++;
}

echo $operateCnt - 1;

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

int N,arr[100];

int main(){
  cin >> N;
  for (int i=0;i<N;i++){
    cin >> arr[i];
  }
  sort(arr,arr+N);
  cout << arr[N-1] - arr[0];
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long r;
  cin >> r;
  cout << r * r << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
a,b,k=map(int,input().split())
ans=[]
for i in range(k):
    if a+i<b-i:

        ans.append(a+i)
        ans.append(b-i)
    elif a+i==b-i:
        ans.append(a+i)
ans.sort()
for ai in ans:
    print(ai)


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,wmax;cin>>n>>wmax;
  int i,j;
  vector<int> v(n);
  vector<int> w(n);
  rep(i,n)cin>>v[i]>>w[i];
  vector<vector<int>> dp(n+1,vector<int>(wmax+1,0));
  rep(i,n)
  {
    rep(j,wmax)
    {
      if(j+1-w[i]>=0)dp[i+1][j+1]=max(dp[i][j+1],dp[i][j+1-w[i]]+v[i]);
      else dp[i+1][j+1]=dp[i][j+1];
    }
  }
  int maxans=0;
  rep(i,wmax+1)maxans=max(maxans,dp[n][i]);
  cout<<maxans<<endl;
}


Measured memory_bytes: 6808
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str;
            str = Console.ReadLine ().Split (' ');

            int a = int.Parse (str[0]);
            int b = int.Parse (str[1]);
            int c = int.Parse (str[2]);

            int count = 0;

            for (int i = a; i <= b; i++)
            {
                if (c % i == 0) count++;
            }

            Console.WriteLine (count);
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}


Measured memory_bytes: 18012
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
using namespace std;

int main() {

	int ans = 0;
	int N; cin >> N;

	if (N >= 105) ans++;
	if (N >= 135) ans++;
	if (N >= 165) ans++;
	if (N >= 189) ans++;
	if (N >= 195) ans++;

	cout << ans << endl;
}

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

void input(std::vector<int> *vector) {
  for (auto iv = vector->begin(); iv != vector->end(); ++iv) {
    std::cin >> *iv;
  }
  std::sort(vector->begin(), vector->end());
}

int main() {
  int n;
  std::cin >> n;

  std::vector<int> a(n);
  std::vector<int> b(n);
  std::vector<int> c(n);
  
  input(&a);
  input(&b);
  input(&c);
  
  auto a_lower = a.begin();
  auto c_upper = c.begin();
  long ans = 0;
  for (auto& bi : b) {
    a_lower = std::lower_bound(a_lower, a.end(), bi);
    long a_count = a_lower - a.begin();
    if (0 == a_count) {
      continue;
    }
    c_upper = std::upper_bound(c_upper, c.end(), bi);
    long c_count = c.end() - c_upper;
    if (0 == c_count) {
      break;
    }
    ans += a_count * c_count;
  }
  
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 1408
//hitachi2020_a.cpp
//Sun Mar  8 20:53:17 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	if (s=="hi" ||
		s=="hihi" ||
		s=="hihihi" ||
		s=="hihihihi" ||
		s=="hihihihihi"){
		cout << "Yes" << endl;
	}else {
		cout << "No"<< endl;
	}
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
from collections import defaultdict
import itertools
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

H, N, = map(int, input().split())
L = [int(v) * -1 for v in input().split()]

L.sort()

ans = 0
for i in range(N, H):
    ans += L[i] * -1

print(ans)

Measured memory_bytes: 27660
#include<bits/stdc++.h>
using namespace std;
string s;
int l = -1,r = -1;
int main() {
	cin >> s;
	int len = s.size();
	for(int i = 0;i < len-1;i++) {
		if(s[i] == s[i+1]) {
			l = i+1;
			r = i+2;
		}
	}
	for(int i = 0;i < len-2;i++) {
		if(s[i] == s[i+2]) {
			l = i+1;
			r = i+3;
		}
	}
	cout << l << " " << r << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
 int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    if(i<10 || (i>=100&&i<=999) || (i>=10000&&i<=99999))
      ans++;
  }
  cout<<ans;
}

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

#define int long long
#define F first
#define S second
#define vi vector<int>


void mymain(){
    int a,b;
    cin >> a >> b;
    int g = __gcd(a,b);
    cout << (a*b)/g << endl;

}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--){
        mymain();
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a>=b) System.out.println("delicious");
        else if(a<b && a+x+1>b) System.out.println("safe");
        else System.out.println("dangerous");
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
using namespace std;

void bubble_sort(vector<int>& vec, int n) {
  bool flg = true;
  int i = 0;
  int cnt = 0;
  while(flg) {
    flg = false;
    for(int j = n - 1; j > i; j--) {
      if(vec[j] < vec[j - 1]) {
        swap(vec[j], vec[j - 1]);
        flg = true;
        cnt++;
      }
    }
    i++;
  }

  for(int k = 0; k < n; k++) {
    cout << vec[k];
    if(k != n - 1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
  cout << cnt << endl;
}

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for(auto& v : vec) {
    cin >> v;
  }
  bubble_sort(vec, n);
  return 0;
}



Measured memory_bytes: 3096
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9;

int main(){
	int a,b,x;scanf("%d%d%d",&a,&b,&x);
	double tmp;
	if(a*a*b/2.0 > x)tmp=90-atan(2*x/(a*pow(b,2)))*180/acos(-1.0);
	else tmp=90-atan(pow(a,3)/2/(pow(a,2)*b-x))*180/acos(-1.0);
	printf("%.7f\n",tmp);

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int N,copy,hyaku,juu,ichi,n,i;
	
	
	scanf("%d",&N);
	
	if(N > 99&&N <1000)
	{
		copy = N;
		
			hyaku = copy/100;
			juu = copy/10 -10*hyaku;
			ichi = copy - 100*hyaku - 10*juu;
		
		n = 100*ichi + 10*juu + ichi;
		
		if(n == N)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
		
	}
	else
	{
		printf("エラー\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>

int main()
{
    int x, a, b;
    std::cin >> x >> a >> b;

    if (std::abs(x - a) < std::abs(x - b)) {
        std::cout << "A" << std::endl;
    } else {
        std::cout << "B" << std::endl;
    }
}


Measured memory_bytes: 256
X = int(input())

if 400 <= X < 600:
    print(8)
elif 600 <= X < 800:
    print(7)
elif 800 <= X < 1000:
    print(6)
elif 1000 <= X < 1200:
    print(5)
elif 1200 <= X < 1400:
    print(4)
elif 1400 <= X < 1600:
    print(3)
elif 1600 <= X < 1800:
    print(2)
else:
    print(1)


Measured memory_bytes: 9144
# 371 ms, 27032 KB
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = []
c = []
 
bc = [map(int, input().split()) for _ in range(q)]
b, c = [list(i) for i in zip(*bc)]
 
dic = {}
for aa in a:
    dic[aa] = dic.get(aa, 0) + 1
 
s = sum(a)
for i in range(q):
    if b[i] not in dic:
        print (str(s))
        continue
    s += (c[i]-b[i]) * dic[b[i]]
    dic[c[i]] = dic.get(c[i], 0) + dic[b[i]]
    del dic[b[i]]
    print(s)

Measured memory_bytes: 72480
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <time.h>
#include <stdlib.h>
#include <bitset>
#include <algorithm>

#include <chrono>

#define INF 1e9
#define LL_INF 1e18

#define fst first
#define snd second
#define pb push_back
#define SZ(x) ((int)(x.size()))

#define MOD1 998244353
#define MOD2 666013
#define P1 255
#define P2 2059

using namespace std;

typedef long long int ll;

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

#define nmax 100010
#define MOD (int)((1e9) + 7)

int n;
int dp[nmax][2]; // 0 white, 1 black
vector <int> g[nmax];

void add_self(int& a, int b)
{
    a += b;

    if (a >= MOD) a -= MOD;
}

void dfs(int node, int p = -1)
{
    dp[node][0] = dp[node][1] = 1;

    for (int u: g[node])
        if (u != p) {

            dfs(u, node);
            
            dp[node][0] = (1LL * dp[node][0] * (dp[u][1] + dp[u][0])) % MOD;
            dp[node][1] = (1LL * dp[node][1] * dp[u][0]) % MOD;
        }
}

int main()
{
    scanf("%d", &n);

    for (int i = 1; i < n; i++)
    {
        int x, y;

        scanf("%d %d", &x, &y);

        g[x].pb(y); g[y].pb(x);
    }

    dfs(1);

    printf("%d", (dp[1][0] + dp[1][1]) % MOD);

    // IMPORTANT!!!!!
    // Are you missing something????
    // check limits, int or ll

    return 0;
}

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

int main(void)
{
    // bits/stdc++.h をincludeしているときは定数M_PIが使えます
    const double PI=3.14159265358979323846;
    double a,b,x;
    cin >> a >> b >> x;
    double s = x / a;
    double ans = 0;
    double a2 = 0;
    // コーナーケース
    if ( s == a * b) {
        ans = 0;
    } else {
        if (s > b * a / 2) {
            // 台形の時
            // 上底bu
            double bu = 2 * s / a - b;
            s -= a * bu;
            b -= bu;
            // a2 = a とするとコーナーケースを考慮する必要がなくなる
            a2 = 2 * s / b;
        } else {
            // 三角形の時
            a2 = 2 * s / b;
        }
        // アークタンジェント計算(結果はラジアン)
        double r = atan(b/a2);
        // ラジアン-角度変換
        ans = r * (180.0 / PI); 
    }
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    std::size_t N;
    std::cin >> N;

    std::size_t a = 0;
    for(std::size_t i=1; i<=N; ++i)
    {
        if(i % 3 == 0 || i % 5 == 0) {continue;}
        a += i;
    }
    std::cout << a << std::endl;
    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
map<pair<int,int>,int>a;
long long h,w,n,sum,ans[1000003],ans1[13];
int a1,b1;
int main()
{
	cin>>h>>w>>n;
	for(int k=1; k<=n; k++)
	{
		scanf("%d%d",&a1,&b1);
		for(int i=max(3,a1); i<=a1+2; i++)
			for(int j=max(b1,3); j<=b1+2; j++)
				if(i<=h&&j<=w)
				{
					if(a[make_pair(i,j)]==0)
						sum++,a[make_pair(i,j)]=sum,ans[sum]=1;
					else
						ans[a[make_pair(i,j)]]++;
				}
	}
	for(long long i=1; i<=sum; i++)
		ans1[ans[i]]++;
	ans1[0]=(h-2)*(w-2)-sum;
	for(long long i=0; i<=9; i++)
		cout<<ans1[i]<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ll X;
    cin >> X;
    ll num = 100;
    ll ans = 0;
    while (1)
    {
        ans++;
        num = (ll)(num * 1.01);
        if (num >= X)
        {
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=200005,mod=1e9+7;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
int n,m;
char s[N];
int dp[N],pre[N];
int main(){
	n=read(),m=read();
	cin>>(s+1);
	int p=1;
	while (p<=m&&s[p]==s[1])
		p++;
	p--;
	if (p==m){
		For(i,2,n)
			dp[i]=i;
		For(i,1,n){
			Add(dp[i],pre[i-2]);
			pre[i]=Add(pre[i-1]+dp[i]);
		}
		cout<<Add(dp[n]+1)<<endl;
		return 0;
	}
	if (n&1)
		return puts("0"),0;
	int maxlen=p+(~p&1);
	int las=p+1;
	For(i,p+2,m)
		if (s[i]!=s[1]){
			if ((i-las-1)&1)
				maxlen=min(maxlen,i-las-1);
			las=i;
		}
	n/=2,maxlen=(maxlen+1)/2;
	For(i,1,maxlen)
		dp[i]=i*2;
	For(i,1,n){
		Add(dp[i],Del(pre[i-1]-pre[max(0,i-maxlen-1)]));
		pre[i]=Add(pre[i-1]+dp[i]);
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <cmath>
typedef long long LL;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(){
  LL N;
  cin >> N;
  
  LL res = 0;
  rep(n,N){
    LL tmp = n+1;
    LL cnt = 0;
    while(tmp>0){
      tmp /= 10;
      cnt++;
    }
    if(cnt %2 ==1){
      res++;
    }
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main(void){
	int n, m;
	scanf("%d%d",&n ,&m);
	if(n==m){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
    return 0; 
}


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

public class Main {
    
    static class Question {
        int N, M;
        
        public void main(FastScanner in, PrintWriter out) {
            N = in.nextInt();
            M = in.nextInt();
            
            boolean[] visited = new boolean[N];
            boolean ans = false;
                
            for (int i = 0; i < M; i++) {
                int u = in.nextInt()-1;
                int v = in.nextInt()-1;
                if (u == 0) {
                    if (visited[v]) {
                        ans = true;
                    }
                    visited[v] = true;
                } else if (v == (N-1)) {
                    if (visited[u]) {
                        ans = true;
                    }
                    visited[u] = true;
                }
            }
            out.println( ans ? "POSSIBLE" : "IMPOSSIBLE" );
        }
        
        public void p(Object o) { System.out.print(o); }
        public void pl(Object o) { System.out.println(o); }
        public void arp(int[] o) { pl( Arrays.toString(o) ); }
        public void arp(boolean[] o) { pl( Arrays.toString(o) ); }
        public void arpp(int[][] o) { 
            for (int i = 0; i < o.length; i++) {
                for (int j = 0; j < o[0].length; j++) { p( o[i][j] + " " ); } pl("");
            }
        }
    }

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Question q = new Question();
        q.main(in, out);
        out.close();
        in.close();
    }
    
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try { st = new StringTokenizer(br.readLine()); } 
                catch (IOException e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }
        public void close() throws IOException { br.close(); }
    }
}


Measured memory_bytes: 45924
#include<iostream>
#include<functional>
#include<algorithm>

using namespace std;

int main(){
	int n;
	int d[110];
	cin >> n;
	for(int i=0; i<n; i++){
	    cin >> d[i];
	}
	int num[110]={0};
	int res=0;
	for(int i=0; i<n; i++){
	    num[d[i]]++;
	}
	for(int i=0; i<=100; i++){
	    if(num[i])
			res++;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int build [4][3][10];
    for(int i = 0; i < 4; i++)
    {
    	for(int j = 0; j < 3; j++)
    	{
    		for(int k = 0; k < 10; k++)
    		{
    			build[i][j][k] = 0;	
			}
	    }
	}
	int n;
	scanf("%d", &n);
	while(n--)
	{
		int a, b, c, d;
		scanf("%d %d %d %d", &a, &b, &c, &d);
		build[a-1][b-1][c-1] += d;
	}
	for(int i = 0; i < 4; i++)
    {
    	for(int j = 0; j < 3; j++)
    	{
    		for(int k = 0; k < 10; k++)
    		{
    			printf(" %d", build[i][j][k]);
			}
			printf("\n");
	    }
	    if(i!=3)
	    {
		    printf("####################\n");
	    }
	}
	
	return 0;
}


Measured memory_bytes: 2756
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<string.h>
#include<vector>
#include<set>
using namespace std;
long long mod=1000000007;
char in[3100];
long long dp[3100][3100];
int r[3100];
int sum[3100];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	scanf("%s",in);
	for(int i=0;i<a;i++)r[i]=i;
	for(int i=0;i<b;i++){
		int p,q;scanf("%d%d",&p,&q);
		p--;q--;
		r[p]=max(r[p],q);
	}
	for(int i=1;i<a;i++){
		r[i]=max(r[i],r[i-1]);
	}
	int cur=0;
	for(int i=0;i<a;i++){
		cur+=in[i]-'0';
		sum[i]=cur;
	}
	dp[0][0]=1;
	for(int i=0;i<a;i++){
		for(int j=0;j<=i;j++){
			if(!dp[i][j])continue;
			int t=sum[r[i]];
			if(j<=t&&t-j<=r[i]-i)dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
			if(j+1<=t&&t-j-1<=r[i]-i)dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod;
		}
	}
	printf("%lld\n",dp[a][sum[a-1]]);
}

Measured memory_bytes: 12672
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		int box;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
		String[] inputNum = br.readLine().split(" ");
		int x = Integer.parseInt(inputNum[0]);
		int y = Integer.parseInt(inputNum[1]);

		if (x == 0 && y == 0) {
			break;
		}

		if(x > y){
			box = x;
			x = y;
			y = box;
		}

		System.out.println(x + " " + y);

		}


	}

}

Measured memory_bytes: 24564
#include<stdio.h>
int main()
{
    int x,b,t,candies;
    scanf("%d %d %d", &x,&b,&t);

    if(x>t) printf("0\n");
    else
    {
        candies=b*(t/x);
        printf("%d\n", candies);
    }
}


Measured memory_bytes: 1732
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

#ifdef DEBUG
#include <util.h>
#else
#define Dump(x)
#endif

using namespace std;

using ll_t = long long;
using ull_t = unsigned long long;
using ld_t = long double;



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

    vector<int> M(S.size(), 0);
    int k = 1;
    for (int i = 0; i < S.size(); ++i)
    {
        M[i] = ((int)(S[S.size() - 1 - i] - '0') * k) % 2019;
        if (i > 0)
        {
            M[i] += M[i - 1];
            M[i] %= 2019;
        }
        k = (k * 10) % 2019;
    }
    
    unordered_map<int, int> mods;
    for (auto m : M)
    {
        auto it = mods.insert({m, 1});
        if (not it.second)
            ++it.first->second;
    }

    size_t n(0);
    for (const auto &p : mods)
    {
        if (p.first == 0)
            n += p.second + (p.second * (p.second - 1) / 2);
        else if (p.second > 1)
            n += p.second * (p.second - 1) / 2;
    }

    cout << n << endl;
}


Measured memory_bytes: 4432
import numpy

n = int(input())
#m = list(map(int, input().split()))
sum = 0 
for i in range(n):
    m = (list(map(str, input().split())))
    sum += float(m[0]) if m[1] == 'JPY' else float(m[0]) * 380000  



print(sum)

Measured memory_bytes: 12468
# -*- coding: utf-8 -*-
import fractions
import numpy as np
 
N,X = map(int, input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
 
x=np.array(x)
 
y=x[1:]-x[:-1]
 
y.sort()
y=list(set(y))
z=y[0]
m=len(y)
i=0
while i < m:
    z=fractions.gcd(z,y[i])
    i+=1
 
print(z)

Measured memory_bytes: 24004
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
#define fil(x) memset(x, 0, sizeof(x))
#define fillb(x) memset(x,false,sizeof(x))
#define fillm(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define pll pair<int, int>
#define pf printf
#define sf scanf
#define all(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define fo(i,n) for(int i=0;i<n;i++)
#define of(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define nl endl

typedef unsigned long long lll;
typedef long long ll;
int knigtx8[] = {2, 2, -2, -2, 1, 1, -1, -1}; ///knight move in chess
int knigty8[] = {1, -1, 1, -1, 2, -2, 2, -2}; ///knight move in chess
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; ///for 8 directions
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1}; ///for 8 directions
int dx4[] = {0, 0, 1, -1}; ///for 4 directions
int dy4[] = {1, -1, 0, 0}; ///for 4 directions
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

int atoz(){
    int frnt,bck,nibo,present,i;string s;
        frnt = abs(s[i]-present);
        bck = 26-frnt;
        nibo = min(frnt,bck);
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

int main()
{
    IOS;
    string s;
    cin>>s;
    int len = s.size();
    int dp[len+1],powe[len];
    int cnt[2019]; ///hold the frequency of the remainder occuring at rem i
    fil(dp);
    fil(cnt);
    cnt[0] = 1;
    ll p=1,ans=0;
    for(int i=len-1;i>=0;i--)
    {
        powe[i] = p;
        dp[i] = (dp[i+1] + (s[i]-'0')*p)%2019;
        p*=10;
        p%=2019;
        ll rem = dp[i];
        ans+=cnt[rem];
        cnt[rem]++;
    }

    /*fo(i,len)
    {
        cout<<"power = "<<powe[i]<<" s = "<<s[i]<<" "<<"dp = "<<dp[i]<<" "<<endl;
    }
    cout<<endl;*/
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main() {
  string a;
  cin >> a;
  string b = "keyence";
  int la = a.length();
  int lb = b.length();

  if (a.substr(0, lb) == b) {
    printf("YES\n");
    return 0;
  }
  if (a.substr(la - lb) == b) {
    printf("YES\n");
    return 0;
  }

  for (int l1 = 1; l1 < lb; l1++) {
    int l2 = lb - l1;
    string c = a.substr(0, l1) + a.substr(la - l2);
    if (c == b) {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a, b, c, n = 0;
	scanf("%d %d %d", &a, &b, &c);
	int i = a;
	while(i <= b)
	{
		if(c % i == 0)
		{
			n++;
		} 
		i++;
	}
	
	printf("%d\n", n);
	return 0;
}


Measured memory_bytes: 2752
#include <stdio.h>

int main(void) {
	int a, b, result;
	
	scanf("%d %d", &a, &b);
	if (a <= b) {
		result = a;
	} else {
		result = a - 1;
	}
	
	printf("%d\n", result);
	
	return 0;
}

Measured memory_bytes: 128
<?php

$list = array();
for ($i = 1; $i <= 100; $i++) {
    $list[$i] = 0;
}
while (TRUE) {
    fscanf(STDIN, '%d', $d);
    if (feof(STDIN)) {
        break;
    }
    $list[$d]++;
}

$mode = 0;
for ($i = 1; $i <= 100; $i++) {
    if ($list[$i] > $mode) {
        $mode = $list[$i];
    }
}

for ($i = 1; $i <= 100; $i++) {
    if ($list[$i] === $mode) {
        echo $i;
        echo PHP_EOL;
    }
}

Measured memory_bytes: 6624
<?php
fscanf(STDIN,"%s %s",$a,$b);
fscanf(STDIN,"%d %d",$c,$d);
fscanf(STDIN,"%s",$e);
if($a == $e){
  $f = $c - 1 ;
  echo $f." ".$d;
}else{
  $g = $d - 1 ;
  echo $c." ".$g;
}
?>


Measured memory_bytes: 3700
// Itp1_5_b.java
import java.io.*;
import java.lang.Integer;
public class Main 
{
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
loop:		while(true) {
				String in  = br.readLine() ;
				String[] hw = in.split(" ");
				int height = Integer.parseInt(hw[0]);
				int width  = Integer.parseInt(hw[1]);
				if ( height == 0 || width == 0 ) {
					break;
				}
				for( int i = 1 ; i <= height ; i++ ) {
					for( int j = 1 ; j <= width ; j++ ) {
						if ( i == 1 || i == height ) {
							System.out.print("#");
						} else {
							if ( j == 1 || j == width ) {
								System.out.print("#");
							} else {
								System.out.print(".");
							}
						}
					}
					System.out.println("");
				}
				System.out.println("");
			}
		} catch ( IOException e ) {
			System.out.println("??¨??????????????????????????????");
		}
	}
}

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

#define int         long long
#define ld          long double
#define fastio      ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define sz(x)       (int)x.size()
#define mod         1000000007
#define mod2        998244353

using namespace std;

/*int power(int a,int n)
{
    if(n == 1)return a%mod;
    if(n == 0)return 1;
    if(n&1)return ((a%mod)*(power((a*a)%mod,n>>1))%mod)%mod;
    return power((a*a)%mod,n>>1)%mod;
}
int gcd(int a,int b)
{
    if(a%b == 0)return b;
    return gcd(b,a%b);
}*/
int n,m,ans;
vector<int>a(maxn),pre(maxn);
map<int,int>mp;

signed main()
{
    fastio;
    cin >> n >> m;
    FOR(i,1,n+1)
    {cin >> a[i];pre[i]=pre[i-1]+a[i];}
    mp[0]++;
    FOR(i,1,n+1)
    {
        ans += mp[pre[i]%m];
        mp[pre[i]%m]++;
    }
    cout << ans;



    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define all(x) x.begin(),x.end()
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

const int N=5e5+60,MOD=1e9+7;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

typedef long long ll;
typedef int inte;
#define int ll

int n,X,Y,p[N];
int find(int x){ return p[x]==x?x:p[x]=find(p[x]); }

struct P{ 
	int c,w,id; 
}a[N]; 
vector<P> b[N]; 
map<int,int> S[N]; 

bool operator<(const P &a,const P &b){ 
	return a.w==b.w?a.c<b.c:a.w<b.w; 
} ; 

void link(int x,int y){ p[find(x)]=find(y);  } 

int fac[N],inv[N]; 

inte main(inte argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	fac[0]=1; lop(i,1,N)fac[i]=1ll*fac[i-1]*i%MOD;
	inv[1]=1; lop(i,2,N)inv[i]=1ll*(MOD-MOD/i)*inv[MOD%i]%MOD;
	inv[0]=1; lop(i,1,N)inv[i]=1ll*inv[i-1]*inv[i]%MOD;

	read(n); 
	read(X); 
	read(Y); 
	rep(i,1,n){
		read(a[i].c);
		read(a[i].w); 
		p[i]=a[i].id=i;
		b[a[i].c].pb(a[i]); 
	}
	rep(i,1,n){
		auto &v=b[i];
		sort(all(v)); 
		for(size_t j=1;j<v.size();++j){
			if(v[0].w+v[j].w<=X){
				link(v[0].id,v[j].id); 
			}
		}
	}
	sort(a+1,a+n+1); 
	int A=1,B; 
	for(B=2;B<=n&&a[A].c==a[B].c;++B);
	rep(i,1,n){
		if(i!=A&&a[i].w+a[A].w<=Y&&a[i].c!=a[A].c){
			link(a[A].id,a[i].id); 
		}
	}
	if(B<=n){
		rep(i,1,n){
			if(i!=B&&a[i].w+a[B].w<=Y&&a[B].c!=a[i].c){
				link(a[B].id,a[i].id); 
			}
		}
	}

	sort(a+1,a+n+1,[](P a,P b){ return a.id<b.id; }); 
	int ans=1;
	rep(i,1,n){
		++S[find(i)][a[i].c];
		Pr("++S[%d][%d]\n",find(i),a[i].c);
	}
	rep(i,1,n)if(find(i)==i){
		int res=1,sum=0;
		for(auto x:S[i]){
			res=1ll*res*inv[x.second]%MOD; 
			sum+=x.second; 
		}
		res=1ll*res*fac[sum]%MOD;
		ans=1ll*ans*res%MOD; 
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 73088
#include<stdio.h>
#include<string.h>
char str[26];
char b[100][101];
int main(){
	int a;
	scanf("%d",&a);
	scanf("%s",str);
	int n=strlen(str);
	for(int i=0;i<a;i++)scanf("%s",b[i]);
	int ret=0;
	for(int i=0;i<a;i++){
		bool on=false;
		int m=strlen(b[i]);
		for(int j=0;j<m;j++){
			for(int k=1;j+k*(n-1)<m;k++){
				int at=j;
				bool ok=true;
				for(int l=0;l<n;l++){
					if(str[l]!=b[i][at])ok=false;
					at+=k;
				}
				if(ok)on=true;
			}
		}
		if(on)ret++;
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 1044
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.clear();
    io::stdin().read_line(&mut buf).unwrap();

    let (r, b) = buf
        .chars()
        .fold((0, 0), |(mut r, mut b), c| {
            match c {
                'R' => r += 1,
                'B' => b += 1,
                _ => (),
            }

            (r, b)
        });

    if r > b {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashSet<Long> set = new HashSet<Long>();
		
		for (int i = 0; i < n; i++) {
			String order = sc.next();
			String name = sc.next();
			long enc = 0;
			
			for (int j = 0; j < name.length(); j++) {
				switch (name.charAt(j)) {
					case 'A':
						enc = enc * 10 + 1;
						break;
					case 'C':
						enc = enc * 10 + 2;
						break;
					case 'G':
						enc = enc * 10 + 3;
						break;
					case 'T':
						enc = enc * 10 + 4;
						break;
				}
			}
			
			if (order.equals("insert")) {
				set.add(enc);
			} else {
				if (set.contains(enc)) {
					System.out.println("yes");
				} else {
					System.out.println("no");
				}
			}
		}
	}
}

Measured memory_bytes: 223156
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e,f,g,h,i,j,k;
    cin>>a>>b>>c>>d>>e>>f>>g>>h>>i>>j;
    k=a+b+c+d+e+f+g+h+i+j;
    cout<<k<<endl;
}


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

int main(void) {
    int N, A[200005], b, i;
    scanf("%d", &N);
    for (i=0; i<N; i++) scanf("%d", &A[i]);
    std::sort(A, A+N);
    // for (i=0; i<N; i++) printf("%d ", A[i]);
    b=0;
    for (i=0; i<N-1; i++) {
        if (A[i]==A[i+1]) {
            b=1;
            break;
        }
    }
    if (b==0) printf("YES");
    else printf("NO");
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define devugv(v)               for (auto& x: v) cerr << x << " "; cerr << '\n';
#define debugvp(v)              for (auto& x: v) cerr << x.fi << " - " << x.se << '\n';
#define FILL(x, val)            memset(x, val, sizeof(x))
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (int)1000000007
#define INF                     (int)0x3f3f3f3f

using namespace std;

#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }  

typedef long long i64; 
typedef vector< int > vi;
typedef vector< i64 > vi64;
typedef pair< int, int > pi;
typedef vector< pair< int, int > > vpi;
typedef vector< vector < int > > vvi;

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in.txt", "r", stdin);
#endif

    int n; cin >> n;
    vi skew(2 * n);
    forn(i, 2 * n) cin >> skew[i];
    sort(rall(skew));
    int ans = 0;
    fore(i, 1, 2 * n - 1, 2) ans += skew[i];
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cout << "time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
#endif
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = []
a.append(n)
sw = 0
count = 1

while True:
    count += 1 
    if n % 2 == 0:
        n = n / 2
    else :
        n = 3*n + 1
    
    for value in a:
        if value == n:
            print(count)
            sw = 1
            break

    if sw == 1:
        break
    a.append(n)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static int[][] mul(int[][] a,int[][] b,int n,int mod) {
		int[][] ret=new int[n][n];
		for (int i=0;i<n;++i)
			for (int j=0;j<n;++j)
				for (int k=0;k<n;++k)
					ret[i][j]=(ret[i][j]+(int)(1L*a[i][k]*b[k][j]%mod))%mod;
		return ret;
	}
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		long K=in.nextLong();
		int[][] a=new int[n][n];
		int mod=1000000007;
		for (int i=0;i<n;++i)
			for (int j=0;j<n;++j)
				a[i][j]=in.nextInt();
		int[][] b=new int[n][n];
		for (int i=0;i<n;++i) b[i][i]=1;
		while (K>0) {
			if ((K&1)>0) b=mul(b,a,n,mod);
			K>>=1;
			a=mul(a,a,n,mod);
		}
		int res=0;
		for (int i=0;i<n;++i)
			for (int j=0;j<n;++j)
				res=(res+b[i][j])%mod;
		System.out.println(res);
	}
}

Measured memory_bytes: 28268
class Array
  # O(self.size)
  # required conditions:
  # only positive values and sorted in ascending order;[1, 2, 3, 4, 5]
  # or only negative values ans sorted in descending order;[-1, -2, -3, -4, -5]
  def is_sorted_and_number_of_pairs_that_prod_is_less_than_or_equal_to(x)
    res = 0
    l = 0
    r = self.size - 1
    while l < r
      r -= 1 while l < r && self[l] * self[r] > x
      res += r - l
      l += 1
    end
    res
  end
end

N, K = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)

posi = []
nega = []
zeros = 0
A.each do |ai|
  if ai < 0
    nega << ai
  elsif ai > 0
    posi << ai
  else
    zeros += 1
  end
end

posi.sort!
nega.sort!.reverse!

posi_size = posi.size
nega_size = nega.size

zero_pairs = zeros * (zeros - 1) / 2 + zeros * (N - zeros)

ng = -(10**18 + 1)
ok = 10**18 + 1

ans = (ng..ok).bsearch do |mid|
  
  cnt = 0
  
  cnt += zero_pairs if mid >= 0

  if mid > 0
    cnt += nega_size * posi_size
    [posi, nega].each do |ary|
      cnt += ary.is_sorted_and_number_of_pairs_that_prod_is_less_than_or_equal_to(mid)
    end
  else
    r = nega_size - 1
    posi.size.times do |l|
      r -= 1 while(r >= 0 && posi[l] * nega[r] <= mid)
      cnt += nega_size - r - 1
    end
  end

  cnt >= K
end

puts ans

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N;
    string S,T;
    cin >> S>>T;
    bool flag = false;

    REPS(i,S.size()){
        char tmp = S.at(S.size() - 1);
        string tmp1;
        tmp1.push_back(tmp);
        S.pop_back();
        S = tmp1 + S;
        if(S==T){
            flag = true;
            break;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll v,e,r;
    cin >> v >>e >>r;
    vvpl g(v);
    rep(i,e){
        ll a,b,c;scanf("%lld %lld %lld",&a,&b,&c);
        g[a].pb(mp(b,c));
    }
    vl d(v,inf);
    d[r]=0;
    priority_queue<pl,vpl,greater<pl>> que;
    que.push(mp(0,r));
    while(!que.empty()){
        pl p=que.top();
        que.pop();
        ll v=p.se;
        if(d[v]<p.fi)continue;
        rep(i,g[v].size()){
            pl ed=g[v][i];
            if(d[ed.fi]>d[v]+ed.se){
                d[ed.fi]=d[v]+ed.se;
                que.push(mp(d[ed.fi],ed.fi));
            }
        }
    }
    rep(i,v){
        if(d[i]==inf)printf("INF\n");
        else printf("%lld\n",d[i]);
    }
}


Measured memory_bytes: 19436
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
int main(void) {
 int N;
 int sum1=0;
 int sum2=0;
 int diff=0;
 int min = 100000;
 scanf("%d",&N);
 int array[N];
 for (int i=0;i<N;i++)
    scanf("%d",&array[i]);
 for (int T=1;T<N;T++){
    for (int i=0;i<N;i++){
          if (i<T)  sum1+=array[i];
         if (i>=T)  sum2+=array[i];

    }
    diff = abs(sum2-sum1);
    if (diff<min) {min=diff;}
    sum1=0;
    sum2=0;
 }
 printf("%d",min);

 return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;
//obj;
class binary{
public:
    bool isOK(int index, int key,vi a) {
    if (a[index] >= key) return true;
    else return false;
}
int binary_search(int key,vi a) {
   
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key,a)) ok = mid;
        else ng = mid;
    }
    return ok;
}
}obj;

int main(){
    int n;cin>>n;
    int a=n+n*n+n*n*n;
    cout<<a<<endl;
 }


Measured memory_bytes: 3632
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n; scan(n);
    string[] ss;
    foreach (_; 0..n) {
        string s = read!string;
        auto t = s.array;
        t.sort();
        ss ~= t.to!string;
    }

    ss.sort();
    long ans = 0;
    int p = 0;
    while (p+1 < ss.length) {

        if (ss[p] == ss[p+1]) {
            int q = p + 1;
            while (q + 1 < ss.length && ss[p] == ss[q + 1]) {
                q++;
            }

            long k = q - p + 1;
            ans += (k * (k - 1)) / 2;
            p = q + 1;
        }
        else {
            p++;
        }
    }

    writeln(ans);
}


Measured memory_bytes: 12028
#!/usr/bin/env python3

#import
#import math
#import numpy as np
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):

        if A[i][j] != "#":
            continue

        ul = 0
        dr = 0

        if i != 0:
            if A[i - 1][j] == "#":
                ul += 1
        if i != H - 1:
            if A[i + 1][j] == "#":
                dr += 1
        if j != 0:
            if A[i][j - 1] == "#":
                ul += 1
        if j != W - 1:
            if A[i][j + 1] == "#":
                dr += 1

        if dr > 1 or ul > 1:
            print("Impossible")
            exit()

print("Possible")


Measured memory_bytes: 9180
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,R = MI()
print(R if N >= 10 else R+100*(10-N))


Measured memory_bytes: 61996
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <stack>

using namespace std;

int main()
{
    stack<int> n;
    string s;

    while (cin >> s) {
        int a, b;
        if (s == "+") {
            
            a = n.top();
            n.pop();
            b = n.top();
            n.pop();
            n.push(a+b);
        }
        else if (s == "-") {
            
            a = n.top();
            n.pop();
            b = n.top();
            n.pop();
            n.push(b-a);
        }
        else if (s == "*") {
            
            a = n.top();
            n.pop();
            b = n.top();
            n.pop();
            n.push(a*b);
        }
        else if (s == "/") {
            
            a = n.top();
            n.pop();
            b = n.top();
            n.pop();
            n.push(b/a);
        }
        else {
            n.push(stoi(s));
        }
    }

    cout << n.top() << endl;
}



Measured memory_bytes: 3160
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep2(i, s, e) for(int i=s; i<e; i++)
#define print(i) cout << i << endl;

int main(){

    string s, t; cin >> s >> t;

    int ans = 0;
    for(int i=0; i<3; i++){
        if(s[i] == t[i]) ans++;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256