akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;


namespace _507_Square
{
	class Program
	{
		static void Main ( string[] args )
		{
			while (true)
			{
				//input
				int num = int.Parse (Console.ReadLine ());

				if (num == 0)
				{
					break;
				}

				//process
				Square square = new Square (num);
				square.Play ();
			}
		}
	}

	class Square
	{
		public Square ( int num )
		{
			NumArray = new int[num];
			NumArray[0] = num;
			ContentIndex = 0;
		}

		private int[] NumArray { set; get; }
		private int ContentIndex { set; get; }

		//?????£????????????????????????????????????
		public void Play ()
		{
			bool continueFlag = true;
			while (continueFlag)
			{
				Print ();
				continueFlag = Operate ();
			}
		}

		//??????????????????
		//???????????\??????true????????\????????£??????false?????????
		private bool Operate ()
		{
			//??????????????????????????¢???????????????
			for (int index = NumArray.Length - 1; 0 <= index; index--)
			{
				//1????????????0??????????????????
				if (NumArray[index] - 1 > 0)
				{
					//1?????????????????????1??????????????¨????????£?????§?°???¢???????´?????????????
					for (int rightIndex = 1; rightIndex + index < NumArray.Length; rightIndex++)
					{
						if (NumArray[index] - 1 >= NumArray[index + rightIndex] + 1)
						{
							//1??????
							NumArray[index] -= 1;

							//???????????????????????????????????????????????¨??????????´???¨???????¶????????????????
							int sum = 1;
							for (int lp = index + 1; lp <= ContentIndex; lp++)
							{
								sum += NumArray[lp];
							}

							//??§?°???¢???????????????????????????
							int allocateNum = NumArray[index];
							int count = 1;
							while (sum > allocateNum)
							{
								NumArray[index + count] = allocateNum;
								sum -= allocateNum;
								count++;
							}
							NumArray[index + count] = sum;

							//?????????
							for (int lp = index + count + 1; lp <= ContentIndex; lp++)
							{
								NumArray[lp] = 0;
							}

							//????????????????¨??????????
							ContentIndex = index + count;

							return true;
						}
					}
				}
			}

			return false;
		}

		//??????????????????????????????
		private void Print ()
		{
			for (int lp = 0; lp < ContentIndex; lp++)
			{
				Console.Write (NumArray[lp] + " ");
			}
			Console.WriteLine (NumArray[ContentIndex]);
		}
	}
}

Measured memory_bytes: 9196
def university(xxx, pattern):
    tate = 0
    yoko = 1
    for current_tate in range(8-xxx[tate]+1):
        for current_yoko in range(8-xxx[yoko]+1):
            if absolutely_fantastic(current_tate, current_yoko):
                return True

def absolutely_fantastic(current_tate, current_yoko):
    tate = 0
    yoko = 1
    run = []
    for add_tate in range(xxx[tate]):
        for add_yoko in range(xxx[yoko]):
            run.append(mapppp[current_tate+add_tate][current_yoko+add_yoko])
    if run == pattern:
        print xxx[2]
        return True

A = {(2,2,'A'):[1,1,1,1]}
B = {(4,1,'B'):[1,1,1,1]}
C = {(1,4,'C'):[1,1,1,1]}
D = {(3,2,'D'):[0,1,1,1,1,0]}
E = {(2,3,'E'):[1,1,0,0,1,1]}
F = {(3,2,'F'):[1,0,1,1,0,1]}
G = {(2,3,'G'):[0,1,1,1,1,0]}
lis = [A,B,C,D,E,F,G]
mapppp = []
while True:
    try:
        for i in range(8):
            input_line = raw_input()
            yoko = [int(char) for char in input_line]
            mapppp.append(yoko)
        for XXX in lis:
            flag = False
            for xxx, pattern in XXX.items():
                if university(xxx, pattern):
                    flag = True
                    break
            if flag == True:
                break
        mapppp = []
        raw_input()
    except EOFError:
        break

Measured memory_bytes: 4344
import java.util.*;

public class Main{
    int n,m;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            n = sc.nextInt();
            m = sc.nextInt();
            if(n==0 && m==0) break;

            PriorityQueue<int[]> q 
                = new PriorityQueue<int[]>(n,new Comparator<int[]>(){
                        public int compare(int[] a, int[] b){
                            return b[1]-a[1];
                        }
                    });

            for(int i=0; i<n; i++){
                int d = sc.nextInt();
                int p = sc.nextInt();
                q.add(new int[]{d,p});
            }

            int ans = 0;
            while(q.size()>0){
                int[] qq = q.poll();
                int d = qq[0], p = qq[1];
                while(m>0 && d>0){
                    m--;
                    d--;
                }
                while(d>0){
                    d--;
                    ans += p;
                }
            }

            System.out.println(ans);
        }
    }

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

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };
 
typedef long long ll;
using namespace std;
 
int main() {
  int a,b;
  while(cin >> a >> b){
    a += b;
    int count = 0;
    
    while(a != 0){
       a /= 10;
      count++;
    }
    
    pout(count);
  }
  return 0;
}


Measured memory_bytes: 3112
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
A = iil()
B = iil()
rep = 0
ans = 0
for i,item in enumerate(B):
    ans += min(A[i],item+rep)
    rep = max(0, item - max(0, A[i] - rep))
print(ans+min(A[-1],rep))

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


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

int dist[301][301];
void WF(int num){
	for(int k = 0;k < num;k++){
		for(int i = 0;i < num;i++){
			for(int j = 0;j < num;j++){
				dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j]);
			}
		}
	}
}

int main(){
	
	int h,w;cin >> h >> w;
	REP(i,10)REP(j,10)cin >> dist[i][j];
	WF(10);
	int ans = 0;
	REP(i,h)REP(j,w){
		int tmp;cin >> tmp;
		if(tmp != -1){
			ans += dist[tmp][1];
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;vector<ll>arr;
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    inarr(n);
    ll check=0;
    for(int i=0;i<n;i++){
        in(temp);arr.push_back(temp);
        check^=temp;
    }
    for(int i=0;i<n;i++){
        cout<<(check^arr[i])<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 5332
#include<bits/stdc++.h>
using namespace std;
int a[1000006];
void sieve()
{
    for(int i=4;i<=1000000;i+=2)a[i]=1;
    for(int i=3;i<=sqrt(1000000);i+=2)
    {
        if(a[i]==0)
        {
            for(int j=i+i;j<=1000000;j+=i)a[j]=1;
        }
    }
}
int main()
{
    int x;
    sieve();
    scanf("%d",&x);
    if(a[x]==0)printf("%d",x);
    else
    {
        for(int i=x+1;i<1000000;i++)
            if(a[i]==0)
        {
            printf("%d",i);
            break;
        }
    }
return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	ll n, m, x[114514], y[114514];
	cin>>n>>m;
	REP(i, n){
		cin>>x[i];
	}
	REP(i, m){
		cin>>y[i];
	}
	ll h=0;
	REP(i, n-1){
		h=(h+(x[i+1]-x[i])*(n-i-1)*(i+1))%MOD;
	}
	ll w=0;
	REP(i, m-1){
		w=(w+(y[i+1]-y[i])*(m-i-1)*(i+1))%MOD;
	}
	cout<<(w*h)%MOD<<'\n';
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int arr[105];
int k;

void solve(){
   scanf("%d",&k); 
   for(int i = 1;i <= k;i = i + 1){
    scanf("%d",&arr[i]);
    if(arr[i] % 2 ==0){
      if(arr[i] % 5 !=0 && arr[i] % 3 !=0){
        printf("DENIED\n");
        return;
      }
    }
   }
 printf("APPROVED\n");
 return;
}

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

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

int main(){
    int a,b,c,d,e,k;
    
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    cin >> k;
    
    int max = std::max({a,b,c,d,e});
    int min = std::min({a,b,c,d,e});
    
    if(max - min > k){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace Multiplication_A
{
    class Calc
    {
        static void Main(string[] args)
        {
            var inp = (Console.ReadLine());
            string[] cal = inp.Split(' ');
            int A = int.Parse(cal[0]);
            int B = int.Parse(cal[1]);

            Console.WriteLine("{0}",A*B);
        }
    }
}


Measured memory_bytes: 17888
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int ans = 0;
    for(int i = 1; i <= N; i++){
      if((1 <= i && i < 10) || (100 <= i && i < 1000) || (10000 <= i && i < 100000)){
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 24404
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007LL;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1LL;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll a[(1 << 18) + 10];

int main(void) {

  int n, D;
  
  scanf("%d", &D);
  n = 1 << D;
  
  rep(i, n) scanf("%lld", &a[i]);

  

  vector<ll> ans(n + 10);
  vector< pair<ll, ll> > b(n + 10);
  vector<int> c(D + 10);
  

  b[0].first = 0;
  b[0].second = -1;
  b[1].first = 1;
  b[1].second = -1;

  
  ans[1] = a[0] + a[1];
  printf("%lld\n", ans[1]);

  
  for (int k = 2; k < n; k++) {
    c.clear();
    int j = 0;
    for (int i = 0; i <= D; i++) {
      if ((k >> i) & 1) c[j++] = i;
    }
    
    vector<ll> d;
    for (int i = j - 2; i >= 0; i--) {
      d.push_back(b[k - (1 << c[i])].first);
      if (b[k - (1 << c[i])].second != -1) {
	d.push_back(b[k - (1 << c[i])].second);
      }
    }
    d.push_back(k);
      
    int f = d[0], s = -1;

    for (int i = 0; i < d.size(); i++) {
      if (a[f] < a[d[i]]) f = d[i];
    }

    for (int i = 0; i < d.size(); i++) {
      if (d[i] != f && (s == -1 || a[s] < a[d[i]])) s = d[i];
    }
    
    b[k].first = f;
    b[k].second = s;

    int l = k, m = j - 1;
    ll g = 0;
    while (m >= 0) {
      l -= 1 << c[m--];
      g = max(g, a[b[l].first]);
    }

    if (s == -1) ans[k] = a[f] + g;
    else ans[k] = a[f] + max(g, a[s]);
    ans[k] = max(ans[k - 1], ans[k]);

    printf("%lld\n", ans[k]);

  }

  return 0;

}

    


Measured memory_bytes: 12416
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
typedef pair<int,int> pii;
int MOD = 998244353;
typedef pair<int,int> pii;

signed main(){

    int n,m;
    cin >> n >> m;
    priority_queue<pii,vector<pii>,greater<pii>> p;
    priority_queue<int> w;

     rep(i,n){
        int a,b;
        cin >> a >> b;
        p.push(MP(a,b));
     }

    int ans = 0;
    for(int i = m-1;i >= 0;i--){
        while(p.size() && p.top().fi + i <= m){
            int b = p.top().se;
            w.push(b);
            p.pop();
        }
        if(w.size()){
            ans += w.top();
            w.pop();
        }
    }
    cout << ans << endl;
    
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc137.contest.atcoder.jp/tasks/abc137_b


Measured memory_bytes: 3568
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n,k;
  string s;
  cin >> n >> k >> s;
  LL mode = 1, tmp = 0;
  LL answer = 0ll;
  vector<LL> rl(1);
  REP(i, s.size()) {
    if(s[i]==mode+'0') ++tmp;
    else {
      rl.push_back(tmp);
      tmp=1;
      mode=1-mode;
    }
  }
  rl.push_back(tmp);
  rl.push_back(0);
  REP(i,rl.size()-1) rl[i+1]+=rl[i];
  if(rl.size()<=k*2+1) answer=n;
  REP(i,n) {
    if(rl.size()<=(i+k)*2+1) break;
    answer=max(answer,rl[(i+k)*2+1]-rl[i*2]);
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    int n; cin >> n;
    set<int> s;
    int cnt = 0;
    rep(i, n) {
        int a; cin >> a;
        int add;
        if(a < 400) add = 1;
        else if(a < 800) add = 2;
        else if(a < 1200) add = 3;
        else if(a < 1600) add = 4;
        else if(a < 2000) add = 5;
        else if(a < 2400) add = 6;
        else if(a < 2800) add = 7;
        else if(a < 3200) add = 8;
        else {
            cnt++;
            continue;
        }
        s.insert(add);
    }
    cout << max<int>(1, s.size()) << ' ' << s.size() + cnt << endl;
}

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

int main(){
    long long N,A;
    string inp;
    cin >> N ;;
    if(N==9 || N%10==9 || N/10==9){
        cout <<"Yes"<<endl;
        return 0;
    }else{
        cout <<"No" <<endl;
        return 0;
    }
    

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int N;
		long M;
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		long[] a = new long[(int) N];
		double check = 0;
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextLong();
			check += a[i];
		}
		;
		check = check / (4 *M);
		int count = 0;
		while (N - 1 >= 0) {
			count += (a[N - 1] >= check) ? 1 : 0;
			N--;
		}
		System.out.println(count >= M ? "Yes" : "No");
	}
}

Measured memory_bytes: 35852
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin>>n>>s;

    int cnt=0,pre=0;
    REP(i,n){
        if(s[i]=='(') cnt++;
        else{
            cnt--;
            if(cnt<0) pre = max(pre,-cnt);
        }
    }
    REP(i,pre) s = '(' + s;
    n += pre;
    cnt=0;
    REP(i,n){
        if(s[i]=='(') cnt++;
        else cnt--;
    }
    REP(i,cnt) s = s + ')';
    cout<<s<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

def main():
    n = int(input().strip())
    a = [0] * n
    for i in range(n):
        a[i] = int(input().strip())
    a = sorted(a)
    ans = 0
    if n % 2 == 0:
        kei1 = sorted([1, -1] + [-2] * ((n-2)//2) + [2] * ((n-2)//2))
        for i in range(n):
            ans += a[i] * kei1[i]
    else:
        kei1 = sorted([-1] * 2 + [2] * (n//2) + [-2] * (n//2 - 1))
        kei2 = sorted([1] * 2 + [2] * (n//2-1) + [-2] * (n//2))
        ans2 = 0
        for i in range(n):
            ans += a[i] * kei1[i]
            ans2 += a[i] * kei2[i]
        ans = max(ans, ans2)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 50524
def main():
    N, M = (int(_) for _ in input().split())
    haco = [1] * (N+1)
    # 0:空, 1:白のみ取り出せる, 2:赤のみ, 3:どっちもあり得る
    cc = [1] * (N+1)
    haco[1] = 2
    for i in range(M):
        x, y = (int(_) for _ in input().split())
        cc[x] -= 1
        cc[y] += 1
        if haco[x] == 1:
            haco[y] = 3 if haco[y] in (2, 3) else 1
        elif haco[x] == 2:
            haco[y] = 2 if haco[y] == 0 else 3
        else:
            haco[y] = 3
        if cc[x] == 0: haco[x] = 0
    output = 0
    for i in range(1, N+1):
        if haco[i] in (2, 3):
            output += 1
    print(output)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 4596
#include <iostream>

using namespace std;

const int inf{int(1e9)};

int main(){
    int N, T; cin >> N >> T;
    int ans{inf};
    for(int i = 0; i < N; ++i){
        int c, t;  cin >> c >> t;
        if(t <= T && c < ans){
            ans = c;
        }
    }
    if( ans == inf ){
        cout << "TLE" << endl;
    }
    else{
        cout << ans << endl;
    }
    return 0;
}


//自分が最初に思いついた解法
/*#include <iostream>
 *#include <vector>
 *#include <algorithm>
 *
 *ugin namespace std;

 int main(){

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

 vector<int> filtered_c;
 for(int i = 0; i < N; ++i){
 if(t[i] <= T){
 filtered_c.push_back(c[i]);
 }
 }

 if(filtered_c.size() == 0){
 cout << "TLE" << endl;
 }
 else{
 cout << *min_element(filtered_c.begin(), filtered_c.end()) << endl;
 }
 return 0;
 }

 */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s;
  cin >> s;
  ll n = s.size();
  REP(i, n-1){
    if(s[i] == s[i+1]){
      printf("%lld %lld\n", i+1, i+2);
      return 0;
    }
    if(i+2 < n && s[i] == s[i+2]){
      printf("%lld %lld\n", i+1, i+3);
      return 0;
    }
  }
  cout << "-1 -1" << endl;
  return 0;
}

Measured memory_bytes: 512
s = input()
cnt = 0
if len(s) ==1:
    print("0")
elif len(s) ==2:
    if len(set(s))==1:
        print("1")
    else:
        print("0")
elif len(s) ==3:
    if len(set(s)) == 1:
        print("1")
    else:
        if s[0] == s[2]:
            print("0")
        else:
            print("1")
else:
    pass
if  len(s)>=2 and s[0]==s[1]:
    s = list(s)
    s[1] = str(abs(int(s[0])-1))
    s = "".join(s)
    cnt +=1
if len(s)%2 and len(s)>=4:
    for i in range(0,len(s)+1,2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s),2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)
elif len(s)%2==0 and len(s)>=4:
    for i in range(0,len(s),2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s)+1,2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)


Measured memory_bytes: 46704
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int x;
  cin >> x;
  if(400 <= x && x <= 599)cout << 8 << endl;
  if(600 <= x && x <= 799)cout << 7 << endl;
  if(800 <= x && x <= 999)cout << 6 << endl;
  if(1000 <= x && x <= 1199)cout << 5 << endl;
  if(1200 <= x && x <= 1399)cout << 4 << endl;
  if(1400 <= x && x <= 1599)cout << 3 << endl;
  if(1600 <= x && x <= 1799)cout << 2 << endl;
  if(1800 <= x && x <= 1999)cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;
int n,m;
vector<vector<int>> G;
vector<int> dp;

int solve(int i){
    if(dp[i]!=-1)return dp[i];
    int res = 0;
    for(auto k:G[i])res=max(res,solve(k)+1);
    dp[i] = res;
    return res;
}


int main(int argc, char const *argv[]) {
    cin>>n>>m;
    G = vector<vector<int>>(n);
    dp = vector<int>(n,-1);
    for(int i=0;i<m;++i){
        int u,v;cin>>u>>v;
        u--;
        v--;
        G[u].push_back(v);
    }
    int res = 0;
    for(int i=0;i<n;++i)res = max(res,solve(i));
    cout<<res<<endl;
    return 0;
}

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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;
typedef long long ll;

const int nc = 26;
int D;
ll c[40], t[400];
ll s[400][40];

ll scoring(){
	vector<int> last(nc+10, -1);

	long long sat = 0;

	for(ll d = 0; d < D; d++){
		last[t[d]] = d;

		for(int i = 0; i < nc; i++){
			sat -= c[i] * (d - last[i]);
		}
		sat += s[d][t[d]];
		//cout << sat << endl;
	}

	return sat;
}

double elapsed_time(chrono::system_clock::time_point start){
  auto now_time = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast<std::chrono::milliseconds>(now_time - start).count();
  //cout << elapsed << endl;
  return elapsed;
}

int main(){
	random_device rnd;
	mt19937 mt(rnd());
	
	cin >> D;

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

	for(int i = 0; i < D; i++){
		for(int j = 0; j < nc; j++){
			cin >> s[i][j];
		}
	}

	ll score = scoring();

	for(int i = 0; i < D; i++){
		t[i] = mt() % nc; //初期解をrandで生成
	}

  auto start = chrono::system_clock::now();
    
	while(1){
      if(elapsed_time(start) > 1.9) break;
      int d, q, old;
      
      d = mt() % D;
      q = mt() % nc;
      old = t[d];
      t[d] = q;
      
      ll new_score = scoring();
      //cout << new_score << endl;
      if(score > new_score){
        t[d] = old;
      }else{
        score = new_score;
      }
	}

  //cout << score << endl;
	for(int i = 0; i < D; i++){
		cout << ++t[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3748
#include<stdio.h>
#include<stdlib.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);

  int ans = 0;
  int color[101] = {0};
  color[a]++;
  color[b]++;
  color[c]++;
  for(int i = 1; i <= 100; ++i){
    if(color[i] != 0) ans ++;
  }

  printf("%d",ans);

  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define init(arr, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
const int inf = pow(10,9);
const int nil = -1;
long long i, n, m, k,t, ans=0;

int main() {
    scanf(" %lld", &n);
    rep(1,n+1) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }

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

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;
using namespace std;

struct SCC{
    vector<vector<int> > g,rg;
    vector<int> vs,cmp,used;
    SCC(int v):g(v),rg(v),cmp(v,-1),used(v,0){}
    
    void add_edge(int src,int dst){
        g[src].pb(dst);
        rg[dst].pb(src);
    }
    void dfs(int v){
        used[v]=true;
        rep(i,g[v].size()){
            if(!used[g[v][i]]) dfs(g[v][i]);
        }
        vs.pb(v);
    }
    void rdfs(int v,int k){
        used[v]=true;
        cmp[v]=k;
        rep(i,rg[v].size()){
            if(!used[rg[v][i]]) rdfs(rg[v][i],k);
        }
    }
    int scc(){
        fill(used.begin(),used.end(),0);
        vs.clear();
        rep(i,used.size()){
            if(!used[i]) dfs(i);
        }
        fill(used.begin(),used.end(),0);
        int k=0;
        for(int i=vs.size()-1;i>=0;--i){
            if(!used[vs[i]]) rdfs(vs[i],k++);
        }
        return k;
    }
};

int main(){
    int v,e;
    cin>>v>>e;
    SCC scc(v);
    int s,t;
    rep(i,e){
        cin>>s>>t;
        scc.add_edge(s,t);
    }
    int k=scc.scc();
    cout<<(v!=k)<<endl;
    return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
char a[3*maxn];
int b[3*maxn]={0};
int c[3*maxn]={0};
int main()
{
    int n,k=0,p=0;
    scanf("%d",&n);
    scanf("%s",a);
    int ans=3*maxn;
    for(int i=0;i<n;i++)
    {
        if(a[i]=='W') p++;
        b[i]=p;
    }
    for(int i=n-1;i>=0;i--)
    {
        if(a[i]=='E') k++;
        c[i]=k;
    }
    for(int i=0;i<n;i++)
    {
        p=b[i],k=c[i];
        ans=min(ans,p+k-1);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

int main(){
	int n;
	bool free[31][50];
	long long dp[31][50];
	while(cin >> n, n){
		memset(dp, 0, sizeof(dp));
		memset(free, false, sizeof(free));
		for(int i=0;i<n;i++) dp[0][i] = (1LL << i);
		for(int i=0;i<n;i++){
			int m, d; cin >> m;
			for(int j=0;j<m;j++){
				cin >> d;
				free[d][i] = true;
			}
		}
		for(int i=1;i<=30;i++){
			long long S = 0LL;
			for(int j=0;j<n;j++){
				dp[i][j] = dp[i-1][j];
				if(free[i][j]) S |= dp[i][j];
			}
			for(int j=0;j<n;j++)
				if(free[i][j]) dp[i][j] = S;
		}
		int ans = -1;
		for(int i=1;i<=30;i++){
			for(int j=0;j<n;j++)
				if(dp[i][j]==(1LL<<n)-1) ans = i;
			if(ans != -1) break;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 880
#include <bits/stdc++.h>  // ver2.1.6
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a.back()<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  string s;
  int n;
  cin >> n >> s;
  int ans = count(ALL(s), '.');
  int minn=0,now=0;
  rep(i,0,n){
    if(s[i]=='#') now++;
    else now--;
    minn = min(minn,now);
  }
  cout << ans + minn << endl;
  return 0;
}


Measured memory_bytes: 720
import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);
    private static Main    main;

    public static void main(String[] args) {

        main = new Main();
        main.run();
    }

    private void run() {

        int dataSet = sc.nextInt();
        int i = 0;
        while (i < dataSet) {
            int input = sc.nextInt();
            System.out.println("Case " + (i + 1) + ":");
            for (int n = 0; n < 10; n++) {
                String out = String.valueOf(square(input));
                out = pick(fill(out));
                System.out.println(Integer.parseInt(out));
                input = Integer.parseInt(out);
            }
            i++;
        }
    }

    private String fill(String str) {

        while (str.length() <= 8) {
            str = "0" + str;
        }
        return str;
    }

    private int square(int i) {

        return i * i;
    }

    private String pick(String str) {

        return str.substring(str.length() - 6, str.length() - 2);
    }
}

Measured memory_bytes: 17236
def digit_sum(number):
    ans = 0
    for n in str(number):
        ans += int(n)
    return ans

def obj_func(number):
    return number/digit_sum(number)

K = int(input())
num_list = []
d = 1
n = 1

for i in range(K):
    num_list.append(n)
    if obj_func(n + 10**(d-1)) > obj_func(n + 10**d):
        d += 1
    n += 10**(d-1)

print(*num_list, sep='\n')


Measured memory_bytes: 3188
// acdart
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <bitset>
#include <cctype>
#include <fstream>
#include <numeric>
#include <utility>
#include <iomanip>
#include <complex>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned long long ULL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector< vi > vvi;
typedef vector< vd > vvd;
typedef vector< vll > vvll;
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define se second
#define fi first
#define PI 3.1415926535897932384626433832795
#define mod9 1000000009ll
#define mod7 1000000007ll
#define inf 0x3f3f3f3f
#define inf8  1023456789ll
#define inf16 10000000000000000ll
const long long INF = 10000000000000000ll;
#define SZ(x) ((int)(x).size())
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define rep(i,a,b) for(i=a;i<=b;i++)
#define lp(i, n) for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n) for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n) for(int i=(j);i>=(int)(n);--i)
#define lson (id << 1)
#define rson (id << 1 | 1)
#define lowb(x) (x & (-x))
#define eps 1e-7
/*********default*********/
#define maxm 
#define maxn 
int d[30];
char a[110];
int main()
{
	int n, m;
	
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%s", a);
		for (int j = 0; j < m; j++) {
			d[a[j] - 'a']++;
		}
	}
	int s = 0, p = 0, t = 0;
	for (int i = 0; i < 26; i++) {
		p += d[i] / 4 * 4;
		d[i] %= 4;
		t += d[i] / 2 * 2;
		d[i] %= 2;
		s += d[i];
	}
	if ((n & 1) && (m & 1)) {
		if (s != 1) {
			puts("No");
		} else {
			if (n + m - 2 >= t) puts("Yes");
			else puts("No");
		}
	} else if (n & 1) {
		if (s != 0) {
			puts("No");
		} else {
			if (m >= t) puts("Yes");
			else puts("No");
		}
	} else if (m & 1) {
		if (s != 0) {
			puts("No");
		} else {
			if (n >= t) puts("Yes");
			else puts("No");
		}
	} else {
		puts(s == 0 && t == 0 ? "Yes" : "No");
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

int dp[1 << 18][18];

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

    int a[2][18];
    for (int h = 0; h < 2; h++) {
        for (int i = 0; i < n; i++) {
            cin >> a[h][i];
        }
    }

    for (int k = 0; k < 1 << n; k++) {
        int x = 0;
        for (int i = 0; i < n; i++) {
            x += k >> i & 1;
        }
        if (x <= 1) continue;

        int c = 0;
        for (int i = n - 1; i >= 0; i--) {
            int t = k & 1 << i;
            if (t) {
                int s = 1 << 30;
                int l = k ^ t;
                for (int j = 0; j < n; j++) {
                    if (l & 1 << j) {
                        if (a[(x ^ j) & 1][j] <= a[(x ^ 1 ^ i) & 1][i]) s = min(s, dp[l][j] + c);
                    }
                }
                dp[k][i] = s;
                c++;
            }
        }
    }

    int r = 1 << 30;
    for (int i = 0; i < n; i++) {
        r = min(r, dp[(1 << n) - 1][i]);
    }

    if (r == 1 << 30) r = -1;
    cout << r << endl;

    return 0;
}

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

int main(){
	int n; cin >> n;
	vector<int> x(n),y(n);
	for(int i=0;i<n;i++) {
		cin >> x[i];
		y[i]=x[i];
	}
	sort(y.begin(),y.end());
	for(int i=0;i<n;i++) {
		if(x[i]<y[n/2]) cout << y[n/2];
		else if(x[i]>y[n/2]) cout << y[n/2-1];
		else if(y[n/2-1]<y[n/2]) cout << y[n/2-1];
		else cout << y[n/2];
		cout << endl;
	}
}


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

#define rep(i,n,s) for(int i=s; i<n; i++)

using namespace std;

int main(){

    int N; cin >> N;
    int B[N-1]; rep(i,N-1,0) cin >> B[i];

    int sum = 0;
    sum = B[0] + B[N-2];

    rep(i,N-2,0) {
        
        sum += min(B[i],B[i+1]);

    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100

 int stack[N];
 int n=0;

 int push(int x){
         n++;
         stack[n]=x;
 }

 int pop(){
   int a;
   a=stack[n];
   n--;

   return a;

 }

 int main(){
  int c;
  int x, a, b;

        while ((c=getchar())!=EOF){
                 if (isdigit(c)){
                         ungetc(c, stdin);
                         scanf("%d", &x);
                         push(x);
                 }
                 else {
                         switch(c) {
                         case '+':
                                 b=pop();
                                 a=pop();
                                 push(a+b);
                                 break;
                         case '-':
                                 b=pop();
                                 a=pop();
                                 push(a-b);
                                 break;
                         case '*':
                                 b=pop();
                                 a=pop();
                                 push(a*b);
                                 break;
                         case '/':
                                 b=pop();
                                 a=pop();
                                 push(a/b);
                                 break;
                         case '\n':
                                         printf("%d\n", pop());
                                         return 0;
                                 exit(1);

                         case ' ':
                                 break;

                         default:
                                 n=0;
                                 break;
                         }
           }
     }
     return 0;
}



Measured memory_bytes: 2124
#N = int(input())
S = str(input())
#X, Y = map(int, input().split())
#C = list(map(int, input().split()))
N  =len(S)
ans = N
for i in range(1, N):
  if S[i] != S[i - 1]:
    now = max(i, N - i)
    ans = min(ans, now)

print(ans)

Measured memory_bytes: 9216
#include <stdio.h>

int main()
{
	int p,q,r,max=-1;
	scanf("%d %d %d",&p,&q,&r);
	if(p>=q&&p>=r)max=p;
	if(q>=r&&q>=p)max=q;
	if(r>=q&&r>=p)max=r;
	printf("%d",p+q+r-max);
	return 0;
}

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

using namespace std;
string s,s1,s2;
bool ispal(string a)
{
    for(int i=0,j=a.size()-1;i<a.size()/2;i++,j--)
        if(a[j]!=a[i])
            return 0;
    return 1;
}
int main()
{
    cin>>s;
    int n=s.size();
    for(int i=1;i<=(n-1)/2;i++)
        s1.push_back(s[i-1]);
    for(int i=(n+3)/2;i<=n;i++)
        s2.push_back(s[i-1]);
    if(ispal(s)&&ispal(s1)&&ispal(s2))
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

int main(){
    long long n;
    cin >> n;
    long long i = 2, num = 0, ans = 0;
    bool is_composite = false;
    while(n != 1){
        if(n % i == 0){
            is_composite = true;
            num++;
            n /= i;
        }
        else{
            long long j = 1;
            while(num - j >= 0){
                num -= j;
                j++;
                ans++;
            }
            num = 0;
            is_composite = false;
            if(i % 2 == 1) i += 2;
            else i++;
        }
        if(i > sqrt(n) && is_composite == false){
            // 素数
            ans++;
            break;
        }
    }
    long long j = 1;
    while(num - j >= 0){
        num -= j;
        j++;
        ans++;
    }
    cout << ans;
    return 0;
}

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




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

	return 0;
}


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

struct node { int t,next; }a[200010];

int f[100010],g[100010],h[100010];
int head[100010],d[100010],n,tot;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void add(int x,int y) { a[++tot].t=y;a[tot].next=head[x];head[x]=tot; }

inline void dfs(int x,int y)
{
	f[x]=g[x]=h[x]=(d[x]==2);
	for (int i=head[x];i;i=a[i].next)
	{
		int t=a[i].t;
		if (t==y) continue;
		dfs(t,x);
		f[x]=max(f[x],max(f[t],g[x]+g[t]));
		g[x]=max(g[x],g[t]+h[x]);
	}
}

int main()
{
	n=rd();tot=0;
	for (int i=1;i<n;i++)
	{
		int x=rd(),y=rd();
		add(x,y);add(y,x);
		d[x]++;d[y]++;
	}
	dfs(1,0);
	int ans=f[1];
	for (int i=1;i<=n;i++) if (d[i]==1) ans++;
	printf("%d\n",ans);
	return 0;
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int N, M;
    bool open = false;

    cin >> N;
    set<string> u;
    REP( i, N ){
        string s; cin >> s;
        u.insert( s );
    }

    cin >> M;
    REP( i, M ){
        string t; cin >> t;
        if( u.find( t ) != u.end() ){
            open ^= 1;
            cout << ( open ? "Opened by " : "Closed by " ) << t << endl;
        }else{
            cout << "Unknown " << t << endl;
        }
    }
}


Measured memory_bytes: 3240
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <memory>        // unique_ptr, shared_ptr, weak_ptr

using namespace std;

using ll = long long int;
using vi = vector<int>;
using vvi = vector<vi>;

#define _LIBCPP_DEBUG 0
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
    long long N;
    int cnt=0;
    cin >> N;

    for (auto i=1; i<=N; i++) {
        for (auto j=1; i*j<=N; j++) {
            long long c = N - i * j;
            if (c > 0) cnt++;
        }
    }
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3188
#include<stdio.h>
int main(void){
    int n,max=0;
    scanf("%d",&n);
    int max_od=0,top2_od=0,max_ev=0,top2_ev=0;
    int v[n];
    int v_od[100001]={0},v_ev[100001]={0};
    //
    for(int i=0;i<n;i++){
        scanf("%d",&v[i]);
        if(max<v[i])max=v[i];
        if(i%2==0){
            v_od[v[i]]++;
        }else{
            v_ev[v[i]]++;
        }
    }

    /*    
    for(int i=0;i<=max;i++){
        printf("v_od[%d]:%d  v_ev[%d]:%d\n",i,v_od[i],i,v_ev[i]);
    }
    */
    

    for(int i=1;i<=max;i++){
        if(v_od[i]>v_od[max_od])max_od=i;
    }
    for(int i=1;i<=max;i++){
        if(v_od[i]>v_od[top2_od] && i!=max_od)top2_od=i;
    }
    for(int i=1;i<=max;i++){
        if(v_ev[i]>=v_ev[max_ev])max_ev=i;
    }
    for(int i=1;i<=max;i++){
        if(v_ev[i]>v_ev[top2_ev] && i!=max_ev)top2_ev=i;
    }
    if(max_od!=max_ev){
        printf("%d\n",n-v_od[max_od]-v_ev[max_ev]);
    }else{
        //if((n-v_od[max_od]-v_ev[top2_ev]) > (n-v_od[top2_od]-v_ev[max_ev])){
        if(v_od[top2_od] > v_ev[top2_ev]){
            printf("%d\n",n-v_od[top2_od]-v_ev[max_ev]);
        }else{
            printf("%d\n",n-v_od[max_od]-v_ev[top2_ev]);
        }
    }
    
    //printf("od_max:%d  od_top2:%d\nev_max:%d  ev_top2:%d\n",v_od[max_od],v_od[top2_od],v_ev[max_ev],v_ev[top2_ev]);
    /*
    printf("max:%d\n",max);
    printf("%d\n",v_ev[87735]);
    */
    return(0);

}

Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define sz 100005

using namespace std;

int main()
{
    ll n,arr[sz],brr[sz];
    map<ll, ll>mp;
    mp.clear();

    scanf("%lld",&n);

    for(ll i=1; i<=n; i++)
    {
        scanf("%lld",&arr[i]);

        mp[arr[i]]++;
    }

    ll m=0;

    map<ll, ll>visited;
    visited.clear();

    for(ll i=1; i<=n; i++)
    {
        if(mp[arr[i]]>=2&&visited[arr[i]]==0)
        {
            brr[m++]=arr[i];

            visited[arr[i]]=1;
        }
    }

    sort(brr, brr+m, greater<ll>());

    if(m>=2)
    {
        if(mp[brr[0]]>=4)
            printf("%lld\n",brr[0]*brr[0]);

        else
            printf("%lld\n",brr[0]*brr[1]);
    }

    else if(m==1)
    {
        if(mp[brr[0]]>=4)
            printf("%lld\n",brr[0]*brr[0]);

        else
            printf("0\n");
    }

    else
        printf("0\n");

    return (0);
}


Measured memory_bytes: 7296
using System;
using System.Collections.Generic;

    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string input = Console.ReadLine();

            string output = "...";
            if (input.Length <= n)
            {
                output = input;
            }
            else
            {
                output = input.Substring(0, n) + output;
            }

            Console.WriteLine(output);
        }
    }

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 10000000000000000
const ll mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b)
{
    ll ans=1;
    while(b!=0)
    {
        if(b&1)
        {
            ans*=a;
            ans%=mod;
        }
        a=(a*a);
        a%=mod;
        b>>=1;
    }
    return ans%mod;
}
void solve()
{
    ll n;
    cin>>n;
    //ll ans=n;
    if(n==1)
    {
        cout<<"1\n";
        return;
    }
    VL prime(n+1,0);
    fr(i,2,n+1)
    {
        ll tmp=i;
        fr(j,2,i+1)
        {
            while(tmp%j==0)
            {
                prime[j]++;
                tmp/=j;
            }
        }
        if(tmp!=1)
        {
            prime[tmp]++;
        }
    }
    ll ans=1;
    fr(i,0,n+1)
    {
        if(prime[i]!=0)
        {
            ans*=(prime[i]+1);
            ans%=mod;
        }
    }
    cout<<ans<<endl;
    //cout<<(power(2,n-1)-2)<<endl;
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
    	solve();
    }
	return 0;
}

Measured memory_bytes: 256