akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
/*int main()
{
    int h,w;
    scanf("%d %d",&h,&w);
    char a[h][w];
    for(int i=0;i<h;i++)
    {

        for(int  j=0;j<w;j++)
            scanf("%c",&a[i][j]);

    }
    int i,j;
     for( i=0;i<h;i++)
    {
        int c=0;
        for( j=0;j<w;j++)
        {
           if(a[i][j]=='#')c=1;
        }
        if(c==0)
        {
            for( j=0;j<w;j++)
            a[i][j]='0';
        }
    }
     for( j=0;i<w;j++)
    {
        int c=0;
        for(i=0;i<h;i++)
        {
           if(a[i][j]=='#')c=1;
        }
        if(c==0)
        {
           for(i=0;i<h;i++)
            a[i][j]='0';
        }
    }
    for( i=0;i<h;i++)
    {

        for( j=0;j<w;j++)
        {
           if(a[i][j]!='0')printf("%c",a[i][j]);
        }
        printf("\n");
    }
    return 0;

//if(a[i][j]!='0')


}*/
int i,j;
int main()
{
    int h,w;
    cin>>h>>w;
    string a[h];
    for( i=0;i<h;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<h;i++)
    {
        int c=0;
        for( j=0;j<w;j++)
        {
            if(a[i][j]=='#') c=1;
        }
        if(c==0)
        for(j=0;j<w;j++)
        {
            a[i][j]='0';
        }
        c=0;

    }
    for( j=0;j<w;j++)
    {
        int c=0;
        for(i=0;i<h;i++)
        {
           if(a[i][j]=='#')c=1;
        }
        if(c==0)
        {
           for(i=0;i<h;i++)
            a[i][j]='0';
        }
        c=0;
    }
    int m=0;
    for(  i=0;i<h;i++)
    {

        for( j=0;j<w;j++)
        {
           if(a[i][j]!='0')cout<<a[i][j];
           else m++;
        }
        if(m!=w)printf("\n");
        m=0;
    }


}


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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i=0;i<N;i++) {
		cin >> A[i];
	}

	bool is_pairwise_prime = true;
	set<int> st;
	for (int i=0;i<N;i++) {
		vector<pair<long long, long long>> vec = prime_factorize(A[i]);
		bool break_flag = false;
		for (auto p : vec) {
			if (st.count(p.first)) {
				is_pairwise_prime = false;
				break_flag = true;
				break;
			} else {
				st.insert(p.first);
			}
		}
	}

	bool is_setwise_prime = true;
	long long tmp = A[0];
	for (int i=1;i<N;i++) {
		tmp = GCD(tmp, A[i]);
	}
	if (tmp != 1) {
		is_setwise_prime = false;
	}

	if (is_pairwise_prime) {
		cout << "pairwise coprime" << endl;
	} else if (is_setwise_prime) {
		cout << "setwise coprime" << endl;
	} else {
		cout << "not coprime" << endl;
	}
}


Measured memory_bytes: 10720
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
#include <bits/stdc++.h>
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a,T b){a=max(a,b);}
template<typename T> inline void minimize(T &a,T b){a=min(a,b);}
template<typename T> inline bool middle(T a,T b,T c){return b<=a && a<=c;}
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
inline void outputVI(VI x){REP(i,SI(x)){cout << three(i," ","") << x[i];}OUT("");}
const int SIZE1=1e6+1000;
const int SIZE2=5010;
const int SIZE3=400;
const int SIZE=SIZE1;
const LL p=7+1e9;
const LL INF=1LL<<60;
const long double EPS=1e-7;
string s;
ut N,M,K,X,L,Y;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE],nums[SIZE],maps[SIZE2][SIZE2],answer=zero;
 
////////////////////////////////////////////////////////////////////////////////////////////
 
////////////////////////////////////////////////////////////////////////////////////////////
void init(){
 
}
LL solve(){
 	cin >> K;
 	REP(i,K) cin >> vals[i];
 	int maxim=2,minium=2;
 	RFOR(i,K-1,0){
 		if(maxim<vals[i]){
 			cout << -1 << endl;
 			return 0;
 		}
 		maxim=maxim/vals[i]*vals[i]+vals[i]-1;
 		minium=(minium+vals[i]-1)/vals[i]*vals[i];
 	}
 	if(minium>maxim){
 		cout << -1 << endl;
 		return 0;
 	}
 	OUT2(minium,maxim);
	return 0;
}
signed main(){
	solve();
	return 0;
}

Measured memory_bytes: 26496
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<iostream>
#include<cstdlib>
#define for(i,a,b) for(i=a;i<b;i++)	
#define MM 1001
int xJ[MM][MM],xO[MM][MM],xI[MM][MM];
int yJ[MM][MM],yO[MM][MM],yI[MM][MM];
char put[MM][MM];
using namespace std;
int main(void)
{
	int n,m,i,j,k,qs,a,b,c,d,sum1,sum2,sum3;

	//??\???
	cin>>m>>n>>k;
	for(i,0,m) cin>>put[i];
	
	for(i,0,m) for(j,0,n) xJ[i][j]=0,xO[i][j]=0,xI[i][j]=0;
	for(i,0,m) for(j,0,n) yJ[i][j]=0,yO[i][j]=0,yI[i][j]=0;
	
	
	//?¨???????????´????
	for(i,0,m) {
		for(j,0,n) {
			if(put[i][j]=='J') {
				if(j!=0)xJ[i][j]=xJ[i][j-1]+1;
				else xJ[i][j]++;
			}
			else if(j!=0)xJ[i][j]+=xJ[i][j-1];
			if(put[i][j]=='O') {
				if(j!=0)xO[i][j]=xO[i][j-1]+1;
				else xO[i][j]++;
			}
			else if(j!=0)xO[i][j]+=xO[i][j-1];
			if(put[i][j]=='I') {
				if(j!=0) xI[i][j]=xI[i][j-1]+1;
				else xI[i][j]++;
			}
			else if(j!=0)xI[i][j]+=xI[i][j-1];
		}
	}
	
	//?¨??´???????????????????????´????
	for(i,0,n) {
		for(j,0,m) {
			if(j!=0) {
				yJ[j][i]=xJ[j][i]+yJ[j-1][i];
				yO[j][i]=xO[j][i]+yO[j-1][i];
				yI[j][i]=xI[j][i]+yI[j-1][i];
			}
			else {
				yJ[j][i]=xJ[j][i];
				yO[j][i]=xO[j][i];
				yI[j][i]=xI[j][i];
			}
		}
	}
	
	//??????????????\?????????????????????
	sum1=0;sum2=0;sum3=0;
	for(i,0,k) {
		cin>>a>>b>>c>>d;a--;b--;c--;d--;
		if(a==0&&b==0) {
			sum1=yJ[c][d];
			sum2=yO[c][d];
			sum3=yI[c][d];
		}
		else {
			sum1=yJ[c][d]-(yJ[a-1][d]+yJ[c][b-1])+yJ[a-1][b-1];
			sum2=yO[c][d]-(yO[a-1][d]+yO[c][b-1])+yO[a-1][b-1];
			sum3=yI[c][d]-(yI[a-1][d]+yI[c][b-1])+yI[a-1][b-1];
		}
	//	printf("%d-( %d + %d )+%d\n",yJ[c][d],yJ[0][d],yJ[c][0],yJ[a-1][b-1]);
		cout<<sum1<<" "<<sum2<<" "<<sum3<<endl;
	}
	//while(k--) {
}
		
	

Measured memory_bytes: 27224
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>

using namespace std;

long long MOD = 1e9 + 7;

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

    long long n, k, q;
    cin >> n >> k >> q;
    vector<long long> a(q, 0);

    for (size_t i = 0; i < q; i++)
    {
        cin >> a[i];
        a[i]--;
    }

    vector<long long> count(n, 0);
    for (auto e : a) {
        count[e]++;
    }
    

    vector<long long> result(n, 0);

    for (size_t i = 0; i < n; i++)
    {
        result[i] = k - q + count[i];
    }

    for (size_t i = 0; i < result.size(); i++)
    {
        if (result[i] <= 0) {
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  for(int i = 0; i < N; i++){
    cin >> S.at(i);
  }
  
  set<string> T;
  for(int i = 0; i < N; i++){
    T.insert(S.at(i));
  }
  
  cout << T.size() << endl;
}


Measured memory_bytes: 25108
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
public class Main {
	static FastScanner stdIn=new FastScanner();
	public static void main(String[] args) {
		int N=stdIn.nextInt();
		int M=stdIn.nextInt();
		int A[][]=new int[M][3];
		int num[]=new int[N+1];
		int ans[][]=new int[M][2];
		for(int i=0;i<M;i++){
			A[i][1]=stdIn.nextInt();
			A[i][0]=stdIn.nextInt();
			A[i][2]=i;
		}
		Arrays.sort(A, (a, b) -> Integer.compare(a[0], b[0]));
		for(int i=0;i<M;i++){
			int P=A[i][1];
			int number=A[i][2];
			num[P]++;
			ans[number][0]=P;
			ans[number][1]=num[P];
		}
		for(int i=0;i<M;i++){
			String a=String.valueOf(ans[i][0]);
			String b=String.valueOf(ans[i][1]);
			int x=6-a.length();
			for(int j=0;j<x;j++){
				a="0"+a;
			}
			x=6-b.length();
			for(int j=0;j<x;j++){
				b="0"+b;
			}
			System.out.println(a+b);
		}
	}
}


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

int main() {
    int n;
    cin >> n;
    auto d = vector<int>(n);
    for (auto &d_i : d)
        cin >> d_i;

    auto count = 0;
    if (n % 2 == 0) {
        sort(d.begin(), d.end());
        auto k_max = d[(n / 2)];
        auto k_min = d[(n / 2) - 1] + 1;
        if (k_min <= k_max) {
            count = k_max - k_min + 1;
        }
    }

    cout << count;
    return 0;
}


Measured memory_bytes: 640
import Control.Applicative
import Text.Printf
import Data.Char
main = do
  v <- map (map (read::String->Int) . words) . lines <$> getContents
  mapM_ (putStrLn . show . aux) v

aux::[Int] -> Int
aux [a, b, n] = let 
  c = (fromIntegral(a) / fromIntegral(b))::Double
  s = take n . drop 1 . dropWhile (\x->x /= '.') . printf "%.100f" $ c
  t = map (\x->ord(x)-ord('0')) s
  in sum t

Measured memory_bytes: 4448
import sys
sys.setrecursionlimit(10**6)

def root(x):
    if pair[x]<0:
        return x
    else:
        tmp=root(pair[x])
        pair[x]=tmp
        return tmp

def unite(x,y):
    x=root(x)
    y=root(y)
    if x==y:return False
    if pair[x]>pair[y]:
        x,y=y,x
    pair[x]+=pair[y]    
    pair[y]=x
    return True

def size(x):
    return -pair[root(x)]

icase=0
if icase==0:
    n,m,k=map(int,input().split())
    g=[[] for i in range(n)]
    x=[[] for i in range(n)]
    a=[0]*m
    b=[0]*m
    pair=[-1]*n
    for i in range(m):
        ai,bi=map(int,input().split())
        g[ai-1].append(bi-1)
        g[bi-1].append(ai-1)
        a[i]=ai-1
        b[i]=bi-1
        unite(a[i],b[i])
    for i in range(k):
        ci,di=map(int,input().split())
        x[ci-1].append(di-1)
        x[di-1].append(ci-1)

for i in range(n):
    ss=size(i)-1
    rooti=root(i)
    for gi in g[i]:
        if root(gi)==rooti:
            ss-=1
    for xi in x[i]:
        if root(xi)==rooti:
            ss-=1
    print(ss,end=" ")
print(" ")
    



Measured memory_bytes: 109948
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

template<typename T>
vector<T> getVector(int N) {
    vector<T> v(N);
    REP(i, N) cin >> v[i];
    return v;
}

int main(void)
{
    double R;
    cin >> R;
    printf("%.20f", 2.0*R*M_PI);
    return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N, K; cin >> N >> K;
    vector<ll> A(N);
    REP(i, 0, N) cin >> A[i];

    REP(i, K, N) {
        if (A[i - K] < A[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

ap=[abs(a[0])]
for i in range(n-1):
    ap.append(abs(a[i+1]-a[i])+ap[i])
ap.append(abs(a[n-1])+ap[n-1])


print(abs(a[1])+ap[n]-ap[1])
for i in range(1,n-1):
    aa=ap[i-1]+abs(a[i+1]-a[i-1])+ap[n]-ap[i+1]
    print(aa)
print(abs(a[n-2])+ap[n-2])
    

Measured memory_bytes: 14048
#include<iostream>
#include<map>
#include<cstring>
#include<queue>
#define Pf p.first
#define Ps p.second
#define Pt MAS[Pf][Ps]
using namespace std;
typedef pair<int,int>P;
int dx[]={0,-1,0,1},dy[]={1,0,-1,0},h,w;
char MAS[22][22];
bool used[22][22][4][16]; //縦 横 向き メモリー //
P moveover(P,int);
bool search(P p,int MUKI,int memory){
  // ※向きの順番 右上左下※ //
  while(true){
    if(used[Pf][Ps][MUKI][memory]==true) return false; // ループ判定 //
    else used[Pf][Ps][MUKI][memory] = true;

    if(Pt == '<') MUKI = 2;
    else if(Pt == '>') MUKI = 0;
    else if(Pt == '^') MUKI = 1;
    else if(Pt == 'v') MUKI = 3;
    else if(Pt == '_') MUKI = (memory==0 ? 0 : 2);
    else if(Pt == '|') MUKI = (memory==0 ? 3 : 1);
    else if(Pt == '?'){
      for(int i=0;i<4;i++){
	if(search(moveover(p,i),i,memory)) return true;
      }
      return false;
    }
    else if(Pt == '@') return true; // Stop!! //
    else if(Pt == '+') memory == 15 ? memory = 0 : memory++;
    else if(Pt == '-') memory == 0 ? memory = 15 : memory--;
    else if(Pt != '.') memory = Pt - '0';
    p = moveover(p,MUKI);
  }
}
int main(){
  cin >> h >> w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> MAS[i][j];
    }
  }
  memset(used,false,sizeof(used));
  cout << (search(P(0,0),0,0)?"YES":"NO") << endl;
}
P moveover(P p,int MUKI){
  Pf += dx[MUKI];
  Ps += dy[MUKI];
  if(Pf < 0) Pf = h-1;
  else if(Pf >= h) Pf = 0;
  if(Ps < 0) Ps = w-1;
  else if(Ps >= w) Ps = 0;
  return p;
}

Measured memory_bytes: 2404
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<vector<int>> A(N, vector<int>(M));
  vector<int> C(N);
  rep(i, N) {
    cin >> C[i];
    rep(j, M) cin >> A[i][j];
  }
  ll ans = longinf;
  rep(i, 1<<N) {
    vector<ll> B(N);
    ll cost = 0;
    rep(j, N) {
      if(i&1<<j) {
        rep(k, M) B[k] += A[j][k];
        cost += C[j];
      }
    }
    bool ok = true;
    rep(k, M) if(B[k] < X) ok = false;
    if(ok) ans = min(cost, ans);
  }
  cout << (ans == longinf ? -1 : ans) << endl;
  return 0;
}


Measured memory_bytes: 3636
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

class ModTools:
    """ 階乗・逆元用のテーブルを構築する """

    def __init__(self, MAX, MOD):

        # nCrならn、nHrならn+rまで作る
        MAX += 1
        self.MAX = MAX
        self.MOD = MOD
        factorial = [1] * MAX
        factorial[0] = factorial[1] = 1
        for i in range(2, MAX):
            factorial[i] = factorial[i-1] * i % MOD
        inverse = [1] * MAX
        inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
        for i in range(MAX-2, -1, -1):
            inverse[i] = inverse[i+1] * (i+1) % MOD
        self.fact = factorial
        self.inv = inverse

    def nCr(self, n, r):
        """ 組み合わせ """

        if n < r: return 0
        r = min(r, n-r)
        numerator = self.fact[n]
        denominator = self.inv[r] * self.inv[n-r] % self.MOD
        return numerator * denominator % self.MOD

N, K = MAP()
M = N - K
mt = ModTools(N, MOD)

for k in range(1, K+1):
    # M+1箇所の隙間からk箇所選ぶ * k箇所に対してK個を最低1個以上入れながら割り振る(写像の6相)
    res = mt.nCr(M+1, k) * mt.nCr(K-1, k-1) % MOD
    print(res)


Measured memory_bytes: 9628
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))

//repetition//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int n,m,s,g;
map<int, vector<TIII> > r;
map<TIII, double> v;

int main(){
	while(1){
		double ret = -1.0;
		cin>>n>>m;
		if(n==0&&m==0)return 0;
		cin>>s>>g;
		r.clear();
		v.clear();
		REP(i,m){
			int x,y,d,c;
			cin>>x>>y>>d>>c;
			r[x].PB(MT(y,d,c));
			r[y].PB(MT(x,d,c));
		}
		priority_queue<pair<double, TIII > , vector<pair<double, TIII > >, greater<pair<double, TIII > > > q;
		q.push(MP(0.0,MP(s, MP(-1, 0))));
		while(!q.empty()){
			pair<double, TIII > tmp = q.top();
			q.pop();
			if(EXIST(v, tmp.second))continue;
			if(tmp.second.first == g && tmp.second.second.second == 1){
				ret = tmp.first;
				break;
			}
			v[tmp.second]=tmp.first;
			int city = tmp.second.first;
			int speed = tmp.second.second.second;
			int pre = tmp.second.second.first;
			double now = tmp.first;
			REP(i, r[city].size()){
				TIII f = r[city][i];
				if(f.first == pre)continue;
				FOR(sp, speed-1, speed+2){
					if(sp<1)continue;
					if(f.second.second >= sp && sp > 0){
						if(!EXIST(v, MP(f.first, MP(city, sp)))){
							q.push(MP(now+(f.second.first*1.0)/(sp*1.0), MP(f.first, MP(city, sp))));
						}
					}
				}
			}
		}
		if(ret < 0.0)cout << "unreachable" <<endl;
		else printf("%.6f\n", ret);
	}
	return 0;
}

Measured memory_bytes: 14644
//Atcoder
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        String str = sc.nextLine();
        int i=0;
        int len = str.length();
        int ans = Integer.MAX_VALUE;
        for(int j=2;j<len;i++,j++) {
            ans = Math.min(ans, Math.abs(753 - Integer.parseInt(str.substring(i, j+1))));
        }

        pw.println(ans);
        pw.close();
    }
}


Measured memory_bytes: 19284
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N, M;
    cin >> N >> M;
    ll pow2 = (ll)pow(2, M);
    print((1900*M + (N-M)*100) * pow2);
    return 0;
}

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

using namespace std;

struct Memo
{

  int count;
  bool flag;

  Memo()
  {
    count = 0;
    flag = false;
  }

};

Memo memo[31][4];

int ProgressNumberOfYears(int step_num, int step_kind)
{

  int kind_count = 0;


  if(step_num == 0) return 1;
  else if(step_num < 0)  return 0;
  else if(memo[step_num][step_kind].count)  return memo[step_num][step_kind].count;
  for(int i = 1; i < 4; ++i) kind_count = kind_count + ProgressNumberOfYears(step_num - i,i);


  memo[step_num][step_kind].count = kind_count;
  //memo[step_num][step_kind].flag = true;

  return kind_count;

}

int main()
{

  int step_num;

  while(cin >> step_num && step_num != 0) cout << ProgressNumberOfYears(step_num,0)/10/365 + 1<< endl;

  return 0;

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  for(int i=0; i<n; ++i) cin >> a[i];
  sort(a.begin(),a.end());
  int ans=a[n-1]-a[0];
  cout << ans << endl;
  return 0;
}

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

int main()
{
    char c;
    cin >> c;

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    {
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){

    long long a, b;
    cin >> a >> b;
    
    for(long long i=0; i<1000000000; i++) {
        long long abs_a = (a-i)<0? -(a-i):(a-i);
        long long abs_b = (b-i)<0? -(b-i):(b-i);
        if(abs_a == abs_b) {
            cout << i << endl;
            return 0;
        }
    }
    
    cout << "IMPOSSIBLE" << endl;

    return 0;    
}


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

int main(){
  int n,max=-1000000,min=1000000;
  long sum=0;
  int* a;

  cin >> n;

  a = new int [n];

  for(int i=0; i<n; i++){
    cin >> a[i];
    if(a[i] > max)
      max = a[i];
    if(a[i] < min)
      min = a[i];
 
    sum += a[i];    
  }
  
  cout << min << " " << max << " " << sum << "\n";
  return 0;
}



Measured memory_bytes: 3148
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int data[] = new int[N+1];
		int res = 0;
		int cnt = 0;
		for(int i = 1; i<=N; i++){
			int input = sc.nextInt();
			if(input == i && i !=N){
				int input2 = sc.nextInt();
				data[i] = input2;
				data[i+1] = input;
				i++;
				cnt++;
			}
			else if(input == i && i ==N){
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 50428
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll n;cin>>n;while(n){
		if(n%10==7) return cout<<"Yes\n",0;
		n/=10;
	}cout<<"No\n";
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

ll i,j,k;

int main(){
	int n;cin>>n;
	if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9){
		cout<<"hon"<<endl;
	}
	if(n%10==0||n%10==1||n%10==6|| n%10==8){
		cout<<"pon"<<endl;
	}
	if(n%10==3){
		cout<<"bon"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        string[] st = new string[3];
        for (int i = 0; i < 3; i++)
        {
            st[i] = cin.next();
        }
        for (int i = 0; i < 3; i++)
        {
            Console.Write(st[i][i]);
        }
        Console.WriteLine();
    }

}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}



Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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





int n;
ll c[10][10];
ll ans;


int main() {

	cin >> n;

	rrep(i, n) {
		int tmp = i;
		int a, b;
		a = tmp % 10;
		while (tmp) {
			if (tmp / 10 == 0)b = tmp % 10;
			tmp /= 10;
		}
		c[a][b]++;
	}

	rrep(i, 9) {
		rrep(j, 9) {
			ans += c[i][j] * c[j][i];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll i,j,k;
    cin>>k;
    string s;
    cin>>s;
    ll n  = sz(s);
    if(n<=k) cout<<s;
    else
    {
        for(i=0;i<k;i++) cout<<s[i];
        cout<<"...";
    }
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
struct node{
	int v, nxt;
}edge[200050];
 
ll b[100050], cntt[2], cnt3, flag/*有无奇环*/, cnt, head[100050];
 
void add(int u, int v){
	edge[++cnt] = (node){v, head[u]};
	head[u] = cnt;
}
 
void dfs(int u, int fa){
	cnt3++;
	for(int i = head[u]; i; i = edge[i].nxt){
		int v = edge[i].v;
		if(v == fa) continue;
		if(b[v]!=-1) {
			if(b[v] == b[u]) flag = 1;
			continue;
		}
		b[v] = b[u] ^ 1;
		cntt[b[v]]++;
		dfs(v, u);
	}
}
 
int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		add(a, b), add(b, a);
	}
	ll ans = 0;
	memset(b, -1, sizeof(b));
	for(int i = 1; i <= n; i++) if(b[i]==-1) {
		b[i] = 1;
		cnt3 = cntt[0] = 0;
		cntt[1] = 1; flag = 0;
		dfs(i, 0);
		if(flag == 1) ans += (cnt3 * (cnt3-1)) >> 1;
		else ans += cntt[1] * cntt[0];
	} 
	printf("%lld", ans-m);
}

Measured memory_bytes: 4480
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int n;
	double sum = 0,m;
	string s;
	cin>>n;
	for(int i = 0; i < n; i++){
		cin>>m>>s;
		if(s == "JPY")
			sum+=m;
		else if(s == "BTC")
			sum+=(m*380000.0);
	} 
	cout<<sum<<endl;
	return 0;
}

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

int main(int argc, const char * argv[]) {
    int N, L;
    int sum = 0;
    int ary[100] = {0};
    
    cin >> N >> L;
    for (int i = 1; i <= N; i++) {
        int a = L + i - 1;
        ary[i - 1] = abs(a);
        sum += a;
    }
    sort(ary, ary + N);
    
    if (sum < 0) {
        cout << sum + ary[0] << endl;
    } else {
        cout << sum - ary[0] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void alert(vector<int> vec){
  int64_t N = vec.size();
  for(int i=0; i<N-1; i++) cout << vec.at(i) << " ";
  cout << vec.at(N-1) << endl;
}

int main(){
  string S; cin >> S;
  if(S=="ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
ll sum(ll xx){
	return ((xx*(xx+1))/2) % MOD;
}
int main(){
	
	ll n,k; cin>>n>>k; ll arr[n]; ll A[n]; ll B[n];
	for(int i = 0; i < n; i++) cin>>arr[i];
	for(int i = 0; i < n; i++) A[i] = 0;
	for(int i = 0; i < n; i++) B[i] = 0;
	ll ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			if(arr[i] > arr[j]) A[i]++;
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(arr[i] > arr[j]) B[i]++;
		}
	}
	for(int i = 0; i < n; i++){
		ans += ((B[i]*(sum(k-1))) + (A[i]*k))%MOD;
	}
	cout<<ans%MOD<<"\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
int main(){
  long long n;
  std::cin >> n;
  std::map<string,int> ma;
  long long ans=0;

  for (int i = 0; i < n; i++) {
    string s;
    std::cin >> s;
    sort(s.begin(),s.end());
    if(ma[s]!=0){ans+=ma[s];}
    ma[s]++;
  }

  std::cout << ans << '\n';




  return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define se second
#define fi first
#define rep(i, l, r) for (ll i = (ll)(l); i < (ll)(r); i++)
#define print(v) for (const auto itr : v){cout << itr << ' ';} cout << endl;
#define mod 1000000007
#define inf 1e18
using namespace std;
const ll INF = 1e18L + 5;
const ll maxn = 1e5*2+5, maxn1=202;
ll ceel(ll a, ll b)
{
   if (a % b == 0)
       return a / b;
   return a / b + 1;
}
ll modneg(ll a,ll m)
{
    a = a % m;
    if(a<0)
        a=a+m;
    return a;
}
ll powermod(ll x, unsigned ll y, ll p){ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); };

int main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll n,k,i,j;
cin>>n>>k;
unsigned ll f[n+2],l[n+2];
f[0]=0; l[n]=n;
for(i=1;i<=n;i++)
{
    f[i]=(i+f[i-1])%mod;
}
for(i=n-1;i>=0;i--)
    l[i]=(l[i+1]+i)%mod;
// for(i=0;i<=n;i++)
//     cout<<l[i]<<" "<<f[i]<<endl;
unsigned ll sum=0;
ll st=k-1,ed=n-(k-1);
// if(ed==st)
// {
//     cout<<"0";
//     exit(0);
// }
for(i=k-1;i<=n;i++)
{
    ll tmp=(l[ed]-f[st]+mod+1)%mod;
    // if(tmp==1)
    //     tmp=0;
    // ll tmp=(l[ed]-f[st]);
    // if(tmp<0)
    //     tmp=(tmp+mod+1)%mod;
    // else
    //     tmp=(tmp+mod+1)%mod;
    sum=(sum+tmp)%mod;
    ed--;
    st++;
}
// if(sum==1)
//     sum=0;
cout<<sum<<endl;
return 0;
}

Measured memory_bytes: 6740
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            if (temp % 2 == 0) {
                if (temp % 5 != 0 && temp % 3 != 0) {
                    System.out.println("DENIED");
                    return;
                }
            }
        }
        System.out.println("APPROVED");
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;

/*  divisor(n)
    入力：整数 n
    出力：nのすべての約数
    計算量：O(√n)
*/
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

using ll = long long;

int main() {
    ll N;
    cin >> N;
    ll ans = 0;

    // K で割り切れない時
    auto div = divisor(N - 1);
    ans += (int)div.size() - 1;

    // K で割り切れる時
    auto dv = divisor(N);
    for (auto k : dv) {
        if (k == 1) continue;
        ll n = N;
        while (n % k == 0) {
            n /= k;
        }
        if (n % k == 1) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define Rep(i,n) for(int i=1;i<=(n);++i)
using LL = long long;
using ULL = unsigned long long;

const LL INF = 1e18;

LL y[3]{2, 3, 5}, z[4];
map<LL, LL> dp;

LL f(LL n) {
    auto it = dp.find(n);
    if(it != dp.end()) return it->second;
    LL x = INF;
    rep(i, 3) {
        LL d = n % y[i];
        if(n) x = min(x, f(n/y[i]) + d * z[3] + z[i]);
        if(n > d) x = min(x, f((n+y[i]-1)/y[i]) + (y[i] - d) * z[3] + z[i]);
    }
    if(x / z[3] >= n) x = min(x, n * z[3]);
    return dp[n] = x;
}

int main()
{
    int T;
    cin >> T;
    while(T--) {
        LL n;
        cin >> n;
        rep(i, 4) cin >> z[i];
        dp.clear();
        cout << f(n) << endl;
    }
	return 0;
}


Measured memory_bytes: 4340
s = input()
n = len(s)

ans = 0
if n % 2 == 0:
    ans = 'No'
elif s != ''.join(list(reversed(s))):
    ans = 'No'
elif s[:int((n-1)/2)] != ''.join(list(reversed(s[:int((n-1)/2)]))):
    ans = 'No'
elif s[int((n+3)/2-1):] != ''.join(list(reversed(s[int((n+3)/2-1):]))):
    ans = 'No'
else:
    ans = 'Yes'
print(ans)

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    int a, b; cin >> a >> b;
    char ans;
    
    if(a + b == 15) ans = '+';
    else if(a * b == 15) ans = '*';
    else ans = 'x';
    
    cout << ans << endl;
    return;
}

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

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

int main() {
    
    int n,p,ans = -1;
    vector <int> a;
    
    cin >> n;
    
    a.assign(n+1,0);
    
    for (int i = 1; i <= n ; i++){
        cin >> a.at(i);
    }
    
    p = 1;
    
    for(int i = 1; i <= n ; i++){
        if(a[p] == 2){
            ans = i;
            break;
        }else{
            p = a[p];
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int N;
  cin >> N;
  vector<float> A;
  rep(i, N) {
    float a;
    cin >> a;
    A.push_back(a);
  }
  float ans = 0;
  rep(i, N) { ans += 1 / A.at(i); }
  cout << 1.0 / ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  int N;
  cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int sum=0;
  for(int i=0;i<N;i++)sum+=v[i];
  int out=0;
  out+=sum%(N*(N+1)/2);
  sum/=(N*(N+1)/2);
  std::vector<int> w(N,sum);
  for(int i=0;i<N;i++)w[i]-=v[(i+1)%N]-v[i];
  int a=0;
  for(int i=0;i<N;i++){
    if(w[i]<0)out++;
    out+=w[i]%N;
    a+=w[i]/N;
  }
  out+=abs(a-sum);
  if(out)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k,n,c_max=0;
  cin>>k>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  for(int i=0;i<n-1;i++){
    if(p[i+1]-p[i]>c_max){
      c_max=p[i+1]-p[i];
    }
  }
  if (c_max<k-p[n-1]+p[0]) c_max=k-p[n-1]+p[0];
  cout<<k-c_max<<endl;

}


Measured memory_bytes: 1024
from bisect import bisect_left

N = int(input())
a = sorted(list(map(int, input().split())))
ans = set()
max_ans = 0
c = 0
for aa in a:
  if aa < 400:
    ans.add(0)
  elif aa < 800:
    ans.add(1)
  elif aa < 1200:
    ans.add(2)
  elif aa < 1600:
    ans.add(3)
  elif aa < 2000:
    ans.add(4)
  elif aa < 2400:
    ans.add(5)
  elif aa < 2800:
    ans.add(6)
  elif aa < 3200:
    ans.add(7)
  else:
    if not ans:
      ans.add(0)
      continue
    max_ans += 1

print(len(ans), len(ans) + max_ans if max_ans else len(ans))

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
const int MOD=1000000007;
const int INF=LLONG_MAX/2;

signed main() {cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    Vi a(n+1),b(n);
    REP(i,0,n+1) cin>>a[i];
    REP(i,0,n) cin>>b[i];
    
    int ans=0;
    REP(i,0,n){
        if(b[i]>a[i]){
            ans+=a[i];
            if(b[i]-a[i]>a[i+1]){
                ans+=a[i+1];
                a[i+1]=0;
            }else{
                ans += (b[i]-a[i]);
                a[i+1] -= (b[i]-a[i]);
            }
        }else{
            ans+=b[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  string a;
  cin >> a;
  cout << ( (a[0]==a[1] &&a[1]==a[2])||
           (a[1]==a[2] && a[2]==a[3]) ? "Yes" : "No" )
    <<endl;
}

Measured memory_bytes: 3584
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;
#ifndef LOCAL
#define endl '\n'
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
const int N = 1005;
int a[N];
vector<int> v[64];
void solve(){
    int n, k;
    cin >> n >> k;
    fr(i, 1, n) cin >> a[i];
    fr(i, 1, n){
        int s = 0;
        fr(j, i, n){
            s += a[j];
            v[0].pb(s);
        }
    }
    int ans = 0;
    int idx = 0;
    for(int i = 40; i >= 0; i--){
        int c = 0;
        for(int x : v[idx]){
            if(x & (1LL << i)) c++;
        }
        if(c >= k){
            ans += (1LL << i);
            for(int x : v[idx]){
                if(x & (1LL << i))
                    v[idx + 1].pb(x);
            }
            idx++;
        }
    }
    cout << ans << endl;
}
signed main()
{
    IO;
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        // freopen("out.txt", "w", stdout);
    #endif
    clock_t clk = clock();
    int t = 1;
    // cin >> t;
    fr(i, 1, t){
        solve();
    }
    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
};

Measured memory_bytes: 6384
import sys
import bisect
input = sys.stdin.readline
 
def main():
    n,k = map(int,input().split())
    a=list(map(int,input().split()))
    cnta=0
    cntb=0
    for i in range(n-1):
        for j in range(n-1-i):
            j+=i+1
            if(a[i]>a[j]):
                cnta+=1
    for i in range(n):
        for j in range(n):
            if(a[i]>a[j] and i!=j):
                cntb+=1
    cntak=int(  (cnta*k) % (1000000007)  )
    x=int(  ((k*(k-1))//2) % (1000000007)  )
    cntbk=int(  (cntb*x) % (1000000007)  )
    
    ans=int(  (cntak+cntbk) % (1000000007)  )
    
    print(ans)
    
main()

Measured memory_bytes: 3188
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>
#include <limits>
#include <map>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++)
    {
        cin >> vec.at(i);
    }
    for (int i = n; i > 0; i--)
    {
        cout << vec[i - 1];
        if (i != 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
}


Measured memory_bytes: 3088
S = list(input())
s = []
cnt = 0
for i in range(len(S)-1):
  if S[i]!=S[i+1]:
    s.append(i+1)
s.append(len(S))
l = [s[0]]
for i in range(1,len(s)):
  l.append(s[i]-s[i-1])
for i in range(0,len(l),2):
  if (l[i]+l[i+1])%2==0:
    a = (l[i]+l[i+1])//2
    l[i] = a
    l[i+1] = a
  else:
    if l[i]%2==1:
      a = (l[i]+l[i+1])//2
      l[i] = a+1
      l[i+1] = a
    else:
      a = (l[i]+l[i+1])//2
      l[i] = a
      l[i+1] = a+1
      
ans = [0]*len(S)
j = 0
for i in range(0,len(s),2):
  ans[s[i]-1],ans[s[i]] = l[j],l[j+1]
  j+=2
for i in range(len(S)):
  print(ans[i],end=" ")

Measured memory_bytes: 10188