akhauriyash/Code-Regression huggingface dataset:
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//Co-occurrence Search
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		boolean head = true;
		while(sc.hasNext()){
			if(!head)sc.nextLine();
			StringBuilder sb = new StringBuilder();
			for(;;){
				String s = sc.nextLine();
				if("".equals(s))break;
				sb.append(s);
			}
			char[] ch = sb.toString().toCharArray();
			int n = ch.length;
			String key = sc.nextLine();
			int k = key.length();
			Map<Character, Integer> ref = new HashMap<Character, Integer>();
			for(int i=0;i<k;i++)ref.put(key.charAt(i), i);
			int[] c = new int[k];
			int kind = 0;
			int s = 0, t = -1;
			int res = 0, min = n+1;
			String ans = "";
			for(;;){
				if(kind==k){
					int len = t-s+1;
					if(len<min){
						min = len;
						res = 1;
						ans = sb.substring(s, t+1);
					}
					else if(len==min)res++;
					if(ref.containsKey(ch[s])){
						int x = ref.get(ch[s]);
						c[x]--;
						if(c[x]==0)kind--;
					}
					s++;
				}
				else{
					t++;
					if(t==n)break;
					if(ref.containsKey(ch[t])){
						int x = ref.get(ch[t]);
						if(c[x]==0)kind++;
						c[x]++;
					}
				}
			}
			System.out.println(res);
			if(res!=0){
				System.out.println();
				for(int i=0;i<ans.length();i+=72)System.out.println(ans.substring(i, Math.min(ans.length(), i+72)));
			}
			System.out.println();
			head = false;
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
N = int(input())
sequence = list(range(1, N + 1))
for i in range(len(sequence)):
    num = sequence[i]
    if num % 3 == 0 and num % 5 == 0:
        sequence[i] = "FizzBuzz"
    elif num % 3 == 0:
        sequence[i] = "Fizz"
    elif num % 5 == 0:
        sequence[i] = "Buzz"
total = 0
for i in sequence:
    if isinstance(i, int):
        total += i
print(total)




Measured memory_bytes: 48272
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();

        while (scanner.hasNext()) {
            int input = Integer.parseInt(scanner.next());
            if (input == 0) {
                break;
            }
            list.add(input);
        }

        IntStream.range(0, list.size())
                .forEach(i -> System.out.println("Case" + " " + (i + 1) + ": " + list.get(i)));
    }
}

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

typedef long long ll;
typedef long double ld;

vector <int> graf[100005];
int visited[100005];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, m;
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        int a, b;
        cin >> a >> b;
        graf[a].push_back(b);
        graf[b].push_back(a);
    }
    queue <int> q;
    q.push(1);
    visited[1] = 1;
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(auto c : graf[v]){
            if(!visited[c]){
               //cout << c << " " << v << endl;
                visited[c] = v;
                q.push(c);
            }
        }
        //cout << visited[4] << endl;
    }
    for(int i=2; i<=n; i++) if(!visited[i]){
        cout << "No";
        return 0;
    }
    cout << "Yes\n";
    for(int i=2; i<=n; i++) cout << visited[i] << "\n";
    return 0;
}


Measured memory_bytes: 10512
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <queue>

#define MAXCHAR 255
#define ll unsigned long long

using namespace std;
const ll dividend = 1000000007;

ll funcComb(int n, int k) 
{
	ll output = 1;
	int sum = n + k;
	vector<int> dividends;
	for (int i = 0; i < k; i++)
	{
		dividends.push_back(k - i);
	}
	for (int i = 0; i < k; i++)
	{
		output *= sum - i;
		for (auto it = dividends.begin(); it != dividends.end(); it++)
		{
			if (*it == 0)
				continue;
			if (output % *it == 0)
			{
				output /= *it;
				*it = 0;
			}
		}
		if (output > dividend)
		{
			output %= dividend;
		}
	}

	return output;
}

int main()
{
	int a;
	int b;
	cin >> a >> b;
	cout << a*b << endl;
	return 0;

}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  string s;

  cin >> s;

  int n = s.size();

  cout << s.substr(0, n-8) << endl;
  
  return 0;
}



Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,m = map(int,readline().split())
ab = [tuple(map(int,readline().split())) for _ in range(n)]
lr = [tuple(map(int,readline().split())) for _ in range(m)]

ab.sort()
a = []
b = []
for i,j in ab:
    a.append(i)
    b.append(j)

from bisect import *
g = [[] for _ in range(n+1)]
lidx = []
ridx = []
for i in range(m):
    l,r = lr[i]
    li = bisect_left(a,l)
    ri = bisect_right(a,r)
    if li != ri:
        lidx.append(li)
        ridx.append(ri)
        g[li].append((ri,i+1))
        g[ri].append((li,i+1))


b.append(0)
for i in range(n-1,-1,-1):
    b[i+1] ^= b[i]

#print(b)
# imos したので、lidx に +1, ridx に -1 と同じ
q = [0]
parent = [-1]*(n+1)
edge_idx = [-1]*(n+1)
order = []
for i in range(n,-1,-1):
    if parent[i] == -1:
        q = [i]
        while q:
            v = q.pop()
            order.append(v)
            if parent[v] == -1: parent[v] = -2
            for c,idx in g[v]:
                if parent[c] == -1:
                    parent[c] = v
                    edge_idx[c] = idx
                    q.append(c)

"""
print(g)
print(lidx)
print(ridx)
print(b,"b")
print(parent,"parent")
print(edge_idx,"e_idx")
print(order)
"""

ans = []    
for i in order[::-1]:
    if b[i] and parent[i] != -2:
        b[i] = 0
        b[parent[i]] ^= 1
        ans.append(edge_idx[i])
    #print(b,i)
    
#print(b)

if all(not i for i in b[:-1]):
    print(len(ans))
    print(*sorted(ans))
else:
    print(-1)





Measured memory_bytes: 172072
#include<iostream>
#define ll long long int

using namespace std;

ll gcd2(int a,int b){
  if(a % b == 0) return b;
  return gcd2(b,a%b);
}

ll gcd3(int a,int b,int c){
  return gcd2(gcd2(a,b),c);
}

int main(void){
  ll K,sum=0;
  cin >> K;
  for(int i=1;i <= K;i++){
    for(int j=1;j <= K;j++){
      for(int k=1;k <= K;k++){
        sum += gcd3(i,j,k);
      }
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
 int  i,j,n;

 cin >> i >> j >> n;

 if (i == j && i != n) {
	 cout << "Yes";
 }
 else {
	 if (i == n && i != j) {
		 cout << "Yes";
	 }
	 else {
		 if (j == n && j != i) {
			 cout << "Yes";
		 }
		 else {
			 cout << "No";
		 }
	 }
 }


}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

			int  N = sc.nextInt();


				if (N == 1) {
					System.out.println("Hello World");
				}else if (N ==2) {
					int  A = sc.nextInt();
					int  B = sc.nextInt();
					System.out.println(A + B);
				}

	}
}

Measured memory_bytes: 21204
N, M = map(int, input().split())
students = [tuple(map(int, input().split())) for i in range(N)]
points = [tuple(map(int, input().split())) for i in range(M)]

for s in students:
    min_d = 10 ** 10
    min_p = 100
    for i in range(M):
        d = abs(points[i][0] - s[0]) + abs(points[i][1] - s[1])
        if d < min_d:
            min_d = d
            min_p = i
    print(min_p + 1)


Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))

dp = [[0] * n for _ in range(n) ]
sum_a = [[0] * n for _ in range(n) ]

for i in range(n):
    sum_a[i][i] = a[i]
    for j in range(i+1,n):
         sum_a[i][j] = sum_a[i][j-1] + a[j]

for i in range(1,n):
    for head in range(n-i):
        tail = head + i
        temp = 10**20
        for j in range(i):
            temp = min(temp, (dp[head][head+j] + dp[head+j+1][tail] + sum_a[head][tail]) )
        dp[head][tail] = temp

print(dp[0][n-1])

Measured memory_bytes: 45036
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    for(ll i = 0; i < n; i++) {
        if(i % 2 == 0 && a[i] % 2 == 1) ++ans;
    }
    cout << ans << endl;
    return;
}

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

Measured memory_bytes: 3644
#include<iostream>
#include<cmath>
#include<climits>
#include<cstdio>

bool isPrime(int n){
	bool bRet = true;

	if( n == 1 || n == 2 ) return true;
	for(int i = 2; i <= sqrt( (double)n ); i++){
		if( n % i == 0 ){
			bRet = false;
		}
	}
	return bRet;
}

int smallPrime(int n){
	for(int i = n - 1; i >= 2; i--){
		if( isPrime( i ) ) return i;
	}
	return 1;
}

int largePrime(int n){
	for(int i = n + 1; i < INT_MAX; i++){
		if( isPrime( i ) ) return i;
	}
}

int main(void){
	while( true ){
		int n;

		if( scanf("%d", &n) != 1 ){
			break;
		}

		printf("%d %d\n", smallPrime( n ), largePrime( n ));
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	string in[6]={
		"..rr....",
		"..rr....",
		"ggyybbww",
		"ggyybbww",
		"..oo....",
		"..oo....",
	};
	string s;
	char tmp;
	cin>>s;
	rep(i,s.size()){
		if(s[i]=='U'){
			in[2]=in[2].substr(2)+in[2].substr(0,2);
			tmp=in[1][3];
			in[1][3]=in[0][3];
			in[0][3]=in[0][2];
			in[0][2]=in[1][2];
			in[1][2]=tmp;
		}else if(s[i]=='F'){
			tmp=in[2][2];
			in[2][2]=in[3][2];
			in[3][2]=in[3][3];
			in[3][3]=in[2][3];
			in[2][3]=tmp;
			tmp=in[1][2];
			in[1][2]=in[3][1];
			in[3][1]=in[4][3];
			in[4][3]=in[2][4];
			in[2][4]=tmp;
			tmp=in[1][3];
			in[1][3]=in[2][1];
			in[2][1]=in[4][2];
			in[4][2]=in[3][4];
			in[3][4]=tmp;
		}else if(s[i]=='R'){
			tmp=in[2][4];
			in[2][4]=in[3][4];
			in[3][4]=in[3][5];
			in[3][5]=in[2][5];
			in[2][5]=tmp;
			tmp=in[0][3];
			in[0][3]=in[2][3];	
			in[2][3]=in[4][3];
			in[4][3]=in[3][6];
			in[3][6]=tmp;
			tmp=in[1][3];
			in[1][3]=in[3][3];
			in[3][3]=in[5][3];
			in[5][3]=in[2][6];
			in[2][6]=tmp;
		}else if(s[i]=='D'){
			in[3]=in[3].substr(6)+in[3].substr(0,6);
			tmp=in[4][2];
			in[4][2]=in[5][2];
			in[5][2]=in[5][3];
			in[5][3]=in[4][3];
			in[4][3]=tmp;
		}else if(s[i]=='B'){
			tmp=in[2][6];
			in[2][6]=in[3][6];
			in[3][6]=in[3][7];
			in[3][7]=in[2][7];
			in[2][7]=tmp;
			tmp=in[2][0];
			in[2][0]=in[0][3];
			in[0][3]=in[3][5];
			in[3][5]=in[5][2];
			in[5][2]=tmp;
			tmp=in[3][0];
			in[3][0]=in[0][2];
			in[0][2]=in[2][5];
			in[2][5]=in[5][3];
			in[5][3]=tmp;
		}else if(s[i]=='L'){
			tmp=in[2][0];
			in[2][0]=in[3][0];
			in[3][0]=in[3][1];
			in[3][1]=in[2][1];
			in[2][1]=tmp;
			tmp=in[1][2];
			in[1][2]=in[2][7];
			in[2][7]=in[5][2];
			in[5][2]=in[3][2];
			in[3][2]=tmp;
			tmp=in[0][2];
			in[0][2]=in[3][7];
			in[3][7]=in[4][2];
			in[4][2]=in[2][2];
			in[2][2]=tmp;
		}
	}
	rep(i,6)cout<<in[i]<<endl;
}

Measured memory_bytes: 1196
#include <cstring>
#include <cstdio>
#include <algorithm>
const int INF = 0x3f3f3f3f;
using namespace std;

const int MAXV = 15;
const int MAXN = 105;
int A, B, D[MAXV][MAXV], F[MAXN][MAXN];

const int PointS = 1;
const int PointT = 2;
int NPoint = 2, NSide = 0, pointX[MAXN], pointY[MAXN];
struct side { int u, v, d; } S[MAXN * MAXN];
inline void link(int u, int v, int d) { S[++NSide] = (side){u, v, d}; } //-1: X, -2: Y

int main() {
    int x, y, a, b;
    scanf("%d%d", &A, &B);
    for(x = 1; x <= A; x++) for(y = 1; y <= B; y++) scanf("%d", &D[x][y]);

    //construct
    for(a = 0; a <= 100; a++) for(b = 0; b <= 100; b++) {
        for(x = 1; x <= A; x++) for(y = 1; y <= B; y++) F[a][b] = max(F[a][b], D[x][y] - a * x - b * y);
    }
    //check if ok
    bool Succ = 1;
    for(x = 1; x <= A; x++) for(y = 1; y <= B; y++) {
        int dist = INF;
        for(a = 0; a <= 100; a++) for(b = 0; b <= 100; b++) dist = min(dist, a * x + b * y + F[a][b]);
        if(dist != D[x][y]) Succ = 0;
    }
    if(!Succ) printf("Impossible");
    else {
        //construct
        pointX[0] = PointS; for(a = 1; a <= 100; a++) pointX[a] = ++NPoint, link(pointX[a - 1], pointX[a], -1);
        pointY[0] = PointT; for(b = 1; b <= 100; b++) pointY[b] = ++NPoint, link(pointY[b], pointY[b - 1], -2);
        for(a = 0; a <= 100; a++) for(b = 0; b <= 100; b++) link(pointX[a], pointY[b], F[a][b]);
        //print
        printf("Possible\n%d %d\n", NPoint, NSide);
        for(int i = 1; i <= NSide; i++) {
            if(S[i].d < 0) printf("%d %d %c\n", S[i].u, S[i].v, (S[i].d == -1) ? 'X' : 'Y');
            else printf("%d %d %d\n", S[i].u, S[i].v, S[i].d);
        }
        printf("%d %d", PointS, PointT);
    }
}

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int d = in.nextInt(), t = in.nextInt(), s = in.nextInt();
            out.println((((double) d) / s) <= ((double) t) ? "Yes" : "No");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

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

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

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

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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

        }

    }
}



Measured memory_bytes: 32388
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var Ai = Sarray();
            var ans = 0L;
            var mask = 1L;
            for (var i = 0; i < 60; ++i, mask <<= 1)
            {
                var one = 0L;
                var zero = 0L;
                foreach(var a in Ai)
                {
                    if (0 == (mask & a))
                        ++zero;
                    else
                        ++one;
                }
                var num = (one * zero) % Mod;
                var cff = mask % Mod;
                ans = (ans + cff * num) % Mod;
            }
            WriteLine(ans);
            Out.Flush();
        }
    }
}

Measured memory_bytes: 59016
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a+b)*c/2<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

ll P, Q, R;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> P >> Q >> R;
  ll m = max(P, Q);
  m = max(m, R);
  ll ans = P + Q + R - m;
  cout << ans << endl;
  
  

  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
void print(long long x){
  if(x==0)return;
  if(x%26==0)print((x/26)-1),putchar('z');
  else print(x/26),putchar('a'+(x%26)-1);
}
int main(){
  long long x;scanf("%lld",&x);
  print(x),puts("");
}

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

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> b(n);
    int aa;
    rep(i,n){
        cin>>aa;
        a[i]=aa;
        b[i]=aa;
    }
    sort(b.begin(),b.end());
    int b0=b[n-1];
    int b1=b[n-2];
    rep(i,n){
        if(a[i]==b0) cout<<b1<<endl;
        else cout<<b0<<endl;
    }
}

Measured memory_bytes: 4708
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
inline int add(int &a,int b){a+=b;if(a>=mod)a-=mod;}
int dp[1<<21],n,a[21][21];
int dfs(int mask)
{
	if(dp[mask]!=-1) return dp[mask];
	if(mask==(1<<n)-1) return dp[mask]=1;
	dp[mask]=0;
	int p=__builtin_popcount(mask);
	for(int i=0;i<n;i++)
		if(a[p][i]&&!(mask&(1<<i)))
			add(dp[mask],dfs(mask|(1<<i)));
	return dp[mask];
}
int main()
{
	memset(dp,-1,sizeof(dp));
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			scanf("%d",&a[i][j]);
	printf("%d\n",dfs(0));
	return 0;
}

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

#define mp     make_pair
#define pb     push_back
#define all(v) v.begin(),v.end()

#define endl    "\n"
#define peek(x) cout<<#x<<" = "<<x<<"\n";
#define FAST    ios_base::sync_with_stdio(0);cin.tie(0);

typedef long long     ll;
typedef long double   ld;
typedef pair<int,int> ii;

const int    inf = 2e9;
const ll     INF = 4e17;
const int    mod = 1e9+7;
const double eps = 1e-9;

void solveA() {
	string s;
	cin >> s;
	int ans = 0, streak = 0;
	char prev;
	for(int i = 0; i < 4; i++) {
		if(i == 0) {prev = s[i]; continue;}
		if(prev == s[i]) streak++;
		ans = max(ans, streak);
		if(prev != s[i]) streak = 0, prev = s[i];
	}
	if(ans >= 2) cout << "Yes\n";
	else cout << "No\n";
}

void solveB() {
	int N;
	cin >> N;
	ll a = 2, b = 1;
	if(N == 0) {puts("2");return;}
	if(N == 1) {puts("1");return;}
	for(int i = 2; i <= N; i++) {
		ll tmp = a+b;
		a = b;
		b = tmp;
	}
	cout << b << endl;
}

int arr[4];
string res;
void f(int pos, int sum, string s) {
	if(pos >= 3) {
		if(sum == 7) res = s;
		return;
	}
	f(pos+1, sum+arr[pos+1], s+"+");
	f(pos+1, sum-arr[pos+1], s+"-");
}

void solveC() {
	string s;
	cin >> s;
	for(int i = 0; i < 4; i++) arr[i] = s[i]-'0';
	f(0,arr[0],"");
	f(0,-arr[0],"-");
	res += "=";
	if(res.size() == 4) for(int i = 0; i < 4; i++) cout << arr[i] << res[i];
	else{
		for(int i = 0; i < 4; i++) cout << res[i] << arr[i];
		cout << res[4];
	}
	cout << "7";

}
int n, m, c[10][10], dp[10], mat[210][210];
int opt(int x) {
	if(x == 1) return 0;
	if(dp[x] != -1) return dp[x];
	int ret = inf;
	for(int i = 0; i <= 9; i++) {
		if(i == x) continue;
		ret = min(ret, c[x][i] + opt(i));
	}
	return dp[x] = ret;
}

void solveD() {
	cin >> n >> m;
	for(int i = 0; i <= 9; i++) 
		for(int j = 0; j <= 9; j++) 
			cin >> c[i][j];
	memset(dp,-1,sizeof dp);
	for(int i = 0; i <= 9; i++) opt(i);
	for(int i = 0; i <= 9; i++) cout << dp[i] << " ";
	long long ans = 0;
	for(int i = 0; i < n; i++) { 
		for(int j = 0; j < m; j++) {
			cin >> mat[i][j];
			if(mat[i][j] == -1) continue;
			ans += dp[mat[i][j]];
		}
	}
	cout << ans << endl;
}

int main() {
	FAST
	solveA();
	//solveB();
	//solveC();
	//solveD();
	return 0;
}



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

intl A[maxn], sum[maxn];
int n, mark;

int main() {
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) scanf("%lld",&A[i]);
	sort(A + 1, A + n + 1);
	for (int i = 1; i <= n; i++) sum[i] = A[i] + sum[i - 1];
	for (int i = 1; i <= n; i++) if (sum[i] - sum[i - 1] > sum[i - 1] * 2LL) mark = i;
	printf("%d\n", n - mark + 1);
	return 0;
}


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

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

ll X,K,D;

cin >> X >> K >> D;

X = abs(X);

if(X/D >= K) cout << X - D*K << endl;
else{
  K = K - X/D;
  X = X - D*(X/D);
  if(K % 2 == 1) X = X - D;
  cout << abs(X) << endl;
}

return 0;

}   


Measured memory_bytes: 3624
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize
    }
    let mut ans = 0;
    for i in 1..n + 1 {
        if i.to_string().len() % 2 == 1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll inf = 1e10;
ll w[105], v[105];
ll dp[3005][3005];
ll a[200005];
int main() {
	string s;
	string t;
	cin >> s >> t;
	for (int i = 0; i <= s.size(); i++) {
		dp[0][i] = 0;
	}
	for (int i = 0; i <= t.size(); i++) {
		dp[i][0] = 0;
	}
	for (int i = 0; i < t.size(); i++) {
		for (int j = 0; j < s.size(); j++) {
			if (s[j] == t[i]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
			}
			else {
				dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
			}
		}
	}

	string ans = "";
	int x = s.size();
	int y = t.size();
	while (x > 0 && y > 0) {
		if (dp[y][x] == dp[y - 1][x]) {
			y--;
		}
		else if (dp[y][x] == dp[y][x - 1]) {
			x--;
		}
		else {
			x--;
			y--;
			ans.push_back(s[x]);
		}
	}
		reverse(ans.begin(), ans.end());
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 70784
import java.util.Scanner;

public class Main {


	/**入力したトランプの数と種類から、持っていないトランプの種類を出力する
	 *
	 * @param args	　枚数、マーク、番号
	 */
	static Scanner scan = new Scanner(System.in);
	public static void main(String[] args){

		int[] spade= new int[13];
		int[] heart = new int[13];
		int[] club = new int[13];
		int[] diamond = new int[13];

		//初期化	0:not found 1:found
		for(int i=0;i<13;i++){
			spade[i] =0;
			heart[i] =0;
			club[i] = 0;
			diamond[i] = 0;
		}

		int rest = scan.nextInt();
		for(int k=1; k < rest * 2;k=k+2){

			String mark = scan.next();//args[k];

			int number = scan.nextInt();//r.parseInt(args[k+1]);

			if(mark.equals("S")){			//spadeの場合
				spade[number-1] =1;
			}
			if(mark.equals("H")){			//heartの場合
				heart[number-1] =1;
			}
			if(mark.equals("C")){			//clubの場合
				club[number-1] = 1;
			}
			if(mark.equals("D")){			//diamondの場合
				diamond[number-1] = 1;
			}

		}

		//output
		for(int j=1;j<=13; j++){
			if(spade[j-1] == 0)
				System.out.println("S "+j);
		}
		for(int j=1;j<=13; j++){
			if(heart[j-1] == 0)
				System.out.println("H "+j);
		}
		for(int j=1;j<=13; j++){
			if(club[j-1] == 0)
				System.out.println("C "+j);
		}
		for(int j=1;j<=13; j++){
			if(diamond[j-1] == 0)
				System.out.println("D "+j);
		}
	}
}



Measured memory_bytes: 26188
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


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

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

    return wrapper

s=list(input())
s[3] = '8'

print(''.join(s))


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && b != c){
        puts("Yes");
    }else if(b == c && c != a){
        puts("Yes");
    }else if(c == a && a != b){
        puts("Yes");
    }else{
        puts("No");
    }

    return 0;
}

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

int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}

int main(void){
    int n;
    scanf("%d",&n);
    int a[n],b[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        b[i]=a[i]-(i+1);
    }
    qsort (b,n,sizeof(int),sort);
    long long int ans1=0,ans2=0;
    if (n%2==0){
        for (int i=0; i<n; i++){
            ans1+=abs(b[i]-b[n/2-1]);
            ans2+=abs(b[i]-b[n/2]);
        }
        if (ans1<ans2){
            printf ("%lld\n",ans1);
        } else {
            printf ("%lld\n",ans2);
        }
    } else {
        for (int i=0; i<n; i++){
            ans1+=abs(b[i]-b[(n+1)/2-1]) ;
        }
        printf ("%lld\n",ans1) ;
    }
	return 0 ;
}

Measured memory_bytes: 2556
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

r=int(input())
g=int(input())
print(2*g-r)

Measured memory_bytes: 38384
x, k , d = map(int, input().split())

c = x//d

a = x - x//d * d
b = d - abs(a)

if x//d%2 == 0:
    odd = a
    even = b
else:
    odd = b
    even = a

if abs(x//d) > k:
    ans = abs(abs(x) - abs(d*k))
else:
    if k%2 ==0:
        ans = odd
    else:
        ans = even

# print(odd,even)
print(abs(ans))

Measured memory_bytes: 9200
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(1e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;


void solve(){
	char c;
	cin >> c;
	if(c == 'a' || c== 'e' || c == 'i' || c == 'o' || c == 'u')
		cout<<"vowel\n";
	else 
		cout << "consonant\n"; 
}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    long long ans = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if (-(a[i] + a[i + 1]) > 0)
        {
            a[i] *= -1;
            a[i + 1] *= -1;
        }
    }
    for (int i = 0; i < n; i++)
    {
        cerr << a[i] << endl;
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int i, j;
  int n;
  int data[100001];
  int odd=0, even=0;
  long int temp;
  int flag=0;

  scanf("%d", &n);

  for (i = 0; i < n;i++){
    scanf("%ld", &temp);
    if(temp % 2 == 0){
      even++;
    }
    else {
      odd++;
    }
  }
  

  if (odd%2 == 1) {
//    flag = 1;
printf("NO");
  }else {
    printf("YES");
  }

  /*
  else {
    even += odd / 2;
    while (even >1){
      if (even % 2 == 1){
        flag = 1;
        break;
      }
      else {
        even = even / 2;
      }
    }
  }
  */


   return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1e9+7 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll a,b,c ;
	cin >> a >> b >> c ;
	cout << min(c,b/a) << endl ;
}


Measured memory_bytes: 3596
// Date: 2020-03-28

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define D(x) cout << #x << " = " << x << endl;
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int main() {
    FIO;
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;

public class Main {
	static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int n = parseInt(sc.next());
		int k = parseInt(sc.next());
		sc.close();
		long ans = n-k+1;
		System.out.println(ans);
		long[][] pas = new long[n+1][n+1];
		pas[0][0] = 1;
		for(i=1;i<=n;i++) {
			pas[i][0] = pas[i-1][0]; 
//			System.out.printf("C(%d,0)=%d%n", i, pas[i][0]);
			for(j=1;j<=i;j++) {
				pas[i][j] = pas[i-1][j-1] + pas[i-1][j]; 
				if(pas[i][j] >= MOD) pas[i][j] %= MOD;
//				System.out.printf("C(%d,%d)=%d%n", i, j, pas[i][j]);
			}
		}
		long ans2 = 0;
		for(i=2;i<=k;i++) {
//			System.out.printf("C(%d,%d)=%d%n", n-k+1, i, pas[n-k+1][i]);
//			System.out.printf("C(%d,%d)=%d%n", k-1, i-1, pas[k-1][i-1]);
			ans2 = pas[n-k+1][i]*pas[k-1][i-1];
//			System.out.println(ans2);
			if(ans2 >= MOD) ans2 %= MOD;
			System.out.println(ans2);
		}
	}
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

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

    if(b <= a) cout << "delicious" << endl;
    else if(0 <=  x - (b - a) ) cout << "safe" << endl;
    else cout << "dangerous" << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque
H,W = map(int,input().split())
mat = []
alr = [[-1 for i in range(W)] for j in range(H)]
que = deque()
for i in range(H):
    mat.append(list(input()))
    for j in range(W):
        if mat[i][j] == '#':
            alr[i][j] = 0
            que.append([i,j])

x1 = [0,0,1,-1]
y1 = [1,-1,0,0]
count = 0
while que:
    q = que.popleft()
    for i in range(4):
        if (0 <= q[0]+x1[i] <= H-1) and (0 <= q[1]+y1[i] <= W-1):
            if mat[q[0]+x1[i]][q[1]+y1[i]] == '.' and alr[q[0]+x1[i]][q[1]+y1[i]] == -1:
                alr[q[0]+x1[i]][q[1]+y1[i]] = alr[q[0]][q[1]] + 1
                count = max(count,alr[q[0]][q[1]] + 1)
                que.append([q[0]+x1[i],q[1]+y1[i]])
                mat[q[0]+x1[i]][q[1]+y1[i]] = '#'

print(count)


Measured memory_bytes: 159580
#include<stdio.h>
int main(){
    int i;
char s[3], t[3];
  gets(s);
  gets(t);
int count=0;
for(i=0; i<3; i++)
{
  if(s[i]== t[i]){
    count++;
  }
}
printf("%d",count);
  return 0;
}


Measured memory_bytes: 128
n = int(input())

s = [input() for i in range(n)]

def shiritori(s):
  if len(s) != len(set(s)):
    return False
  
  for i in range(n-1):
    if s[i][-1] != s[i+1][0]:
      return False
  
  return True

if __name__ == '__main__':
  if shiritori(s):
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3060
#include <stdio.h>

long div(long n, long x);

int main(void)
{
	long long  a, b, x;
	long long count = 0;
	
	scanf("%lld%lld%lld", &a, &b, &x);
	count = div(b, x) - div(a - 1, x);
	printf("%lld", count);
	return 0;
}
long div(long n, long x)
{
	if(n == -1) {
		return 0;
	}
	else {
		return n / x + 1;
	}
}

Measured memory_bytes: 128
using System;

namespace ITP1_10_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            double a = double.Parse(strs[0]);
            double b = double.Parse(strs[1]);
            double th = double.Parse(strs[2])/180*Math.PI;
            double c = Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(th));
            double s = a * b * Math.Sin(th) / 2f;
            Console.WriteLine(s);
            Console.WriteLine(a + b + c);
            Console.WriteLine(s * 2 / a);
        }
    }
}

Measured memory_bytes: 9116
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k=map(int,input().split())
H=list(map(int,input().split()))

H.sort()
for i in range(n-k):
    count+=(H[i])
print(count)

Measured memory_bytes: 91888
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#ifdef ONLINE_JUDGE
#define D(...)
#else
#define D(...)cerr<<__LINE__<<":"<<"["<<#__VA_ARGS__<<"]->",P(__VA_ARGS__)
#endif
void P(){cerr<<endl;} 
template<typename H,typename...T>void P(H h,T...t){cerr<<h<<" ";P(t...);}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    string s,t;cin>>s>>t;
    int cnt=s.size();
    while(cnt--){
        if(s==t){
            return cout<<"Yes",0;
        }
        rotate(&s[0],&s[1],&s[int(s.size())]);
    }
    cout<<"No";
    



}

Measured memory_bytes: 3600
def check(S, T):
    n = len(S)
    m = {}
    d = {}
    for i in range(n):
        s = S[i]
        t = T[i]
        if t not in d:
            d[t] = s
        if d[t] != s:
            return False
        if s not in m:
            m[s] = t
        if m[s] != t:
            return False
    return True


def main():
    S = input()
    T = input()
    if check(S, T):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3632
import java.util.*;
import java.util.concurrent.atomic.LongAccumulator;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long ans = Long.MAX_VALUE;
        long f, b;
        for (long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                b = n / i;
                f = Math.max(clac_digit(i), clac_digit(b));
                ans = Math.min(ans, f);
            }
        }
        System.out.println(ans);
    }

    public static long clac_digit(long n) {
        long res = 0;
        while (n > 0) {
            res++;
            n /= 10;
        }
        return res;
    }
}

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

public class Main {

	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] numbers = line.split(" ");
		
		int x = Integer.parseInt(numbers[0]);
		int y = Integer.parseInt(numbers[1]);
		
		int max = Math.max(x, y);
		int min = Math.min(x, y);
				
		while(true){
			if(max % min == 0){
				break;
			}
			
			//ユークリッドの互除法
			int v = min;
			min = max % min;
			max = v;
		}
		
		System.out.println(min);
		
	}
	
}

Measured memory_bytes: 16896
whn = list (map(int, input().split()))
x = 0
y = 0
flag = 0

for i in range(whn[2]):
    xya = list(map(int,input().split()))
    if xya[2] == 1:
        x = max(x, xya[0])
    elif xya[2] == 2:
        whn[0] = min(whn[0], xya[0])
    elif xya[2] == 3:
        y = max(y, xya[1])
    else:
        whn[1] = min(whn[1], xya[1])
    if x >= whn[0] or y >= whn[1]:
        print(0)
        flag += 1
        break
        
if flag == 0:
    print((whn[0]-x)*(whn[1]-y))


Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var n int

func rec(a, keta int, f3, f5, f7 bool) int {
	if a > n {
		return 0
	}

	ret := 0
	if f3 && f5 && f7 {
		ret++
	}
	ret += rec(a+3*keta, keta*10, true, f5, f7)
	ret += rec(a+5*keta, keta*10, f3, true, f7)
	ret += rec(a+7*keta, keta*10, f3, f5, true)

	return ret
}

func solve() {
	n = getInt()

	ans := rec(0, 1, false, false, false)
	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


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

int a[4000];
int ans;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define XX first
#define YY second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N, Q;
string S[114514];
int nxt[414514][26];
int cnt[414514][26][26];
int num[414514];
bool leaf[414514];
bool calced[114514];
int inc[114514];
int g_cur = 1;

void Register(string &s) {
  int n = s.size();
  int v = 1;
  num[v]++;
  rep(i, n) {
    int idx = s[i] - 'a';
    if (!nxt[v][idx]) {
      nxt[v][idx] = ++g_cur;
    }
    v = nxt[v][idx];
    num[v]++;
  }
  leaf[v] = 1;
}

void Calc(int k, int v=1, int idx=0) {
  if (leaf[v]) inc[k]++;
  if (idx >= S[k].size()) return;
  int e = S[k][idx] - 'a';
  assert(nxt[v][e]);
  rep(i, 26) {
    if (i == e) continue;
    int u = nxt[v][i];
    if (!u) continue;
    cnt[k][i][e] += num[u];
  }
  Calc(k, nxt[v][e], idx+1);
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> N;
  rep(i, N) {
    cin >> S[i];
    Register(S[i]);
  }

  cin >> Q;
  string ord;
  rep(i, Q) {
    int k;
    cin >> k;
    --k;
    if (!calced[k]) {
      Calc(k);
      calced[k] = 1;
    }
    cin >> ord;
    int ans = 0;
    rep(i, 26) {
      reps(j, i+1, 26) {
        ans += cnt[k][ord[i]-'a'][ord[j]-'a'];
      }
    }
    cout << ans+inc[k] << endl;
  }
}


Measured memory_bytes: 125952
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	string s;
	cin >> n >> s;
	int to = 0;
	int ans = 3e5 + 5;
	rep(i,0,n)to += s[i] == 'E'; 	
	
	rep(i,0,n){
		gmin(ans, to);
		to += s[i] == 'E' ? -1:1;
	}
	gmin(ans, to);
	
	cout << ans << '\n';
}


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

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) break;
    getchar();
    string data;
    getline(cin,data);

    for(int i=0;i<n;i++){
      string temp;
      for(int k=0;k<data.size();k++){
        for(int j=0;;j++){
          if(data[j+k]!=data[k] || j>=data.size()){
            k=j+k-1;
            if(j<10)
              temp+=(j+'0');
            else if(j<100){
              temp+=((j/10)+'0');
              temp+=((j%10)+'0');
            }
            else if(j<1000){
              temp+=((j/100)+'0');
              j%=100;
              temp+=((j/10)+'0');
              temp+=((j%10)+'0');
            }
            temp+=data[k];
            break;
          }
        }
      }
      data=temp;
    }

    cout << data << endl;
  }
  return 0;
}

Measured memory_bytes: 0