akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
#ABC122 D

#条件を満たさないものは以下の5通りで追加する文字列+3文字を見れば決まる
#ACG,GAC,AGC,A?GC,AG?C
n = int(input())
#メモ化再帰
memo = [{} for i in range(n+1)]
mod = 10**9 + 7

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1],t[i] = t[i],t[i-1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True

def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == n:
        return 1
    ret = 0
    #AGCTを1文字ずつ追加してみる
    for c in 'AGCT':
        #cを追加したときにTrue(不適でない)なら
        if ok(last3 + c):
            #現在位置を1つ進めてcを追加した値を足す
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % mod
    #値を格納
    memo[cur][last3] = ret
    return ret
print(dfs(0,'TTT'))


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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  if(n <= 999) cout << "ABC" << endl;
  else cout << "ABD" << endl;
  return 0;
}


/*





















*/


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

using i64 = int64_t;

int main(){
    int n;
    string s;
    cin >> n >> s;
    if(n % 2)cout << "No" << endl;
    else{
        if(s.substr(0, n/2) == s.substr(n/2)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import sys

N=int(input())
W_li=[]
W=input()
W_li.append(W)

for i in range(N-1):
    W=input()
    if W in W_li:
        print("No")
        sys.exit()
    elif W_li[i][-1:]!=W[0]:
        print("No")
        sys.exit()
    else:
        W_li.append(W)
        
print("Yes")


Measured memory_bytes: 3060
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int K, X;

int main() {
	cin >> K >> X;
	int ans = X - K + 1;
	REP(i, 2 * K - 1) {
		cout << ans << " ";
		ans++;
	}
}

/*
4 3 1 2
*/

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

string reverse(string str, int first, int end);
string replace (string str, int first, int end, string rep);

int main(){
    string str;
    string imp;
    int q = 0;

    cin >> str;
    cin >> q;

    for(int i = 0; i < q; i++){
        cin >> imp;
        if(imp == "replace"){
            int s = 0,e = 0;
            string rep;
            cin >> s >> e >> rep;
            str = replace(str,s,e,rep);
        }else if(imp == "reverse"){
            int s = 0,e = 0;
            cin >> s >> e;
            str = reverse(str,s,e);
        }else if(imp == "print"){
            int s = 0,e = 0;
            cin >> s >> e;
            for(int j = s; j <= e; j++){
                cout << str[j];
            }
            cout << endl;
        }
        //cout << str;

        
        
    }

    return 0;
}
string replace (string str, int first, int end, string rep){
    string buf = str;
    for(int i = first; i <= end; i++){
        buf[i] = rep[i - first];
    }
    return buf;
}
string reverse(string str, int first, int end){
    string buf = str;
    int f_buf = first;
    for(int i = end; i >= first; i--){
        buf[f_buf] = str[i];
        f_buf++;
    }

    return buf;
}


Measured memory_bytes: 3172
// ABC 106 C

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

int gcd(int u, int v)
{
  return (v != 0) ? gcd(v, u % v) : u;
}

void dump(vector<int> a)
{
  for (auto v : a) {
    cerr << v << " ";
  }
  cerr << endl;
}

const ll days = 500000000000000;

int main(int argc, char** argv) {
  string s;
  cin >> s;
  ll k;
  cin >> k;

  rep(i, s.size()) {
    ll num = s[i] - '0';
    k -= pow(num, days);
    if (k <= 0) {
      cout << s[i] << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    char S[4];
    int count = 0;
    scanf("%s",S);
    for(int i=0;i<4;i++){
        if(S[i]=='+'){
            count++;
        }
		else{
            count--;
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
from collections import Counter

n=int(input())
V=list(map(int,input().split()))

V1=V[0::2]
V2=V[1::2]

V1c=Counter(V1).most_common()
V2c=Counter(V2).most_common()


if V1c[0][0]==V2c[0][0]:
  if len(V1c)==1 and len(V2c)==1:
    print(n//2)
  elif len(V1c)==1:
    print(V2c[0][1])
  elif len(V2c)==1:
    print(V1c[0][1])   
  else:
    print(n-max(V1c[0][1]+V2c[1][1],V1c[1][1]+V2c[0][1]))
else:
  print(n-V1c[0][1]-V2c[0][1])

Measured memory_bytes: 21084
#include <bits/stdc++.h>
using namespace std;
const double PI = 4 * atan(1);

int T[3005];

long double x = 0.0;
long double y = 0.0;

int main(){
	int N, L; cin >> N >> L;
	for (int i = 0; i < N; i++){
		cin >> T[i];
	}
	for (int i = 0; i < N; i++){
		for (int j = i + 1; j < N; j++){
			x -= (j - i - 1) * cos(PI * (T[i] + T[j]) / L);
			y -= (j - i - 1) * sin(PI * (T[i] + T[j]) / L);
			x += (N - j + i - 1) * cos(PI * (T[i] + T[j]) / L);
			y += (N - j + i - 1) * sin(PI * (T[i] + T[j]) / L);
		}
	}
	x *= 6; y *= 6;
	x /= N; y /= N;
	x /= (N - 1); y /= (N - 1);
	x /= (N - 2); y /= (N - 2);
	cout << fixed << setprecision(15);
	cout << x << ' ' << y << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
const int sz=1e9+7;

int main()
{
	ll n, a, b, ans=0;
	cin>>n>>a>>b;
	if(a==0)cout<<"0"<<endl;
	else{
	ans+=(a*(n/(a+b)));

	ll m=n%(a+b);

	if(m<=a)ans+=m;
	else ans+=a;

	cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.immutable
import scala.collection.mutable.ListBuffer

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val num1, num2 = sc.next
    val num = (num1 + num2).toInt
    val numRoot:Int = Math.sqrt(num).toInt

    if(num equals(numRoot*numRoot)) println("Yes") else println("No")

  }

}

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

using namespace std;
typedef long long ll;

int main(void) {
	int x, i;
	cin >> x;
	if (x == 7 || x == 5 || x == 3)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		int nico = Integer.parseInt(sc.nextLine());
		for (int i = 0; i < nico; i++) {
			String[] params = sc.nextLine().split(" ");
			
			double[] points = new double[8];
			for (int j = 0; j < points.length; j++) {
				points[j] = Double.parseDouble(params[j]);
			}
			
			long dx0 = Math.round((points[2] - points[0]) * 100000.0);
			long dy0 = Math.round((points[3] - points[1]) * 100000.0);
			long dx1 = Math.round((points[6] - points[4]) * 100000.0);
			long dy1 = Math.round((points[7] - points[5]) * 100000.0);

			long d = (dx0 * dy1 - dy0 * dx1);
			if (d == 0) System.out.println("YES");
			else System.out.println("NO");
		}
	}
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    string N;
    cin >> N;

    int sum = 0;
    for (char c : N) sum += c - '0';
    if (sum%9 == 0) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P=pair<int,int>;
int main() {
    long long a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    long long dis=abs(b-a);
    ll run=v-w;
    if(run<=0){
        cout<<"NO"<<endl;
    }else{
        if(dis%run==0 && dis/run<=t) cout<<"YES"<<endl;
        else if(dis/run<=t-1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }

}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){

  int A,B;
  cin>>A>>B;
  int ans=0;
  int i10000=0;
  int i1000=0;
  int i100=0;
  int i10=0;
  int i1=0;
  for(int k=A;k<=B;k++){
  
    int i=k;
    i10000=i/10000;
    i-=i10000*10000;
    i1000=i/1000;
    i-=i1000*1000;
    i100=i/100;
    i-=i100*100;
    i10=i/10;
    i-=i10*10;
    i1=i;
    if(i10000==i1&&i1000==i10)ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, a[100005];

int main() {
  INCANT;
  cin >> N;
  bool flag = false;
  rep(i, N) {
    cin >> a[i];
    if (a[i]%2==1) flag = true;
  }
  string ans = flag?"first":"second";
  cout << ans << endl; 
  
  return 0;
}

Measured memory_bytes: 4020
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
ll lol[1000003];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
   //cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
        
        ll n;
        cin>>n;
        ll a[n+2];
        
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            lol[a[i]]++;
        }
        ll ans=0;
        for(int i=1;i<=n;i++)
        {
           lol[a[i]]--;
            ll w=0;
           for(int j=1;j<=sqrt(a[i]);j++)
           {
              if(a[i]%j==0)
              {
                  if(lol[a[i]/j]==0&&lol[j]==0)
                    continue;
                  else
                    {
                        w=1;
                        break;
                    }
              }

           }
           lol[a[i]]++;
           if(w==0)
            ans++;
        //cout<<ans<<endl;
        }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 13076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Heat Strokes
 */
public class Main {

	static int INF = 1 << 29;

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

		int A, B, X;
		StringTokenizer st = new StringTokenizer(br.readLine());
		A = parseInt(st.nextToken());
		B = parseInt(st.nextToken());
		X = parseInt(st.nextToken());

		int[] dp = new int[X + 1000 + 1];
		Arrays.fill(dp, INF);
		dp[0] = 0;

		for (int i = 0; i <= X; i++) {
			if (dp[i + 1000] > dp[i] + A) {
				dp[i + 1000] = dp[i] + A;
			}
		}

		for (int i = 0; i <= X + 500; i++) {
			if (dp[i + 500] > dp[i] + B) {
				dp[i + 500] = dp[i] + B;
			}
		}

		int ans = INF;
		for (int i = X + 1000; i >= X; i--) {
			if (dp[i] < ans) ans = dp[i];
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 24412
#include<iostream>
#include<utility>
#include<tuple>
#include<set>
#include<list>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define int long long

const long long MAXN = 1e6;
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;

signed main(){
    size_t K;
    cin >> K;
    vector<int> dist;
    dist.reserve(K);
    for (size_t i = 0; i < K; i++) dist.push_back(INF);
    dist[1] = 1;
    vector<int> currents;
    currents.push_back(1);
    while(!currents.empty()){
      vector<int> nexts;
      for(auto current : currents)
      {
        if (dist[(current + 1) % K] > dist[current] + 1){
          nexts.push_back((current+1) % K);
          dist[(current+1) % K] = dist[current] + 1;
        }
        if (dist[(current * 10) % K] > dist[current]){
          nexts.push_back((current*10) % K);
          dist[(current*10) % K] = dist[current];
        }
      }
      currents = nexts;
    }

    cout << dist[0] << endl;
    return 0;
}




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

int main() {
  int n, i;
  cin >> n;
  
  vector<int> a(n + 1), b(n);
  for(i = 0; i < n + 1; i++){
    cin >> a.at(i);
  }
  for(i = 0; i < n; i++){
    cin >> b.at(i);
  }
  
  long long ans = 0;
  for(i = 0; i < n; i++){
    if(a.at(i) <= b.at(i)){
      ans += a.at(i);
      b.at(i) -= a.at(i);
      a.at(i) = 0;
      if(a.at(i + 1) <= b.at(i)){
        ans += a.at(i + 1);
        b.at(i) -= a.at(i + 1);
        a.at(i + 1) = 0;
      }
      else{
        ans += b.at(i);
        a.at(i + 1) -= b.at(i);
        b.at(i) = 0;
      }
    }
    else{
      ans += b.at(i);
      a.at(i) -= b.at(i);
      b.at(i) = 0;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long long LL;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, K, S;
	cin >> N >> K >> S;
	if (S <= 5 * 1e8) {
		for (LL n = 0; n < K; n++) {
			cout << S;
			if (n != N - 1)cout << " ";
		}
		for (LL n = 0; n < N - K; n++) {
			cout << 2 * S;
			if (n != N - K - 1)cout << " ";
		}
		cout << "\n";
	}
	else {
		for (LL n = 0; n < K; n++) {
			cout << S;
			if (n != N - 1)cout << " ";
		}
		for (LL n = 0; n < N - K; n++) {
			cout << 1;
			if (n != N - K - 1)cout << " ";
		}
		cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
	string x;
	vector<int> p, a;
	int n;
	getline(cin, x);
	p.push_back(0);
	a.push_back(0);
	while(n=x.find("peach", p.back() + 5), ~n)
		p.push_back(n);
	while(n=x.find("apple", a.back() + 5), ~n)
		a.push_back(n);
	for(int i = 1; i < p.size(); i++)
		x.replace(p[i], 5, "apple");
	for(int i = 1; i < a.size(); i++)
		x.replace(a[i], 5, "peach");
	cout<< x <<endl;
	return 0;
}


Measured memory_bytes: 3148
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#define INF 16777216
typedef long long llong;
using namespace std;

llong EN2D(llong,llong);
llong EN2R(llong,llong);
llong D2EN(llong,llong);
llong R2EN(llong,llong);

int main(){
  llong M,Cd,Cr,MD,MR,RA,DA;
  int rD,rR;
  cin >> M >> rD >> rR >> Cd >> Cr;
  
  MD=D2EN(Cd,rD);
  MR=R2EN(Cr,rR);
  if(M<MD+MR){
    cout<<-1<<endl;
  }else{
    DA=D2EN( EN2D(10000,rD),rD);
    RA=R2EN( EN2R(10000,rR),rR);
    cout<<M-MD-MR<<endl;
  }

  return 0;
}

llong EN2D(llong x,llong rD){
  return (rD*x)/100 + ((rD*x)%100>0);
}
llong EN2R(llong x,llong rR){
  return (rR*x)/100 + ((rR*x)%100>0);
}
llong D2EN(llong x,llong rD){
  return (100*x)/rD + ((100*x)%rD>0);
}
llong R2EN(llong x,llong rR){
  return (100*x)/rR + ((100*x)%rR>0);
}

Measured memory_bytes: 1172
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        for (int i=0;i<N;i++) {
            X[i] = sc.nextInt();
        }

        int ans = 1_000_000_000;
        for (int i=1;i<=100;i++) {
            int sum = 0;
            for (int j=0;j<N;j++) {
                sum+=(X[j]-i)*(X[j]-i);
            }
            ans = Math.min(ans, sum);
        }
        System.out.println(ans);
    }
}

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

int Pow(int n, int m);
int Max(int N[], int n);
int Min(int N[], int n);
int Sum(int N[], int n);



int main()
{
	int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
	int x3 = 0, y3 = 0, x4 = 0, y4 = 0;
	scanf("%d%d%d%d", &x1,&y1, &x2, &y2);
	
	int Vx = 0, Vy = 0;

	if (x1 <= x2) {
		if (y1 <= y2) {
			Vx = x2 - x1;
			Vy = y2 - y1;

			x3 = x2 - Vy;
			y3 = y2 + Vx;
			x4 = x1 - Vy;
			y4 = y1 + Vx;
		}
		else if(y2 < y1) {
			Vx = x2 - x1;
			Vy = y1 - y2;

			x3 = x2 + Vy;
			y3 = y2 + Vx;
			x4 = x1 + Vy;
			y4 = y1 + Vx;
		}
	}
	else if (x2 < x1) {
		if (y1 <= y2) {
			Vx = x1 - x2;
			Vy = y2 - y1;

			x3 = x2 - Vy;
			y3 = y2 - Vx;
			x4 = x1 - Vy;
			y4 = y1 - Vx;
		}
		else if(y2 < y1) {
			Vx = x1 - x2;
			Vy = y1 - y2;

			x3 = x2 + Vy;
			y3 = y2 - Vx;
			x4 = x1 + Vy;
			y4 = y1 - Vx;
		}
	}
	

	printf("%d %d %d %d", x3, y3, x4, y4);

	return 0;
}

int Pow(int n, int m) {
	int ret = 1;

	for (int i = 0; i < m; i++) {
		ret *= n;
	}

	return ret;
}

int Max(int N[], int n) {
	int max = N[0];

	for (int i = 0; i < n; i++) {
		max = max < N[i] ? N[i]: max;
	}

	return max;
}

int Min(int N[], int n) {
	int min = N[0];

	for (int i = 0; i < n; i++) {
		min = min > N[i] ? N[i] : min;
	}

	return min;
}

int Sum(int N[], int n) {
	int sum = 0;

	for (int i = 0; i < n; i++) {
		sum += N[i];
	}

	return sum;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  priority_queue<int> a;
  rep(i, n){
    int in;
    cin >> in;
    a.push(in);
  }
  rep(i, m){
    int po = a.top();
    a.pop();
    po >>= 1;
    a.push(po);
  }

  ll ans = 0;
  while(!a.empty()){
    ans += a.top();
    a.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

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

int main()
{
    ll N,M;
    cin >> N >> M;
    ll ans=1;
    for(ll i=1; i*i<=M; i++){
        if(M%i==0){
            if(N<=M/i) ans=max(i,ans);
            if(N<=i) ans=max(M/i,ans);
        }
    }
    cout << ans << endl;




    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<map>
#include<cmath>
#include<set>
#include<string>
using namespace std;
#define rep(i,n) for(int i =0;i < n;i++)
int main() {
    string s, t;
    cin >> s >> t;
    for (int i = 0; i <= s.size();i++) {
        rotate(s.begin(),s.begin()+1,s.end());
        if (s == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
 }

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
        
        while (scan.hasNext()){
      double w=scan.nextDouble();		 
      if(w>91.00)System.out.println("heavy");
      else if(81.00<w&&w<=91.00)System.out.println("light heavy");
      else if(75.00<w&&w<=81.00)System.out.println("middle");
      else if(69.00<w&&w<=75.00)System.out.println("light middle");
      else if(64.00<w&&w<=69.00)System.out.println("welter");
      else if(60.00<w&&w<=64.00)System.out.println("light welter");
      else if(57.00<w&&w<=60.00)System.out.println("light");
      else if(54.00<w&&w<=57.00)System.out.println("feather");
      else if(51.00<w&&w<=54.00)System.out.println("bantam");
      else if(48.00<w&&w<=51.00)System.out.println("fly");
      else System.out.println("light fly");
      }
        }
      

}

Measured memory_bytes: 12000
def main
  n = gets.chomp.to_i
  hash = {}
  count = 0
  n.times do
    s = gets.chomp
    h = s.split('').sort.join
    if hash[h]
      count += hash[h]
      hash[h] += 1
    else
      hash[h] = 1
    end
  end
  puts count
end

main if $0 == __FILE__


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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
const int mxn = 2e5;
const int M = 1e9 + 7;

ll pw(ll b, ll e)
{
	ll res = 1;
	while (e)
	{
		if (e % 2)
			res = (res * b) % M;
		b = (b * b) % M;
		e >>= 1; // e/=2;
	}
	return res;
}

ll iv[mxn + 1];
ll nck(int n, int k)
{
	ll ans = 1;
	for (int i = 1; i <= k; i++)
		ans = ans * (n - i + 1) % M * iv[i] % M;
	return ans;
}
int main()
{
	fast;
	iv[1] = 1;
	for (int i = 2; i <= mxn; i++)
		iv[i] = M - M / i * iv[M % i] % M;
	int n, a, b;
	cin >> n >> a >> b;
	ll ans = pw(2, n) - 1;
	// cout << (ans + 2 * M - nck(n, a) - nck(n, b) + M) % M;
	ans = (ans - nck(n,a) - nck(n,b))%M;
	if(ans < 0) ans += M;
	cout << ans;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int fact(int n)
{
    int ans = 1;
    rep1r(i, n) ans *= i;
    return ans;
}

int main(){
    int n, a = 0, b = 0;
    cin >> n;
    vi p, q;
    rep(i, n) {
        int d, s;
        cin >> d;
        p.push_back(d);
        if (i == n-1) break;
        s = d - 1;
        rep(j, i) {
            if (p[j] < d) s--;
        }
        a += s * fact(n-1-i);
    }
    rep(i, n) {
        int d, s;
        cin >> d;
        q.push_back(d);
        if (i == n-1) break;
        s = d - 1;
        rep(j, i) {
            if (q[j] < d) s--;
        }
        b += s * fact(n-1-i);
    }
    cout << abs(a-b) << endl;
    return 0;
}



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

int main() {
	long long N, M, ANS = 0;
	static bool X[100000] = {};
	priority_queue<long long> PQ;
	static vector<long long> V[100000];
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		long long A, B;
		cin >> A >> B;
		A--;
		V[A].push_back(B);
	}
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < V[i].size(); j++) {
			PQ.push(V[i][j]);
		}
		if (!PQ.empty()) {
			ANS += PQ.top();
			PQ.pop();
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
#define N 4005
using namespace std;
int n,ans,f[N][N],a[N],w[N],b[N],sumw[N][N],sumb[N][N];
char c[N];
int main(){
	scanf("%d",&n);getchar();
	for (int i=1;i<=2*n;i++){
		c[i]=getchar();
		scanf("%d",&a[i]);getchar();
		if (c[i]=='W') w[a[i]]=i; else b[a[i]]=i;
	}
	for (int i=1;i<=2*n;i++){
		for (int j=1;j<=n;j++){
			if (c[i]=='W'){
				if (a[i]<=j) sumw[i][j]=sumw[i-1][j]+1; else sumw[i][j]=sumw[i-1][j];
				sumb[i][j]=sumb[i-1][j];
			} else
			if (c[i]=='B'){
				if (a[i]<=j) sumb[i][j]=sumb[i-1][j]+1; else sumb[i][j]=sumb[i-1][j];
				sumw[i][j]=sumw[i-1][j];
			}
		}
	}
	memset(f,0x3f3f3f3f,sizeof(f));
	f[0][0]=0;
	for (int i=0;i<=n;i++)
	for (int j=0;j<=n;j++){
		int t=w[i+1];
		f[i+1][j]=min(f[i+1][j],f[i][j]+t-sumw[t][i]-sumb[t][j]-1);
		t=b[j+1];
		f[i][j+1]=min(f[i][j+1],f[i][j]+t-sumw[t][i]-sumb[t][j]-1);
	}
	printf("%d\n",f[n][n]);
}

Measured memory_bytes: 187776
//line = require('fs').readFileSync('tmp', 'ascii').split('\r\n'); // win
line = require('fs').readFileSync('/dev/stdin', 'ascii').split('\n'); // linux

res = [];
for (i in line) {
	str = line[i];
	if (str === '0') break;
	sum = 0;
	for (j in str) sum += parseInt(str[j]);
	res.push(sum);
}
console.log(res.join('\n'));

Measured memory_bytes: 15784
#include<stdio.h>
#define MAX 200000

void insert(int, int);
int r_search();
void rec(int, int);
void print();

struct Node{
  int parent;
  int child;
  int sibling;
};

int n;
struct Node Node[MAX];//それぞれのノードは構造体で保存する
int Depth[MAX];//各ノードの深さを配列に格納する

int main(){
  int Node_num, Node_Index;//これから入力するノードの数とノードの番号を記録
  int node, child, root;
  int i, j;
  
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    Node[i].parent = -1;
    Node[i].sibling = -1;
    Node[i].child = -1;//構造体のノードを全て初期化する
  }

  //ノードの中にデータを入れていく
  for(i = 0; i < n; i++){
    scanf("%d %d", &Node_Index, &Node_num);
    insert(Node_Index, Node_num);
  }

  //rootがどこなのかを探索する
  root = r_search();

  //それぞれのノードの深さを配列に記録する
  rec(root, 0);

  //出力していく
  print();
  
  return 0;
}

void insert(int Node_Index, int Node_num){
  int child, node;
  int i, j;

  for(i = 0; i < Node_num; i++){
    scanf("%d", &node);
    
    if(i == 0){
      Node[Node_Index].child = node;
    }else{
      Node[child].sibling = node;
    }
    
    child = node;
    Node[node].parent = Node_Index;
  }
}

int r_search(){
  int i;
  for(i = 0; i < n; i++){
    if(Node[i].parent == -1){
      return i;
    }
  }
  return 0;//ここのelseはあんまり意味がないかも
}

void rec(int node, int depth){
  Depth[node] = depth;
  if(Node[node].sibling != -1){
    //右の兄弟に同じ深さを設定する
    rec(Node[node].sibling, depth);
  }

  if(Node[node].child != -1){
    //一番左の子供に自分の深さ+1を設定する
    rec(Node[node].child, depth + 1);
  }
}

void print(){
  int i, j;
  int child;
  
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ", i, Node[i].parent, Depth[i]);
    if(Node[i].parent == -1){
      printf("root, ");
    }else if(Node[i].child == -1){
      printf("leaf, ");
    }else{
      printf("internal node, ");
    }
    
    child = Node[i].child;
    printf("[");
    for(j = 0; child != -1; j++){
      if(j != 0)printf(", ");
      printf("%d",child);
      child = Node[child].sibling;
    }
    printf("]\n");
  }
}
  




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

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

using namespace std;
using graph=vector<vector<int>>;

vector<int> topological_order(const graph& D){
	int n=D.size();
	vector<int> deg(n);
	rep(u,n) for(int v:D[u]) deg[v]++;

	vector<int> res;
	queue<int> Q;
	rep(u,n) if(deg[u]==0) Q.emplace(u);
	while(!Q.empty()){
		int u=Q.front(); Q.pop();
		res.emplace_back(u);
		for(int v:D[u]) if(--deg[v]==0) Q.emplace(v);
	}
	return res;
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	graph G(n);
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		G[u].emplace_back(v);
	}

	vector<int> dp(n);
	for(int u:topological_order(G)){
		for(int v:G[u]) dp[v]=max(dp[v],dp[u]+1);
	}
	printf("%d\n",*max_element(dp.begin(),dp.end()));

	return 0;
}


Measured memory_bytes: 7164
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int n,ans;
    cin>>n;
    ans=111*(n/111);
    if(n%111!=0)ans+=111;
    cout<<ans<<endl;
}

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

int main(){
  int  N, i;
  float x, tot;
  char s[4];
  
  scanf("%d", &N);
  
  for (i = 0; i < N; i++){
    scanf("%f %s", &x, s);
    if(strcmp(s, "JPY") == 0){
      tot += x;
    } else {
      tot += x*380000;
    }
  }
  
  printf("%f\n", tot);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define sz(v) (int)(v.size())
#define pb push_back
#define all(v) v.begin(),v.end()
 
int main(){
    FAST
    ll n;
    cin>>n;
    vll v(n),ans(n);
    ll sum1=0,sum2=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        sum1+=v[i];
    }
    for(int i=1;i<n;i+=2) sum2+=(2*v[i]);
    ans[0]=sum1-sum2;
    cout<<ans[0]<<" ";
    for(int i=1;i<n;i++){
        ans[i]=2*v[i-1]-ans[i-1];
        cout<<ans[i]<<" ";
    }
    
    
}

Measured memory_bytes: 2944
<?php
list($n, $x) = explode(" ", trim(fgets(STDIN)));
$array = explode(" ", trim(fgets(STDIN)));
$array[] = $x;
sort($array);
for($i = 0; $i < count($array) - 1; $i++){
    $d[] = $array[$i + 1] - $array[$i];
}

echo gcdAll($d);

//配列の最大公約数
function gcdAll($array){
    $gcd = $array[0];
    for($i = 1; $i < count($array); $i++){
        $gcd = gcd($gcd, $array[$i]);
    }
    return $gcd;
}

//最大公約数
function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}


Measured memory_bytes: 18932
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(true)
	    {
	int n=scan.nextInt();
	if(n==0)break;
	int num[][]=new int[n+1][n+1];
	for(int i=0;i<n;i++)
	    {
		int sum=0;
		for(int j=0;j<n;j++)
		    {
			num[i][j]=scan.nextInt();
			sum+=num[i][j];
		    }
		num[i][n]=sum;
	    }
	for(int i=0;i<n+1;i++)
	    {
		int sum=0;
		for(int j=0;j<n+1;j++)
		    {
			sum+=num[j][i];
		    }
		num[n][i]=sum;
	    }
	for(int i=0;i<n+1;i++)
	    {
		
		for(int j=0;j<n+1;j++)
		    {
			
			System.out.printf("%5d",num[i][j]);	
		    }
		System.out.println();
	    }
	    }
    }
}

Measured memory_bytes: 23928
n = int(input())
a = [] #手持ちのカード
for i in range(n):
    x, y = input().split()
    a.append([x, y])

trump = [] #トランプ全体
for i in range(1,14):
    trump.append(['S', str(i)])
    trump.append(['H', str(i)])
    trump.append(['C', str(i)])
    trump.append(['D', str(i)])

#手持ちを引く #ここがわからん
dif = []
for i in range(1,14):
    dif.append(['S', str(i)])
    dif.append(['H', str(i)])
    dif.append(['C', str(i)])
    dif.append(['D', str(i)])
for i in range(len(trump)):
    for j in range(len(a)):
        if trump[i] == a[j]:
            dif.remove(trump[i])

for i in range(len(dif)):
    x = dif[i]
    if x[0] == "S":
        print(x[0] +' '+ x[1])
for i in range(len(dif)):
    x = dif[i]
    if x[0] == "H":
        print(x[0] + ' '+ x[1])
for i in range(len(dif)):
    x = dif[i]
    if x[0] == "C":
        print(x[0] + ' '+ x[1])
for i in range(len(dif)):
    x = dif[i]
    if x[0] == "D":
        print(x[0] + ' '+ x[1])


Measured memory_bytes: 5612
// inputに入力データ全体が入る
function Main(input) {

	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");

	//文字列から10進数に変換するときはparseIntを使います
	var N = parseInt(tmp[0], 10);
	var Y = parseInt(tmp[1], 10);

	var man = -1;
	var gosen = -1;
	var sen = -1;

	var mantani = Y/10000;
	for(i=0;i<=mantani;i++){
		for(j=0;j<= N - i ;j++){
			if(Y == i * 10000 + j * 5000 + (N-i-j) *1000){
				man = i;
				gosen = j;
				sen = N-i-j;
			
			}
			
			
		}
		if(man != -1){
			break;
		}
		
	}
	 

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

Measured memory_bytes: 21064
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);



    cin >> A;
    cin >> B;
    cout << 6-A-B << endl;
    

}

Measured memory_bytes: 3596
group = [0] * 13
for i in [1, 3, 5, 7, 8, 10, 12]:
	group[i] = 1
for i in [4, 6, 9, 11]:
	group[i] = 2
group[2] = 3
x, y = map(int, input().split())
print("Yes" if group[x] == group[y] else "No")

Measured memory_bytes: 61976
/* ex3_2
   tamayama */

#include<stdio.h>

int main(void){
    int N;
    int pencil;
    scanf("%d",&N);
    pencil = N;
    
    /*一の位の数をpencilから引いて、一の位を0にする。このときどんな数を引くかで区別*/
    if((pencil-2)%10 == 0 || (pencil-4)%10 == 0 || (pencil-5)%10 == 0 || (pencil-7)%10 == 0 || (pencil-9)%10 == 0){
        printf("hon");
    }else if(pencil%10 == 0 || (pencil-1)%10 == 0 || (pencil-6)%10 == 0 || (pencil-8)%10 == 0){
        printf("pon");
    }else{
        printf("bon");
    }
    return 0;
}


Measured memory_bytes: 1696
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;

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; }

long long int a[3][100001];

struct data {
	int number;
	string name;
	int value;
};

bool biggerthan(::data a, ::data b) {
	if (a.name != b.name) return a.name < b.name;
	return a.value > b.value;
}

int r,d,x;

int mo[3000] = {};
int hayasu(int a) {
	if (a == 2000) return x;
	if (mo[a] != 0) return mo[a];
	return r * hayasu(a - 1) - d;
}
int main() {
	cin >> r >> d >> x;
	for (int i = 2001; i <= 2010; i++) {
		cout << hayasu(i) << endl;
	}
}

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

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

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

  int len = s.length();
  for(int i = len; i >= 0; --i){
    string tmp = s.substr(i, len - i) + s.substr(0,i);
    if(tmp == t){
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int sum(int N)
{
	if (N == 1) {
		return 1;
	} else {
		return N + sum(N-1);
	}
}

int main()
{
	int N;
	scanf("%d", &N);
	printf("%d\n", sum(N));
	return 0;
}


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

using namespace std;

int main(){

    int d,g;cin >> d >> g;

    vector<int> p(d),c(d);

    for(int i = 0 ; i < d ; i++){
        cin >> p[i] >> c[i];
    }
    
    int ans = 1e9;
    for(int i = 0; i < (1 << d) ; i++){
        int s = 0, num = 0, rest_max = -1;
        for(int j = 0; j < d; j++){
            if(i & (1 << j)){
                s += 100 * (j+1) * p[j] + c[j];
                num += p[j];
            }else{
                rest_max = j;
            }
        }
        if(s < g){
            int s1 = 100 * (rest_max + 1);
            int need = (g - s + s1 - 1) / s1;
            if(need >= p[rest_max]){
                continue;
            }
            num += need;
        }
        ans = min(ans, num);
    }

    cout << ans << endl;

    return 0;
}

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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

/*ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}*/

/*ll dx[]= {0,0,1,-1};
ll dy[]= {1,-1,0,0};*/

int main()
{

    string ss;
    cin >> ss;
    ll len=ss.size();
    ll ans=len;
    map<string, ll> m;
    m["maerd"]=m["remaerd"]=m["esare"]=m["resare"]=1LL;
    string ch;
    for(ll i=ss.size()-1;i>=0;i--)
    {
        if(ch.size() > 6) break;
        ch+=ss[i];
        if(m[ch])
        {

            ll minu=ch.size();
            ans-=minu;
            ch.clear();
        }
    }
    if(m[ch]) ans-=ch.size();
    if(ans==0) cout << "YES\n";
    else cout << "NO\n";
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define maxn 190
template <typename T>inline T read()
{
    register T sum=0;
    register char cc=getchar();
    int sym=1;
    while(cc!='-'&&(cc>'9'||cc<'0'))cc=getchar();
    if(cc=='-')sym=-1,cc=getchar();
    sum=sum*10+cc-'0';
    cc=getchar();
    while(cc>='0'&&cc<='9')sum=sum*10+cc-'0',cc=getchar();
    return sym*sum;
}
template <typename T>inline T read(T &a)
{
    a=read<T>();
    return a;
}
template <typename T,typename... Others> inline void read(T& a, Others&... b)
{
    a=read(a);
	read(b...);
}
int n,m,ans,sum[maxn][maxn],f[2][maxn][maxn][maxn];
char str[maxn];
bool zero(int a,int b,int c,int d)
{
	int siz=(b-a+1)*(d-c+1);
	int v=sum[b][d]-sum[a-1][d]-sum[b][c-1]+sum[a-1][c-1];
	return v==siz||v==0;
}
void init()
{
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			sum[i][j]+=sum[i-1][j];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			sum[i][j]+=sum[i][j-1];
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
			for(int l=1,r;l<=m;l=r)
			{
				r=l;
				while(r<=m&&zero(i,j,l,r))
					r+=1;
				for(int k=l;k<r;k++)
					f[0][i][j][k]=r-1;
				if(l==r)
				{
					f[0][i][j][l]=l-1;
					r+=1;
				}
			}
}
int find(int p,int a,int b,int c)
{
	int l=a,r=b-1,res=0;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		int v1=f[p][a][mid][c];
		int v2=f[p][mid+1][b][c];
		res=max(res,min(v1,v2));
		if(v1<v2)
			r=mid-1;
		else
			l=mid+1;
	}
	return res;
}
void DP(int p)
{
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
			for(int l=1;l<=m;l++)
			{
				int v;
				if(f[p^1][i][j][l]!=m)
				{
					v=f[p^1][i][j][f[p^1][i][j][l]+1];
					v=max(v,find(p^1,i,j,l));
				}
				else
					v=m;
				f[p][i][j][l]=v;
			}
}
int main()
{
	read(n,m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",str+1);
		for(int j=1;j<=m;j++)
			if(str[j]=='#')
				sum[i][j]=1;
	}
	init();
	ans=0;
	for(int i=1,op=1;f[op^1][1][n][1]<m;i++,op^=1)
	{
		DP(op);
		ans=i;
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 53376
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}


const int mxn = 1e7+1;
int dp[mxn];

void solve()
{
  int n;
  cin >> n;

  dp[1]=1;
  for(int i=2;i<mxn;i++)
  {
    dp[i]++;
    for(int j=1;j*i<mxn;j++)
    {
        dp[i*j]++;
    }
  }
  
  int an = 0;

  for(int i=1;i<=n;i++)
  {
    //cout<<i<<" "<<dp[i]<<endl;
    an += i*dp[i];
  }
  cout<<an<<endl;
}


int32_t main()
{
  //pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 81728
#include<bits/stdc++.h>
    using namespace std;
     
    int main(void){
      unsigned long long int a,ans_i;
      long double b,ans_d;
      cin>>a>>b;
      ans_d=((long double)a)*b;
      ans_i=(unsigned long long int)ans_d;
      cout<<ans_i<<endl;
    }

Measured memory_bytes: 3720
n = int(input())
t, a = map(int, input().split())
listh = list(map(int, input().split()))
temp = 100000
index = 0

for i in range(n):
    c = t - listh[i] * 0.006
    diff = abs(c-a)
    if temp > diff:
        temp = diff
        index = i+1

print(index)


Measured memory_bytes: 9268