akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

int N;
ll a[100010];

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
    cin >> N;
    rep(i, N) cin >> a[i];

    ll L[N+1], R[N+1];
    L[0] = 0, R[N+1] = 0;
    for (int i = 0; i <= N; i++) {
        L[i+1] = gcd(L[i], a[i]);
    }
    for (int i = N; i >= 0; i--) {
        R[i] = gcd(R[i+1], a[i]);
    }

    // for (auto x : L) cout << x << ' ';
    // cout << endl;
    // for (auto x : R) cout << x << ' ';
    // cout << endl;

    ll res = 0;
    for (int i = 0; i < N; i++) {
        ll tmp = gcd(L[i], R[i+1]);
        if (tmp > res) res = tmp;
    }
    cout << res << endl;
}


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

int a[112345],t1[112345],t2[112345];

int main()
{
	int i,n,ans=0,m1,m2,c1,c2,n1,n2;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=1;i<=n;i+=2)
	{
		t1[a[i]]++;
		t2[a[i+1]]++;
	}
	m1=m2=0;
	for(i=1;i<=100000;i++)
	{
		if(t1[i]>c1)c1=t1[i];
		if(t1[i]>m1){n1=i;c1=m1;m1=t1[i];}
		if(t2[i]>c2)c2=t2[i];
		if(t2[i]>m2){n2=i;c2=m2;m2=t2[i];}
	}
	if(n1!=n2)
		ans=n-m1-m2;
	else
		ans=min(n-m1-c2 , n-m2-c1);
	printf("%d",ans);
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

template<class T> T umax(T a,T b) {return (a>b?a:b);}
template<class T> T umin(T a,T b) {return (a<b?a:b);}
template<class T,class P> T umax(T a,P b) {return (a>b?a:b);}
template<class T,class P> T umin(T a,P b) {return (a<b?a:b);}

typedef long long int ll;
const int maxn = 1e5+7;
const ll mod = 1e9+7;

bool compare(const pair<ll,ll>& x, const pair<ll,ll>& y) {
    if(x.second == y.second) return x.first < y.first;
    return x.second < y.second;
}

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

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

vector<int> G[100005];
int dp[100005];

int dfs(int u) {
    if(G[u].size() == 0) {
        return 0;
    }
    int ans = 0;
    for(int i=0;i<G[u].size();i++) {
        int v = G[u][i];
        if(dp[v] == 1e9) {
            dp[v] = dfs(v);
        }
        ans = max(ans,dp[v]);
    }
    dp[u] = ans + 1;
    return ans + 1;
}

int main() {
    int n,m,u,v;
    cin >> n >> m;
    for(int i=0;i<m;i++) {
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
    }
    for(int i=0;i<n;i++) {
        dp[i] = 1e9;
    }
    for(int i=0;i<n;i++) {
        dp[i] = dfs(i);
    }
    int ans = 0;
    for(int i=0;i<n;i++) {
        ans = max(ans,dp[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9472
n, m = map(int, input().split())

all_like = [0 for i in range(m)]
#print(all_like)

for i in range(n):
    line = []
    for part in input().split()[1:]:
        all_like[int(part)-1] += 1

#print(all_like)

cnt = 0
for part in all_like:
    if part == n:
        cnt += 1

print(cnt)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
 
#define pi 3.1415926535

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

  vector<int> a(100001, 0);
  int tmp;
  ll sum = 0;
  for(int i = 0 ;i < n; i++){
    cin >> tmp;
    a[tmp]++;
    sum += tmp;
  }

  int q;
  cin >> q;

  vector<ll> ans(q, 0);

  int b, c;
  for(int i = 0; i < q; i++){
    cin >> b >> c;

    a[c] += a[b];
    sum += a[b] * (c - b);
    a[b] = 0;

    ans[i] = sum;
  }
  
  for(int i = 0; i < q; i++){
    cout << ans[i] << endl;
  }

  return 0; 
}

Measured memory_bytes: 4228
from itertools import combinations

def gcd(a, b):
    if a < b:
        tmp = a
        a = b
        b = tmp

    r = a % b
    while r!=0:
        a = b
        b = r
        r = a % b
    return b

def gcd_three(a, b, c):
    temp = gcd(a, b)
    return gcd(temp, c)

K = int(input())
ans = 0

ans += sum(range(1, K+1))
ans += 6*sum([gcd(*t) for t in combinations(range(1, K+1), 2)])
ans += 6*sum([gcd_three(*t) for t in combinations(range(1, K+1), 3)])

print(ans)

Measured memory_bytes: 160208
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int n, p;
	cin >> n >> p;
	vector<int> a(n+1);
	REP1(i, n) cin >> a[i];
	ll dp[n+1][2];
	dp[0][0] = 1; dp[0][1] = 0;
	REP1(i, n) {
		if(a[i] % 2 == 0){
			dp[i][0] = dp[i-1][0] * 2;
			dp[i][1] = dp[i-1][1] * 2;
		}
		else{
			dp[i][0] = dp[i-1][0] + dp[i-1][1];
			dp[i][1] = dp[i-1][1] + dp[i-1][0];
		}
	}
	cout << dp[n][p] << endl;
}

Measured memory_bytes: 3600
#!/bin/bash
read N
for i in $(seq 1 $N); do
  line="${line} T${i}"
done
read $line
read M
declare -a P=()
declare -a X=()
for i in $(seq 1 $M); do
  read p x
  P+=($p)
  X+=($x)
done

num=0
sum=0

for i in $(seq 1 $N); do
  num=$((num + T$i))
done

for i in $(seq 0 $((M-1))); do
  echo $(( num + ${X[$i]} - T${P[$i]}))
done


Measured memory_bytes: 636
N=int(input())
d={}
k=[]
for x in range(N):
  S,P=input().split()
  if S not in k:
    k.append(S)
    d[S]=[]
  d[S].append([int(P),x+1])
k.sort()
for y in k:
  d[y].sort(reverse=True)
  for z in range(len(d[y])):
    print(d[y][z][1])

Measured memory_bytes: 9188
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

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

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int n;
	cin>>n;
	int ans[100005];
	for(int x=1;x<=100;x++){
		for(int y=1;y<=100;y++){
			for(int z=1;z<=100;z++){
				int tmp = x*x + y*y + z*z + x*y + y*z + z*x;
				if(tmp>n){
					break;
				}
				ans[tmp]++;
			}
		}
	}
	for(int i=1;i<=n;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;int f=0;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0){f=1;break;}
  }
  if(f==1)cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
}
  


Measured memory_bytes: 3632
a,b,x = map(int,input().split())
x /= a
import math
PI = math.pi
if x > a*b//2:
    print("{:.10}".format(math.atan2((a*b-x)*2, a*a)*180/PI))
else:
    print("{:.10}".format(math.atan2(b*b,x*2)*180/PI))


Measured memory_bytes: 2940
//minamoto
#include<bits/stdc++.h>
#define R register
#define pb push_back
#define fi first
#define se second
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
const int N=2e5+5;
typedef long long ll;
typedef pair<int,int> pi;
struct node;typedef node* ptr;
inline ll max(R ll x,R ll y){return x>y?x:y;}
struct node{
	ptr lc,rc;ll t,mx;
	inline void upd(){mx=max(lc->mx+t,rc->mx+t);}
}e[N<<2],*rt,*pp=e;
int n,m;vector<pi>pos[N];
void build(ptr &p,int l,int r){
	p=++pp;if(l==r)return;
	int mid=(l+r)>>1;
	build(p->lc,l,mid),build(p->rc,mid+1,r);
}
void update(ptr p,int l,int r,int ql,int qr,int v){
	if(ql<=l&&qr>=r)return p->t+=v,p->mx+=v,void();
	int mid=(l+r)>>1;
	if(ql<=mid)update(p->lc,l,mid,ql,qr,v);
	if(qr>mid)update(p->rc,mid+1,r,ql,qr,v);
	p->upd();
}
void change(ptr p,int l,int r,int x,ll v){
	if(l==r)return p->mx=v,void();
	int mid=(l+r)>>1;
	x<=mid?change(p->lc,l,mid,x,v):change(p->rc,mid+1,r,x,v);
	p->upd();
}
int main(){
//	freopen("testdata.in","r",stdin);
	n=read(),m=read();
	for(R int l,r,x;m;--m)l=read(),r=read(),x=read(),pos[r].pb(pi(l,x));
	build(rt,1,n);
	fp(i,1,n){
		change(rt,1,n,i,rt->mx);
		for(vector<pi>::iterator it=pos[i].begin();it!=pos[i].end();++it)
			update(rt,1,n,it->fi,i,it->se);
	}
	printf("%lld\n",max(rt->mx,0ll));
	return 0;
}

Measured memory_bytes: 28032
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int D[100001];
int main() {
	int N;
	int R=0;
	cin>>N;
	for(int i=0;i<N;i++)cin>>D[i];


	int a1=1,a2=1,a3=1;
	for(int i=1;i<N;i++){
		if(D[i]!=D[i-1]){
			a1+=1;
			a2+=1;
			a3+=1;
		}
		if(D[i]==D[i-1]){
			R=max(R,a3);
			a3=a2+1;
			a2=a1+1;
			a1=1;
		}
	}

	R=max(R,a1);
	R=max(R,a2);
	R=max(R,a3);

	cout<<R<<endl;
	return 0;
}

Measured memory_bytes: 3380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf=1e16;
int n,a[410];
ll f[410][410],s[410];
int main()
{
	scanf("%d",&n);
	for (int i=0;i<=n;i++)
	{
		for (int j=0;j<=n;j++)
		{
			f[i][j]=inf;
		}
	}
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		s[i]=s[i-1]+a[i];
		f[i][i]=0;
	}
	for (int l=1;l<n;l++)
	{
		for (int i=1;i+l<=n;i++)
		{
			int j=i+l;
			for (int k=i;k<j;k++)
			{
				f[i][j]=min(f[i][j],f[i][k]+f[k+1][j]);
			}
			f[i][j]+=s[j]-s[i-1];
		}
	}
	/*
	for (int i=1;i<=n;i++)
	{
		for (int j=i;j<=n;j++)
		{
			cerr<<f[i][j]<<" ";
		}
		cerr<<endl;
	}
	*/
	cout<<f[1][n]<<endl;
	return 0;
}


Measured memory_bytes: 1536
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

class Main
{
    int visited[];
    List<List<Integer>> graph;
    int path[];

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int V = sc.nextInt();
        int E = sc.nextInt();
        // System.out.print(V+" "+E);
        Main object=new Main();
        sc.nextLine();
        object.graph = new ArrayList<List<Integer>>();
        for (int i = 0; i < V; i++) {
            object.graph.add(new ArrayList<Integer>());
        }
        for (int i = 0; i < E; i++) {
            object.graph.get(sc.nextInt()-1).add(sc.nextInt());
            sc.nextLine();
        }
        object.visited = new int[V];
        object.path= new int[V];
        
        int max=0;
        for(int i=1;i<=V;i++)
        {
             max=(int)Math.max(max,object.neigh(i));
            // System.out.print(max+" ");
        }
        System.out.println(max);
        sc.close();
     }

     public int neigh(int n)
      {
          int max=0;
         if(visited[n-1]==1)
           return(path[n-1]);
         for(int i=0;i<graph.get(n-1).size();i++)
         {
            max=(int)Math.max(max,1+neigh(graph.get(n-1).get(i)));
         }
         visited[n-1]=1;
         path[n-1]=max;
         return(max);
     }
}

Measured memory_bytes: 75644
c=[0,2,5,5,4,5,6,3,7,6]
I=lambda:map(int,input().split())
N,M=I()
A=sorted(I())[::-1]
d=[0]
for i in range(N):l=[d[i+1-c[a]]for a in A if i+2>c[a]];d+=[-1 if len(l)==0 else max(l)+1]
S=''
T=0
for i in range(d[N]):
 for a in A:
  b=c[a]
  if N-T-b>=0 and d[N-T-b]==d[N]-1-i:S+=str(a);T+=b;break
print(S)

Measured memory_bytes: 3408
#include <stdio.h>
 int main(void){
   int times,i;

   scanf("%d",&times);

   int K[times];
   int P[times];

   for(i=0;i<times;i++){
     scanf("%d %d",&K[i],&P[i]);
   }

   for(i=0;i<times;i++){
     if(K[i]%P[i]==0){
       printf("%d\n",P[i]);
     }else{
       printf("%d\n",K[i]%P[i]);
     }
   }
   return 0;
 }

Measured memory_bytes: 596
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
  	Scanner scan = new Scanner(System.in);
    
    String str = scan.next();
  
    int len = str.length();
   
    String ans[] = new String[10];
    int i;
    int j = 0;
    for(i = 0; i < len; i++){
      if(str.charAt(i) != 'B'){
      	ans[j] = String.valueOf(str.charAt(i));
        j++;
      }
      else if(str.charAt(i) == 'B'){
        if(j != 0){
          j--;
          ans[j] = "";
        }
      	
      }
    }
    
    for(String a : ans){
      if(a != null){
         System.out.print(a);     
      }
      else{
      	break;
      }
    }
  }
}


Measured memory_bytes: 20820
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		String N = sc.next();
		int length = N.length();
		for (int i = 0; i < length; i++) {
			char c = N.charAt(i);
			if (i == A) {
				if (c != '-') {
					System.out.println("No"); 
					return;
				}
			} else {
				if (c < '0' || c > '9') {
					System.out.println("No"); 
					return;
				}
			}
		}
		System.out.println("Yes"); 
	}
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s, pr = "", su = "";
  cin >> s;
  int q, t, f, tc = 0;
  char c;
  cin >> q;
  for (int i = 0; i < q; ++i){
	cin >> t;
	if (t == 1){
		++tc;
	}else{
	cin >> f;
	cin >> c;
	if (f == 1){
		(tc % 2 == 0) ? pr = c + pr : su = c + su;
	}else{
		(tc % 2 == 0) ? su = c + su : pr = c + pr;	
	}
	}

}
if (tc % 2 == 0){
reverse(su.begin(),su.end());
s = pr + s + su;
}else{
s = pr + s;
reverse(s.begin(),s.end());
s = su + s;
}
cout << s << "\n";
return 0;
}


Measured memory_bytes: 1320
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;

#define N 3
#define N2 9

struct Puzzle
{
    int f[N2];
    int space;
    string path;
    int i;

    bool operator < (const Puzzle &p) const
    {
        int i;
        for(i=0;i<N2;i++)
        {
            if(f[i] == p.f[i]) continue;
            return f[i] > p.f[i];
        }
        return false;
    }
};

static const int dx[4] = {-1,0,1,0};
static const int dy[4] = {0,-1,0,1};
static const char dir[4] = {'u','l','d','r'};

bool isTarget(Puzzle p)
{
    int i;

    for(i=0;i<N2;i++)
    {
       if(p.f[i] != (i+1)) return false;
    }
       return true; 
}

string bfs(Puzzle s)
{
    queue<Puzzle> Q;
    map<Puzzle,bool> V;
    Puzzle u,v;
    s.path = "";
    Q.push(s);
    V[s] = true;

    while(!Q.empty())
    {
        u = Q.front();Q.pop();
        if(isTarget(u)) return u.path;
        int sx = u.space / N;
        int sy = u.space % N;
        for(int r=0;r<4;r++)
        {
            int tx = sx + dx[r];
            int ty = sy + dy[r];
            if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
            v = u;
            swap(v.f[u.space],v.f[tx * N + ty]);
            v.space = tx * N + ty;
            if(!V[v])
            {
                V[v] = true;
                v.path += dir[r];
                Q.push(v);
            }
        }
    }

    return "unsolvable";

}

int main()
{
    Puzzle in;

    for(int i=0;i<N2;i++)
    {
        cin >> in.f[i];
        if(in.f[i] == 0)
        {
            in.f[i] = N2;
            in.space = i;
        }
    }

    string ans = bfs(in);
    cout << ans.size() << endl;

    return 0;

}


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

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

	long long int n,t;
	vector <long long int> v;

	cin >> n;

	for(int i=0;i<5;i++)
	{
		cin >> t;
		v.push_back(t);
	}

	long long int res = 0;
	for(int i=0;i<5;i++)
	{
		long long int x = ceil((n*1.0)/v[i]);
		x+=4;
		res = max(res,x);
	}

	cout << res << '\n';

	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() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  
  vector<int> b(N);
  rep(i, N) b[i] = a[i];
  
  sort(b.begin(), b.end());
  
  rep(i, N){
    if(a[i] == b[N-1]) cout << b[N-2] << endl;
    else cout << b[N-1] << endl;
  }

}

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

typedef long long ll;

int main()
{
  int n;
  ll  L[100];

  L[0] = 2;
  L[1] = 1;
  cin >> n;

  for(int i = 2; i <= n; i++){
    L[i] = L[i-1] + L[i-2];
  }

  cout << L[n] << endl;


  return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> ab(n);

	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ab[i] = make_pair(b, a);
	}

	bool flg = true;

	sort(ab.begin(), ab.end());

	int now = 0;

	for (int i = 0; i < n; i++) {
		now += ab[i].second;
		if (now > ab[i].first) {
			flg = false;
			break;
		}
	}

	if(flg){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	ll a,b,c;
	cin>>a>>b>>c;
	if(a+b>=c)
	{
		cout<<"No\n";
		return 0;
	}
	if(4*a*b<(c-a-b)*(c-a-b))cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long N;
  cin>>N;
  long long total=0;
  for(int i=1;i<=N;i++){
      if(i%3==0) continue;
      if(i%5==0) continue;
      //cout<<i<<endl;
      total=total+i;
  }
  cout<<total<<endl;
  
  
  return 0;
}
 
  
  
  
  


 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    string a,b,c;
    cin>>a>>b>>c;
    queue<char> aq,bq,cq;
    rep(i,a.size()){
        aq.push(a.at(i));
    }
    rep(i,b.size()){
        bq.push(b.at(i));
    }
    rep(i,c.size()){
        cq.push(c.at(i));
    }
    bool isContinue=true;
    char ans;
    char now='a';
    while(isContinue){
        if(now=='a'){
            if(aq.empty()){
                ans='A';
                isContinue=false;
            }
            now=aq.front();
            aq.pop();
        }
        if(now=='b'){
            if(bq.empty()){
                ans='B';
                isContinue=false;
            }
            now=bq.front();
            bq.pop();
        }
        if(now=='c'){
            if(cq.empty()){
                ans='C';
                isContinue=false;
            }
            now=cq.front();
            cq.pop();
        }                
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// Problem : E - Logs
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#define _CRT_SECURE_NO_WARNINGS
#include <queue>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const int N = 2e5+7;
const double eps = 1e-3;
int a[N],n,k;
bool check(double x)
{
	int res = 0;
	for(int i = 1;i <= n;++i)
	{
		res += floor(a[i] / x);
	}
	return res <= k;
}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> n >> k;
	for(int i = 1;i <= n;++i)	cin >> a[i];
	double l = 1,r = 1e9;
	while(r - l > eps)
	{
		double mid = (l + r) / 2;
		if(check(mid))	r = mid;
		else l = mid;
	}
	cout << (int)ceil(l);
    return 0;
}


Measured memory_bytes: 3992
using System;
using System.Collections.Generic;
using System.Linq;

class A
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		var n = h[0];

		var r = new List<int>();
		var uf = new UF(n);

		for (int i = 0; i < h[1]; i++)
		{
			var q = Read();
			if (q[0] == 0)
				uf.Unite(q[1], q[2]);
			else
				r.Add(uf.AreUnited(q[1], q[2]) ? 1 : 0);
		}
		Console.WriteLine(string.Join("\n", r));
	}
}

class UF
{
	int[] p;
	public UF(int n) { p = Enumerable.Range(0, n).ToArray(); }

	public void Unite(int a, int b) { if (!AreUnited(a, b)) p[p[b]] = p[a]; }
	public bool AreUnited(int a, int b) => GetRoot(a) == GetRoot(b);
	public int GetRoot(int a) => p[a] == a ? a : p[a] = GetRoot(p[a]);
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
string S[101];
int cnt[256];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) {
		cin>>S[y];
		FORR(c,S[y]) cnt[c-'a']++;
	}
	int p1=0,p2=0,p4=0;
	if(H%2 && W%2) {
		p1=1;
		p2=((H-1)+(W-1))/2;
	}
	else if(H%2) {
		p2=W/2;
	}
	else if(W%2) {
		p2=H/2;
	}
	
	p4=(H*W-p1-p2*2)/4;
	
	while(p4) {
		FOR(i,26) if(cnt[i]>=4) {
			cnt[i]-=4;
			p4--;
			break;
		}
		if(i==26) return _P("No\n");
	}
	while(p2) {
		FOR(i,26) if(cnt[i]>=2) {
			cnt[i]-=2;
			p2--;
			break;
		}
		if(i==26) return _P("No\n");
	}
	while(p1) {
		FOR(i,26) if(cnt[i]>=1) {
			cnt[i]-=1;
			p1--;
			break;
		}
		if(i==26) return _P("No\n");
	}
	_P("Yes\n");
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
def main():
    H, W = map(int, input().split())
    S = []
    for _ in range(H):
        s = list(input())
        S.append(s)
    R = [[0]*W for _ in range(H)]
    L = [[0]*W for _ in range(H)]
    U = [[0]*W for _ in range(H)]
    D = [[0]*W for _ in range(H)]
    for i in range(H):
        cnt1 = 0
        cnt2 = 0
        for j in range(W):
            if S[i][j]=='#':
                cnt1 = 0
            else:
                cnt1 += 1
                L[i][j] = cnt1
        for j in range(W-1, -1, -1):
            if S[i][j]=='#':
                cnt2 = 0
            else:
                cnt2 += 1
                R[i][j] = cnt2

    for j in range(W):
        cnt1 = 0
        cnt2 = 0
        for i in range(H):
            if S[i][j]=='#':
                cnt1 = 0
            else:
                cnt1 += 1
                U[i][j] = cnt1
        for i in range(H-1,-1,-1):
            if S[i][j]=='#':
                cnt2 = 0
            else:
                cnt2 += 1
                D[i][j] = cnt2

    ans = 0
    for i in range(H):
        for j in range(W):
            ans = max(ans, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)
    print(ans)


if __name__ == '__main__':
    main()

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

signed main () {
	int n;
    cin >> n;
    vector < int > cnt(26, 100000000);
    vector < string > s(n);
    for (int i = 0; i < n; ++i)
		cin >> s[i];
    for (char c = 'a'; c <= 'z'; ++c) {
        for (int i = 0; i < n; ++i) {
			int k = 0;
			for (int j = 0; j < int(s[i].size()); ++j)
				k += int(s[i][j] == c);
            cnt[c - 'a'] = min(cnt[c - 'a'], k);
        }
    }
    for (auto c = 'a'; c <= 'z'; ++c) {
		if (cnt[c - 'a'] < 5000) {
			for (int i = 0; i < cnt[c - 'a']; ++i)
				cout << c;
        }
    }
    cout << '\n';
}


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

const int INF = 1e12;

signed main() {
    int n;
    cin >> n;

    vector<int> item;
    item.push_back(1);
    for(int i = 1;;i++){
        if(pow(6,i) > n) break;
        item.push_back(pow(6,i));
    }

    for(int i = 1;; i++){
        if(pow(9,i) > n) break;
        item.push_back(pow(9,i));
    }

    sort(item.begin(),item.end());
    int m = item.size();
    vector<vector<int>> dp(m + 1, vector<int>(n + 1,INF));
    dp[0][n] = 0;
    for(int i = 0; i < m; i++){
        for(int j = n; j >= 0; j--){
            if(j - item[i] >= 0) dp[i][j - item[i]] = min(dp[i][j - item[i]], dp[i][j] + 1);
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }

    cout << dp[m - 1][0] << endl;

}

Measured memory_bytes: 11264
import Prelude hiding (Right, Left)
import Data.List
import Data.Maybe
import qualified Data.IntSet as S

data Dist n = Up | Left | Down | Right deriving Show
data FT     = F Int | T deriving Show

main = do
    s <- concatMap (\x-> if head x == 'F' 
        then [F $ length x] 
        else replicate (length x) T) . group <$> getLine
    [x,y] <- map read . words <$> getLine :: IO [Int]
    putStrLn $ if dpR (S.singleton 0) (S.singleton 0) s (x,y) then "Yes" else "No"

dpR slr sud [] (gx,gy) = S.member gx slr && S.member gy sud
dpR slr sud (x:xs) (gx,gy) = case x of
    F n -> let slr' = S.foldr (\k s -> S.insert (k+n) s) S.empty slr
           in  dpR slr' sud xs (gx,gy)
    T   -> dpUD slr sud xs (gx,gy)

dpLR slr sud [] (gx,gy) = S.member gx slr && S.member gy sud
dpLR slr sud (x:xs) (gx,gy) = case x of
    F n -> let slr' = insertKeys slr n
           in  dpLR slr' sud xs (gx,gy)
    T   -> dpUD slr sud xs (gx,gy)

dpUD slr sud [] (gx,gy) = S.member gx slr && S.member gy sud
dpUD slr sud (x:xs) (gx,gy) = case x of
    F n -> let sud' = insertKeys sud n
           in  dpUD slr sud' xs (gx,gy)
    T   -> dpLR slr sud xs (gx,gy)

insertKeys set n = S.foldr (\k s -> S.insert (k-n) $ S.insert (k+n) s) S.empty set

Measured memory_bytes: 2428
// Who_Says_a_Pun? 
// https://atcoder.jp/contests/abc141/tasks/abc141_e
// date: 2020-08-11T20:47:18.409724

// #配列の初期化 #0埋め #memsetではなく{0}

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

#define REP(i, n) for(ll i=0;i<ll(n);i++)
#define REPD(i, n) for(ll i=n-1;i>=0;i--)
#define FOR(i, a, b) for(ll i=a;i<=ll(b);i++)
#define FORD(i, a, b) for(ll i=a;i>=ll(b);i--)

#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

template<typename T, typename ...Args>
void IN(T& first, Args&... args) {
    ((cin >> first), ..., (cin >> args)); //C++17
}

template<char Sep, typename T, typename ...Args>
void print_sep(const T& first, const Args&... args) {
    ((cout << first), ..., (cout << Sep << args)); //C++17
}

template<typename... Words>
void OUT(Words... words) {
    print_sep<' '>(words...);
    cout << endl;
    return;
}

#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 5000 //10^5:配列の最大のrange

int main(void){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    ll N;
    string s;
    IN(N);
    IN(s);

    // https://qiita.com/Ki4mTaria/items/b6ab0bcbe9c87d4dc071#%E9%85%8D%E5%88%97%E6%A7%8B%E9%80%A0%E4%BD%93%E3%81%AE%E4%B8%AD%E8%BA%AB
    static bool arr[MAXR][MAXR]= {false};
    REP(i,N) FOR(j,i,N) {
        arr[i][j] = s[i] == s[j];
    }

    ll max_len=0;
    FOR(i, 1, N-1) {
        ll buf_len=0;
        FOR(j, 0, N - i - 1) {
            if (arr[j][i+j]) {
                buf_len++;
            } else{
                buf_len=0;
            }
            max_len = max(max_len, buf_len);
            if (buf_len==i) {
                break;
            }
        }
    }
    OUT(max_len);
    return 0;

}


Measured memory_bytes: 27600
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
const int MaxN = 1000;
using namespace std;
vector <int> G[MaxN + 5];
int match[MaxN + 4];
struct NODE {
	int x, y;
}a[MaxN + 5];
bool vis[MaxN + 5];
bool Dfs(int x) {
	vis[x] = true;
	for (int i = 0; i < G[x].size(); i++) {
		int v = G[x][i], w = match[v];
		if(w < 0 || !vis[w] && Dfs(w)) {
			match[v] = x;
			match[x] = v;
			return true;
		}
	}
	return false;
}
int main() 
{
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d%d", &a[i].x, &a[i].y);
	for (int i = 1; i <= n; i++) {
		int x, y; scanf("%d%d", &x, &y);
		for (int j = 1; j <= n; j++) {
			if(a[j].x < x && a[j].y < y) {
				G[j].push_back(n + i);
				G[n + 1].push_back(j);
			}
		}
	}
	int ans = 0; memset(match, -1, sizeof(match));
	for (int i = 1; i <= n; i++) {
		memset(vis, 0, sizeof(vis));
		if(match[i] < 0) {
			if(Dfs(i)) ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
// vector<int> vec(3); = vector<int> vec={0,0,0}
// vec.at()
// sort(num.begin(),num.end(), greater<int>());
// reverse(num.begin(),num.end());
// transform(a.begin(), a.end(), a.begin(), ::toupper);
 
// 切り上げ　a/b+1
//  1からNの総和　N*(N+1)/2
 
int main() {
  int x,y;
  cin >> x >> y;
  int a[13] = {0,1,2,1,3,1,3,1,1,3,1,3,1};
  
  cout << (a[x] == a[y] ? "Yes":"No") << endl;
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define fr                first
#define sc                second
#define vc                vector
#define endl              '\n'
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define LSB(i)            ((i)&-(i))

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 1e5 + 5;
int a[N][4];
int n;
int dp[N][4];


void solve()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i][1] >> a[i][2] >> a[i][3];
    }

    mem1(dp);

    dp[1][1] = a[1][1];
    dp[1][2] = a[1][2];
    dp[1][3] = a[1][3];

    for (int i = 2; i <= n; i++)
    {
        for (int j = 1; j <= 3; j++)
        {
            for (int k = 1; k <= 3; k++)
            {
                if (k != j)
                {
                    dp[i][k] = max(dp[i][k], dp[i - 1][j] + a[i][k]);
                }
            }
        }
    }
    cout << max(dp[n][1], max(dp[n][2], dp[n][3]));
}
signed main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin>>s;
    char a,b;
    a=s[0];
    int ans=0;
    for(int i=1;i<s.size();i++){
        b=s[i];
        if(a!=b)ans++;
        a=b;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#include <bits/stdc++.h>
using namespace std;
#include<stdbool.h>
#include<math.h>
#include<string.h>
#define ll long long
#define db double
#define max(a, b) a>b?a:b
#define min(a, b) a<b?a:b
#define sz 500000005

ll a[100005], deg[100005];

int main()
{
    ll n, k, i, sum=0, b, c, q;
    scanf("%lld", &n);
    for(i=0; i<n; i++)
    {
        scanf("%lld", &a[i]);
        sum+=a[i];
        deg[a[i]]++;
    }
    scanf("%lld", &q);
    for(i=0; i<q; i++)
    {
        scanf("%lld %lld", &b, &c);
        sum+=((deg[b]*c)-(deg[b]*b));
        deg[c]+=deg[b];
        deg[b]=0;
        printf("%lld\n", sum);
    }
    return 0;
}


Measured memory_bytes: 5248
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    string s,t;
    cin >> s >> t;
    //置換対応表
    char s_to_t[26]={};
    char t_to_s[26]={};
    int ch[26]={};
    bool yn=true;
    for(int i=0; i<s.size(); i++){
        int si=s[i]-'a', ti=t[i]-'a';
        if(s_to_t[si]){
            if(s_to_t[si] != t[i]){
                yn = false;
            }
        }
        if(t_to_s[ti]){
            if(t_to_s[ti] != s[i]){
                yn = false;
            }
        }
        s_to_t[si] = t[i];
        t_to_s[ti] = s[i];
    }
    if(yn){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 776
import java.util.*;
public class Main {
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();

        int[]B = new int[A]; 
        
        for (int i = 0 ; i< A; i++){
            
            B[i]  = sc.nextInt();

        }

        sc.close();

        // 答えを初期化
        int ans = 0;
        // 配列に順次アクセス
        for (int i = 0;i<A-1;i++){        
            
            // 右隣への比較回数
            int cnt = 0;
            // jは配列のアクセスしている連番を示す
            for (int j = i;j < A;j++){
                // 最右に移動済みならループから抜ける
                if (j == A-1){
                    break;
                }
                
                //　右隣と比較
                if (B[j] >=B[j+1]){
                    cnt++;
                // 比較終了
                } else{
                    
                    break;

                }


            }
            // 移動回数が最大値を取っているならば答えを更新
            if (ans < cnt){
            
                ans = cnt;
            }
            
            if (ans >= A-i){
                break;
            }
        }
        System.out.println(ans);
    }
       
}       

Measured memory_bytes: 49624
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
double dp[20004][104];
int v[20004]={0};
int t1[204],t2[204];
int n,tot;
int main() {
//	freopen("D.in","r",stdin);
	while (~scanf("%d",&n)) {
		tot=0;
		for (int i=1;i<=n;++i) scanf("%d",&t1[i]);
		for (int i=1;i<=n;++i) scanf("%d",&t2[i]);
		for (int i=1;i<=n;++i)
			while (t1[i]--) v[++tot]=t2[i];
		for (int i=0;i<=tot;++i)
			for (int j=0;j<=v[i];++j)
				dp[i][j]=-1.0;
		dp[0][0]=0;
		for (int i=1;i<=tot;++i)
			for (int j=0;j<=v[i];++j) {
				if (j-1>v[i-1]) break;
				if (j-1<=v[i-1]&&dp[i-1][j-1]!=-1.0) dp[i][j]=max(dp[i][j],dp[i-1][j-1]+0.5*((j<<1)-1));
				if (j<=v[i-1]&&dp[i-1][j]!=-1.0) {
					dp[i][j]=max(dp[i][j],dp[i-1][j]+j);
					if (j<v[i]) dp[i][j]=max(dp[i][j],dp[i-1][j]+j+0.25);
				}
				if (j+1<=v[i-1]&&dp[i-1][j+1]!=-1.0&&j+1<=v[i]) dp[i][j]=max(dp[i][j],dp[i-1][j+1]+0.5*(j<<1|1));
			}
/*		for (int i=1;i<=tot;++i) {
			for (int j=0;j<=v[i];++j)
				cout<<dp[i][j]<<' ';
			cout<<endl;
		}*/
		printf("%lf\n",dp[tot][0]);
	}
	return 0;
}

Measured memory_bytes: 16512
Uses math;
var N,i:integer;
    H:array[1..100010] of integer;
    dp:array[1..100010] of integer;
begin
 read(N);
for i := 1 to N do read(H[i]);
 dp[1]:=0;dp[2]:=abs(H[2]-H[1]);
for i := 1 to N do
 begin
  dp[i+1]:=min(dp[i+1],dp[i]+abs(H[i+1]-H[i]));
  
  dp[i+2]:=dp[i]+abs(H[i+2]-H[i]);
 end;
write(dp[N])
end.

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define MAX_N 103
#define MAX_V 10
#define MAX_M 101
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"

signed main(){
	cout<<fixed<<setprecision(7);
	string s, t, temp;
	int sizes, sizet, f = false, count = 0, ma = 0;
	vector<string> vs;
	cin>>s>>t;
	
	sizes = s.size();
	sizet = t.size();
	
	// for(int i = sizes-1; i >= 0; i++){
		// if(s[i] == '?' || ){
			// count++;
		// } else {
			// count = 0;
		// }
		// if(count == sizet){
			// f = i;
			// break;
		// }
	// }
	for(int i = 0; i < sizes; i++){
		int counta = 0;
		bool flag = true;
		for(int j = 0; j < sizet; j++){
			if(s[i+j] != t[j] && s[i+j] != '?'){
				flag = false;
				break;
			}
			// cout<<i<<" "<<j<<" "<<s[i+j]<<" "<<t[j]<<endl;
			// if(s[i+j] == t[j])counta++;
		}
		// cout<<counta<<endl;
		// if(flag && counta >= ma){
			// f = i;
			// ma = counta;
			// break;
		// }
		if(flag){
			f = true;
			temp.clear();
			for(int j = 0; j < i; j++){
				temp += s[j]=='?'?'a':s[j];
			}
			temp += t;
			for(int j = i+sizet; j < sizes; j++){
				temp += s[j]=='?'?'a':s[j];
			}
			vs.push_back(temp);
		}
		
	}
	if(f == false){
		cout<<"UNRESTORABLE"<<endl;
		return 0;
	}
	
	
	// for(int i = 0; i < sizes; i++){
		// if(f <= i && i <= sizet-1+f){
			// cout<<t[i-f];
		// } else if(s[i] == '?'){
			// cout<<"a";
		// } else {
			// cout<<s[i];
		// }
	// }
	
	// cout<<endl;	
	
	sort(vs.begin(), vs.end());
	cout<<vs[0]<<endl;
	return 0;
}

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

int main()
{
    unordered_set<string> st;
    int n;
    cin >> n;
    string s;
    rep(i, n) {
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 17616
#include<iostream>
#include<iostream>
using namespace std;
int main(){
   int t,n,sam;
   string comand;

   while(cin >> n,n != 0){
	sam = 1;
	int dice[6] = {1,2,3,5,4,6};
	for(int i=0;i<n;i++){
		cin >> comand;
		if(comand == "North"){
			t = dice[0];
			dice[0] = dice[1];
			dice[1] = dice[5];
			dice[5] = dice[3];
			dice[3] = t;
		}else if(comand == "East"){
			t = dice[0];
			dice[0] = dice[4];
			dice[4] = dice[5];
			dice[5] = dice[2];
			dice[2] = t;
		}else if(comand == "West"){
			t = dice[0];
			dice[0] = dice[2];
			dice[2] = dice[5];
			dice[5] = dice[4];
			dice[4] = t;
		}else if(comand == "South"){
			t = dice[0];
			dice[0] = dice[3];
			dice[3] = dice[5];
			dice[5] = dice[1];
			dice[1] = t;
		}else if(comand == "Right"){
			t = dice[1];
			dice[1] = dice[2];
			dice[2] = dice[3];
			dice[3] = dice[4];
			dice[4] = t;
		}else if(comand == "Left"){
			t = dice[1];
			dice[1] = dice[4];
			dice[4] = dice[3];
			dice[3] = dice[2];
			dice[2] = t;
		}

		sam += dice[0];
	}

	cout << sam << endl;

   }

   return 0;
}

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

int main(){
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> A(N+1);
  for(int64_t i=1; i<=N; i++){
    cin >> A.at(i);
  }
  vector<int64_t> T(N+1);
  vector<int64_t> P(N+1, -1);
  T.at(0)=1;
  P.at(1)=0;
  int64_t start=-1;
  int64_t goal=-1;
  for(int64_t i=1; i<=N; i++){
    T.at(i)=A.at(T.at(i-1));
    if(P.at(T.at(i))!=-1){
      start=P.at(T.at(i));
      goal=i;
      break;
    }
    P.at(T.at(i))=i;
  }
  if(K<start){
    cout << T.at(K) << endl;
  }
  else{
    int64_t U=(K-start)%(goal-start);
    cout << T.at(start+U) << endl;
  }
}

Measured memory_bytes: 8012
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)

//小文字=大文字+32

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

}
	



Measured memory_bytes: 3592
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <vector>

using namespace std;
const long long mod = 1e9 + 7;

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

    vector<int> oks(N + 1, true);
    for (int i = 0; i < M; ++i)
    {
        int a;
        cin >> a;
        oks[a] = false;
    }

    vector<long long int> dp(N + 1);
    dp[0] = 1;
    for (int now = 0; now < N; ++now)
    {
        for (int next = now + 1; next <= min(N, now + 2); ++next)
        {
            if (oks[next])
            {
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int N,W[100],i,j,temp,min=100000,s1,s2;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    scanf("%d",&W[i]);
    
    for(i=0;i<N;i++){
        s1=0; s2=0;
        for(j=0;j<=i;j++)
        s1+=W[j];
        for(j=i+1;j<N;j++)
        s2+=W[j];
        if(abs(s1-s2)<min)
        min=abs(s1-s2);
    }
  
    printf("%d",min);
    return(0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll r,g,b;
        cin>>r>>g>>b;
        ll c=100*r+g*10+b;
        if(c%4==0)
        cout<<"YES";
        else
        cout<<"NO";
    }    
    return 0;
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
const int MAX_N=101000;
int par[MAX_N];
int sizeofit[MAX_N];
void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        sizeofit[i]=1;
    }
}
int root(int x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=root(par[x]); 
    }
}
bool same(int x,int y){
    return root(x)==root(y);
}
void unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y){
        return;
    }else{
        sizeofit[y]=sizeofit[y]+sizeofit[x];
        par[x]=y;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N=in();
    ll M=in();
    vector<ll> ans;
    vector<pair<int,int>> bridge;
    init(101000);
    ll a;ll b; 
    REP(i,M){
        cin>>a>>b;
        bridge.push_back(make_pair(a,b));
    }
  
    ll ans_temp;ans_temp=N*(N-1)/2;
  //debug(ans_temp);
    ans.push_back(ans_temp);
    REP(i,M){
        a=bridge[M-i-1].first;
        b=bridge[M-i-1].second;
        //debug(root(a));
        //debug(root(b));
        if(same(a,b)){
            ans.push_back(ans_temp);
            //cout<<a<<" "<<b<<endl;
        }else{
            ans.push_back(ans_temp-sizeofit[root(a)]*sizeofit[root(b)]);
            ans_temp-=sizeofit[root(a)]*sizeofit[root(b)];
            unite(a,b);
        }
    }
    REP(i,ans.size()-1){
        print(ans[ans.size()-i-2]);
    }
    return 0;
}


Measured memory_bytes: 3828