akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i,n) cin >> A.at(i);
  sort(A.begin(),A.end());
  int ans = 1;
  if(n%2 ==0){
    int num = 1,i =0;
    while(i<n){
      if(A.at(i)==num && A.at(i+1)==num){
        i += 2;
        num += 2;
        ans *= 2; ans %= MOD;
      }
      else{
        ans = 0;
        break;
      }
    }
  }else{
    int num = 0,i=0;
    if(A.at(0)==num){
      num += 2;
      ++ i;
      while(i<n){
        if(A.at(i)==num && A.at(i+1)==num){
          i += 2;
          num += 2;
          ans *= 2; ans %= MOD;
        }
        else{
          ans = 0;
          break;
        }
      }
    }else{
      ans = 0;
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll n,k;cin>>n>>k;
    vector<ll> v(n);
    for(ll &i:v)cin>>i;
    map<ll,int> m;
    vector<int> temp;
    bool ok=1;int cur=0,curindex=1;
    while(ok){
        if(!m[cur]){m[cur]=curindex++;cur=v[cur]-1;}
        else {ok=0;}
    }
    if(k<m[cur]){
        int curi=0;
        cur=0;
        while(curi<k)cur=v[cur]-1,curi++;
        cout<<cur+1<<endl;return 0;
    }
    k-=m[cur]-1;
    m[cur]=-1;
    while(1){
        temp.push_back(cur);
        cur=v[cur]-1;
        if(m[cur]==-1)break;
    }
    //for(auto a:temp)cout<<a<<' ';cout<<endl;
    cout<<temp[(k)%temp.size()]+1;
    
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair

using namespace std;

using uint=unsigned int;
using ll=long long;

uint xor128(){
	static uint d[]={1145141919,1919810893,810893364,364114514};
	uint t=d[0]^(d[0]<<11);
	REP(i,3)
		d[i]=d[i+1];
	return d[3]=d[3]^(d[3]>>19)^(t^(t>>8));
}

struct Node{
	Node *l,*r;
	uint pri;
	int s,v,mn;
} buf[200000];

using NP=Node*;

NP newNode(int v){
	static int c=0;
	buf[c]=Node{NULL,NULL,xor128(),1,v,v};
	return &buf[c++];
}

const int inf=1145141919;

inline int Mini(NP x){
	return x?x->mn:inf;
}

inline int Size(NP x){
	return x?x->s:0;
}

inline NP Update(NP x){
	x->s=Size(x->l)+Size(x->r)+1;
	x->mn=min({x->v,Mini(x->l),Mini(x->r)});
	return x;
}

inline NP LinkL(NP x,NP l){
	x->l=l;
	return Update(x);
}

inline NP LinkR(NP x,NP r){
	x->r=r;
	return Update(x);
}

inline NP CutL(NP x){
	x->l=NULL;
	return Update(x);
}

inline NP CutR(NP x){
	x->r=NULL;
	return Update(x);
}

inline NP Merge(NP a,NP b){
	if(!a)
		return b;
	else if(!b)
		return a;
	else if(a->pri>b->pri)
		return LinkR(a,Merge(a->r,b));
	else
		return LinkL(b,Merge(a,b->l));
}

using Res=Node;

inline Res Split(NP x,int k){
	if(k<=0)
		return Res{NULL,x};
	else if(x->s<=k)
		return Res{x,NULL};
	else if(k<=Size(x->l)){
		Res s=Split(x->l,k);
		return Res{s.l,LinkL(x,s.r)};
	}else{
		Res s=Split(x->r,k-Size(x->l)-1);
		return Res{LinkR(x,s.l),s.r};
	}
}

inline void Set(NP x,int k,int v){
	int ls=Size(x->l);
	if(k<ls)
		Set(x->l,k,v);
	else if(k==ls)
		x->v=v;
	else
		Set(x->r,k-ls-1,v);
	Update(x);
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

NP t[200000];

int main(){
	int n=read(),q=read();
	REP(i,n)
		t[i]=newNode(read());
	while(n>1){
		int k=n/2;
		REP(i,k)
			t[i]=Merge(t[i*2],t[i*2+1]);
		if(k*2<n)
			t[k]=t[k*2];
		n=(n+1)/2;
	}
	NP root=t[0];
	REP(_,q){
		int x=read(),y=read(),z=read();
		if(x==0){
			Res s1=Split(root,y);
			Res s2=Split(s1.r,z+1-y-1);
			Res s3=Split(s2.r,1);
			root=Merge(Merge(s1.l,s3.l),Merge(s2.l,s3.r));
		}else if(x==1){
			Res s1=Split(root,y);
			Res s2=Split(s1.r,z+1-y);
			printf("%d\n",Mini(s2.l));
			root=Merge(s1.l,Merge(s2.l,s2.r));
		}else if(x==2){
			Set(root,y,z);
		}
	}
}

Measured memory_bytes: 11044
n = int(input())
a, xy = [], []
for i in range(n):
    a_ = int(input())
    xy_ = [list(map(int, input().split())) for i in range(a_)]
    a.append(a_)
    xy.append(xy_)
ans = 0
for bit in range(1 << n):
    OK = True
    cnt = 0
    for i in range(n):
        if (bit >> i) & 1:
            cnt += 1
            for j, k in xy[i]:
                if not (bit >> (j - 1) & 1) == k:
                    OK = False
                    break
    if OK:
        ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3064
import sys
import bisect

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]

    A.sort()
    B.sort()
    C.sort()
    B_ruiseki = [0]

    for i, b in enumerate(B):
        B_ruiseki.append(bisect.bisect_left(A, b) + B_ruiseki[i])

    ans = 0
    for i, c in enumerate(C):
        ans += B_ruiseki[bisect.bisect_left(B, c)]

    print(ans)




    

if __name__ == '__main__':
    main()



Measured memory_bytes: 23008
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
priority_queue<int,vector<int>,greater<int> > q;
int R,C,n,Max=-1;
struct node{
	int x,y,x1,y1,c1,c2;
}a[100010],b[200010];int cnt=0,num=0,sta[200010],top=0,N=0;
bool cmp(node a,node b) {return a.c1<b.c1;}
int qs(int x,int y)
{
	/*if(x==1) return y;
	if(y==C) return C+x-1;
	if(x==R) return R+C-1+C-y;
	return R+C+C-2+R-x;*/
	if(x==0) return 2*R+C+C-y;
    if(y==0) return x+y;
    if(x==R) return R+y;
    if(y==C) return R+C+R-x;
}
int main()
{
	scanf("%d %d %d",&R,&C,&n);//R++;C++;
	for(int i=1;i<=n;i++)
	{
		int x,y,x1,y1;scanf("%d %d %d %d",&x,&y,&x1,&y1);
		//x++;y++;x1++;y1++;
		bool k1=(x==0||x==R||y==0||y==C);
		bool k2=(x1==0||x1==R||y1==0||y1==C);
		if(k1&&k2)
		{
			a[++cnt].x=x,a[cnt].y=y,a[cnt].x1=x1,a[cnt].y1=y1;
			a[cnt].c1=qs(x,y);a[cnt].c2=qs(x1,y1);
		}
	}
	//for(int i=1;i<=cnt;i++) if(a[i].c1>a[i].c2) swap(a[i].c1,a[i].c2);
	for(int i=1;i<=cnt;i++) b[++N].c1=a[i].c1,b[N].c2=i,b[++N].c1=a[i].c2,b[N].c2=i;
	sort(b+1,b+N+1,cmp);//printf("ok\n");
	//for(int i=1;i<=N;i++) printf("%d %d\n",b[i].c1,b[i].c2);
	for(int i=1;i<=N;i++)
	{
		/*while(!q.empty()&&q.top()<=a[i].c1) q.pop();
		if(!q.empty())
		{
			int x=q.top();
			if(x<a[i].c2) {printf("NO");return 0;}
		}
		q.push(a[i].c2);*/
		if(top&&sta[top]==b[i].c2) top--;
		else sta[++top]=b[i].c2;
	}
	if(!top) printf("YES");
	else printf("NO");
}

Measured memory_bytes: 7680
class Factorial:
    def __init__(self,n,mod):
        self.f=[1]
        for i in range(1,n+1):
            self.f.append(self.f[-1]*i%mod)
        self.i=[pow(self.f[-1],mod-2,mod)]
        for i in range(1,n+1)[::-1]:
            self.i.append(self.i[-1]*i%mod)
        self.i.reverse()
    def factorial(self,i):
        return self.f[i]
    def ifactorial(self,i):
        return self.i[i]
    def comb(self,n,k):
        return self.f[n]*self.i[n-k]*self.i[k]
n,m,k=map(int,input().split())
M=10**9+7
print((sum(m*m*i*(n-i)for i in range(n))+sum(n*n*i*(m-i)for i in range(m)))*Factorial(n*m,M).comb(n*m-2,k-2)%M)

Measured memory_bytes: 54644
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


int a,b,c;

int main(){
	cin >> a >> b >> c;
	
	if(a+b+c >= 22)cout << "bust" << endl;
	else cout << "win" << endl;
	
	return 0;
}

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

#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define endl '\n'
#define eps  1e-9
const double pi=acos(-1);
const int mod=1e9+7;
//____________________


int32_t main()
{ 
  io;
 
   
  int n,m,x;
  int a[m+1]={0};

  cin>>n>>m;
  int k;
  for(int i=0;i<n;i++)
  {
    cin>>k;
    for(int j=0;j<k;j++)
    {
      cin>>x;
      a[x]++;
    }
  }
  int tot=0;
  for(int i=1;i<=m;i++)
  {
    if(a[i]==n)
      tot++;
  }
  cout<<tot;
 return 0;
}

Measured memory_bytes: 49408
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int coin500 = sc.nextInt();
		int coin100 = sc.nextInt();
		int coin50 = sc.nextInt();
		int x = sc.nextInt();
		int ans = 0;
		for(int i = 0; i <= coin500; ++i){
			for(int j = 0; j <= coin100; ++j){
				for(int k = 0; k <= coin50; ++k){
					int tmp = i * 500 + j * 100 + k * 50;
					if(tmp == x) ans++;
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int n;
double a,d;
double f(int n,double a,double d){
	if(n == 1) return a+d/2.0;
	double m = (double)n;
	return a+(m*2.0-1.0)/2*d+f(n-1,a*(m+1.0)/m+2.5/m*d,(m+2.0)/m*d);
}
int main(){
	scanf("%d%lf%lf",&n,&a,&d);
	printf("%.12f\n",f(n,a,d));
}

Measured memory_bytes: 6528
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FIntervalsOnTree solver = new FIntervalsOnTree();
        solver.solve(1, in, out);
        out.close();
    }

    static class FIntervalsOnTree {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int n = s.nextInt();
            long res = 0;
            for (int i = 1; i <= n; i++)
                res += (long) i * (i + 1) / 2;
            for (int i = 0; i < n - 1; i++) {
                int a = s.nextInt() - 1;
                int b = s.nextInt() - 1;
                int u = Math.min(a, b);
                int v = Math.max(a, b);
                res -= (long) (u + 1) * (n - v);
            }
            w.println(res);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 35832
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

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

  if (R < 1200) cout << "ABC" << endl;
  else if (1200 <= R && R < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
}

Measured memory_bytes: 256
S = list(input())
a = list('dream')
b = list('dreamer')
c = list('erase')
d = list('eraser')

while True:
    if S[-5:] == a:
        del S[-5:]
    elif S[-7:] == b:
        del S[-7:]
    elif S[-5:] == c:
        del S[-5:]
    elif S[-6:] == d:
        del S[-6:]
    else:
        break
        
if len(S) == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3956
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nmk = readln.split.to!(int[]);
    auto N = nmk[0];
    auto M = nmk[1];
    auto K = nmk[2];

    foreach (y; 0..N+1) {
        foreach (x; 0..M+1) {
            if (x*y + (M-x)*(N-y) == K) {
                writeln("Yes");
                return;
            }
        }
    }
    writeln("No");
    return;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define avjo ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    avjo;
    long n;
    cin>>n;
    long long a[n-1],i;
    map<long,long> m;
    for(i=0;i<n-1;i++)
    {
        cin>>a[i];
        m[a[i]]+=1;
    }
    for(i=1;i<=n;i++)
    {
        cout<<m[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 17712
#include<stdio.h>
int isprime(int a);
int main(){
  int a,b,c=0,i;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&b);
    c+=isprime(b);
  }
  printf("%d\n",c);
  return 0;
}

int isprime(int a){
  int i=3;
  if(a==2)return 1;
  if(a<2 ||a%2==0)return 0;
  while(i*i<=a){
    if(a%i==0)return 0;
    i+=2;
  }
  return 1;
}



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

int an[5000], bu[5000];
int main() {
	int a, b; scanf("%d%d", &a, &b);
	rep(i, a)scanf("%d", &an[i]);
	rep(i, b)scanf("%d", &bu[i]);
	int Max = 0;
	rep(i, b - Max) {
		int*p = an;
		int cnt = 0;
		for (int j = i; j < b; j++) {
			if ((p = find(p, an + a, bu[j])) != an + a) {
				cnt++; p++;
			}
			else break;
		}
		Max = max(Max, cnt);
	}
	printf("%d\n", Max);
}

Measured memory_bytes: 3268
using System;

namespace AizuOnline
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] i = Console.ReadLine().Split();
            int w = int.Parse(i[0]),
                h = int.Parse(i[1]),
                x = int.Parse(i[2]),
                y = int.Parse(i[3]),
                r = int.Parse(i[4]);

            if (x < r || x > w-r || y < r || y > h-r)
            {
                Console.WriteLine("No");
                return;
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 9000
import sys

A, B, C = map(int,input().split())
#A 解毒剤・美味しくない
#B 解毒剤・美味しい
#C 毒入り・美味しい

def solve(A,B,C):
  if A + B >= C:
    return B + C
  else:
    return B + B + A + 1

print(solve(A,B,C))

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a!=b&&b!=c&&a!=c) {
        cout<<3<<endl;
    }
      else if(a==b&&b==c&&a==c){
        cout<<1<<endl;
      }
    else if(a==b || b==c ||a==c) {
        cout<<2<<endl;
    }
    
    
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int K;
  cin>>K;
  string S;
  cin>>S;
  if(S.size()<=K)cout<<S<<endl;
  else {
    for(int i=0;i<K;i++)cout<<S[i];
    cout<<"..."<<endl;
  }
  return 0;
}


Measured memory_bytes: 3612
import collections as c

n = int(input())
s = []
ans = 0

for i in range(n):
    t = list(input())
    t.sort()
    t = str(t)
    s.append(t)

s = c.Counter(s)
for i in s.values():
    ans += i*(i-1)//2
print(ans)

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

int main(void)
{
    int N,M,A[10000],sum=0;
    cin>>N>>M;
    for(int i=0; i<M ; i++)
    {
        cin>>A[i];
        sum = sum + A[i];
    }
    if(sum > N)
    {
        sum = -1;
        cout<<sum<<endl;
    }
    else cout<<N-sum<<endl;
}


Measured memory_bytes: 3692
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
const int INF = 100100100;
using namespace std;

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

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

    vector<int> salp(26, -1), talp(26, -1);
    REP(i, s.size()) {
        int a = s[i] - 'a';
        int b = t[i] - 'a';
        if (salp[a] != -1 || talp[b] != -1) {
            if (salp[a] != b || talp[b] != a) {
                cout << "No" << endl;
                return 0;
            }
        }

        salp[a] = b;
        talp[b] = a;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 916
import collections

S=input()
T=input()

def SameGroup(word):
    CW=collections.Counter(word)
    CWval,CWcou=zip(*CW.most_common())
    Count=[]
    for i in range(len(CWval)):
        if CWcou[i]==1:
            break
        else:
            Count.append([])
            for j in range(len(word)):
                if word[j]==CWval[i]:
                    Count[-1].append(j)
    return(Count)

print('YNeos'[SameGroup(S)!=SameGroup(T)::2])

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

using namespace std;

long long hoge(int n, int m, int q, vector<vector<int>> vec, vector<int> vec2 = {}) {
  if (static_cast<int>(vec2.size()) == n) {
    long long vsum = 0;
    for (auto &v : vec) {
      if (vec2[v[1] - 1] - vec2[v[0] - 1] == v[2])
        vsum += v[3];
    }
    return vsum;
  }

  long long ans = -1;
  int i = static_cast<int>(vec2.size()) == 0 ? 1 : *vec2.rbegin();
  for (; i <= m; ++i) {
    vector<int> tmp = vec2;
    tmp.push_back(i);
    long long ret = hoge(n, m, q, vec, tmp);
    ans = max(ans, ret);
  }
  return ans;
}

int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<int>> vec(q, vector<int>(4));
  for (auto &v : vec)
    cin >> v[0] >> v[1] >> v[2] >> v[3];
 cout << hoge(n, m, q, vec) << endl;
}


Measured memory_bytes: 3668
import sys
N, M = map(int, input().split())

Lmax = 1
Rmin = N
for line in sys.stdin:  # much faster than input
    L, R = map(int, line.split())
    Lmax = max(L, Lmax)
    Rmin = min(R, Rmin)

print(max(0, Rmin - Lmax + 1))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
	  #define endl "\n"
	  #define ll long long int
	  #define mod 1000000007
	  #define inf 1000000000000000001;
	  using namespace std;
	  int check(string str) 
	{ 
    // Compute sum of digits 
    int n = str.length(); 
    int digitSum = 0; 
    for (int i=0; i<n; i++) 
        digitSum += (str[i]-'0'); 
  
    // Check if sum of digits is divisible by 9. 
    return (digitSum % 9 == 0); 
	} 
  
	  int main()
	  {
	    //  #ifndef ONLINE_JUDGE
	    //  // for getting input from input.txt
	    //  freopen("input.txt", "r", stdin);
	    //  // for writing output to output.txt
	    //  freopen("output.txt", "w", stdout);
	    // #endif
	    std::ios::sync_with_stdio(false);
	    cin.tie(NULL);
	     string s;
	     cin>>s;
    check(s)?  cout << "Yes" : cout << "No "; 
    return 0; 
	    return 0;
	  }


Measured memory_bytes: 3752
#include <iostream>

using namespace std;

int main() {
  int N, L[100] = {}, count = 0;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> L[i];
  }
  for (int j = 0; j<N; j++){
    for (int k = j+1; k<N; k++){
      for (int l = k+1; l<N; l++){
        if((L[j] != L[k] && L[k]!=L[l] && L[l]!=L[j]) && L[j]+L[k] > L[l] && L[k]+L[l] > L[j] && L[j]+L[l] > L[k]) {
          count++;}
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3632
n = int(input())
m = n * 1

if n == 1:
    print(1)
    exit()

sqr = int(n**0.5)
l1 = len(str(sqr))

pf = {}
for i in range(2, int(m**0.5) + 1):
    while not m % i:
        pf[i] = pf.get(i, 0) + 1
        m //= i
if m > 1:
    pf[m] = 1

ls = sorted(pf.items(), key=lambda x: x[0], reverse=True)
l2 = len(str(ls[0][0]))
other = n // ls[0][0]
l3 = len(str(other))

if l1 <= l2 < l3:
    print(l3)
else:
    print(max(l1, l2))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int h, w;
string a, x;
int main() {
	cin>>h>>w;
	for(int i=0; i<w+2; i++) x += '#';
	cout<<x<<endl;
	for(int i=0; i<h; i++) cin>>a, cout<<'#'<<a<<"#\n";
	cout<<x<<endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
    var s, ans string

    fmt.Scan(&s)
    for i := 0; i < len(s); i++ {
        if s[i] == 'B' {
            if len(ans) != 0 {
                ans = ans[:len(ans)-1]
            }
        } else {
            ans += string(s[i])
        }
    }
    fmt.Println( ans )
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,cnt=0;
    cin >> n;
    for ( int i=0; i<n; i++ ) {
        int a;
        cin >> a;
        cnt+=(a%2);
    }
    if ( cnt%2 ) puts("NO");
    else puts("YES");
    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 5;



int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, ans = 60;
    cin >> n;
    for(int i = 0; i < n; i++){
        int x, cnt = 0;
        cin >> x;
        while(x%2 == 0){
            x/=2;
            cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans;


    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	h, _ := r.nextInt(), r.nextInt()
	r.Scan(true)
	a := r.nextStringArray().toInts()

	sumInt := func(src []int) (vs int) {
		vs = 0
		for i := range src {
			vs += src[i]
		}
		return
	}
	s := sumInt(a)

	fmt.Fprintln(stdout, []string{"No", "Yes"}[b2i(h <= s)])
}


Measured memory_bytes: 4608
#list(map(int, input().split()))

while(1):
	N=int(input());
	if(N==0):
		break;

	MAP=[[0 for i in range(2)] for j in range(N)];
	for i in range(N):
		MAP[i][0],MAP[i][1]=input().split();

	N2=int(input());
	a=[0 for i in range(N2)];
	for i in range(N2):
		a[i]=input();

	for i in a:
		flag=0;
		for j in range(N):
			if(i[0]==MAP[j][0][0]):
				print(MAP[j][1][0],end="");
				flag=1;
				break;
		if(flag==0):
			print(i[0],end="");

	print();



Measured memory_bytes: 7900
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define re register
#define rep(i,s,t) for(re int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(re int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define pt(x) putchar(x)
#define pti(x) printf("%d",x)
#define ptll(x) printf("%lld",x)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
using namespace std;
il int ci(){
	re char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	re int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}
bool f[100023];
int main(){
	int n=ci();
	f[0]= 1;
	rep(c,100,105) rep(i,c,n) f[i]|= f[i-c];
	printf("%d\n",f[n]);
	return 0;
}


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

struct Rectangle {
  int height;
  int pos;
};

int getLargestRect(int size, int buffer[]) {
  stack<Rectangle> S;
  int maxv = 0;
  buffer[size] = 0;

  for (int i = 0; i <= size; i++) {
    Rectangle rect;
    rect.height = buffer[i];
    rect.pos = i;
    if (S.empty()) {
      S.push(rect);
    }
    if (S.top().height < rect.height) {
      S.push(rect);
    }
    else if (S.top().height == rect.height) {
      ;
    }
    else if (S.top().height > rect.height) {
      int target = i;
      while (!S.empty() && S.top().height >= rect.height) {
        Rectangle pre = S.top(); S.pop();
        int area = pre.height * (i - pre.pos);
        maxv = max(maxv, area);
        target = pre.pos;
      }
      rect.pos = target;
      S.push(rect);
    }
  }
  return maxv;
}

int H, W;
int buffer[MAX][MAX];
int T[MAX][MAX];

int getLargestRect() {
  for (int j = 0; j < W; j++) {
    for (int i = 0; i < H; i++) {
      if (buffer[i][j]) T[i][j] = 0;
      else T[i][j] = (i > 0 ? T[i-1][j]+1 : 1);
    }
  }

  int maxv = 0;
  for (int i = 0; i < H; i++) {
    maxv = max(maxv, getLargestRect(W, T[i]));
  }
  return maxv;
}

int main() {
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> buffer[i][j];
    }
  }

  cout << getLargestRect() << endl;

  return 0;
}



Measured memory_bytes: 18376
frag = 'No'
s = [0,0,0,0]
3.times do 
  a,b = gets.split(" ").map!{|i| i.to_i}
  if a == 1 then s[0] += 1 end
  if a == 2 then s[1] += 1 end
 if a == 3 then s[2] += 1 end
 if a == 4 then s[3] += 1 end
 if b == 1 then s[0] += 1 end
  if b == 2 then s[1] += 1 end
 if b == 3 then s[2] += 1 end
 if b == 4 then s[3] += 1 end
end 
if s == [1,1, 2, 2] or s == [1, 2, 2, 1] or s == [2, 2 , 1, 1] or s == [2, 1, 2, 1] or s == [2, 1, 1, 2] or s == [1, 2, 1,2 ] 
 puts 'YES'
else puts 'NO'
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define inf (1e8)
#define eps (1e-11)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1,Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;

class Circle{
public:
  Point c;
  double r;
  Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

Point rotate(Point base,Point a,double r){
  Point b=a-base;
  a.x=b.x*cos((r/180)*M_PI)-b.y*sin((r/180)*M_PI);
  a.y=b.x*sin((r/180)*M_PI)+b.y*cos((r/180)*M_PI);
  a=a+base;
  return a;
}

vector<Point> vp;
int n;

pair<Circle,Circle> makeCirclebySegment(Point a,Point b,int r){
  Point m=a+(b-a)/2.0;
  double d=sqrt(r*r-abs(m-b)*abs(m-b));
  Vector v=(rotate(m,a,90)-m)*(d/abs(m-a));
  Point A=m+v,B=m-v;
  return mp(Circle(A,1),Circle(B,1));
}

int PointsInCircle(Circle C)
{
  int num=0;
  for(int i=0;i<n;i++){
    if(abs(vp[i]-C.c)-1<eps)num++;
  }
  return num;
}

int main()
{
  double x,y;

  while(1){
    cin>>n;
    if(n==0)break;
    vp.clear();

    for(int i=0;i<n;i++){
      cin>>x>>y;
      vp.push_back(Point(x,y));
    }
    int ans=1;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	if(2-abs(vp[i]-vp[j])<eps)continue;
	pair<Circle,Circle> pc=makeCirclebySegment(vp[i],vp[j],1);
	ans=max(ans,PointsInCircle(pc.f));
	ans=max(ans,PointsInCircle(pc.s));
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int check(string s, char c){
    bool uniq(true), excl(true);
    REP(i, s.length()){
        if(s[i] == c) excl = false;
        else uniq = false;
    }
    return 2*uniq + excl;
}

int main(){
    string s; cin >> s;
    int n(s.length()), ans(INF);
    for(char c('a'); c <= 'z'; ++c){
        string t(s);
        int ck = check(t, c);
        if(ck & 2){
            ans = 0; continue;
        }
        if(ck & 1) continue;
        REP(i, n-1){
            string tt("");
            REP(j, t.length()-1){
                if(t[j] != c && t[j+1] != c) tt += t[j];
                else tt += c;
            }
            if(check(tt, c) & 2){
                chmin(ans, i+1); break;
            }
            t = tt;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N, X = gets.split.map(&:to_i)
towns = gets.split.map(&:to_i).sort
first_point = nil
diff_array = []


diff = 123456789000

towns.each_with_index{|i, idx|
  if X > i
    if diff > (X - i)
      first_point = i
      diff = (X - i)
    end
  else
    if diff > (i - X)
      first_point = i
      diff = (i - X)
    end
  end

  unless idx == 0
    diff_array << (towns[idx]-towns[idx-1])
  end
}

diff_array << diff
if diff_array.length == 1
  diff_array << diff
end
diff_array.delete(0)
diff_array.sort!

def gcd(x, y)
  if y == 0
    return y
  end

  if y > x
    gcd(y, x)
  end

  r = x % y
  if r.zero?
    return y
  end

  gcd(y, r)
end

result = diff_array.reduce{|memo, item|
  gcd(memo, item)
}

puts result


Measured memory_bytes: 11000
//解説見た
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

bool f(vector<int> &v, int x, int k) {
    lint cnt = 0;
    for (auto i: v) {
        cnt += (i+x-1)/x - 1;
    }
    if (cnt <= k) return true;
    return false;
}

int main() {
    int n,k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ok = *max_element(a.begin(), a.end() );
    int ng = 0;
    while (abs(ok-ng) > 1) {
        int mid = (ok+ng) / 2;
        if (f(a,mid,k)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto& e : a) {
		cin >> e;
	}
	sort(begin(a), end(a));
	int m = -1;
	for (auto it = begin(a); it != end(a) - 1; it++) {
		if (abs(2 * *it - a.back()) < abs(2 * m - a.back())) {
			m = *it;
		}
	}
	cout << a.back() << " " << m << endl;
	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

int main() {
	string h;
	cin >> h;
	vector<int>v(h.length(), 1);

	for (int i = 0; i < h.length() - 1; ++i) {
		if (h[i] == h[i + 1] && h[i] == 'R') {
			v[i + 2] += v[i];
			v[i] = 0;
		}
	}
	for (int i = h.length() - 1; i > 0; --i) {
		if (h[i] == h[i - 1] && h[i] == 'L') {
			v[i - 2] += v[i];
			v[i] = 0;
		}
	}

	outp(v);
}

Measured memory_bytes: 1408
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

int dp[2][1005],fc[1005],in[1005];

int C(int n,int r){
	if(n<r){
		return 0;
	}
	return mul(mul(fc[n],in[r]),in[n-r]);
}

int str[1005][1005];

void stirling(int n=1000){ 
   str[0][0]=1; 
   for (int i=1;i<=n;i++){ 
     str[i][0]=str[i-1][i-1]; 
      for (int j=1;j<=i;j++) 
         str[i][j]=str[i-1][j-1]+str[i][j-1]; 
   }  
} 

int calc(int count,int size){
	int ans=1;
	int tot=size*count;
	for(int i=0;i<count;i++){
		ans=mul(ans,C(tot,size));
		tot-=size;
	}
	return mul(ans,in[count]);
}

void solve(){
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	dp[0][n]=1;
	debug(calc(4,2));
	for(int i=a;i<=b;i++){
		for(int set=c;set<=d;set++){
			if(set*i>n){
				break;
			}
			int cnst=calc(set,i);
			for(int last=n;last>=set*i;last--){
				add(dp[1][last-set*i],mul(mul(cnst,C(last,set*i)),dp[0][last]));
			}
		}
		for(int j=0;j<=n;j++){
			add(dp[0][j],dp[1][j]);
			dp[1][j]=0;
		}
	}
	cout<<dp[0][0];
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	fc[0]=1;
	for(int i=1;i<=1000;i++){
		fc[i]=mul(fc[i-1],i);
	}
	in[1000]=powz(fc[1000],mod-2);
	for(int i=999;i>=0;i--){
		in[i]=mul(in[i+1],i+1);
	}
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b,c;
	cin>>a>>b>>c;
	if((a*100+b*10+c)%4==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22)
        cout << "bust"
             << "\n";
    else
        cout << "win"
             << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(0,0), B(0,0);
  for(int i=0; i<N+1; i++){
    int a;
    cin >>a;
    A.push_back(a);
  }
  for(int i=0; i<N; i++){
    int b;
    cin >>b;
    B.push_back(b);
  }
  long long ans=0;
  for(int i=N-1; i>=0; i--){
    long long temp;
    temp=(B[i]-A[i+1]);
    if(temp>=0){
      ans+=A[i+1];
      A[i+1]=0;
      B[i]=temp;
    }
    else{
      ans+=B[i];
      A[i+1]-=B[i];
      B[i]=0;
    }
    if(B[i]==0) continue;
    //i
    temp=(B[i]-A[i]);
    if(temp>=0){
      ans+=A[i];
      A[i]=0;
      B[i]=temp;
    }
    else{
      ans+=B[i];
      A[i]-=B[i];
      B[i]=0;
    }    
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);

    string s;
    getline(cin,s);
    if(s=="Sunny")
    {
        cout<<"Cloudy"<<endl;
    }
    else if(s=="Rainy")
    {
        cout<<"Sunny"<<endl;
    }
    else if(s=="Cloudy")
    {
        cout<<"Rainy"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}
 
void solve(){
 
 
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    ll x;cin>>x;
    ll ans=x/500*1000;
    x%=500;
    ans+=x-x%5;
    cout<<ans<<endl;

	return 0;
}
 



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

#define ll long long int
#define li long int
#define ld long double
#define W while
#define endl "\n"
#define For(i,s,x) for(i=s;i<x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define FoR(i,x) for(i=1;i<=x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define pb push_back
#define pp pop_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007

#define IO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(v) v.begin(),v.end()
 
typedef unsigned long long ull;
typedef pair <int, int> pii;
 
const int N = 1e5+5;
const int M = 1e5+5;
const int inf = INT_MAX;
const int MOD = 1e7+9;
int main() {
    IO;
	int t;
	t=1;
	W(t--){
	    ll n,i;
	    cin>>n;
        bool flag=false;
	        ll num=7%n;
	        FoR(i,1000000){
	            if(num==0){
	                cout<<i<<endl;
	                return 0;
	            }
	            num=(num*10+7)%n;
	        }
	    cout<<"-1"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<stdbool.h>

int main(void){
	int node[100],i,j,k,p1,p2;
	bool ans;
	
	while(!feof(stdin)){
		for(i=0;i<100;i++) node[i]=0;
		while(scanf("%d%d",&p1,&p2)!=EOF && p1 && p2){ 
			node[p1-1]++;
			node[p2-1]++;
		}
		ans=true;
		if(!(node[0]%2 && node[1]%2)) ans=false;
		else for(i=2;i<100;i++) if(node[i]%2) ans=false;
		if(feof(stdin)) break;
		puts(ans?"OK":"NG");
	}
	
	return 0;
}

Measured memory_bytes: 588
# 1 "k.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "k.cpp"
# 1 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 1
       
# 12 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/bits/stdc++.h" 1
 #include <bits/stdc++.h>
# 13 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/assoc_container.hpp" 1
 #include <ext/pb_ds/assoc_container.hpp>
# 14 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/tree_policy.hpp" 1
 #include <ext/pb_ds/tree_policy.hpp>
# 15 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2







using namespace std;
using namespace __gnu_pbds;

using ii = pair<long long, long long>;
using vi = vector<long long>;
using vd = vector<long double>;
using vb = vector<bool>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvb = vector<vb>;
using vvii = vector<vii>;
# 50 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
inline long long mod(const long long n, const long long m = ((long long)1e9+7)){
    return (n%m + m)%m;
}

/**
 * Euclidean GCD.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long gcd(const long long a, const long long b){
    if(a < 0 or b < 0)
        return gcd(abs(a), abs(b));
    if(a == 0)
        return b;
    return gcd(b%a, a);
}

/**
 * Euclidean derivated LCM.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long lcm(const long long a, const long long b){
    // same as a*b/gcd(a, b) but avoiding overflow.
    return a/gcd(a, b)*b;
}
# 2 "k.cpp" 2

long long dp[2][(long long)1e5+1];

long long solve(vi &arr, long long acc, long long cur){
    long long &res = dp[cur][acc];
    if(res == -1){
        res = cur;
        for(long long i:arr){
            if(acc-i >= 0 and solve(arr, acc-i, !cur) == !cur)
                res = !cur;
        }
    }
    return res;
}

int32_t main(){
    (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL));
    long long n, k;
    cin >> n >> k;
    vi arr(n);
    for(long long &i:arr)
        cin >> i;
    memset(dp, -1, sizeof(dp));
    if(solve(arr, k, 0))
        cout << "First" << "\n";
    else
        cout << "Second" << "\n";
    return 0;
}


Measured memory_bytes: 9600