akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <set>

int main() {
    int N, temp;
    std::cin >> N;
    
    std::set<int> d;
    for (int i=0; i<N; ++i) {
        std::cin >> temp;
        d.insert(temp);
    }
    
    std::cout << d.size() << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<map>
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<limits.h>
#include<unordered_map>
using namespace std;
int n,m,x;
const int N = 20;
int a[N][N];
int c[N];
int main() {
    int n,m,x; cin >> n >> m >> x;
    for (int i = 0; i < n; i ++) {
        cin >> c[i];
        for (int j = 0; j < m; j ++) {
            cin >> a[i][j];
        }
    }
    long long ans = LLONG_MAX;
    for (int i = 0; i < (1 << n); i ++) {
        vector<int> b(m, 0);
        long long cost = 0;
        for (int j = 0; j < n; j ++) {
            if (i >> j & 1) {
                cost += c[j];
                for (int l = 0; l < m; l ++) {
                    b[l] += a[j][l];
                }
            }
        }
        bool f = true;
        for (int j = 0; j < m; j ++) {
            if (b[j] < x) {
                f = false; break;
            }
        }
        if (f) ans = min(ans, cost);
    }
    if (ans == LLONG_MAX) {
        cout << "-1";
    }
    else
    cout << ans << endl;
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n, m;
	cin >> n >> m;
	
	int a;
	vector<bool> ok(n, true);
	for(int i = 0; i < m; ++i) {
		cin >> a;
		ok[a] = false;
	}
	
	vector<ll> dp(n + 10, 0);
	dp[0] = 1;
	
	for(int i = 0; i < n; ++i) {
		if( ok[i + 1] ) {
			dp[i + 1] += dp[i];
			dp[i + 1] %= MOD_LL;
		}
		
		if( ok[i + 2] ) {
			dp[i + 2] += dp[i];
			dp[i + 2] %= MOD_LL;
		}
	}
	
	cout << dp[n] << endl;
	
	return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

bool is_palindrome(string s)
{
  int n = s.size();
  for (int i = 0; i < n / 2; ++i) {
    if (s[i] != s[n - 1 - i]) { return false; }
  }
  return true;
}

int main()
{
  int A, B;
  scanf("%d %d", &A, &B);
  int ans = 0;
  for (int i = A; i <= B; ++i) {
    string s = to_string(i);
    if (is_palindrome(s)) { ++ans; }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for _ in range(M)]
nodes = [0] * (N + 1)
for a, b in AB:
    nodes[a] += 1
    nodes[b] += 1
for x in nodes:
    if x % 2:
        print('NO')
        exit()
print('YES')


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int n; cin >> n;
  vl a(n); ina(a,n);
  vl nums(1,INFL);
  rep(i,n) {
    auto it = upper_bound(all(nums),-a[i]);
    if (it == nums.end()) {
      nums.pb(-a[i]);
    } else {
      *it = -a[i];
    }
    // outa(nums,nums.size());
  }
  cout << nums.size() << endl;
  return 0;
}


Measured memory_bytes: 2168
from sys import stdin


def main():
    lines = stdin.readlines()
    N, M = map(int, lines[0].split())
    print(sum(1
              for i in range(1 << N)
              if sum(1
                     for s, p in zip(
                         (sum(1 << int(j) - 1
                              for j in i.split()[1:])
                          for i in lines[1:-1]),
                         (int(i) for i in lines[-1].split()))
                     if bin(i & s).count("1") % 2 == p) == M))
    return


main()


Measured memory_bytes: 3064
#define ll long long
#define elif else if

#include <iostream>

using namespace std;

ll n, k;
ll a[100000];
ll l = 0, r = k - 1, temp, mi = 999999999;

int main(){
	cin >> n >> k;
	for (ll i = 0; i < n; i++){
		cin >> a[i];
	}
	for (r = k - 1; r < n; r++){
		if (a[r] <= 0){
			temp = 0 - a[l];
		}
		elif (a[l] >= 0){
			temp = a[r];
		}
		else{
			if (-a[l] < a[r]) temp = 0 - a[l] * 2 + a[r];
			else temp = 0 - a[l] + a[r] * 2;
		}
		if (temp < mi) mi = temp;
		l++;
	}
	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int a;
	char s[11];

	scanf("%d", &a);
	scanf("%s", s);

	if (a >= 3200) //Aが3200以上のとき
	{
		printf("%s\n", s);
	}
	else //3200未満のとき
	{
		printf("red\n");
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int N;
    vector<int> W;
    cin >> N;
    W.resize(N);
    int sum = 0;
    REP(i, N) {
        cin >> W[i];
        sum += W[i];
    }
    int ans = LLINF;
    int cur = 0;
    REP(i, N-1) {
        cur += W[i];
        int diff = sum - cur;
        ans = min(ans, abs(diff - cur));
    }
    printf("%lld\n", ans);
    return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

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

  int n, m;
  cin >> n >> m;

  vvi g(n);
  rep(i,0,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].pb(b);
    g[b].pb(a);
  }

  queue<int> q;

  vi vis(n);
  vi p(n);
  vis[0] = 1;
  q.push(0);
  while (not q.empty()) {
    int u = q.front(); q.pop();
    for (auto v: g[u]) {
      if (not vis[v]) {
        vis[v] = 1;
        p[v] = u;
        q.push(v);
      }
    }
  }

  rep(i,0,n) if (not vis[i]) {
    cout << "No\n";
    return 0;
  }

  cout << "Yes\n";
  rep(i,1,n) cout << p[i]+1 << '\n';
}

Measured memory_bytes: 10604
from operator import itemgetter
n, m = map(int, input().split())
a = list(map(int, input().split()))
op = [list(map(int, input().split())) for _ in range(m)]
op.sort(key=itemgetter(1), reverse=True)
a.sort()

idx = 0
ans = 0
for i in range(n):
    if idx < m and op[idx][1] > a[i]:
        ans += op[idx][1]
    else:
        ans += a[i]

    if idx < m and op[idx][0] > 1:
        op[idx][0] -= 1
    else:
        idx += 1


print(ans)


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

int main() {
  string S, T;
  cin >> S >> T;
  for (int i=0; i<S.size(); i++) {
    if ( S.at(i) != T.at(i) ) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main(void){
    string s,t;cin>>s>>t;
    int ans=0;
    rep(i,3){
        if(s[i]==t[i])ans++;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define f first
#define s second
 
const int N = 1000*1000 + 10;
const ll mod = 1e9 + 7;
const ll inf = 1e16;

ll g[N];

ll pw(ll x, ll n)
{
	if(n == 0)
		return 1;
	if(n%2 == 0)
		return pw(((x%mod)*(x%mod))%mod, n/2)%mod;
	return ((pw(((x%mod)*(x%mod))%mod, n/2)%mod) * (x%mod)) % mod;

}


 
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);	
 
 
 	int n, k;
 	cin >> n >> k;
 	ll ans = 0;
 	for(int i = k; i >= 1; i--)
 	{
 		g[i] = pw(k/i, n);
 		for(int j = 2*i; j <= k; j += i)
 		{
 			g[i] += mod;
 			g[i] -= g[j];
 			g[i] %= mod;
 		}
 		
 		ans += ((g[i]%mod)*(i%mod))%mod;
 		ans %= mod;
 	}
 	cout << ans << endl;

	
	
	
	return 0;
}
 


Measured memory_bytes: 4376
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args) throws IOException
	{
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    int n=Integer.parseInt(br.readLine());
	    long ans=0;
	    for(int i=1;i<=n;i++)
	    {
	        long temp=(long)n/i;
	        ans+=(long)temp*(temp+1)*i/2;
	    }
	    System.out.println(ans);
	}
}


Measured memory_bytes: 32104
n=int(input())
X=list(map(float,input().split()))
Y=list(map(float,input().split()))
for p in range(1,4):
    Dxy=float(0)
    for i in range(n):
        Dxy+=abs(X[i]-Y[i])**p
    Dxy=Dxy**(1/p)
    print(Dxy)
Dxy=float(0)
for i in range(n):
    if Dxy<abs(X[i]-Y[i]):Dxy=abs(X[i]-Y[i])
print(Dxy)


Measured memory_bytes: 5656
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <algorithm>

using namespace std;
#define n_max 100000

int main()
{
    int N; 
    int sum = 0;
    vector<int> a;

    cin >> N;

    for(int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());

    cout << a.size() << endl;

    return 0;
}


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

using namespace std;

int m[2222][1111];
int main()
{
	int n, k;
	cin >> n >> k;
	int kk = k * 2;
	for (int i = 0; i < n; i++) {
		int x, y; char c;
		scanf("%d%d %c", &x, &y, &c);
		x %= kk, y %= kk;
		if (y >= k) {
			y -= k;
			x = (x + k) % kk;
		}
		if (c == 'B')
			x = (x + k) % kk;
		m[x + 1][y + 1]++;
	}
	for (int i = 0; i < kk; i++)
		for (int j = 0; j < k; j++)
			m[i + 1][j + 1] += m[i + 1][j];
	for (int j = 0; j < k; j++)
		for (int i = 0; i < kk; i++)
			m[i + 1][j + 1] += m[i][j + 1];
	int a = 0;
	for (int i = 0; i < kk; i++) {
		if (i < k)
			for (int j = 0; j < k; j++)
				a = max(a, m[i + k][k] + m[kk][j] - m[i + k][j] - m[i + k][j] - m[i][k] + m[i][j] + m[i][j]);
		else
			for (int j = 0; j < k; j++)
				a = max(a, m[kk][k] - m[i][k] - m[kk][j] + m[i][j] + m[i][j] + m[i - k][k] - m[i - k][j] - m[i - k][j]);
	}
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, X;
  cin >> N >> X;
  vector<int> a(N);
  int sum = 0;
  int rest = 0;
  int min = 1 << 30;
  int ans = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    if(min > a[i]){
      min = a[i];
    }
    sum += a[i];
  }
  rest = X - sum;
  ans= rest/min + N;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] s = new long[n + 1];
            long cur = 0;
            for (int i = 1; i <= n; ++i) {
                cur += in.nextInt();
                s[i] = cur;
            }
            Arrays.sort(s);
            long res = 0;
            for (int i = 0; i < s.length; ) {
                int j = i;
                while (j < s.length && s[i] == s[j]) ++j;
                res += (j - i) * (long) (j - i - 1) / 2;
                i = j;
            }
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main(){
int N;
  cin>>N;
  vector<int>d(N);
  for(int i=0; i<N; i++){
   cin>>d[i];
  }
  
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  
  int ans=0;
  for(int i=0; i<N; i++){
   if(d[i]>d[i+1]){ans++;}
  }
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void){
	int m1,m2,m3,i,a=0;
	for(i=0;i<10;i++){
		scanf("%d",&a);
		if(m1<a){
			m3=m2;
			m2=m1;
			m1=a;
		}else{
			if(m2<a){
				m3=m2;
				m2=a;
			}else{
				if(m3<a){
					m3=a;
				}
			}
		}
	}
	printf("%d\n%d\n%d\n",m1,m2,m3);
	return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <vector>
using namespace std;

int N, M;
int Q;
vector<vector<int> > G(100010);
int a, b;
int v[100010], d[100010], c[100010];
int tm[11][100010];
int color[11][100010];

void solve()
{
	int i, j, k;
	for(i=0; i<=10; i++){
		for(j=0; j<N; j++)
			tm[i][j] = -1;
	}
	for(i=0; i<Q; i++){
		//if(tm[d[i]][v[i]] != -1)
		tm[d[i]][v[i]] = i;
		color[d[i]][v[i]] = c[i];
	}
	for(i=10; i>0; i--){
		for(j=0; j<N; j++){
			if(tm[i][j] == -1)
				continue;
			if(tm[i][j] > tm[0][j]){
				tm[0][j] = tm[i][j];
				color[0][j] = color[i][j];
			}
			for(k=0; k<G[j].size(); k++){
				int uu = G[j][k];
				if(tm[i][j] > tm[i-1][uu]){
					tm[i-1][uu] = tm[i][j];
					color[i-1][uu] = color[i][j];
				}
			}
		}
	}
	for(i=0; i<N; i++){
		printf("%d\n", color[0][i]);
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int i;
	scanf("%d%d", &N, &M);
	for(i=0; i<M; i++){
		scanf("%d%d", &a, &b);
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	scanf("%d", &Q);
	for(i=0; i<Q; i++){
		scanf("%d%d%d", &v[i], &d[i], &c[i]);
		v[i] --;
	}
	solve();
	return 0;
}

Measured memory_bytes: 16896
using System;
using System.IO;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
    
namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string strFormula = Console.ReadLine();
            string[] elem = strFormula.Split(' ');
            List<int> array = new List<int>();
            foreach(string str in elem)
            {
                if (isNumeric(str))
                {
                    push(array,int.Parse(str));
                }
                else
                {
                    int last = 0;
                    int fore = 0;
                    switch (str)
                    {
                        case "+":
                            last = pop(array);
                            fore = pop(array);
                            push(array,(fore + last));
                            break;
                        case "-":
                            last = pop(array);
                            fore = pop(array);
                            push(array, (fore - last));
                            break;
                        case "*":
                            last = pop(array);
                            fore = pop(array);
                            push(array, (fore * last));
                            break;
                    }
                        
                }
            }
            Console.WriteLine(array[0]);
        }

        private static void push(List<int> array,int elem)
        {
             array.Add(elem);
        }

        private static int pop(List<int> array)
        {
            int result = array[array.Count - 1];
            array.RemoveAt(array.Count - 1);
            return result;
        }
        
        public static bool isNumeric(string str)
        {
            bool result = true;
            try
            {
                int.Parse(str);
            }
            catch
            {
                result = false;
            }

            return result;
        }

         
        
    }
}

Measured memory_bytes: 9256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int H,W,h,w;
  cin >>H>>W>>h>>w;
  vector<vector<int>> v(H, vector<int>(W,0));//0=＝白
  rep(i,h) rep(j,W)v[i][j]=1;
  rep(i,H) rep(j,w)v[i][j]=1;
  
  int ans =0;
  rep(i,H)rep(j,W){
    if(v[i][j]==0)ans++;
  }
  cout<<ans<<endl;
  return 0;
    
  
}


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

int main(){
  string s;
  cin >> s;
  if(s=="SUN")
    cout << 7;
  if(s=="MON")
    cout << 6;
  if(s=="TUE")
    cout << 5;
  if(s=="WED")
    cout << 4;
  if(s=="THU")
    cout << 3;
  if(s=="FRI")
    cout << 2;
  if(s=="SAT")
    cout << 1;
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    int X = max(A,max(B,C));
    int D[3];
    D[0] = X - A;
    D[1] = X - B;
    D[2] = X - C;
    int S = D[0] + D[1] + D[2];
    
    if(D[0] % 2 == 0 && D[1] % 2 == 0 && D[2] % 2 == 0)
    {
    	cout << S/2 << endl;
    }
    else if(S % 2 == 0)
    {
    	cout << S/2 << endl;
    }
    else 
    {
    	cout << (S+1)/2 + 1<< endl;
    }

	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	llint n; cin >> n;
	llint power = 1;
	for (int i = 1; i <= n; i++) {
		power *= i;
		power %= 1000000007;
	}
	cout << power << endl;
	return 0;
}

Measured memory_bytes: 256
import math

c60 = math.cos(math.radians(60))
s60 = math.sin(math.radians(60))

def koch(d, p1, p2):
    """ Print the coordinates of the vertices of Koch Curve.
    d is the depth of recursion.
    p1, p2 are coordinates of end point of the initial state.
    """
    if d == 0:
        return

    sx = (2 * p1[0] + p2[0]) / 3
    sy = (2 * p1[1] + p2[1]) / 3

    tx = (p1[0] + 2 * p2[0]) / 3
    ty = (p1[1] + 2 * p2[1]) / 3

    dx = tx - sx
    dy = ty - sy

    ux = dx * c60 - dy * s60 + sx
    uy = dx * s60 + dy * c60 + sy

    koch(d - 1, p1, (sx, sy))
    print("{0:.8f} {1:.8f}".format(sx, sy))

    koch(d - 1, (sx, sy), (ux, uy))
    print("{0:.8f} {1:.8f}".format(ux, uy))

    koch(d - 1, (ux, uy), (tx, ty))
    print("{0:.8f} {1:.8f}".format(tx, ty))

    koch(d - 1, (tx, ty), p2)


n = int(input())

ax = 0
ay = 0

bx = 100
by = 0

print("{0:.8f} {1:.8f}".format(ax, ay))
koch(n, (ax, ay), (bx, by))
print("{0:.8f} {1:.8f}".format(bx, by))

Measured memory_bytes: 7928
#include <stdio.h>
typedef long long ll;
const ll M = 1000000007;
ll fact[400001]={1,};
ll powmod(ll a, ll n){
    ll ret = 1;
    for(int i=0;i<31;i++){
        if(n&(1<<i)){
            ret = (ret*a)%M;
        }
        a = (a*a)%M;
    }
    return ret;
}
ll inverse(ll x){
    return powmod(x,M-2);
}
ll comb(int n, int x){
    ll ret = fact[n];
    ret = (ret*inverse(fact[n-x]))%M;
    ret = (ret*inverse(fact[x]))%M;
    return ret;
}

int main(){
    for(int i=1;i<=400000;i++){
        fact[i] = (fact[i-1]*i)%M;
    }
    int N,K;
    scanf("%d %d",&N,&K);
    if(K>=N-1) printf("%lld",comb(2*N-1,N));
    else{
        ll ret = 0;
        for(int i=N-K;i<=N;i++){
            ll c = comb(N,i);
            c = (c*c)%M;
            ll d = (i*inverse(N))%M;
            ret += (c*d)%M;
            ret%=M;
        }
        printf("%lld",ret);
    }
}


Measured memory_bytes: 3328
n = int(input())
f = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]
ans = []
for i in range(1,2**10):
    a = [0]*n
    for j in range(10):
        if i >> j & 1:
            for k in range(n):
                a[k] += f[k][j]
    ans.append(sum([p[i][a[i]] for i in range(n)]))
print(max(ans))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<numeric>
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
const int maxn=1000000;
#define what_is(x) cerr << #x << " is " << x << endl;
const int MOD = 1e9 + 7;
using namespace std;
string abc="abcdefghijklmnopqrstuvwxyz";
int powmod(int a, int b, int MOD = MOD){
    if(!a and !b)    return 1ll;
    if(!a)    return a;
    int res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)    res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
bool check(int n) {return (((double)sqrt(n)-floor((double)sqrt(n)))==0);}
vector<bool> sieve(maxn + 1, true);
void fillprime() {
    sieve[0] = sieve[1] = false;
    for (int i = 2; i <= maxn; ++i) {
        if (sieve[i] && (int) i * i <= maxn) {
            for (int j = i * i; j <= maxn; j += i) {
                sieve[j] = false;
            }
        }
    }
}
const int nn=1e5+5;
void solve() {
       int n;
       cin>>n;
       if(n%1000==0)
       {
           cout<<0;
           return;
       }
       cout<<(((n/1000)+1)*1000)-n;
}

int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //fillprime();
    //int t;cin>>t;while(t--)
        solve();
}

Measured memory_bytes: 3756
A = input()
B = input()
C = input()

a = b = c = 0
turn = "a"

while 1:
    if turn == "a":
        if a == len(A):
            print("A")
            break
        turn = A[a]
        a += 1
    elif turn == "b":
        if b == len(B):
            print("B")
            break
        turn = B[b]
        b += 1
    else:
        if c == len(C):
            print("C")
            break
        turn = C[c]
        c += 1

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

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

    int n;
    while(cin >> n && n){

        int data[10] = {};
        for(int i = 0; i < n; ++i){
            int a;
            cin >> a;
            data[a] ++;
        }

        for(int i = 0; i < 10; ++i){
            if(data[i] == 0){
                cout << '-' << endl;
            }
            else {
                for(int j = 0; j < data[i]; ++j){
                    cout << '*';
                }
                cout << endl;
            }
        }
    }

   return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>


using namespace std;

int num(int x){
  int ret = 0;
  while (x > 0){
    ret += x%10;
    x /= 10;
  }
  return ret;
}
int main(){
  string A, B, s, t;
  int a, b, N, i, j, k, cnt=0;
  cin >> A >> B;

  a = stoi(A);
  b = stoi(B);
  for (i = a; i <= b; i++){
    s = to_string(i);
    t = s;
    reverse(t.begin(), t.end());
    if (s == t)
      cnt ++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, m; cin >> n >> m;
	vector<vector<ll>> g(n);
	
	zep(i, 0, m){
		ll a, b; cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	vector<bool> use(n, 0);
	vector<ll> ans(n);
	use[0] = true;
	queue<ll> q;
	q.push(0);
	while(!q.empty()){
		ll at = q.front(); q.pop();
		
		zep(i, 0, g[at].size()){
			ll nx = g[at][i];
			if(!use[nx]){
				ans[nx] = at;
				use[nx] = true;
				q.push(nx);
			}
		}
	}
	
	print("Yes")
	zep(i, 1, n){
		print(ans[i]+1)
	}
	return 0;
}

Measured memory_bytes: 13092
#include <iostream>
#include <string>
#include <vector>

using namespace std;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_C&lang=jp
// 安定ソート
static void printArray(vector<string> vector) {
    int size = vector.size();
    for (int i = 0; i < size; ++i) {
        if (i == size - 1) {
            cout << vector[i] << endl;
        } else {
            cout << vector[i] << " ";
        }
    }
}

static string isStable(vector<string> in, vector<string> out) {
    int N = in.size();
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            for (int a = 0; a < N; ++a) {
                for (int b = a + 1; b < N; ++b) {
                    if (in[i].substr(1, 1) == in[j].substr(1, 1) && in[i] == out[b] && in[j] == out[a]) {
                        return "Not stable";
                    }
                }
            }
        }
    }
    return "Stable";
}


int main() {
    int N;
    cin >> N;
    vector<string> cards(N);

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

    vector<string> bubbleCards(N);
    bubbleCards = cards;

    vector<string> selectionCards(N);
    selectionCards = cards;

    // Bubble Sort
    for (int i = 0; i < N; ++i) {
        for (int j = N - 1; j > i; --j) {
            if (bubbleCards[j].substr(1, 1) < bubbleCards[j - 1].substr(1, 1)) {
                swap(bubbleCards[j], bubbleCards[j - 1]);
            }
        }
    }

    // printArray(bubbleCards);
    // cout << isStable(cards, bubbleCards) << endl;

    // Selection Sort
    for (int i = 0; i < N; ++i) {
        int minj = i;
        for (int j = i; j < N; ++j) {
            if (selectionCards[j].substr(1, 1) < selectionCards[minj].substr(1, 1)) {
                minj = j;
            }
        }
        swap(selectionCards[i], selectionCards[minj]);
    }

    // printArray(selectionCards);
    //cout << isStable(cards, selectionCards) << endl;

    printArray(bubbleCards);
    // cout << "D2 C3 H4 S4 C9" << endl;
    // cout << "Stable" << endl;
    cout << isStable(cards, bubbleCards) << endl;

    printArray(selectionCards);
    // cout << "D2 C3 S4 H4 C9" << endl;
    //cout << "Not stable" << endl;
    cout << isStable(cards, selectionCards) << endl;
    return 0;
}




Measured memory_bytes: 3216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String str = br.readLine();
			if(str==null){
				break;
			}
			String s[] =str.split(" ");
			Stack<Double> stack = new Stack<Double>();
			for(int i = 0; i < s.length;i++){
				if(s[i].equals("+")){
					double a = stack.pop();
					double b = stack.pop();
					stack.push(a+b);
				}
				else if(s[i].equals("-")){
					double a = stack.pop();
					double b = stack.pop();
					stack.push(b-a);
				}
				else if(s[i].equals("*")){
					double a = stack.pop();
					double b = stack.pop();
					stack.push(a*b);
				}
				else if(s[i].equals("/")){
					double a = stack.pop();
					double b = stack.pop();
					stack.push(b/a);
				}
				else{
					stack.push(Double.parseDouble(s[i]));
				}
			}
			System.out.printf("%.6f\n", stack.pop());
		}

	}

}

Measured memory_bytes: 12000
import math
a, b, x = map(int, input().split())
if x/a < a*b/2:
  theta = math.atan(2*x/(b*b*a))
  print(90-math.degrees(theta))
else:
  theta = math.atan((2*a*b*a-2*x)/(a*a*a))
  print(math.degrees(theta))


Measured memory_bytes: 38640
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

s = input()
t = input()

ans = float('inf')
for i in range(len(s)-len(t)+1):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            cnt += 1
    ans = min(ans,cnt)

print(ans)

Measured memory_bytes: 31168
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	double x[3], y[3];
	for (int i = 0; i < 3; i++) {
		cin >> x[i] >> y[i];
	}
	for (int i = 2; i >= 0; i--) {
		x[i] -= x[0];
		y[i] -= y[0];
	}
	double a[3], aa = 0;
	for (int i = 0; i < 3; i++) {
		int j = i + 1;
		a[i] = hypot(x[i] - x[j % 3], y[i] - y[j % 3]);
		aa += a[i];
	}
	double r = abs(x[2] * y[1] - x[1] * y[2]) / aa;
	double ans = 0;
	cerr << r << endl;
	for (int i = 0; i < 3; i++) {
		ans = max(ans, a[i] / (2 + a[i] / r));
	}
	cout << setprecision(20) << fixed << ans << endl;
	return 0;	
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
using namespace std;
using ll = long long;

const ll MOD = static_cast<ll>(1e9 + 7);

int main() {
    ll N, M; cin >> N >> M;
    vector<ll> A(M);
    for (auto &a : A) cin >> a;
    vector<ll> DP(N + 1, 0);
    for (auto a : A) DP[a] = -1;
    DP[0] = 1;
    if (DP[1] != -1) DP[1] = 1;
    for (int i = 2; i <= N; i++) {
        if (DP[i] == -1) continue;
        if (DP[i - 2] != -1) DP[i] += DP[i - 2];
        if (DP[i - 1] != -1) DP[i] += DP[i - 1];
        DP[i] %= MOD;
    }
    cout << DP[N] % MOD << endl;
}

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

const long long mod=1e9+7;
const int N=2e5+7;
string s;


int main()
{
   cin>>s;
   if(s.size()==2)
   {
   	if(s[0]==s[1])
   	   cout<<1<<" "<<2<<endl;
   	else
   	  cout<<-1<<" "<<-1<<endl;
   	  return 0;
   }
   for(int i=2;i<s.size();i++)
   {
   	  if(s[i]==s[i-1]||s[i]==s[i-2]||s[i-2]==s[i-1])
   	  {
   	  	cout<<i-1<<" "<<i+1<<endl;
   	  	return 0;
	  }
   }
   cout<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 512
import itertools
N,M = map(int,input().split())
switch = [list(map(int,input().split())) for m in range(M)]
p = list(map(int,input().split()))
S = list(itertools.product([0,1], repeat=N))
ans = 0
for s in S:
    s_ok = 0
    for m in range(M):
        count = 0
        for i in range(1, len(switch[m])):
            if s[switch[m][i]-1] == 1:
                count += 1
        if count%2 == p[m]:
            s_ok += 1
        else:
            break
    if s_ok == M:
        ans += 1
print(ans)


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

using namespace std;

const int MOD = 1000000007;

template<typename T>
class SegTree {
public:
    explicit SegTree(int n, T def) : N(calcN_(n)), def(def), mVal(2*calcN_(n)-1, def) {}
    void update(int idx, T value){
        int i = N + idx - 1;
        update_(mVal[i], value);
        while(i > 0){
            i = (i-1)/2;
            mVal[i] = operate(mVal[2*i+1], mVal[2*i+2]);
        }
    }
    T get(int l, int r){
        l = max(0, l);
        r = min(N, r);
        int offset = N;
        T resL = def;
        T resR = def;
        while(offset > 0){
            if(l >= r) break;
            if(l&1){ resL = operate(resL, mVal[offset+l-1]); l++; }
            if(r&1){ resR = operate(mVal[offset+r-2], resR); }
            l /= 2;
            r /= 2;
            offset /= 2;
        }
        return operate(resL, resR);
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    void update_(T& data, T val) { data = val; }
    T operate(T a, T b) { return a+b; }
    const int N;
    const T def;
    vector<T> mVal;
};

int main(){
    int N; cin >> N;
    vector<long long> fact(N+1);
    fact[0] = fact[1] = 1;
    for(int i=2;i<=N;i++) fact[i] = fact[i-1] * i % MOD;
    const long long inv2 = MOD - MOD/2;
    vector<int> a(N);
    vector<int> forget(N+1, 1);
    int forgetSum = 0;
    for(auto& t : a){
        cin >> t;
        forget[t] = 0;
        --t;
    }
    for(int i=0;i<N;i++) if(forget[i+1]) forgetSum = (forgetSum + i) % MOD;
    for(int i=0;i<N;i++) forget[i+1] += forget[i];
    const int M = forget.back();
    long long res = fact[M];
    long long dec = 0;
    int cnt = 0;
    SegTree<int> seg(N, 0);
    for(int i=0;i<N;i++){
        if(a[i] == -1){
            long long sum = forgetSum * fact[M-1] % MOD;
            sum = (sum + MOD - cnt * fact[M] % MOD * inv2 % MOD) % MOD;
            sum = (sum + MOD - dec) % MOD;
            res += sum * fact[N-1-i];
            res %= MOD;
            ++cnt;
        } else {
            long long sum = (a[i] - seg.get(0, a[i])) * fact[M] % MOD;
            long long less = forget[a[i]+1];
            sum = (sum + MOD - less * cnt % MOD * fact[M-1] % MOD) % MOD;
            res += sum * fact[N-1-i];
            res %= MOD;
            dec += (M-less) * fact[M-1];
            dec %= MOD;
            seg.update(a[i], 1);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 15124
/*
* @Author: Kabid
* @Date:   2020-04-19 17:59:10
*/

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#define in(x)  scanf("%d", &x);
#define ins(x)  scanf("%s", &x);
#define out(x) printf("%d", x);
#define lin puts("");
#define _ putchar(' ');

int main(){
	int r;
	double pi=acos(-1);
	scanf("%d",&r);
	printf("%lf",2*pi*(double)r);

	
    return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int curr = 0;
    int ans = 0;
    for(int i=0;i<s.length();i++){
        if(s[i] == 'R'){
            curr++;
        }
        else{
            ans = max(curr,ans);
            curr = 0;
        }
    }
    ans = max(curr,ans);
    cout<<ans;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> h(n+1);
    for(int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    h[n] = 0;

    int ans = 0;
    while(true)
    {
        bool flag = false;
        int bpos = 0, nmin = 0;
        for(int i = 0; i <= n; i++)
        {
            if(h[i] != 0)
            {
                if(nmin == 0) nmin = h[i];
                else
                {  
                    nmin = min(nmin, h[i]);
                }
                flag = true;
                continue;
            }

            for(int j = bpos; j < i; j++)
            {
                h[j] -= nmin;
            }
            bpos = i + 1;
            ans += nmin;
            nmin = 0;
        }
        if(!flag) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        string s = sc.Next();
        Console.WriteLine(s.Contains('7') ? "Yes" : "No");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 25888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N , M;
cin >> N >> M;
vector<int>wakaisuu(N,0);
vector<int>ackaisuu(N,0);
int ac,pen;
ac = 0; pen = 0;
for (int i=0; i < M; i++){
 int p;
 string s;
 cin >> p >> s;
 if (s == "AC"){
 if (ackaisuu.at(p-1)==0){ac++; ackaisuu.at(p-1) ++; pen += wakaisuu.at(p-1);}
 }
 
 else{wakaisuu.at(p-1) ++;}
 }
  cout << ac << ' ' << pen << endl;
}

Measured memory_bytes: 1024
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


h, w = inpl()
A = []
for i in range(h):
    a = list(input())
    A.append(a)

comp = []
for i in range(h):
    for j in range(w):
        if A[i][j] == '#':
            comp.append([1 for _ in range(w)])
            break
    else:
        comp.append([0 for _ in range(w)])

B = list(zip(*A))[:]
comp = list(zip(*comp))[:]
for i in range(w):
    for j in range(h):
        if B[i][j] == '#':
            # comp[i] = list(comp[i])
            break
    else:
        comp[i] = [0 for _ in range(h)]

comp = list(zip(*comp))[:]


ans = []
for i in range(h):
    tmp = []
    for j in range(w):
        if comp[i][j] == 1: tmp.append(A[i][j])
    if tmp != []:
        ans.append(tmp)


for i in range(len(ans)):
    print(''.join(ans[i]))

Measured memory_bytes: 3444
#include<queue>
#include<cstdio>
#include <stdio.h>
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX_W 100
#define MAX_H 100
#define MAX_N 500
using namespace std;
const int INF = 100000000;
typedef pair<int, int> P;

int N,W,H,S,T,X,Y,x,y;
int iX[MAX_N];
int iY[MAX_N];
int M[MAX_H][MAX_W];
int count[MAX_H][MAX_W];
bool check[MAX_H][MAX_W];
int dx[2] = {1,0};
int dy[2] = {0,1};

int main(){
  while(true){
    cin >> N;
    if(N == 0){
      break;
    }
    cin >> W >> H;
    rep(i,N){
      cin >> X >> Y;
      iX[i] = X;
      iY[i] = Y;
    }
    cin >> S >> T;
    rep(i,H){
      rep(j,W){
        M[i][j] = 0;
        count[i][j] = 0;
      }
    }
    rep(i,N){
      M[iY[i] - 1][iX[i] -1] = 1;
    }

    rep(i,H-T+1){
      rep(j,W-S+1){
        rep(k,H){
          rep(l,W){
            check[k][l] = false;
          }
        }
        queue<P> que;
        que.push(P(j,i));
        if(M[i][j] == 1){
          count[i][j] = 1;
        }
        check[i][j] = true;
        while(que.size()){
          P q = que.front();que.pop();
          rep(k,2){
            int nx = q.first + dx[k], ny = q.second + dy[k];
            if(0 <= nx && nx < j + S && 0 <= ny && ny < i + T && check[ny][nx] == false){
              if(M[ny][nx] == 1)
                count[i][j] += 1;
              que.push(P(nx,ny));
              check[ny][nx] = true;
            }
          }
        }
      }
    }
    int m = 0;
    rep(i,H-T+1){
      rep(j,W-S+1){
        if(count[i][j] > m)
          m = count[i][j];
        }
      }
      printf("%d\n",m);
    }
  }


Measured memory_bytes: 3244
N, m = map(int, input().split())
mlist = sorted(list(map(int, input().split())))

ilist = [i for i in range(N+1)] #1행 (앞으로 i행)

for i in range(m-1):  #i행
    cm = mlist[i+1]
    copy1 = ilist[:]   #(i-1)행
    for k in range(1,N+1):    #k열
        if (cm > k):
            ilist[k] = copy1[k]
        else:
            ilist[k] = min(copy1[k], (ilist[k-cm] + 1))
print(ilist[-1])


Measured memory_bytes: 9844
import java.util.*;

class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = 0;
        for (int i = 0; i < 5; i++) {
            x = sc.nextInt();
            if (x == 0) {
                System.out.println(i + 1);
            }
        }

    }
}

Measured memory_bytes: 35560
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N, M;
    std::cin >> N >> M;

    std::vector<int> a(M);
    std::vector<int> b(M);

    for (int i = 0; i < M; i++) {
        std::cin >> a[i] >> b[i];
    }

    bool flag = false;
    std::set<int> s;
    for (int i = 0; i < M; i++) {
        if (b[i] == N) {
            s.insert(a[i]);
        }
    }
    for (int i = 0; i < M; i++) {
        if (a[i] == 1) {
            auto it = s.find(b[i]);
            if (it != s.end()) {
                flag = true;
                break;
            }
        }
    }

    if (flag) {
        std::cout << "POSSIBLE" << std::endl;
    } else {
        std::cout << "IMPOSSIBLE" << std::endl;
    }
    return 0;
}

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    ll N; cin >> N;
    vector<ll> A(N+1,1);
    ll ans = 0;
    for(int i = 2; i <= N; ++i) {
        for(int j = i; j <= N; j += i) A[j]++;
    }
    for(int i = 1; i <= N; ++i) {
        ans += A[i]*i;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 81392
#include<iostream>
#include<string>
using namespace std;
int main(){
	string str,word;
	int i,counter=0;
	getline(cin,word);
	for(i=0;i<word.size();i++){
		if(word[i]>='A' && word[i]<='Z'){
			word[i]+='a'-'A';
		}
	}
	while(1){
	cin>>str;
		if(str=="END_OF_TEXT"){
			break;
		}
		for(i=0;i<str.size();i++){
		if(str[i]>='A' && str[i]<='Z'){
			str[i]+='a'-'A';
		}
		}
		if(str==word){
			counter++;
		}
	}
	cout<<counter<<endl;
	return 0;

}

Measured memory_bytes: 3120