akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<int,ll>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;
const int MAX_N = 100005;

class Edge{
  public:
    int cost; ll to;
    Edge(int cost,ll to)
      :cost(cost),to(to){}
};

void dijkstra(ll start,unordered_map<ll,vector<Edge>> &graph,unordered_map<ll,int> &dist){
  priority_queue<Pl,vector<Pl>,greater<Pl>> que;
  dist[start] = 0;
  que.push(Pl(0,start));
  while(!que.empty()){
    Pl p=que.top(); que.pop();
    ll v=p.second; //行き先
    if(dist[v]==0&&v!=0LL) dist[v] = INF;
    if(dist[v]<p.first) continue;
    for(Edge e: graph[v]){
      if(dist[e.to]==0&&e.to!=0LL) dist[e.to] = INF;
      if(dist[v]+e.cost<dist[e.to]){
        dist[e.to]=dist[v]+e.cost;
        que.push(Pl(dist[e.to],e.to));
      }
    }
  }
  return ;
}

void add_edge(ll p,ll q,ll c,unordered_map<ll,vector<Edge>> &graph){
  ll p0,pc,q0,qc;
  p0 = ll(p); q0 = ll(q);
  pc = p0 | (c<<30);
  qc = q0 | (c<<30);
  graph[p0].pb(Edge(1,pc));
  graph[pc].pb(Edge(1,p0));
  graph[pc].pb(Edge(0,qc));
  graph[qc].pb(Edge(0,pc));
  graph[qc].pb(Edge(1,q0));
  graph[q0].pb(Edge(1,qc));
}

int main(){
  ll N,M; cin >> N >> M;
  unordered_map<ll,vector<Edge>> graph;
  unordered_map<ll,int> dist;
  rep(i,M){
    ll p,q,c; scanf("%lld%lld%lld",&p,&q,&c);
    p--; q--;
    add_edge(p,q,c,graph);
  }
  dijkstra(0LL,graph,dist);
  ll ans;
  if(dist[ll(N-1)]!=0 && dist[ll(N-1)]!=INF){
    ans = dist[ll(N-1)]/2LL;
  }else{
    ans = -1LL;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 77172
#include<bits/stdc++.h>
using namespace std;
int N,M;
unordered_map<int,int> ids;
int main(){
  cin >> N >> M;
  vector<int> V(N);
  for(int &a: V) cin >> a;
  reverse( V.begin(), V.end() );
  int cnt = 0;
  for(int i=0;i<N&&cnt<M;i++){
    if( ids.count( V[i] ) ) continue;
    ids[V[i]]=1;
    cout << V[i] << endl;
    cnt++;
  }
}

Measured memory_bytes: 5404
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
//FUCK.......MISSED AN EASY ONE ....SHITTT

#define int long long
//#define ll long long
#define N 1005
#define M 1000000009
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define ld long double
#define inf 200000000009
#define pii pair<pi,pi>
//||

//"\n"
vector<string>s;
int n,m,k;
vector<vector<vector<int> > >vis,d,vis2;

int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int check(int x,int y)
{
    if(x<0 || y<0 || x>=n || y>=m || s[x][y]=='@')
        return 0;
    return 1;
}
void bfs(int x,int y)
{
    int j;
    deque<pii> q;//x,y,dir,dist(k waala)
    q.push_front({{x,y},{0,0}});
    q.push_front({{x,y},{1,0}});
    q.push_front({{x,y},{2,0}});
    q.push_front({{x,y},{3,0}});

    d[x][y][0]=1;
    d[x][y][1]=1;
    d[x][y][2]=1;
    d[x][y][3]=1;

    vis[x][y][0]=1;
    vis[x][y][1]=1;
    vis[x][y][2]=1;
    vis[x][y][3]=1;

    while(!q.empty())
    {
        pii x=q.front();

        int x1=x.F.F;
        int y1=x.F.S;
        int d1=x.S.F;
        int dist=x.S.S;


        q.pop_front();

        if(vis2[x1][y1][d1])
            continue;
        vis2[x1][y1][d1]=1;

        for(j=0;j<4;j++)
        {
            if(check(x1+dx[j],y1+dy[j]) )
            {
                //cout<<x1+dx[j]<<" "<<y1+dy[j]<<endl;
                if(j==d1&& dist<k && d[x1+dx[j]][y1+dy[j]][j]>d[x1][y1][d1])
                {
                    q.push_front({{x1+dx[j],y1+dy[j]},{j,dist+1}});
                    d[x1+dx[j]][y1+dy[j]][j]=min(d[x1+dx[j]][y1+dy[j]][j],d[x1][y1][d1]);
                    vis[x1+dx[j]][y1+dy[j]][j]=1;
                }

                else if( d[x1+dx[j]][y1+dy[j]][j]>d[x1][y1][d1]+1)
                {
                     q.push_back({{x1+dx[j],y1+dy[j]},{j,1}});

                    d[x1+dx[j]][y1+dy[j]][j]=min( d[x1+dx[j]][y1+dy[j]][j],d[x1][y1][d1]+1);
                    vis[x1+dx[j]][y1+dy[j]][j]=1;
                }
            }
        }
    }

}

main()
{
    ios::sync_with_stdio(false);
  cin.tie(NULL);
int i,ans=(int)1e9,j;
cin>>n>>m>>k;
s.resize(n);
int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
vector<vector<int> > temp;
temp.assign(m,vector<int>(4,0));
vis.assign(n,temp);
d.assign(n,temp);
vis2.assign(n,temp);

for(i=0;i<n;i++)
    cin>>s[i];

for(i=0;i<n;i++)
    for(j=0;j<m;j++)
    for(int gg=0;gg<4;gg++)
        d[i][j][gg]=(int)1e9;

x1--;
y1--;
x2--;
y2--;
bfs(x1,y1);
if(x1==x2 && y1==y2)
{cout<<0<<endl;
return 0;}

//cout<<d[0][2][1]<<endl;
for(j=0;j<4;j++)
    ans=min(ans,d[x2][y2][j]);
    if(ans==(int)1e9)
        cout<<-1;
    else
cout<<ans;

    return 0;
}

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

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

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

int main(){
    int X,Y;
    cin>>X>>Y;
    bool ok=true;
    if(Y<2*X)ok=false;
    if(4*X<Y)ok=false;
    if(Y%2==1)ok=false;
    cout<<(ok?"Yes":"No")<<endl;
}


Measured memory_bytes: 3636
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 1000000000
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define AU(i,x)    for(auto i=x.begin(); i!=x.end(); ++i)
# define ALL(A) A.begin(),A.end()
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;
const int N=100005;
///Code begin..................................................................
inline LL Scan() {
    LL x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}


int main()
{
    int a, b, c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d\n",min(a*b,c));
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

int main() {
  unsigned long long l;

  std::cin >> l;

  std::cout << std::fixed << std::setprecision(10)
            << static_cast<double>(l * l * l) / 27.0 << std::endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
i = 1
ans = 0
r = int(n**(1/2))
for i in range(1,r+1):
    if (n-i)%i == 0:
        if ((n-i)//i) > i:
            ans += (n-i)//i
        else:
            break
print(ans)

Measured memory_bytes: 3060
def check(c,num):
    for i in range(8):
        if c[i]=="*":continue
        if c[i]!=num[i]:return False
    return True

while True:
    n,m=map(int,raw_input().split())
    if n==m==0:break
    L=[raw_input().split() for i in range(n)]
    s=0
    for i in range(m):
        num=raw_input()
        for c in L:
            if check(c[0],num):
                s+=int(c[1])
                break
    print s

Measured memory_bytes: 4264
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll v[305][305],vis[305];
void solve(){
	ll n,m;
	cin>>n>>m;
	for(ll i=1;i<=n;i++)
	for(ll j=1;j<=m;j++)
	cin>>v[i][j];
	ll c=0,res=pow(10,10);
	while(c<m){
		vector<ll> cnt(m+1,0);
		for(ll i=1;i<=n;i++){
			for(ll j=1;j<=m;j++)
			if(!vis[v[i][j]]){
				cnt[v[i][j]]++;
				break;
			}
		}
		ll hi=0,hell=0;
		for(ll i=1;i<=m;i++){
			hi=max(hi,cnt[i]);
			if(hi==cnt[i])
			hell=i;
		}
		vis[hell]=1;
		res=min(res,hi);
		c++;
	}
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int MOD = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if(s.at(0)-'A'<=26) {
		cout << 'A' << endl;
	} else {
		cout << 'a' << endl;
	}
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int constexpr maxn = 100009;
int n, k;
int h[maxn];
int dp[maxn];
bool done[maxn];

void read_input()
{
    cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> h[i];
}

int go(int i) {
    if(i < 1) return 1000000001;
    if(i == 1) return 0;
    if(done[i]) return dp[i];

    dp[i] = 1000000001;
    for(int j = 1; j <= k; j++) {
        dp[i] = min(dp[i], go(i - j) + abs(h[i] - h[i - j]));
    }
    done[i] = true;
    return dp[i];
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    read_input();
    cout << go(n) << endl;
}


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

using namespace std;
using ll = long long;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, std::string S){
  ll ans = N;
  ll b = 0;
  for(int i=0; i<N; i++){
    if(S[i]=='.')
      b++;
  }
  ans = min(ans, b);
  for(int i=0; i<N; i++) {
    if(S[i]=='.') {
      b--;
    } else {
      b++;
    }
    ans = min(ans, b);
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}



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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	unsigned int width;
	scanf("%u", &width);
	//cin >> width;
	vector <unsigned int> up(width), mid(width), down(width);
	for (unsigned int i = 0; i < width; ++i) {
		//cin >> up[i];
		scanf("%u", &up[i]);
	}
	for (unsigned int i = 0; i < width; ++i) {
		//cin >> mid[i];
		scanf("%u", &mid[i]);
	}
	for (unsigned int i = 0; i < width; ++i) {
		//cin >> down[i];
		scanf("%u", &down[i]);
	}
	sort(up.begin(), up.end());
	sort(mid.begin(), mid.end());
	sort(down.begin(), down.end());
	// ---
	long long count = 0;
	for (long long i = 0; i < width; ++i) {
		long long up_multi = 0, down_multi = 0;
		up_multi = distance(up.begin(), lower_bound(up.begin(), up.end(), mid[i]));
		down_multi = distance(upper_bound(down.begin(), down.end(), mid[i]), down.end());
		count += up_multi * down_multi;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1408
s = int(input())
List = []
List.append(s)

i = 0
while(True):
    i += 1
    if(s % 2 == 0):
        s = s / 2
        List.append(s)
    else:
        s = 3 * s + 1
        List.append(s)

    a = List[-1]
    if(List.count(a) != 1):
        break

print(i+1)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ri register int
using namespace std;
const int rlen = 1 << 20 | 5;
char buf[rlen], *ib = buf, *ob = buf;
#define gc() (((ib == ob) && (ob = (ib = buf) + fread(buf, 1, rlen, stdin))), ib == ob ? -1 : *ib++)
#define pb push_back
#define rez resize
#define ppp pop_back
inline int read() {
  static int ans;
  static char ch;
  for (ans = 0, ch = gc(); !isdigit(ch); ch = gc());
  while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = gc();
  return ans;
}
inline int Read(char *s) {
  static int top;
  static char ch;
  for (ch = gc(), top = 0; !isalpha(ch); ch = gc());
  while (isalpha(ch)) s[++top] = ch, ch = gc();
  return top;
}
typedef long long ll;
typedef pair <int, int> pii;
#define fi first
#define se second
inline ll readl() {
  static ll ans;
  static char ch;
  for (ans = 0, ch = gc(); !isdigit(ch); ch = gc());
  while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = gc();
  return ans;
}
template <typename T> inline void exgcd(T a, T b, T &x, T &y) {
  if (!b) { x = 1, y = 0; return; }
  exgcd(b, a - a / b * b, y, x), y -= a / b * x;
}
namespace modular {
  const int mod = 998244353;
  int ret;
  inline int add(int a, int b) { return a < mod - b ? a + b : a - mod + b; }
  inline int dec(int a, int b) { return a < b ? a - b + mod : a - b; }
  inline int mul(int a, int b) { return (ll) a * b % mod; }
  inline void Add(int &a, int b) { a = a < mod - b ? a + b : a - mod + b; }
  inline void Dec(int &a, int b) { a = a < b ? a - b + mod : a - b; }
  inline void Mul(int &a, int b) { a = (ll) a * b % mod; }
  inline int ksm(int a, int p) { for (ret = 1; p; p >>= 1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1); return ret; }
  inline int fix(int x) {
    x <= -mod || x >= mod ? x %= mod : 0;
    return x < 0 ? x + mod : x;
  }
  inline int Inv(int a) {
    static int x, y;
    return exgcd(a, mod, x, y), fix(x);
  }
}  using namespace modular;
const int N = 3e6 + 5;
int n, m, fac[N], ifac[N];
inline int C(int n, int m) { return n < m || m < 0 ? 0 : mul(fac[n], mul(ifac[m], ifac[n - m])); }
inline void init_fac() {
  int lm = 3000000;
  fac[0] = fac[1] = ifac[0] = ifac[1] = 1;
  for (ri i = 2; i <= lm; ++i) fac[i] = mul(fac[i - 1], i);
  ifac[lm] = Inv(fac[lm]);
  for (ri i = lm - 1; i > 1; --i) ifac[i] = mul(ifac[i + 1], i + 1);
}
int main() {
  #ifdef ldxcaicai
  freopen("lx.in", "r", stdin);
  #endif
  n = read(), m = read(), init_fac();
  int res = 0, tot = 0;
  for (ri x = m, cur; x >= 0; x -= 2) {
    int mt = C(n, x), S = (3 * m - x) / 2;
    cur = C(S + n - 1, n - 1);
    Dec(cur,  mul(n - x, C(S - (m + 1) + n - 1, n - 1)));
    Dec(cur,  mul(x, C(S - m + n - 1, n - 1)));
    Mul(mt, cur);
    Add(res, mt);
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 27068
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace ALDS1_3
{
    class Progarm
    {
        static void Main()
        {
            var i = new LinkedList<string>();
            var l = int.Parse(Console.ReadLine());
 
            for (var j = 0; j < l; j++)
            {
                var _t = Console.ReadLine().Split();
                 
                if (_t.Length == 1)
                {
                    if (_t[0] == "deleteFirst")
                        i.Remove(i.First);
                    else
                        i.Remove(i.Last);
                }
                else
                {
                    if (_t[0] == "insert")
                        i.AddFirst(_t[1]);
                    else
                    {
                        var node = i.First;

                        while (node != null)
                        {
                            if (node.Value == _t[1])
                            {
                                i.Remove(node);
                                break;
                            }
                            node = node.Next;
                        }
                    }
                }        
            }

            Console.WriteLine(string.Join(" ", i.ToArray()));
         }
    }
}

Measured memory_bytes: 147032
from collections import deque

n, m = map(int, input().split())

adj = [[] for _ in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

q = deque()
q.append(1)

visited = set()
mark = [-1 for _ in range(n+1)]

while len(visited) < n:
    _from = q.popleft()
    if _from in visited:
        continue
    visited.add(_from)
    for i in adj[_from]:
        q.append(i)
        if mark[i] == -1:
            mark[i] = _from

if len(visited) < n:
    print('No')
else:
    print('Yes')
    for i in range(2, n+1):
        print(mark[i])



Measured memory_bytes: 109796
def main():
    import sys
    from heapq import heappop, heappush

    def input(): return sys.stdin.readline().rstrip()

    def dijkstra(s):
        inf = 10**6
        dist = [inf]*10
        dist[1] = 0
        que = [(0, 1)]
        while que:
            cost, node = heappop(que)
            if cost > dist[node]:
                continue
            for i in range(10):
                if i == node:
                    continue
                if dist[i] > dist[node] + g[i][node]:
                    dist[i] = dist[node]+g[i][node]
                    heappush(que, (dist[i], i))
        return dist
    
    h, w = map(int, input().split())
    g = [[] for _ in range(10)]
    for i in range(10):
        g[i] = list(map(int, input().split()))

    from collections import defaultdict
    c_lis = defaultdict(int)
    for i in range(h):
        for j in input().split():
            tmp = int(j)
            if abs(tmp) != 1:
                c_lis[tmp] += 1
    
    dist = dijkstra(1)
    ans = 0
    for key in c_lis:
        ans += c_lis[key]*dist[key]
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 9428
import heapq

n, m = map(int, input().split())
a = map(int, input().split())
a = list(map(lambda x: -x, a))
heapq.heapify(a)

for i in range(m):
    tmp = -heapq.heappop(a) // 2
    heapq.heappush(a, -tmp)

print(-sum(a))


Measured memory_bytes: 14252
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] sortedWords = new String[N];
        for (int i = 0; i < N; i++) {
            String word = sc.next();
            char[] tmp = word.toCharArray();
            Arrays.sort(tmp);
            String sortedWord = String.valueOf(tmp);
            sortedWords[i] = sortedWord;
        }

        long ans = 0;
        // ここをソートしてから、同じものが並ぶ数をカウントしてみるか？
        Arrays.sort(sortedWords);
        int sameWordCount = 0;
        for (int i = 0; i <= N - 2; i++) {
            if(sortedWords[i].equals(sortedWords[i + 1])) {
                sameWordCount++;
                if (i == N - 2) {
                    ans += calcCombination(sameWordCount + 1,2);
                    break;
                }
            }
            else {
                ans += calcCombination(sameWordCount + 1,2);
                sameWordCount = 0;
            }
        }
        System.out.print(ans);
    }

    long calcCombination(int n, int r) {
        if (n < 0 || r < 0) {
            throw new IllegalArgumentException("Arguments must be 0 and over.");
        }
        else if (n == r || r == 0) {
            return 1;
        }
        else if (n < r) {
            return 0;
        }
        else {
            long result = 1;
            for (int i = 1; i <= r; i++) {
                result = result * (n - i + 1) / i;
            }
            return result;
        }
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 51984
import math

N = input()
A = map(int, raw_input().split())
c=0
for i in range(0,N):
  minj = i
  for j in range(i,N):
    if A[j] < A[minj]:
      minj=j
  A[i],A[minj]=A[minj],A[i]
  if minj!=i:
    c+=1

print ' '.join(map(str, A))
print c


Measured memory_bytes: 4716
#include <iostream>
#include <vector>

using namespace std;

void solve()
{
	int N;
	while(cin >> N, N)
	{
		vector<int> Vec(N);
		for(int i = 0; i < N; ++i)
		{
			cin >> Vec[i];
		}
		int Max = -999999999;
		for(int i = 0; i < N; ++i)
		{
			int sum = 0;
			for(int j = i; j < N; ++j)
			{
				sum += Vec[j];
				if(sum > Max)
				{
					Max = sum;
				}
			}
		}
		cout << Max << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
	int a[5];
	int i,s=0,m=0;
	for(i=0;i<3;i++)
	scanf("%d" ,&a[i]);
	for(i=0;i<3;i++)
	{
		if(a[i]==5) s++;
		if(a[i]==7) m++;
	}
	 if(s==2&&m==1)
	 printf("YES");
	 else printf("NO");//
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//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) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    if((a < c && c < b) || (b < c && c < a)) PUTS("Yes")
    else PUTS("No")
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))

#A.sort()
ans = 10**5
a = 0

b = sum(A)
ansind = -1
for i in range(n):
    a += A[i]
    b -= A[i]
    ab = abs(a-b)
    if ans > ab :
        ans = ab
        ansind = i
        #print(a)

print(ans)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 7;
bool isPrime(int x){
    if(x==1) return false;
    for(int i = 2; i <= sqrt(x); i++){
        if(x%i==0) return false;
    }
    return true;
}
int main(){
    int x;
    cin >> x;
    for(int i = x; i < 1e8; i++){
        if(isPrime(i)){
            cout << i;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int n;
    long x;
    scan(n, x);

    auto a = new long[](n + 1); // 長さ
    auto b = new long[](n + 1); // Pの枚数

    a[0] = b[0] = 1;

    foreach (i ; 1 .. n + 1) {
        a[i] = 2L*a[i-1] + 3;
        b[i] = 2L*b[i-1] + 1;
    }

    long query(int L, long x) {
        if (L == 0) {
            return x == 1;
        }
        if (x <= 1) {
            return 0;
        }
        else if (x < (a[L] + 1) / 2) {
            return query(L-1, x - 1);
        }
        else if (x == (a[L] + 1) / 2) {
            return b[L-1] + 1;
        }
        else if (x < a[L] - 1) {
            return b[L-1] + 1 + query(L-1, x - (a[L] + 1) / 2);
        }
        else {
            return 2*b[L-1] + 1;
        }
    }

    long ans = query(n, x);

    writeln(ans);

}


















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
ll mo=1000000007;
int main() 
{ 
	ll t1=1;
	//cin>>t1;
	while(t1)
	{
		ll n;
		cin>>n;	
		ll arr[n];
		for(ll i=0;i<n;i++)cin>>arr[i];
		sort(arr,arr+n);
	    if(arr[0]==0)cout<<"0"<<endl;
		else
		{
		ll ans=1;
	    bool st=true;
		for(ll i=0;i<n;i++)
		{
			//cout<<ans*arr[i]<<endl;
			if(arr[i]>1000000000000000000/ans)
			{
				cout<<-1<<endl;
				st=false;
				break;
			}
			ans = ans*arr[i];
		}
		if(st==true)cout<<ans<<endl;
	    }
		t1--;
    }
    return 0; 
}

Measured memory_bytes: 4364
x, n = map(int, input().split(" "))
p = input()
if p == "":
    print(x)
    exit(0)
p = list(map(int, p.split(" ")))
answer = 0
for i in range(1, 102):
    if i not in p:
        if abs(x - answer) > abs(i - x):
            answer = i
print(answer)

Measured memory_bytes: 61748
using System.Collections.Generic;
using static System.Console;

class Program {
	static void Main() {
		var W = NextInt();
		var a = NextInt();
		var b = NextInt();

		if (b > a + W) {
			WriteLine(b - a - W);
		} else if (a > b + W) {
			WriteLine(a - b - W);
		} else {
			WriteLine(0);
		}
	}

	static int NextInt() {
		return int.Parse(NextString());
	}

	static string NextString() {
		var result = new List<char>();
		while (true) {
			int next = Read();
			if (next < 0)
				break;
			var nextChar = (char)next;
			if (!char.IsWhiteSpace(nextChar))
				result.Add(nextChar);
			else if (nextChar != '\r')
				break;
		}
		return string.Join("", result);
	}
}


Measured memory_bytes: 13268
import sys
input = sys.stdin.readline
import time
import numpy as np

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

Sunuke = np.zeros(n)

for i in range(k):
    d = int(input())
    Okashi = np.zeros(n)
    for a in input().split():
        Okashi[int(a)-1] += 1
    Sunuke += Okashi


ans = n - np.count_nonzero(Sunuke)
print(ans)


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

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


    for (size_t i = 0; i < S.size(); i++)
    {
        S.at(i) = (S.at(i) - 'A' + N) % 26 + 'A';
    }

    cout << S;
    
}

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

int main() {
    int n;
    cin >> n;
    
    string t, h;
    int taro = 0, hanako = 0;
    for (int i = 0; i < n; i++) {
        cin >> t >> h;
        if (t == h) {
            taro++;
            hanako++;
            continue;
        }

        if (t > h) {
            taro += 3;
        } else {
            hanako += 3;
        }
    }
    cout << taro << " " << hanako << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;


#define INF 1e+9



int main(){

  int n,m;
  cin >> n >> m;
  vector<int> c(m+1,0);
  for(int i=1; i<=m; i++)
    cin >> c[i];


 
  vvi dp(m+2,vi(n+1,INF));  // dp[i][j]: i???????????????????????§??§???j??????????????????????????????????°??????°
  dp[0][0] = 0;
  for(int i=0; i<=m; i++){
		for(int j=0; j<=n; j++){
			  // dp[i][j] ????????????
			  dp[i+1][j] = min(dp[i][j], dp[i+1][j]); // i?????????????????????????????????
			  if(j+c[i] > n) continue;
			  dp[i][j+c[i]] = min(dp[i][j]+1,dp[i][j+c[i]]); //i???????????????????????´????????????
			  dp[i+1][j+c[i]] = min(dp[i][j]+1,dp[i+1][j+c[i]]); //i???????????????????????´????????????
		}
  }
  cout << dp[m][n] << endl;
  

  

}

Measured memory_bytes: 5492
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int a[26] = {};
	string s;
	cin >> s;
	REP(i,s.size()){
		a[s[i] - 'a']++;
	}
	REP(i,26){
		if(a[i] & 1){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int R;

int main(){
    scanf("%d", &R);
    if (R< 1200) {
        printf("%s\n", "ABC");
    } else if (R < 2800) {
        printf("%s\n", "ARC");
    } else {
        printf("%s\n", "AGC");
    }
    return 0;
}


Measured memory_bytes: 256
# B-Checkpoints
# 問題URL:http://abc057.contest.atcoder.jp/tasks/abc057_b

N, M = map(int, input().split()) #まずNとMを取得
ABs = [] # 学生のいる座標
CDs = [] #　チェックポイントの座標

# 2行目よりN行分学生の座標を取得してABsに格納
for i in range(N):
    ABs.append([int(x) for x in input().split()])

# 2+N行目よりM行分チェックポイントの座標を取得してCDsに格納
for i in range(M):
    CDs.append([int(x) for x in input().split()])

for a,b in ABs:
    #ABsの中身をa,b、CDsの中身をc,dとして取り出し各チェックポイントごとの距離を測定
    distance = [abs(a-c) + abs(b-d) for c,d in CDs]
    
    #　距離が同じ場合は最も番号が早いものを出力する。=(min()はもともとそのようにできている。早いもの優先）
    #+1はリストは0番目から、チェックポイントは1番目から始まるため
    print(distance.index(min(distance)) + 1)

Measured memory_bytes: 3064
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>();
		for(int i=0; i<n; i++){
			p[i] = sc.nextInt();
			hm.put(p[i], i);
		}
		sc.close();
		
		int[] a = new int[n];
		int[] b = new int[n];
		
		for(int i=0; i<n; i++){
			a[i] = 20000 * i + hm.get(i+1) + 1;
			b[i] = 20000 * (n-i) + 1;
		}
		
		StringBuilder sba = new StringBuilder();
		StringBuilder sbb = new StringBuilder();
		
		for(int i=0; i<n; i++){
			sba.append(a[i] + " ");
			sbb.append(b[i] + " ");
		}
		System.out.println(sba.toString());
		System.out.println(sbb.toString());

	}

}

Measured memory_bytes: 32076
#include <bits/stdc++.h>
using namespace std;
const int MAX = 3e5 + 5;
int N, wsum[MAX], esum[MAX];
char S[MAX];

int main(){
	scanf("%d", &N);
	scanf("%s", S + 1);
	for(int i = 1; i <= N; i++){
		if(S[i] == 'W')	wsum[i]++;
		else esum[i]++;
		wsum[i] += wsum[i - 1];
		esum[i] += esum[i - 1];
	}
	int ans = 1e9;
	for(int i = 1; i <= N; i++){
		int le = wsum[i - 1];
		int ri = esum[N] - esum[i];
		ans = min(ans, le + ri);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)n; i++)
int main() {
  const int MAX_NM=50;
  int n,m,a[MAX_NM],b[MAX_NM]; cin>>n>>m;
  rep(i,m){
    cin>>a[i]>>b[i];
    a[i]--; b[i]--;
  }
  rep(i,n){
    int c=0;
    rep(j,m) if(a[j]==i||b[j]==i) c++;
    cout<<c<<endl;;
  }
}

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N;
double T, A;

int main() {
    cin >> N >> T >> A;
    double ans = 0, tmp = LINF;
    REP(i, N) {
        double H;
        cin >> H;
        if(tmp > abs(T - H * 0.006 - A)) {
            tmp = abs(T - H * 0.006 - A);
            ans = i + 1;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
n = int(input())
ws = [str(input()) for i in range(n)]
before_w=""
ok = True
ends=[]
for i, w in enumerate(ws):
    if i == 0:
        before_w = w
        ends.append(w)
        continue
    if w[0] == before_w[-1]:
        before_w = w
        if(w in ends):
            ok=False
            break
        ends.append(w)

        continue
    else:
        ok = False
        break

if ok:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    int time=0,temp=a;
    if(a<0){
        for(temp=a;temp<0;temp++){
            time += c;
        }
        temp=0;
        time+=d;
    }
    for(; temp <b; temp++){
        time+=e;
    }
    cout << time <<endl;
}


Measured memory_bytes: 3056
def main() -> None:
    X1, Y1, X2, Y2 = map(int, input().split())
    X3, Y3 = X2-(Y2-Y1), Y2+(X2-X1)
    X4, Y4 = X3-(X2-X1), Y3-(Y2-Y1)
    print(str(X3) + " " + str(Y3) + " " + str(X4) + " " + str(Y4))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	int H, W;
	while (1){
		cin >> H >> W;
		if (H == 0 & W == 0)break;
		for (int i = 0; i < H; i++){
			for (int i = 0; i < W; i++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
		return 0;
}

Measured memory_bytes: 3080
/*
ID: tohoast1
TASK: transform
LANG: C++
*/
#include <bits/stdc++.h>
#include <bitset>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define speedup ios_base::sync_with_stdio(NULL)
#define fin freopen("transform.in", "r", stdin)
#define fout freopen("transform.out", "w", stdout)
#define FILENAME
#define PUBG push_back
#define p_b pop_back
#define mp make_pair
#define fi first
#define se second
#define cls clear
#define INF const int ci = 1e6 + 100
#define K_INF 1e9 + 7
#define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

using namespace std;
typedef long long LL;
typedef long L;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef string STR;
STR a, b, ans;
int N;

int main() {
    speedup;
    #ifdef FILENAMEs
        fin;
        fout;
    #endif // FILENAME
    cin.tie(0); cout.tie(0);
    cin >> N >> a >> b;
    for (int i = 0 ; i < N ; ++ i) {
        ans += a[i];
        ans += b[i];
    }
    cout << ans;
    ///time;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool ispal(string s,int l,int h)
{
	
	while(l<h)
	{
		if(s[l]!=s[h])return false;
		l++;h--;
	}
	return true;
}
int main() {
	string s;
	cin>>s;
	int n=s.length();
	int x=(n-1)/2;
	int y=(n+3)/2;
	if(ispal(s,0,n-1) && ispal(s,0,x-1) && ispal(s,y-1,n-1))
		cout<<"Yes\n";
	else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
int main ()
{
int A,B,C,D;
scanf("%d %d %d %d",&A,&B,&C,&D);
if (A*B>C*D)
cout<<A*B;
else if (C*D>A*B)
cout<<C*D;
else 
cout<<A*B;


}

Measured memory_bytes: 256
unittest
{
	assert( [ "3 1 1", "1 2 1", "2 1 2", "3 3 10" ].parse.expand.solve == 3 );
	assert( [ "1 1 10", "10 10 10" ].parse.expand.solve == -1 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nmm = input.front.split.to!( long[] );
	auto abcs = new long[ 3 ][ nmm[ 0 ] ];
	foreach( ref abc; abcs )
	{
		input.popFront;
		abc = input.front.split.to!( long[] );
	}
	return tuple( nmm[ 1 ], nmm[ 2 ], abcs );
}

auto solve( long ma, long mb, long[ 3 ][] abcs )
{
	// dp[ 物質Aの含有量 ][ 物質Bの含有量 ] = 混合物の最小コスト
	auto dp = new long[][]( 1 + abcs.length * 3, 1 + abcs.length * 3 );
	foreach( ref x; dp ) x[] = long.max;
	dp[ 0 ][ 0 ] = 0L;
	foreach( i, abc; abcs )
	{
		// 同じ薬品を何個も混ぜないように逆順に更新する
		for( auto a = dp.length.signed - 1; abc[ 0 ] <= a; a-- )
		{
			for( auto b = dp[ a ].length.signed - 1; abc[ 1 ] <= b; b-- )
			{
				if( dp[ a - abc[ 0 ] ][ b - abc[ 1 ] ] == long.max ) continue;
				dp[ a ][ b ] = min( dp[ a ][ b ], dp[ a - abc[ 0 ] ][ b - abc[ 1 ] ] + abc[ 2 ] );
			}
		}
	}
	
	// 混合比が条件を満たしているもののうち、最小コストを検索
	auto ans = long.max;
	for( auto a = ma, b = mb; a < dp.length && b < dp[ a ].length; a += ma, b += mb )
	{
		ans = min( ans, dp[ a ][ b ] );
	}
	if( ans == long.max ) return -1;
	else                  return ans;
}


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
#define M 100005
struct D{
	int x,y;
	bool operator<(D a)const{return y==a.y?x<a.x:y>a.y;}
}A[M];
int n,m,F[M];
int gf(int x){return x==F[x]?x:F[x]=gf(F[x]);}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;++i)scanf("%d%d",&A[i].x,&A[i].y);
	for(int i=1;i<=m;++i)F[i]=i;
	sort(A+1,A+n+1);
	long long ans=0;
	for(int i=1;i<=n;++i){
		int p=m-A[i].x+1;
		if(p<=0)continue;
		int fa=gf(p);
		if(fa)ans+=A[i].y,F[fa]=fa-1;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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 / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}


//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

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








Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=55;
const int mod=1e9+7;
int n,m,q;
int a[maxn],b[maxn],c[maxn],d[maxn];
int A[maxn];
int ans=-1;
void dfs(int now,int num)
{
    if(num==n+1)
    {
        int sum=0;
        for(int i=1;i<=q;i++)
        {
            if(A[b[i]]-A[a[i]]==c[i])
                sum+=d[i];
        }
        ans=max(ans,sum);
        return;
    }
    for(int i=now;i<=m;i++)
    {
        A[num]=now;
        dfs(i,num+1);
    }
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
    cin>>n>>m>>q;
    for(int i=1;i<=q;i++)
    {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    dfs(1,1);
    cout<<ans<<'\n';





}

Measured memory_bytes: 3620
e=input
a=[]
for _ in[0]*int(e()):
 X,z=e(),[]
 for y in e():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 a+=[len(z)]
print(*a,sep='\n')


Measured memory_bytes: 5624
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	static int n;
	static int m;
	static int q;
	static int a[];
	static int b[];
	static int c[];
	static int d[];
	static int ans;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		n = sc.nextInt();
		m = sc.nextInt();
		q = sc.nextInt();

		a = new int[q];
		b = new int[q];
		c = new int[q];
		d = new int[q];

		for (int i=0; i<q; i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}

		ans = 0;

		LinkedList<Integer> def = new LinkedList<Integer>();
		def.add(1);
		dfs(def);

		System.out.println(ans);
	}

	public static void dfs(LinkedList<Integer> A){
		if (A.size() == n+1){
			int score = 0;

			for (int i=0; i<q; i++){
				if (A.get(b[i]) - A.get(a[i]) == c[i]){
					score += d[i];
				}
			}

			ans= Math.max(score, ans);
			return;
		}

		A.add(A.getLast());
		while (A.getLast() <= m){
			dfs((LinkedList<Integer>)A.clone());
			A.set(A.size()-1, A.getLast()+1);
		}
	}
}

Measured memory_bytes: 57368
#include<iostream>
using namespace std;
int main()
{
	long long sum=0,n,a,b;
	cin>>n>>a>>b;
	if(n>1&&b>=a||n==1&&a==b)
        cout<<(n-2)*(b-a)+1<<endl;
    else
        cout<<0<<endl; 
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int h,w;
string s[30];

int f(int si,int sj){
    int dis[h][w];
    rep(i,h){
        rep(j,w){
            dis[i][j]=INF;
        }
    }
    dis[si][sj]=0;
    queue<pair<int,int>> q;
    q.push(make_pair(si,sj));
    while(!q.empty()){
        auto now=q.front();q.pop();
        rep(i,4){
            int ni=now.first+dx[i],nj=now.second+dy[i];
            if(0<=ni and ni<h and 0<=nj and nj<w and s[ni][nj]!='#' and dis[ni][nj]>=INF){
                q.push(make_pair(ni,nj));
                dis[ni][nj]=dis[now.first][now.second]+1;
            }
        }
    }

    int ret=0;
    rep(i,h){
        rep(j,w){
            if(s[i][j]!='#')
            chmax(ret,dis[i][j]);
        }
    }
    return ret;
}

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

    cin>>h>>w;
    rep(i,h)cin>>s[i];
    int ans=0;
    rep(i,h){
        rep(j,w){
            if(s[i][j]!='#'){
                chmax(ans,f(i,j));
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::min;

fn main() {
    let n: usize = read();
    let c: usize = read();
    let mut transform: Vec<Vec<i64>> = vec![vec![0; c]; c];

    for i in 0..c {
        for j in 0..c {
            transform[i][j] = read();
        }
    }

    let mut map: Vec<Vec<i64>> = vec![vec![0; n]; n];
    for i in 0..n {
        for j in 0..n {
            map[i][j] = read();
        }
    }
    // for k in 0..c {
    //     for i in 0..c {
    //         for j in 0..c {
    //             transform[i][j] = min(transform[i][j], transform[i][k] + transform[k][j]);
    //         }
    //     }
    // }

    let mut memo: Vec<Vec<i64>> = vec![vec![0; 3]; c];

    for i in 0..n {
        for j in 0..n {
            for k in 0..c {
                let oc = map[i][j];
                let ncc = transform[oc as usize - 1][k];
                memo[k][(i + j) % 3] += ncc;
            }
        }
    }
    // for i in 0..c {
    //     println!("{:?}", memo[i]);
    // }

    let mut minv = std::i64::MAX;
    for i in 0..c {
        for j in 0..c {
            for k in 0..c {
                if i == j || j == k || k == i {
                    continue;
                }
                minv = min(minv, memo[i][0] + memo[j][1] + memo[k][2]);
                minv = min(minv, memo[i][0] + memo[j][2] + memo[k][1]);
                minv = min(minv, memo[i][1] + memo[j][2] + memo[k][0]);
                minv = min(minv, memo[i][1] + memo[j][0] + memo[k][2]);
                minv = min(minv, memo[i][2] + memo[j][1] + memo[k][0]);
                minv = min(minv, memo[i][2] + memo[j][0] + memo[k][1]);
            }
        }
    }
    println!("{}", minv);
}


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


int main()
{
	int a;
	cin>>a;
	if(a<3200)
	{
		cout<<"red"<<endl;
	}
	else
	{
		string s;
		cin>>s;
		cout<<s<<endl;
	}
	return 0;
}


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

using namespace std;

int main(){
	string str; cin >> str;
	int mid = (int)str.length() / 2;
	int ans = 0;
	for(int i=0; i<mid; i++) if(str[i] != str[(int)str.length()-i-1]) ans++;
	cout << ans << endl;
	return 0;
}

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

int
main(int argc, char *argv[])
{
  char s[27];
  scanf("%s", s);
  
  int n = strlen(s);
  int flag = 0;
  
  for(int i = 1; i < n; i++){
    for(int j = 0; j < i; j++){
      if(s[i] == s[j]){
        flag++;
        break;
      }
    }
    if(flag > 0){
      break;
    }
  }
  
  if(flag > 0){
    printf("no\n");
  }
  else{
    printf("yes\n");
  }
  
  return 0;
}
  

Measured memory_bytes: 128