akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <deque>

struct Line {
  long long a;
  long long b;
  
  long long eval(long long x) const {
    return a * x + b;
  }
};

std::deque<Line> lines;

double xIntersect(const Line &l1, const Line &l2) {
  // l1.a * x12 + l1.b == l2.a * x12 + l2.b
  // (l1.a - l2.a) * x12 == (l2.b - l1.b)
  // x12 == (l2.b - l1.b) / (l1.a - l2.a)
  return (double)(l2.b - l1.b) / (l1.a - l2.a);
}

bool ok(const Line &l1, const Line &l2, const Line &l3) {
  // l1.a * x12 + l1.b == l2.a * x12 + l2.b
  // (l1.a - l2.a) * x12 == (l2.b - l1.b)
  // x12 == (l2.b - l1.b) / (l1.a - l2.a)
  
  // l2.a * x23 + l2.b == l3.a * x23 + l3.b
  // (l2.a - l3.a) * x23 == l3.b - l2.b
  // x23 == (l3.b - l2.b) / (l2.a - l3.a)
  
  // return x12 < x23
  // (l2.b - l1.b) / (l1.a - l2.a) < (l3.b - l2.b) / (l2.a - l3.a)
  // (l2.b - l1.b) * (l2.a - l3.a) < (l3.b - l2.b) * (l1.a - l2.a)
  return (l2.b - l1.b) * (l2.a - l3.a) < (l3.b - l2.b) * (l1.a - l2.a);
}

int main() {
  int n;
  long long c;
  scanf("%d%lld", &n, &c);
  long long h[n];
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &h[i]);
  }
  long long MinCost[1 + n];
  MinCost[1] = 0;
  lines.push_back(Line{-2 * h[1], MinCost[1] + h[1] * h[1]});
  for (int i = 2; i <= n; i++) {
    /*
    for (int j = 1; j < i; j++) {
      MinCost[i] = min(MinCost[j] + (h[j] - h[i]) * (h[j] - h[i]) + c);
      MinCost[i] = c + min(MinCost[j] + h[j] * h[j] - 2 * h[i] * h[j] + h[i] * h[i]);
      MinCost[i] = c + h[i] * h[i] + min((-2 * h[j]) * h[i] + (MinCost[j] + h[j] * h[j]));
    }//*/
    while (lines.size() >= 2 && xIntersect(lines[0], lines[1]) < h[i]) {
      lines.pop_front();
    }
    MinCost[i] = c + h[i] * h[i] + lines[0].eval(h[i]);
    Line lastLine = Line{-2 * h[i], MinCost[i] + h[i] * h[i]};
    while (lines.size() >= 2 && !ok(lines.end()[-2], lines.end()[-1], lastLine)) {
      lines.pop_back();
    }
    lines.push_back(lastLine);
  }
  printf("%lld\n", MinCost[n]);
  return 0;
}


Measured memory_bytes: 5504
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<int> a(N);
  for (auto& ai: a) {
    int i, p;
    scanf("%d.%d", &i, &p);
    ai = 1000*i + p;
  }

  std::vector<int> b = a;
  std::sort(b.begin(), b.end());

  for (auto ai: a) {
    auto lb = std::lower_bound(b.begin(), b.end(), ai);
    auto ub = std::upper_bound(b.begin(), b.end(), ai);

    int draw = (ub-lb) - 1;
    int win = (lb-b.begin());
    printf("%d\n", draw+3*win);
  }
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster

    int n;

    cin>>n;

    int x=n%1000;

    if(x!=0)
        x=1000-x;


    cout<<x<<endl;




    return 0;
}


Measured memory_bytes: 3652
import java.util.*;

public class Main {
  
  public static void main (String[] args){
    
    Main main = new Main();
    main.solve();
  }
  
  private void solve (){
    
    Scanner scanner = new Scanner (System.in);
    
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int C = scanner.nextInt();
    
    int kaisuu = B/A;
    
    if (kaisuu>=C){
      System.out.println(C);
    } else {
      System.out.println(kaisuu);
    }
  }
}

Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        int N = NextInt();
        string S = NextString();
        Dictionary<char, long> d = new Dictionary<char, long>();
        for (char c = 'a'; c <= 'z'; c++) d[c] = 0;
        foreach (char c in S) d[c]++;
        //使わないorどれか使う
        long ans = 1;
        for (char c = 'a'; c <= 'z'; c++) {
            ans *= d[c] + 1;
            ans %= INF;
        }
        Console.WriteLine(ans - 1);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 14048
#include<cstdio>
int main(){
	int k,a,b,ans;
	scanf("%d%d%d",&k,&a,&b);
	if(b<=a+2||k<=a){
		printf("%d\n",k+1);
		return 0;
	}
	ans=a;k-=a-1;if(k&1){ans++;k--;}
	printf("%lld\n",ans+(long long)(b-a)*k/2);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#define INF 0x3f3f3f3f
#define ms(x, y) memset(x, y, sizeof(x))
char _;
typedef long long ll;
ll N, W, w[101], v[101], dp[100001], maxv;
int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> N >> W;
    ms(dp, INF);
    dp[0] = 0;
    for (int i = 0; i < N; i++){
        cin >> w[i] >> v[i];
        maxv = max(v[i], maxv);
    }
    for (int i = 0; i < N; i++){
        for (int j = maxv * N; j >= v[i]; j--){
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
        }
    }
    for (int i = maxv * N; i >= 0; i--){
        if (dp[i] <= W){
            cout << i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1152
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
int K;
char S[12];
int main(){
  int i;
  rd(N);
  rd(S);
  rd(K);K += (-1);
  for(i=(0);i<(N);i++){
    if(S[i]!=S[K]){
      S[i] = '*';
    }
  }
  wt_L(S);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191123-1

// --- original code ---
// int N, K;
// char S[12];
// {
//   rd(N,S,K--);
//   rep(i,N) if(S[i]!=S[K]) S[i] = '*';
//   wt(S);
// }


Measured memory_bytes: 256
def is_popular(products, reference):
	for p in products:
		if p < reference:
			return False
	
	return True


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

a.sort(reverse = True)
reference = sum(a) / (4.0 * m)

if is_popular(a[:m], reference):
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3060
l,r = map(int,input().split())
a = 1 + l/2019
if a*2019 <= r:
  print (0)
else:
  mi = 1234567891234567890
  for i in range(l,r):
    for j in range(i+1, r+1):
      mi = min(mi,(i*j)%2019)
  print(mi)

Measured memory_bytes: 3060
// AOJ 2251 Merry Christmas
// 2018.3.6 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 2002
short hi[MAX], to[MAX][MAX];
char  seen[MAX];
short match[MAX];

int bpm(int u)
{
	int i, v;

	for (i = 0; i < hi[u]; i++) {
		v = to[u][i];
		if (seen[v]) continue;
		seen[v] = 1;
		if (match[v] < 0 || bpm(match[v])) {
			match[u] = v, match[v] = u;
			return 1;
		}
	}
	return 0;
}

#define INF 0x10101010
typedef struct { int p, t; } T;
T pt[1002];
int dist[102][102];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int cmp(T *a, T *b) { return a->t - b->t; }

int main()
{
	int N, M, L, u, v, d, k;

	while (N = in()) {
		M = in(), L = in();
		memset(dist, INF, sizeof(dist));
		for (k = 0; k < N; k++) dist[k][k] = 0;
		for (k = 0; k < M; k++) {
			u = in(), v = in(), d = in();
			dist[u][v] = dist[v][u] = d;
		}
		for (k = 0; k < N; k++) {
			for (u = 0; u < N; u++) if (dist[u][k] != INF) {
				for (v = 0; v < N; v++) if (dist[k][v] != INF) {
					d = dist[u][k] + dist[k][v];
					if (dist[u][v] > d) dist[u][v] = d;
				}
			}
		}

		for (k = 0; k < L; k++) pt[k].p = in(), pt[k].t = in();

		qsort(pt, L, sizeof(T), cmp);
		memset(hi, 0, sizeof(hi));
		for (u = 0; u < L; u++) for (v = 0; v < L; v++) if (u != v) {
			if (dist[pt[u].p][pt[v].p] <= pt[v].t-pt[u].t) to[u][hi[u]++] = v+L;
		}

	    memset(match, -1, L << 2);
		k = L;
		for (u = 0; u < L; u++) {
			memset(seen, 0, L << 1);
			if (bpm(u)) k--;
		}
		printf("%d\n", k);
	}
	return 0;
}


Measured memory_bytes: 5752
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
    return;
}
ll powe[60];
void power()
{
    powe[0]=1;
    REP(i,1,15)
    {
        powe[i]=2*powe[i-1];
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll facto(ll n,ll k)
{
	if(n<=k)
	return 1;
	if(k==1)
	{
		return n;
	}
	if(k==2)
	{
		return ((n)*(n-1))/2;
	}
	return ((n)*(n-1)*(n-2))/6;
}
bool my(pair<double,ll> p1, pair<double,ll> p2)
{
	if(p1.f<p2.f)
	return true;
	if(p1.f==p2.f && p2.s>p1.s)
	return true;
	return false;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c;
    cin>>a>>b>>c;
    if((a==b && b!=c) || (b==c && c!=a) || (a==c && b!=c))
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }

	return 0;
}

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

using namespace std;

int main(){
    string s;
    long long int K;
    cin >> s;
    cin >> K;

    for(int i=0;i<s.size();i++){
            
        if(i==s.size()-1){
            s[i] = 'a' + (s[i]-'a'+K)%26;
        }else{
            if(s[i]!='a' && 'a'+26-s[i]<=K){
                K -= 'a'+26-s[i];
                s[i] = 'a';
            }
        }
    }

    cout << s << endl;
}

Measured memory_bytes: 512
//@kotatsugame_t -> @dolyplpl -> @Wednesdaywww
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int n,m,a[50],b[50],c[50],d[50];
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<m;i++)
	{
		cin>>c[i]>>d[i];
	}
	for(int i=0;i<n;i++)
	{
		int mindis=1e9,ansindex;
		for(int j=0;j<m;j++)
		{
			if(abs(a[i]-c[j])+abs(b[i]-d[j])<mindis)
			{
				mindis=abs(a[i]-c[j])+abs(b[i]-d[j]);
				ansindex=j+1;
			}
		}
		cout<<ansindex<<endl;
	}
	/* onakasuita */
	return 114514>1919810;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,j,m=1e9,s,d[100010];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&d[i]);
  for(i=0;i<101;i++){
    for(j=s=0;j<n;j++)s+=(d[j]-i)*(d[j]-i);
    if(m>s)m=s;
  }
  printf("%d\n",m);
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
int n,m;
char s[200005];
ll f[200005][2],sum[200005];
ll DP(int n,int l)
{
	f[1][1]=1;
	for(int i=2;i<=n+1;i++)
	{
		f[i][1]=(f[i-1][1]+f[i-1][0])%MOD;
		f[i][0]=(f[i-1][1]+f[i-1][0]-(i-1>l?f[i-l-1][1]:0)+MOD)%MOD;
	}
	sum[1]=f[1][1];
	for(int i=2;i<=n+1;i++)
	  sum[i]=(sum[i-1]+f[i][1])%MOD;
	ll ans=f[n+1][1];
	for(int st=2;st<=l+1;st++)
	  ans+=sum[n-st+1]-sum[n-l-1];
	ans%=MOD;
	if(ans<0)ans+=MOD;
	return ans;
}
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	if(s[1]=='B')
	{
		for(int i=1;i<=m;i++)
		{
			if(s[i]=='B')s[i]='R';
			else s[i]='B';
		}
	}
	int l=200001;
	int i=1;
	while(s[i]=='R')i++;
	if(i>m)
	{
		printf("%lld\n",DP(n,1));
		return 0;
	}
	if(n&1)
	{
		printf("0\n");
		return 0;
	}
	if(i&1)l=min(l,i);
	else l=min(l,i-1);
	while(i<=m)
	{
		while(s[i]=='B')i++;
		int len=0;
		while(s[i]=='R')len++,i++;
		if(i>m)break;
		if(len&1)l=min(l,len);
	}
	printf("%lld\n",DP(n/2,l/2)*2%MOD);
	return 0;
}

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

using namespace std;

int co[4]={10,50,100,500};

int main(){
	bool ni=false;
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		if(ni) cout << endl;
		else ni=true;
		int a[4],b[4];
		for(int i=0;i<4;i++){
			cin >> a[i];
		}
		int ch=-1*n;
		for(int i=0;i<4;i++){
			ch+=a[i]*co[i];
		}
		b[3]=ch/500;
		b[2]=ch%500/100;
		b[1]=ch%100/50;
		b[0]=ch%50/10;
		for(int i=0;i<4;i++){
			if(a[i]-b[i]>0){
				cout << co[i] << " " << a[i]-b[i] << endl;
			}
		}
	}
	return 0;
}


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

using namespace std;

int main()
{
    string s, t;

    cin >> s >> t;

    int n = s.length();
    int m = t.length();

    int dp[n+1][m+1];
    pair <int, int> prev[n+1][m+1];

    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= m; j++)
        {
            dp[i][j] = 0;
            prev[i][j] = make_pair(-1, -1);
        }
    }

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (dp[i-1][j] > dp[i][j-1])
            {
                dp[i][j] = dp[i-1][j];
                prev[i][j] = prev[i-1][j];
            }
            else
            {
                dp[i][j] = dp[i][j-1];
                prev[i][j] = prev[i][j-1];
            }

            if (s[i-1] == t[j-1])
            {
                dp[i][j] = max(dp[i][j], 1 + dp[i-1][j-1]);
                prev[i][j] = make_pair(i-1, j-1);
            }
        }
    }

    int i = prev[n][m].first;
    int j = prev[n][m].second;
    
    string ans = "";

    while (i > 0 && j > 0)
    {
        ans = ans + s[i];

        int pi = prev[i][j].first;
        int pj = prev[i][j].second;

        i = pi;
        j = pj;
    }

    if (i != -1 && j != -1)
        ans = ans + s[i];

    reverse(ans.begin(), ans.end());

    cout << ans << "\n";


    return 0;
}

Measured memory_bytes: 105856
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int h, w;
string a[10];
bool ans;
/**********************************************/

void dfs(int x, int y){
    a[y][x] = '.';
    if(x == w-1 && y == h-1){
        ans = true;
        REP(i, h){
            REP(j, w){
    //            cout << a[i][j];
                if(a[i][j] == '#') ans = false; 
            }
      //      cout << endl;
        }
    }
    if(a[y+1][x] == '#'){ 
        dfs(x, y+1);
        a[y+1][x] = '#';
    }
    else if(a[y][x+1] == '#'){ 
        dfs(x+1, y);
        a[y][x+1] = '#';
    }
}

int main(){
    cin >> h >> w;
    REP(i, h){
        cin >> a[i];
    }

    dfs(0, 0);
    if(ans) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  a.erase(unique(all(a)),a.end());
  if(a.size()==n){
    cout<<"YES"<<endl;
  }
  else {
    cout<<"NO"<<endl;
  }  return 0;

}


Measured memory_bytes: 1792
#include<stdio.h>
int a[200005];
int ans[200005];
int main()

{
    int N;
    scanf("%d",&N);

    for(int i=2;i<=N;i++)
    {
        scanf("%d",&a[i]);
        ans[a[i]]++;
    }
    for(int j=1;j<=N;j++)
    {
        printf("%d\n",ans[j]);
    }

    return 0;

}


Measured memory_bytes: 3268
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
*/

main:-
    get_number(A),
    get_number(B),
    X is 6 - A - B,
    writeln(X).


Measured memory_bytes: 8184
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


l, r, d = map(int, input().split())
a = l + (d - l%d) if l%d > 0 else l
b = r - r%d
# print(a, b)
print((b-a)//d + 1)

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

typedef long double ld;
using P = complex<ld>;
const ld eps = 1e-10;

ld cross(const P &a, const P &b) { return a.real() * b.imag() - a.imag() * b.real(); }

template<class iter>
std::pair<P, ld> min_ball(iter left, iter right, int seed = 1333) {
    const int n = right - left;

    assert(n >= 1);
    if (n == 1) {
        return {*left, ld(0)};
    }

    std::mt19937 mt(seed);
    std::shuffle(left, right, mt);
    // std::random_shuffle(left, right); // simple but deprecated

    iter ps = left;
    using circle = std::pair<P, ld>;

    auto make_circle_3 = [](const P &a, const P &b, const P &c) -> circle {
        ld A = std::norm(b - c), B = std::norm(c - a), C = std::norm(a - b),
                S = cross(b - a, c - a);
        P p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / (4 * S * S);
        ld r2 = std::norm(p - a);
        return {p, r2};
    };

    auto make_circle_2 = [](const P &a, const P &b) -> circle {
        P c = (a + b) / (ld) 2;
        ld r2 = std::norm(a - c);
        return {c, r2};
    };

    auto in_circle = [](const P &a, const circle &c) -> bool {
        return std::norm(a - c.first) <= c.second + eps;
    };

    circle c = make_circle_2(ps[0], ps[1]);

    // MiniDisc
    for (int i = 2; i < n; ++i) {
        if (!in_circle(ps[i], c)) {
            // MiniDiscWithPoint
            c = make_circle_2(ps[0], ps[i]);
            for (int j = 1; j < i; ++j) {
                if (!in_circle(ps[j], c)) {
                    // MiniDiscWith2Points
                    c = make_circle_2(ps[i], ps[j]);
                    for (int k = 0; k < j; ++k) {
                        if (!in_circle(ps[k], c)) {
                            c = make_circle_3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

int main() {
    int n;
    cin >> n;
    vector<P> dots;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        P p(x, y);
        dots.push_back(p);
    }

    auto ans = min_ball(dots.begin(), dots.end());
    double ad = sqrt(ans.second);
    printf("%.20f\n", ad);


}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a_min = min(a)
while True:
    flag = 0
    a_attacked = [10 ** 9, 0]
    for i in range(n):
        if 0 < a[i] % a_min < a_attacked[0]:
            a_attacked[0] = a[i] % a_min
            a_attacked[1] = i
            flag = 1
    if flag == 0:
        break
    else:
        a_min = a_attacked[0]
        a[a_attacked[1]] = a_attacked[0]
print(a_min)


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

int main(){
    int n;
    cin>>n;
    string s,a,b;
    cin>>s;
    if(n%2!=0)
    cout<<"No"<<endl;
    if(n%2==0){
        for(int i=0;i<n/2;i++)
            a+=s[i];
        for(int i=n/2;i<n;i++)
            b+=s[i];
        if(a==b)
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
"""
AtCoder
    :author: vierbein
"""
from __future__ import absolute_import, division, print_function

# import itertools as it
# import collections
import sys


def pp(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


A, B, C = map(int, input().split())
print(max(0, C - A + B))

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<queue<int>> lane(n + 1);
  int cmd, info;
  int index, min_len;
  int i, j;
  for (i = 0; i < m; i++) {
    cin >> cmd >> info;
    if (cmd == 0) {
      cout << lane[info].front() << endl;
      lane[info].pop();
    } else {
      min_len = lane[1].size();
      index = 1;
      for (j = 1; j < lane.size(); j++) {
        if (min_len > lane[j].size()) {
          min_len = lane[j].size();
          index = j;
        }
      }
      lane[index].push(info);
    }
  }
  return 0;
}



Measured memory_bytes: 3164
MOD = 1000000007
N,K = map(int,input().split())
A = list(map(int,input().split()))
# import numpy as np
# A = np.random.rand(2000)
def bubble_sort(A):
    cnt = 0
    for i in range(len(A)):
        for j in range(len(A)-1, i, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                cnt += 1
    return cnt

def sigma(k):
    #return int((1/2)*(k%MOD)*((k+1)%MOD))
    return k*(k+1)//2


# B = []
# for k in range(K):
#     B.extend(A)
# print (bubble_sort(B))


C = []
for k in range(2):
    C.extend(A)
cnt = bubble_sort(A)
#print (cnt)
diff = bubble_sort(C) - 2 * cnt
#print (diff)
a = (K*cnt)
b = (diff*sigma(K-1))
print ((a+b)%MOD)


Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>

#define ll long long
#define pll pair<ll, ll>

#define reps(i, f, n) for (int i = (f); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

const int INF = 1111111111;
const double EPS = 1e-9;

using namespace std;
const int MOD = 1000000007;

class ChooseMOD
{
public:
	int MOD;
	vector<long long> fact, fact_inv, inv;

	ChooseMOD(int size, int mod) : MOD(mod)
	{
		fact.resize(size + 5);
		fact_inv.resize(size + 5);
		inv.resize(size + 5);
		fact[0] = fact[1] = 1;
		fact_inv[0] = fact_inv[1] = 1;
		inv[1] = 1;
		for (int i = 2; i < size + 5; i++)
		{
			fact[i] = fact[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
			fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
		}
	}

	long long nCk(int n, int k)
	{
		return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
	}
};

const int N = 2111111;

void init()
{
}

ll pow25[N];
ll pow26[N];

void solve()
{
	int n;
	string s;
	cin >> n >> s;

	ChooseMOD choose = ChooseMOD(N, MOD);

	pow25[0] = 1;
	pow26[0] = 1;
	reps(i, 1, N)
	{
		pow25[i] = (pow25[i - 1] * 25) % MOD;
		pow26[i] = (pow26[i - 1] * 26) % MOD;
	}

	ll sum = 0;

	rep(i, n + 1)
	{
		int left = i;
		int right = n - i;

		ll leftnCk = choose.nCk(left + s.size() - 1, left);
		ll leftpow = pow25[left];
		ll leftSum = (leftnCk * leftpow) % MOD;
		ll rightSum = pow26[right];
		ll all = (leftSum * rightSum) % MOD;

		//cout << i << " " << left << " " << right << " || " << leftnCk << " " << leftpow << " " << leftSum << " " << rightSum << " " << all << " " << endl;

		sum = (sum + all) % MOD;
	}

	cout << sum << endl;
}

int main()
{
	init();
	solve();
}


Measured memory_bytes: 86392
/*
[arc099] D - Snuke Numbers
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const double EPS = 1e-6;

int K;

double f(ll a) {
    int ret = 0;
    for (ll i = a; i > 0; i /= 10) {
        ret += i % 10;
    }
    return (double)a / ret;
}

void solve() {
    ll ans = 1;
    ll d = 1;
    for (int k = 0; k < K; k++) {
        cout << ans << endl;
        if (f(ans + d) + EPS >= f(ans + d * 10)) {
            d *= 10;
        }
        ans += d;
    }
}

int main() {
    cin >> K;

    solve();

    return 0;
}


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

using namespace std;

int main() {

	int N;
	cin >> N;

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

	int minimum = 2147483647;
	int maxRieki = vNum[1] - vNum[0];
	for (int i = 0; i < vNum.size(); i++)
	{
		maxRieki = max(maxRieki, vNum[i] - minimum);

		if (vNum[i] < minimum)
		{
			minimum = vNum[i];
		}
	}

	cout << maxRieki << endl;
	
	return 0;
}





Measured memory_bytes: 3620
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  K--;
  if (S.at(K) == 'A') {
    S.at(K) = 'a';
  }
  else if (S.at(K) == 'B') {
    S.at(K) = 'b';
  }
  else if (S.at(K) == 'C') {
    S.at(K) = 'c';
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
 int A,B,C,D;
  cin>>A>>B>>C>>D;
  while(true){
    C-=B;if(C<=0){cout<<"Yes"<<endl;break;}
    A-=D;if(A<=0){cout<<"No"<<endl;break;}}
 return 0;
}

Measured memory_bytes: 3672
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    d = [0] * 101
    for i in range(25):
        d[i*4] = 1
    for i in range(7,101):
        if d[i-7] == 1:
            d[i] = 1
    n = I()
    if d[n] == 1:
        return 'Yes'
    return 'No'




print(main())


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

using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	vector<int> a(n);
	for(int &x : a) scanf("%d", &x);
	int mx = -1, smx = -1;
	for(int x : a) {
		if(x > mx) swap(x, mx);
		if(x >smx) swap(x,smx);
	}
	for(int x : a) {
		printf("%d\n", x == mx ? smx : mx);
	}
}


Measured memory_bytes: 4036
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int s,w;cin>>s>>w;
	if(w>=s){
    cout<<"unsafe"<<endl;
  }
  else{
    cout<<"safe"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <tuple>
typedef long long int ll;
using namespace std;
#define MAXN 1000001
#define mod 1000000007
ll Pow(ll a, ll n) {
    if (n == 0) return 1;
    if (n % 2) return (a * Pow(a, n - 1)) % mod;
    else {
        ll k = Pow(a, n / 2);
        return (k * k) % mod;
    }
}
ll gyakusuu[MAXN + 1];
int main() {
    // Fn = (n + N - 1)C(N - 1) * 25**(n)
    // Gn = Fn + 26 * Gn-1
    for (int i = 1; i <= MAXN; i++) {
        gyakusuu[i] = Pow(i, mod - 2);
    }
    ll k;
    string s;
    cin >> k >> s;
    ll N = s.length();
    ll g = 1; // n = 0;
    ll f = N * 25; // n = 1;
    for (int i = 1; i <= k; i++) {
        g = (f + 26 * g) % mod;
        f = ( (25 * (i + N) % mod) * gyakusuu[i + 1] % mod ) * f % mod;
    }
    cout << g << endl;
    return 0;
}

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

typedef long long ll;

int main() {
    string s;
    int ans = 0;
    int cnt = 0;
    cin >> s;
    for (int i = s.size()-1; i >= 0; i--) {
        if (s[i] == 'T') {
            cnt++;
        } else {
            if (cnt > 0) {
                ans++;
                cnt--;
            }
        }

    }
    cout << s.size() - ans*2 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;        

    int k; cin >> k;
    string res;
    
    while(k--){
       res += "ACL";
    }
    cout<<res;

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "First" << '\n'; exit(0); }
inline void no() { cout << "Second" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  string s; cin >> s;
  int n = s.size();
  if (n % 2 == 0) {
    if (s[0] == s[n-1]) yes(); else no();
  } else {
    if (s[0] == s[n-1]) no(); else yes();
  }
}


Measured memory_bytes: 512
import atexit
import io
import sys

buff = io.BytesIO()
sys.stdout = buff


@atexit.register
def write():
    sys.__stdout__.write(buff.getvalue())

n = input()
s = raw_input()
if s.count('R') > s.count('B'):
	print 'Yes'
else:
	print 'No'

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

int n,k,ans=0;
int tot=0,h[100005],a[100005];
struct Edge{
	int x,next;
}e[200005];

inline void add_edge(int x,int y){
	e[++tot].x=y;
	e[tot].next=h[x],h[x]=tot;
}

int dfs(int x,int deep){
	int ret=deep;
	for(int i=h[x];i;i=e[i].next)
		ret=max(ret,dfs(e[i].x,deep+1));
	if(a[x]!=1&&ret-deep==k-1)return ans++,0;
	else return ret;
}

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	if(a[1]!=1)ans=a[1]=1;
	for(int i=2;i<=n;i++)add_edge(a[i],i);
	dfs(1,0),printf("%d",ans);
}

Measured memory_bytes: 6528
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int N;
string W[110];

int main() {
	cin >> N;
	REP(i, N) cin >> W[i];
	for (int i = 1; i < N; i++) {
		if (W[i - 1][W[i - 1].length() - 1] != W[i][0]) {
			cout << "No" << endl;
			return 0;
		}
	}
	sort(W, W + N);
//	REP(i, N) cout << W[i] << endl;
	for (int i = 1; i < N; i++) {
		if (W[i] == W[i - 1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << (A+B==C+D ? "Balanced":A+B>C+D?"Left":"Right") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int n;
    string s;
    cin >> n >> s;
    for(int i=0; i<s.length(); i++){
        s[i]=(s[i]-'A'+n)%26+'A';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#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);
  }
  
  string ans = "APPROVED";
  for (int i = 0; i < N; i++) {
    if (A.at(i) % 2 == 0 && A.at(i) % 3 != 0 && A.at(i) % 5 != 0) {
      ans = "DENIED";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(raw_input())
nums = []

for i in range(N):
    nums.append(int(raw_input()))

m = -1000000000000000000000000
minvalue = nums[0]

for i in range(1, len(nums)):
    minvalue = min(minvalue, nums[i-1])
    value = nums[i] - minvalue
    if m <= value:
        m = value

print(m)

Measured memory_bytes: 18904
def solve(k, n, a_list):
    res = a_list[n - 1] - a_list[0]
    a_list_s = list(sorted(a_list))
    for i in range(n - 1):
        res_a = k - (a_list_s[i + 1] - a_list_s[i])
        if res_a < res:
            res = res_a
    return res


def main():
    k, n = map(int, input().split())
    a_list = list(map(int, input().split()))
    res = solve(k, n, a_list)
    print(res)


def test():
    assert solve(20, 3, [5, 10, 15]) == 10
    assert solve(20, 3, [0, 5, 15]) == 10


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 26444
K = int(input())
N = 10**6
a = [0] * N

a[0] = 7
for i in range(1, N):
    a[i] = (a[i-1] * 10 + 7) % K
a[0] %= K
for i in range(N):
    if a[i] == 0:
        print(i+1)
        break
else:
    print(-1)

Measured memory_bytes: 48544
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  int a,b;
  cin>>a>>b;
  if((a+b)%2==1){
    cout<<"IMPOSSIBLE"<<endl;
  }else{
    cout<<(a+b)/2<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int h1, h2;
	int m1, m2;
	int s1, s2;
	int t[3];
	int i;
	
	for (i = 0; i < 3; i++){
		scanf("%d %d %d %d %d %d", &h1, &m1, &s1, &h2, &m2, &s2);
		t[i] = (h2 * 3600 + m2 * 60 + s2) - (h1 * 3600 + m1 * 60 + s1);
	}
	for (i = 0; i < 3; i++){
		printf("%d %d %d\n", t[i] / 3600, t[i] % 3600 / 60, t[i] % 60);
	}
	return (0);
}

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

int main()
{
	char s[10];
	cin>>s;
	if(s[0]=='S')
	{
		cout<<"Cloudy"<<endl;
	}
	else if(s[0]=='C')
	{
		cout<<"Rainy"<<endl;
	}
	else if(s[0]=='R')
	{
		cout<<"Sunny"<<endl;
	}
	return 0;
	
}

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

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;


void solve()
{
   string s;
   cin>>s;
   if(s[1]=='B')
   {
           cout<<"ARC";
           return;
   }
   cout<<"ABC";
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define int long long
using namespace std;
int x[10000001];
signed main(){
	int n, i, j, ans=0;
	cin >> n;
	for(i=1; i<=n; i++)
		for(j=1; i*j<=n; j++) x[i*j]++;
	for(i=1; i<=n; i++) ans+=i*x[i];
	cout << ans << endl;
	return 0;
}

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


int main(){
  int N ; 
  cin >> N ; 
  int cnt = 0 ; 
  vector<int> H(N) ; 
  
  for(int i = 0 ; i < N ; i++){
    cin >> H.at(i) ; 
  }
  int max = H.at(0) ; 
  
  for(int i = 1 ; i < N ; i++){
    if( max <= H.at(i) ){
      max = H.at(i) ; 
      cnt++ ; 
    }
  }  
  
  cout << cnt+1 << endl ; 
  
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();
		sc.close();
		boolean isYes = true;
		for (int i = 0; i < line1.length(); i++) {
			if (i ==  line1.length() - 1) {
				break;
			}
			String temp = line1.substring(i + 1);
			if (temp.indexOf(line1.charAt(i)) >= 0) {
				isYes = false;
				break;
			}
		}
		if (isYes) {
			System.out.println("yes");
		} else {
			System.out.println("no");
		}
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

bool debug = false;
const int NIL = -1;
const ll INF = 400000000000;
const int NUM = 100010;
clock_t START, END;

queue<int> Q;
list<int> out;
vector<int> G[NUM], Arl;
int prenum[NUM], cor[NUM], lowest[NUM], _Arl[NUM];
int cnt;

void dfs(int u)
{
	int _min;
	_min = prenum[u] = ++cnt;
	for (int i = 0; i < G[u].size(); i++) {
		int v = G[u][i];
		if (!prenum[v]) {
			dfs(v);
			_min = min(_min, lowest[v]);
			if (lowest[v] >= prenum[u] && _Arl[u] == 0) {
				Arl.push_back(u);
				_Arl[u]++;
			}
		}
		else if (prenum[v] < _min)
			_min = prenum[v];
	}
	lowest[u] = _min;
}

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in44.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int V, E, s, t, ctree = 0;;
	bool negative = false;
	cin >> V >> E;
	for (int i = 0; i < E; i++) {
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	cnt++;
	prenum[0] = cnt;
	lowest[0] = cnt;
	for (int i = 0; i < G[0].size(); i++) {
		int v = G[0][i];
		if (!prenum[v]) {
			dfs(v);
			ctree++;
		}
	}
	if (ctree >= 2 && _Arl[0] == 0) {
		Arl.push_back(0);
	}
	sort(Arl.begin(), Arl.end());
	for (vector<int>::iterator it = Arl.begin(); it != Arl.end(); it++)
		cout << *it << endl;
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 6680
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=3005,mod=1000000007;
int n,m,dp[N][N][2],ans;
inline void add(int &a,int b){
	a=a+b>=mod?a+b-mod:a+b;
}
int main(){
	n=read(); m=read();
	dp[0][0][0]=1;
	for(int i=1;i<=n;i++)dp[0][i][1]=1;
	for(int i=0;i<m;i++){	
		for(int j=0;j<=n;j++){
			for(int k=0;k<2;k++){
				if(j<n){add(dp[i+1][j+1][k],dp[i][j][k]); add(dp[i+1][j][k],dp[i][j][k]);}
				if(j){add(j==1?dp[i+1][j-1][0]:dp[i+1][j-1][k],dp[i][j][k]); add(j==1?dp[i+1][j][0]:dp[i+1][j][k],dp[i][j][k]);}
			}
			//cout<<i<<" "<<j<<" "<<dp[i][j][0]<<" "<<dp[i][j][1]<<endl;
		}
	}
	ans=dp[m][0][1];
	for(int i=0;i<=n;i++)add(ans,dp[m][i][0]);
	cout<<ans<<endl;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
#define SC scanf
#define PR printf
#define pb push_back
#define mp make_pair
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define db double
#define ldb long double
#define uint unsigned
#define ll long long
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef map<int,int> mii;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const int xx[4]={1,-1,0,0};
const int yy[4]={0,0,1,-1};
int inline nextin(){
	int t;
	if(scanf("%d",&t)!=1)exit(0);
	return t;
}
int inline in(){
	int x=0,c;
	for(;(uint)((c=getchar())-'0')>=10;){
		if(c=='-')return -in();
		if(!~c)throw ~0;
	}
	do{
		x=(x<<3)+(x<<1)+(c-'0');
	}while((uint)((c=getchar())-'0')<10);
	return x;
}
char p[100005];
int P[100005],S[100005];
int main(){
	int n;
	scanf("%d%s",&n,p);
	for(int i=0;p[i];i++){
		if(p[i]=='o')P[i+1]=0;
		else P[i+1]=1;
	}
	P[n+1]=P[1];
	for(int i=0;i<8;i++){
		S[0]=i&1;
		S[1]=(i>>1)&1;
		S[2]=(i>>2)&1;
		for(int j=2;j<=n+1;j++){
			S[j+1]=S[j-2]^P[j];
		}
		if(S[0]^S[n]^S[1]^S[n+1]||S[1]^S[n+1]^S[2]^S[n+2])continue;
		for(int j=1;j<=n;j++){
			printf("%c",(S[j]^S[j-1])?'W':'S');
		}
		printf("\n");
		return 0;
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

int main()
{
    int h,w;
    while(1){
    scanf("%d %d",&h,&w);
    if(h==0 && w==0)
        break;
    for(int i=0;i<h;i++){
        for(int l=0;l<w;l++){
            if(i%2==0 && l%2==0){
              printf("#");
            }else if(i%2!=0 && l%2==0){
               printf("."); 
            }else if(i%2!=0 && l%2!=0){
               printf("#");
            }else{
                printf(".");
            }
        }
        printf("\n");
    }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2596