akhauriyash/Code-Regression huggingface dataset:
#if 0

#endif

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

int Q;
int L[1000+10][1000+10];

int main() {
  cin >> Q;
  string X, Y;
  for (int i = 0; i < Q; i++) {
    for (int j = 0; j < 1000+10; j++) {
      L[0][j] = 0; L[j][0] = 0;
    }
    cin >> X >> Y;
    for (int x = 1; x <= X.length(); x++) {
      for (int y = 1; y <= Y.length(); y++) {
        if (X[x-1] == Y[y-1])
          L[x][y] = L[x-1][y-1]+1;
        else
          L[x][y] = max(L[x-1][y], L[x][y-1]);
      }
    }

    cout << L[X.length()][Y.length()] << endl;
  }
}



Measured memory_bytes: 7160
n,k=[int(i) for i in input().split()]    
m=n+2-k
a=-m*(m+1)*(2*m+1)//6
b=(n-2*k+3)*m*(m+1)//2
c=m*(-k**2+3*k+n*k-n-1)
mod=10**9+7

a=a%mod
b=b%mod
c=c%mod

ans=a+b+c

print(ans%mod)

Measured memory_bytes: 9156
#include <stdio.h>

int main() {
  int A, B;
  scanf("%d %d%*c", &A, &B);
  if (A == B)
    printf("Draw\n");
  else if (A == 1)
    printf("Alice\n");
  else if (B == 1)
    printf("Bob\n");
  else if (A > B)
    printf("Alice\n");
  else
    printf("Bob\n");
  return 0;
}



Measured memory_bytes: 128
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
    
using namespace std;

typedef long long ll;


int main() {
    string s;
    cin >> s;
    string k = "keyence";
    
    int i = 0, j = 0;
    while(s[i] == k[j]) {
        i++;
        j++;
        if (j == 7) {
            cout << "YES" << endl;
            return 0;
        }
    }
    while(s[s.size() - (7-i)] == k[j]) {
        i++;
        j++;
        if (i == 7) {
            cout << "YES" << endl;
            return 0;
        }
    }
    
    
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    vector<int> v;
    int num, tmp;
    cin >> num;
    for(int i=0; i<num; i++){
        cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    decltype(v)::iterator result = std::unique(v.begin(), v.end());
    if(result != v.end()){ cout << "NO";}
    else{cout << "YES";}
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(int argc, char const *argv[])
{
	string s; cin >> s;
	int n = s.size();
	int ans0 = 0, ans1 = 0;
	rep(i, n) {
		if (i % 2 == 0 && s[i] == '1') ans0++;
		if (i % 2 == 1 && s[i] == '0') ans0++;
		if (i % 2 == 0 && s[i] == '0') ans1++;
		if (i % 2 == 1 && s[i] == '1') ans1++;
	}
	printf("%d\n", min(ans0, ans1));
	return 0;
}

Measured memory_bytes: 512
s = str(input())
ans = [0 for _ in range(len(s)+1)]
for i in range(len(s)):
    if(s[i] == '<'):
        ans[i+1] = ans[i]+1
for i in range(len(s),0,-1):
    if(s[i-1] == '>'):
        ans[i-1] = max(ans[i-1],ans[i]+1)
print(sum(ans))

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

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

int main(){
  int k, ans = 0;

  cin >> k;

  for(int a = 1; a < k + 1; a++){
    for(int b = 1; b < k + 1; b++){
      for(int c = 1; c < k + 1; c++){
        ans = ans + gcd(gcd(a, b), c);
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

def main():
    a,b,c=mis()
    if 2 < c-b-a:
        print(Yes if 4*a*b < (c-b-a)**2 else No)
    else:
        print(No)




main()







Measured memory_bytes: 5164
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include <cstdio>
using namespace std;

long long m, n, x, y;
long long f[12] = { 0,9,18,108,198,1098,1998,10998,19998,109998,199998,1099998 };    //预处理从1到10^i-1之间共有f[i]个回文数

long long find(long long x)
{
	if (x == 0) return 0;	
	if (x<10) return x;		
	long long w, i, ans, t, na, a, b, nx;
	w = 0;
	nx = x;
	while (nx)			
	{
		w++;
		nx /= 10;
	}
	ans = f[w - 1];			
	t = 1;
	for (int k = 1;k <= (w / 2);k++) t *= 10;
	if (w % 2 == 0)     
	{
		a = (x / t);
		b = (x%t);
		t = t / 10;
		ans = ans + (a - t);
		na = 0;
		while (a)
		{
			na = na * 10 + a % 10;
			a /= 10;
		}
	}
	else           
	{
		a = (x / t);
		t *= 10;
		b = (x%t);
		t = t / 10;
		ans = ans + (a - t);
		na = 0;
		while (a)
		{
			na = na * 10 + a % 10;
			a /= 10;
		}
	}
	if (b >= na) ans++;
	return ans;

}

int main()
{
	int m, n;
	scanf("%d%d", &m, &n);
	m = m - 1;
	x = find(m);
	y = find(n);
	printf("%d", y - x);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int NIL = -1;

struct Node {
    int parent, left, right;
};

int n;
int D[50], H[50];
Node nodes[50];

int getSibling(int id, Node node) {
    if (node.parent == -1) return NIL;
    Node parent = nodes[node.parent];
    int left = parent.left; 
    int right = parent.right;
    return left == id ? right : left;
}

int getDegree(Node node) {
    int c = 0;
    if(node.right != -1) c++;
    if(node.left != -1) c++;
    return c;
}

void getDepth(int i, int depth) {
    D[i] = depth;
    if (nodes[i].left != NIL) getDepth(nodes[i].left, depth+ 1);
    if (nodes[i].right != NIL) getDepth(nodes[i].right, depth+ 1);
}

int getHeight(int i) {
    int h1 = 0, h2 = 0;
    if (nodes[i].left != NIL) h1 = getHeight(nodes[i].left) + 1;
    if (nodes[i].right != NIL) h2 = getHeight(nodes[i].right) + 1;
    return H[i] = (h1 > h2 ? h1 : h2);
}


void printNode(int id, Node node) {
    cout << "node " << id << ": ";
    cout << "parent = " << node.parent << ", ";
    cout << "sibling = " << getSibling(id, node) << ", ";
    int deg = getDegree(node);
    cout << "degree = " << deg << ", ";

    cout << "depth = " << D[id] << ", ";
    cout << "height = " << H[id] << ", ";
    if (node.parent == -1) cout << "root";
    else if (deg > 0) cout << "internal node";
    else cout << "leaf";
    cout << endl;
}

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        nodes[i].parent = nodes[i].left = nodes[i].right = NIL;
    }
    for(int i = 0; i < n; i++) {
        int num, left, right;
        cin >> num >> left >> right;
        nodes[num].left  = left;
        nodes[num].right = right;
        nodes[left].parent = num;
        nodes[right].parent = num;
    }
    int j = 0;
    while (nodes[j].parent != NIL) {
        j++;
    }
    getDepth(j, 0);
    getHeight(j);
    for(int i = 0;i < n; i++) {
        printNode(i, nodes[i]);
    }

    return 0;
}



Measured memory_bytes: 3096
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long a = long.Parse(input[0]);
		long b = long.Parse(input[1]);
    long c = long.Parse(input[2]);
		long answer = b + Math.Min(c, a+b+1);

		Console.WriteLine(answer);
	}
}

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

int n,now;
int a[200010];
long long ans;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	ans=a[n];
	now=3;
	for(int i=n-1;i;i--)
	{
		if(now>n) break;
		ans+=a[i];
		now++;
		if(now>n) break;
		ans+=a[i];
		now++;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {

  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  
  int ans=1,x=a.at(0);
  bool judge=true;
  while(x!=2){
    if(ans==N){
      judge=false;
      break;
    }
      
    x=a.at(x-1);
    ans++;
  }
  
  if(judge){
    cout << ans << endl;
  }
  else{
    cout << "-1" << endl;
  }
  
}

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

#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

int main(void) {
	int   N, T;
	int   c[100], t[100], i, min = 1001;
	i_cin2(N, T);
	for (i = 0; i < N; i++) {
		i_cin2(c[i], t[i]);
		if (t[i] <= T && c[i] < min) min = c[i];
	}
	if (min == 1001) {
		s_cout("TLE"); return 0;
    }
	i_cout(min);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<set>
#include <algorithm>
#define ll long long 
#include <string.h>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
using namespace std;
ll int f[1000007]={0};
int main()
{
	ll int n;
	cin>>n;
	ll int a[n],i,j;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		f[a[i]]++;
	}
	ll int ans=0;
	sort(a,a+n);
	
		
		for(i=0;i<n;i++)
		{
			f[a[i]]--;
			
			ll int fl=0;
			for(j=1;j*j<=a[i];j++)
			{
				if (a[i]%j==0)
				{
					if (f[j]>=1 || f[a[i]/j]>=1)
					{
						fl=1;
						break;
						
					}
				}
			}
			if (fl!=1)
			ans++;
			f[a[i]]++;
			
			
		}
		cout<<ans<<endl;
		

}
    
	
		

	
			

		


 







Measured memory_bytes: 12812
// C - March
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define out(x) cout << x << '\n'
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
//---------------------------------------------------------------------------------------------------
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
//---------------------------------------------------------------------------------------------------

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

lli solve()
{
  lli a = 0, b = 0, c = 0, h = 0, n = 0, w = 0, ans = 0, count = 0;
  string s = "", t = "";
  vector<pair<lli, lli>> pr;
  map<lli, lli> mp;
  set<lli> st;
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  vs d;
  map<char, lli> e;
  rep(i, 0, n)
  {
    cin >> s;
    if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H')
    {
      e[s[0]]++;
      count++;
    }
  }
  b = e.size();
  for (auto x : e)
  {
    char Z = x.first;
    for (auto y : e)
    {
      char ZZ = y.first;
      for (auto z : e)
      {
        if (x.first != y.first && y.first != z.first && x.first != z.first)
        {
          if (z.first > ZZ && ZZ > Z)
          {
            ans += x.second * y.second * z.second;
            // cout << x.first << " " << y.first << " " << z.first << endl;
          }
        }
      }
    }
  }
  if (b >= 3)
  {
    return ans;
  }
  else
  {
    return 0;
  }
}

//---------------------------------------------------------------------------------------------------
signed main()
{
  out(solve());
}

Measured memory_bytes: 3660
val = input().split(' ')
x = int(val[0])
y = int(val[1])
a = int(val[2])
b = int(val[3])
c = int(val[4])
 
p_list = sorted([int(a) for a in input().split(' ')])
q_list = sorted([int(a) for a in input().split(' ')])
r_list = sorted([int(a) for a in input().split(' ')])
p_list.reverse()
q_list.reverse()
r_list.reverse()
 
xapples = p_list[0:x]
yapples = q_list[0:y]
zapples = r_list[0:x+y]
 
xapples.extend(yapples)
xapples.extend(zapples)
tmp_apples = sorted(xapples)
tmp_apples.reverse()
apples = tmp_apples[0:x+y]
print(sum(apples))


Measured memory_bytes: 24972
Module _20190427

    Sub Main()

        Dim sRead As String = Console.ReadLine()

        Dim iMinutes As Decimal = CDec(sRead.Split(" ")(2)) + 0.5

        Dim iEndFlg As Integer = 0
        Dim iTotalCount As Integer = 0
        Dim iLoopCount As Integer = 1

        Do While iEndFlg = 0

            If iLoopCount * sRead.Split(" ")(0) > iMinutes Then

                iEndFlg = 1

            Else

                iTotalCount = iTotalCount + CInt(sRead.Split(" ")(1))

            End If

            iLoopCount = iLoopCount + 1

        Loop

        Console.WriteLine(iTotalCount)

    End Sub

End Module


Measured memory_bytes: 13268
#include <cstdio>
#include <queue>
using namespace std;

int a[100001];

struct Event {
    int time,num;
    Event(int t,int n) : time(t), num(n) {;}
};

bool operator<(const Event &e,const Event &f) {
    return e.time > f.time;
}

int main() {
    int n,l;
    scanf("%d%d", &n, &l);

    for(int i=0; i<n; ++i) scanf("%d", &a[i]);

    if(n == 1) {
        printf("%d\n", l-a[0]);
        return 0;
    }

    priority_queue<Event> q;
    if(a[0] > a[1])
        q.push(Event(l-a[0],0));

    for(int i=1; i<n-1; ++i) {
        if(a[i] > a[i-1] && a[i] > a[i+1])
            q.push(Event(l-a[i],i));
    }
    if(a[n-1] > a[n-2]) {
        q.push(Event(l-a[n-1],n-1));
    }

    int cnt = 0,ans = 0;

    while(!q.empty()) {
        Event e = q.top(); q.pop();
        if(a[e.num] == 0) continue;
        cnt++; a[e.num] = 0;
        if(cnt == n) ans = e.time;
        if(e.num-1 >= 0 && a[e.num-1] != 0) {
            if(e.num-1 == 0 || a[e.num-2] < a[e.num-1])
                q.push(Event(e.time+l-a[e.num-1],e.num-1));
        }
        if(e.num+1 < n && a[e.num+1] != 0) {
            if(e.num+1 == n-1 || a[e.num+2] < a[e.num+1])
                q.push(Event(e.time+l-a[e.num+1],e.num+1));
        }
    }

    printf("%d\n", ans);
}

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

int main(){
    int n,l,num;
    cin >> n;
    vector<int> v;
    rep(i,n){
        cin>>l;
      	v.push_back(l);
;    }
  vector<int> v2 =v;
  sort(v.begin(),v.end());

  for(int i=0;i<n;i++){
  if(v[i] != v2[i]) num++;
  }
  if(v2==v||num==2){
  cout<<"YES"<<endl;
  }else{
  cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
def solve():
    from sys import stdin, setrecursionlimit
    setrecursionlimit(4000)
    f_i = stdin
    
    def dfs(pos):
        area_map[pos] = '0'
        for mv in move:
            next_pos = pos + mv
            if area_map[next_pos] == '1':
                dfs(next_pos)
    
    while True:
        w, h = map(int, f_i.readline().split())
        if w == 0:
            break
        
        area_map = ['0'] * (w + 2)
        for i in range(h):
            area_map += ['0'] + f_i.readline().split() + ['0']
        area_map += ['0'] * (w + 2)
        
        move = (1, -1, w + 1, w + 2, w + 3, -w - 3, -w - 2, -w - 1)
        
        ans = 0
        for i in range((w + 2) * (h + 2)):
            if area_map[i] == '1':
                dfs(i)
                ans += 1
        
        print(ans)

solve()


Measured memory_bytes: 8544
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=1e5+10;
ll dp[MAX];
int main (){
    int N,W;cin >> N >> W;
    memset(dp,63,sizeof dp);
    dp[0]=0;
    for(int i=0;i<N;i++){
        int w,val;
        cin >> w >> val;
        for(int j=MAX;j>=0;j--){
            if(j-val>=0)
                dp[j]=min(dp[j],dp[j-val]+w);
        }

    }
    int res=0;
    for(int i=0;i<MAX;i++){
        if(dp[i]<=W) res = max(res,i);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll         long long int 
#define pb         push_back
#define umap       unordered_map
#define mod        1000000007
#define all(x)     (x).begin(), (x).end()
#define rall(x)    (x).rbegin(), (x).rend()
#define MN(a,b,c)  min(a,min(b,c))
#define MX(a,b,c)  max(a,max(b,c))
#define pr1         pair<ll,ll>
#define F          first
#define S          second
#define mP         make_pair
#define f(i,n)     for(int i=0;i<n;i++)
#define f1(i,x,y)  for(int i=x;i<=y;i++)
#define f2(i,x,y)  for(int i=x;i>=y;i--)
#define yes        cout<<"YES"<<"\n"
#define no         cout<<"NO"<<"\n"
#define modsum(a,b)  ((a%mod)+(b%mod))%mod
#define modpro(a,b)  ((a%mod)*(b%mod))%mod
//__builtin_popcount(x)
//__builtin_parity(x)   =(number of set bits)%2
//__builtin_clz(x)      to count the number of leading  zeroes 
//__builtin_ctz(x)      to count the number of trailing zeroes 
//__gcd(a,b)
using namespace std;
int main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
ll n,x,t;
cin>>n>>x>>t;
ll y=n/x;
if(n%x)y++;
cout<<y*t;
}
  

Measured memory_bytes: 3636
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
// #define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
  void solve()
  {
int n;
cin>>n;
vi v(n);
forn(i,n)cin>>v[i];
sort(all(v));
i64 ans=0;
forn(i,n)
{
  fore(j,i+1,n-1)
  {
    fore(k,j+1,n-1)
    {
      if(v[i]==v[j]||v[i]==v[k]||v[j]==v[k])continue;
      ans+=(v[i]+v[j]>v[k]);
    }
  }
}
cout<<ans;

  }
  
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
    #endif
int t=1;
while(t--)
{
  solve();
}

    return 0;
  }


Measured memory_bytes: 3608
import java.util.*;
 
public class Main {
	
	public static final int A = 0;
	public static final int B = 1;
	
    public static void main( String args[] ) {
        Scanner scan = new Scanner( System.in );
		
		double x1 = scan.nextDouble();
		double y1 = scan.nextDouble();
		double x2 = scan.nextDouble();
		double y2 = scan.nextDouble();
		
		double width = x2 - x1;
		double height = y2 - y1;
		
		double distance = Math.sqrt( ( width * width + height * height ) );
		System.out.println( distance );
		
	}
	
}

Measured memory_bytes: 18324
n, m = map(int,input().split())
store = [list(map(int,input().split())) for _ in range(n)]
store = sorted(store, key=lambda x: x[0])

i = 0
ans = 0
while True:
    if store[i][1] < m:
        ans += store[i][0]*store[i][1]
        m -= store[i][1]
        i += 1
    else:
        ans += m*store[i][0]
        break
print(ans)


Measured memory_bytes: 29788
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
void pre(){}
void solve(){
    ll x;cin>>x;
    ll a = 360;
    cout<<a/__gcd(x,a)<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m,x,y;
char f[55][55];
int rui[55][55];
int calc(int a,int b,int c,int d)
{
	return rui[b][d]-rui[a-1][d]-rui[b][c-1]+rui[a-1][c-1];
}
int dp[45][45][45][45];
int rec(int a,int b,int c,int d){
	if(dp[a][b][c][d] < 100000) 
		return dp[a][b][c][d];
	int &ret = dp[a][b][c][d];
	ret = min(calc(a,x,c,y),ret);
	ret = min(calc(a,x,y,d),ret);
	ret = min(calc(x,b,c,y),ret);
	ret = min(calc(x,b,y,d),ret);
	for(int X=x;X<=b;X++) 
	{
		for(int Y=y;Y<=d;Y++)
		{
		if(X==b && Y==d) 
			continue;
		ret = min(ret,calc(X+1,b,c,Y)+calc(a,X,Y+1,d)+rec(a,X,c,Y));
		}
	}
	
	for(int X=x;X<=b;X++) 
	{
		for(int Y=c;Y<=y;Y++)
		{
			if(X==b && Y==c) 
				continue;
			ret = min(ret,calc(X+1,b,Y,d)+calc(a,X,c,Y-1)+rec(a,X,Y,d));
		}
	}
	
	for(int X=a;X<=x;X++) 
	{
		for(int Y=y;Y<=d;Y++)
		{
			if(X==a && Y==d) 
				continue;
			ret = min(ret,calc(a,X-1,c,Y)+calc(X,b,Y+1,d)+rec(X,b,c,Y));
		}
	}
	
	for(int X=a;X<=x;X++) 
	{
		for(int Y=c;Y<=y;Y++)
		{
			if(X==a && Y==c) 
				continue;
			ret = min(ret,calc(a,X-1,Y,d)+calc(X,b,c,Y-1)+rec(X,b,Y,d));
		}
	}
	return ret;
}
int main()
{
//	freopen("haner.in","r",stdin);
//	freopen("haner.out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		string str; cin>>str;
		for(int j=1;j<=m;j++)
			f[i][j] = str[j-1];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(f[i][j] == 'P')
			{
				x = i;
				y = j;
			}
			rui[i][j] = (f[i][j]=='#'?1:0);
			rui[i][j] += rui[i-1][j];
			rui[i][j] += rui[i][j-1];
			rui[i][j] -= rui[i-1][j-1];
		}
	}
	rep(i,45)rep(j,45)rep(k,45)rep(l,45)dp[i][j][k][l] = INF;
	cout << rec(1,n,1,m) << endl;
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, a, b; cin >> n >> a >> b;
	Int m = n / (a+b);
	cout << m * a + min(a, n - m * (a+b)) << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){int a[4],b[4],sum1=0,sum2=0,i;for(i=0;i<4;i++){scanf("%d",&a[i]);
sum1+=a[i];}for(i=0;i<4;i++){scanf("%d",&b[i]);sum2+=b[i];}if(sum1>sum2){
printf("%d\n",sum1);}else{printf("%d\n",sum2);}return 0;}

Measured memory_bytes: 588
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
bool sortbysec(const pair<int,int> &a,
               const pair<int,int> &b)
{
    return (a.second < b.second);
}
int main()
{
    ll t=1,i,j,k=0,n,z,a,b,c,d,x,y,m,p,q,r;
    //cin>>t;
    while(t--)
    {
        cin>>n>>x>>y;
        a=n/x;
        if(n%x!=0)
        {
            a+=1;
        }
        cout<<a*y<<endl;
    }
    return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll a, b;
  cin >> a >> b;

  cout << a * b << endl;

  return 0;
}


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

typedef long long LL;

int main(){
    LL n,x;
    scanf("%lld %lld",&n,&x);
    LL a=max(n-x,x);
    LL b=min(n-x,x);
    LL ans=n;
    while(1){
        if(a%b==0){
            ans+=b*(2*(a/b)-1);
            break;
        }
        else{
            ans+=b*(2*(a/b));
            a=a%b; 
            swap(a,b);
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define tt ll t;cin >> t;while(t--)
#define int3(x,y,z) ll x,y,z;cin >> x >> y >> z;
#define int2(x,y) ll x,y;cin >> x >>y;
#define int1(x) ll x;cin>>x;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


bool cmp(pair<string,int>p1,pair<string,int>p2) {
    return p1.ss > p2.ss;
}

const int MAXN = 5 * 100000 + 10;


int32_t main() {
    fio
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    h=(h*60+m);
    double degh= (double)(360*h)/(60*12);
    double degm= (double)(360*m)/60;
    double angle= abs(degh-degm); // in deg
    angle= double(angle)*( (double)M_PI /180);
    int a2 = a*a;
    int b2 = b*b;
    double ans =(double) a2 + (double)b2 - (double)2 * a * b * cos(angle);
    
    cout<<fixed<<setprecision(10)<<sqrt(ans)<<endl;
    return 0;

}






Measured memory_bytes: 4220
#include<bits/stdc++.h>
using namespace std;
struct UnionFind{
  vector<int> r,p,ws;
  UnionFind(){}
  UnionFind(int size){init(size);}
  void init(int size){
    r.resize(size,0);
    p.resize(size,0);
    ws.resize(size,0);
    for(int i=0;i<size;i++) r[i]=1,p[i]=i;
  }
  int find(int x){
    if(x==p[x]){
      return x;
    }else{
      int t=find(p[x]);
      ws[x]+=ws[p[x]];
      return p[x]=t;
    }
  }
  int weight(int x){
    find(x);
    return ws[x];
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y,int w){
    w+=weight(x);
    w-=weight(y);
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y),w=-w;
    r[x]+=r[y];
    p[y]=x;
    ws[y]=w;
  }
  int diff(int x,int y){
    return weight(y)-weight(x);
  }
};
int main(){
  int n,m;
  while(cin>>n>>m,n||m){
    UnionFind u(n);
    for(int i=0;i<m;i++){
      int a,b;
      char c;
      cin>>c>>a>>b;
      a--;b--;
      if(c=='!'){
	int w;
	cin>>w;
	u.unite(a,b,w);
      }else{
	if(!u.same(a,b)) cout<<"UNKNOWN"<<endl;
	else cout<<u.diff(a,b)<<endl;
      }
    }
  }
  return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    string INF = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
    string ans = INF;

    for(int i=0;i + t.size() <= s.size();i++){
        bool can = true;
        for(int j=0;j<t.size();j++){
            can &= (s[i+j] == t[j] || s[i+j] == '?');
        }
        if(can){
            string res = s;
            for(int j=0; j < t.size();j++){
                    res[i+j] = t[j];
                }
            for(char& c : res){
                if(c == '?') c  = 'a';
            }
            ans = min(res,INF);
        }
    }
    if(ans==INF) cout<<"UNRESTORABLE\n";
    else cout<<ans<<endl;

}

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

using namespace std;


string sanitize(string s) {
    for(int i = 0 ; i < s.size() ; i++){
        char &c = s[i];
        if (c >= '0' && c <= '9') continue;
        c = ' ';
    }
    return s;
}

struct Edge {
    int cap;
    int flow;
    Edge(){
        cap = 0;
        flow = 0;
    }

    int residue() {
        return cap - flow;
    }
};

typedef map<int, Edge> Edges;

vector<Edges> g;


int S(){ return g.size()-1; }
int T(){ return g.size()-2; }

void process_np(string s) {
    stringstream ss(sanitize(s));
    int a, b;
    ss >> a >> b;
    g[S()][a].cap += b;
}

void process_nc(string s) {
    stringstream ss(sanitize(s));
    int a, b;
    ss >> a >> b;
    g[a][T()].cap += b;
}

void process_edge(string s) {
    stringstream ss(sanitize(s));
    int a, b, c;
    ss >> a >> b >> c;
    g[a][b].cap += c;
}

vector<int> dist;
vector<bool> visit;

#define INF 1e9


int dfs(int s, const int &t, int flow) {
    if (flow <= 0 || visit[s]) return 0;
    if (s == t) return flow;
    visit[s] = true;
    int ans = 0;
    for(Edges::iterator e = g[s].begin(); e != g[s].end(); ++e ){
        if (dist[e->first] != dist[s] + 1) continue;

        const int used = dfs(e->first, t, min(flow, e->second.residue()));
        if (used > 0) {
            g[s][e->first].flow += used;
            g[e->first][s].flow -= used;
            ans = used;
            break;
        }
    }
    visit[s] = false;
    return ans;

}

int max_flow(int s, int t) {
    int ans = 0;
    visit.resize(g.size());
    dist.resize(g.size());
    while (true) {
        bool update = false;
        fill(dist.begin(), dist.end(), INF);
        queue<int> Q;
        Q.push(s);
        dist[s] = 0;
        while (!Q.empty()) {
            int q = Q.front();
            Q.pop();
            for(map<int, Edge>::iterator e = g[q].begin(); e != g[q].end(); ++e ){
                if (e->second.residue() > 0 && dist[e->first] == INF) {
                    dist[e->first] = dist[q] + 1;
                    Q.push(e->first);
                }
            }
        }
        while (true) {
            fill(visit.begin(), visit.end(), false);
            int flow = dfs(s, t, INF);
            if (flow == 0) break;
            ans += flow;
            update = true;
        }
        if (!update) break;
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    g = vector<map<int, Edge> >(n);

    for (int i = 0; i < m; i++) {
        int a,b, c;
        cin >> a >> b >> c;
        g[a][b].cap += c;
    }
    cout << max_flow(0, n-1) << endl;

}




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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
// const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto &(i) : (vec))
/*
template <class T>
int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
*/
template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

short int i, j, working, next_short, n, m;
short int cost[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main(void){
  scanf("%hd%hd", &n, &m); short int A[m], DP[n + 8];
  for(i = 0; i < m; i++) cin >> A[i]; sort(A, A + m);
  DP[0] = 0; for(i = 1; i < n + 8; i++) DP[i] = -1;
  for(i = 0; i < n; i++) for(j = 0; j < m; j++) chmax<short int>(DP[i + cost[A[j]] ], DP[i] + 1);
  char res[DP[n]]; working = n;
  //for(i = 0; i < n; i++) cout << "DP[" << i << "] = " << DP[i] << "\n";
  for(i = 0; i < DP[n]; i++){
    for(j = 0; j < m; j++) if(working >= A[j]) if(DP[working] - DP[working - cost[A[j]]] == 1) next_short = A[j];
    //cout << j << " : " << next_short << ", working = " << working <<"\n";
    working -= cost[next_short];
    res[i] = '0' + next_short;
  }
  for(i = 0; i < DP[n]; i++) putchar(res[i]); putchar('\n');
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, long long x, std::vector<long long> a){
    if(N == 2){
        cout << max(a[0]+a[1]-x, 0LL) << endl;
        return;
    }
    ll cnt = 0;
    for(ll i=1; i< N-1; i++){
        ll tmp =  min(a[i], max(a[i-1]+a[i]-x, 0LL));
        cnt += tmp;
        a[i] -= tmp;
    }
    cnt += max(a[0]+a[1]-x, 0LL);
    cnt += max(a[N-2]+a[N-1]-x, 0LL);
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long x;
    scanf("%lld",&x);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, x, std::move(a));
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    ll n;

    cin >> n;

    vector<ll> a(n);
    deque<ll> b;

    ll i, len = n - 1;

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

    for (i = 1; i <= n; i++) {
        if (i % 2 != 0) b.push_back(a[i - 1]);
        else b.push_front(a[i - 1]);
    }

    if (n % 2 != 0) std::reverse(b.begin(), b.end());

    for (i = 0; i < len; i++) cout << b[i] << " ";
    cout << b[len] << endl;

    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int sum;
  cin >> sum;
  int counter = 0;
  for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
      for(int k=0; k<=c; k++){
        if(500 * i + 100 * j + 50 * k == sum){
          counter++;
        }
      }
    }
  }
  cout << counter;
  return 0;
}

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

int main() {
 int n; cin >> n;
 vector<int> a(n),b(n);
 int amax=-1;
  rep(i,n){
   cin >> a[i];
   b[i]=a[i];
    if(a[i]>amax){
     amax=a[i];
    }
  }
 sort(b.begin(),b.end());

  rep(i,n){
    if(a[i]!=amax)cout << amax << endl;
    else cout << b[n-2] << endl;
  }
}


Measured memory_bytes: 4836
C11C12C13=input()
C21C22C23=input()
if (C11C12C13[0]==C21C22C23[2] and C11C12C13[2]==C21C22C23[0] and C11C12C13[1]==C21C22C23[1]):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#include<iostream>
#include<cmath>
#include<set>
#include<vector>
#include<cassert>

using namespace std;

const double eps = 1e-11;

bool eq(double a, double b){
  return abs(b-a)<eps;
}

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

const double inf = 1e30;

int main()
{
  int p,n;
  while( cin >> p >> n ){
    if( p == 0 && n == 0 ) break;
    double rp = sqrt(p);

    double min_diff_lower = inf;
    double min_diff_upper = inf;
    int ans_lower_p, ans_lower_q, ans_upper_p, ans_upper_q;

    for(int i = 1; i <= n; ++i){
      int r = n;
      int l = 1;
      int cnt = 0;
      int m;
      while(cnt++<20){
        m = (r+l)/2;
        if( (double)m/i > rp ){
          r = m;
        }else{
          l = m;
        }
      }
      ++m;
      if( rp-(double)m/i < 0 ) --m;

      assert(rp-(double)m/i>0);
      if( min_diff_lower > rp-(double)m/i ){
        min_diff_lower = rp-(double)m/i;
        ans_lower_p = m;
        ans_lower_q = i;
      }
      
      for(int j = m+1; j <= n; ++j){
        if( (double)j/i > rp ){
          m = j;
          break;
        }
      }

      if( ((double)m/i-rp) > 0 && min_diff_upper > ((double)m/i-rp) ){
        min_diff_upper = (double)m/i - rp;
        ans_upper_p = m;
        ans_upper_q = i;
      }
    }

    int lower_gcd = gcd(ans_lower_p, ans_lower_q);
    int upper_gcd = gcd(ans_upper_p, ans_upper_q);
    ans_lower_p /= lower_gcd;
    ans_lower_q /= lower_gcd;

    ans_upper_p /= upper_gcd;
    ans_upper_q /= upper_gcd;


    cout << ans_upper_p<<"/"<<ans_upper_q<<" "<<ans_lower_p<<"/"<<ans_lower_q<<endl;
  }

  return 0;
}

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

int main(void) {
  ios::sync_with_stdio(false);
  int N, X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;

  // WF
  vector<vector<int>> G(N, vector<int>(N));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      int shortX = abs(X - i) + 1 + abs(j - Y);
      int shortY = abs(X - j) + 1 + abs(i - Y);
      G[i][j] = min(abs(j - i), min(shortX, shortY));
    }
  }

  vector<int> answer(N, 0);
  for (int i = 0; i < N; ++i) {
    for (int j = i; j < N; ++j) {
      answer[G[i][j]]++;
    }
  }
  for (int i = 1; i < N; ++i) cout << answer[i] << endl;
  return 0;
}


Measured memory_bytes: 16000
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;

char ch[50];

int main() {
    scanf("%s",ch+1);
    if(ch[1] == 'S') puts("Cloudy");
    if(ch[1] == 'C') puts("Rainy");
    if(ch[1] == 'R') puts("Sunny");
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int a[5];
int k;

int main()
{
  rep( i, 5 )
    scanf( "%d", a+i );
  scanf( "%d", &k );

  int ans = 0;
  rep( i, 5 ) repi( j, i+1, 5 )
    ans += abs(a[i]-a[j]) > k;

  puts( ans?":(":"Yay!" );

  return 0;
}

Measured memory_bytes: 128
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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


int main() {
	string s;
	cin >> s;
	string ans;
	int n = s.size();
	rep(i, n) ans.push_back('x');
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

string s;
ll ans;

void dfs(int i,ll now){
    if(i == s.size()){
        ans += now;
    }else{
        dfs(i+1,now*10+(s[i]-'0')); //追加なし
        dfs(i+1,0),ans += now*(1<<(s.size()-1-i)); //追加する
    }
}

int main()
{
    cin >> s;
    dfs(0,0);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int d, n;

	cin >> d >> n;

	if (d == 0) {
		if (n != 100) Out(n);
      	else Out(101);
	} else if (d == 1) {
		if (n != 100) Out(100 * n);
      	else Out(100 * n + 100);
	} else {
     	if (n != 100) Out(10000 * n);
      	else Out(10000 * n + 10000);
    }
	
	return 0;
}


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

        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int order = sc.nextInt();

        int cnt = 0, div = Math.min(num1, num2) + 1;
        while(cnt < order){
            div--;
            if(num1 % div == 0 && num2 % div == 0){
                cnt++;
            }
        }
        System.out.println(div);
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<climits>
#include<algorithm>
using namespace std;

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

	vector<int> route(R, 0);
	for(int i=0; i<R; i++)
	{
		int r;
		cin >> r;
		r--;

		route[i] = r;
	}
	sort(route.begin(), route.end());

	const int init = INT_MAX/2;
	vector<vector<int>> cost(N, vector<int>(N, init));
	for(int i=0; i<N; i++)
		cost[i][i] = 0;
	for(int i=0; i<M; i++)
	{
		int A, B, C;
		cin >> A >> B >> C;

		A--;
		B--;

		cost[A][B] = C;
		cost[B][A] = C;
	}

	for(int i=0; i<N; i++)
	{
		for(int j=0; j<N; j++)
		{
			for(int k=0; k<N; k++)
			{
				cost[j][k] = min(cost[j][k], cost[j][i]+cost[i][k]);
			}
		}
	}

	int ret = INT_MAX;
	do
	{
		int d = 0;
		for(int i=0; i<R-1; i++)
		{
			d += cost[route[i]][route[i+1]];
		}
		ret = min(ret, d);

	}while(next_permutation(route.begin(), route.end()));
	

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 384