akhauriyash/Code-Regression huggingface dataset:
from bisect import bisect_left

N = int(input())
S = list(input())
lst = [[] for _ in range(10)]
for i in range(N):
    lst[int(S[i])].append(i)

# print (lst)

ans = 0
#3桁回す
for i in range(10):
    if len(lst[i]) == 0:
        continue
    for j in range(10):
        if len(lst[j]) == 0:
            continue
        for k in range(10):
            if len(lst[k]) == 0:
                continue
            #1桁目
            tmp = -1
            tmp = bisect_left(lst[i], tmp)
            #2桁目
            tmp = bisect_left(lst[j], lst[i][tmp] + 1)
            if tmp >= len(lst[j]):
                continue
            #3桁目
            tmp = bisect_left(lst[k], lst[j][tmp] + 1)
            if tmp >= len(lst[k]):
                continue
            # print (i, j, k)
            ans += 1

print (ans)

Measured memory_bytes: 41328
# coding: utf-8
# Your code here!

import sys

N, A, B, C, D = map(int, input().rstrip().split())
S = [x for x in input()]

if A < B and B < D and D < C:
    chain_rock = 0
    if S[B-2] == '.':
        chain_empty = 1
    else:
        chain_empty = 0
    max_chain_empty = 0
    for i in range(B-1, D):
        if S[i] == '.':
            chain_empty += 1
            chain_rock = 0
        else:
            chain_empty = 0
            chain_rock += 1
            
        max_chain_empty = max(max_chain_empty, chain_empty)
        if chain_rock >= 2:
            print('No')
            sys.exit()
            
    if max_chain_empty < 3:
        if not (S[D-2] == '.' and S[D] == '.'):
            print('No')
            sys.exit()
            
    chain_rock = 0
    for i in range(A, C):
        if S[i] == '#':
            chain_rock += 1
        else:
            chain_rock = 0
            
        if chain_rock >= 2:
            print('No')
            sys.exit()
            
else:
    chain_rock = 0
    for i in range(A, C):
        if S[i] == '#':
            chain_rock += 1
        else:
            chain_rock = 0
            
        if chain_rock >= 2:
            print('No')
            sys.exit()
            
    chain_rock = 0
    for i in range(B, D):
        if S[i] == '#':
            chain_rock += 1
        else:
            chain_rock = 0
            
        if chain_rock >= 2:
            print('No')
            sys.exit()

print('Yes')
    

Measured memory_bytes: 59768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int k=1;
    while(a>0 && c>0)
    {
        if(k==1)
        {
            c-=b;
        }
        else
            a-=d;
        k*=-1;
    }
    if(a<=0)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3636
a, b = map(int, input().split())

ans =0
if a>=b:
  ans += a
  a = a-1
else:
  ans +=b
  b =b-1
  
if a>=b:
  ans += a
  a = a-1
else:
  ans +=b
  b =b-1
  
print(ans)

Measured memory_bytes: 3060
# ALDS1_1_A: Insertion Sort
N = int(input())
A = list(map(int, input().split())) 

def insertionSort(A, N):
    print(" ".join(map(str, A)))
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j = j - 1
        A[j+1] = v
        print(" ".join(map(str, A)))
    
insertionSort(A, N)


Measured memory_bytes: 5604
N = int(input())
a = list(map(int,input().split()))
ans = []

avg = 0
if (max(a)+min(a))%2 == 0:
    avg = (max(a)+min(a))/2
else:
    avg = (max(a)+min(a))/2+1

for i in range(-100,101,1):
    sum = 0
    for j in a:
        sum += (j-i)**2
    ans.append(sum)
    
print(min(ans))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

using P = pair<char, ll>;

vector<P> runLength(const string& s) {
    vector<P> res;
    char now = s[0];
    ll cnt = 1;
    rep(i, 1, s.size()) {
        if (now == s[i]) {
            ++cnt;
        }
        else {
            res.emplace_back(now, cnt);
            now = s[i];
            cnt = 1;
        }
    }
    res.emplace_back(now, cnt);
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    vector<P> v = runLength(S);
    ll ans = 0;
    int l = 0;
    if (v[l].first == '>') {
        ans += v[l].second * (v[l].second + 1) / 2;
        ++l;
    }
    int r = (int)v.size();
    if (v[r - 1].first == '<') {
        ans += v[r - 1].second * (v[r - 1].second + 1) / 2;
        --r;
    }
    for (int i = l; i < r; i += 2) {
        ll min_val = min(v[i].second, v[i + 1].second);
        ll max_val = max(v[i].second, v[i + 1].second);
        ans += max_val * (max_val + 1) / 2;
        ans += min_val * (min_val - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7188
import sys
input = sys.stdin.readline

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

cnt, town = 0, 1
l, s = [], set()
while True:
    town = a[town - 1]
    cnt += 1
    if cnt == k:
        print(town)
        exit()
    if town in s:
        loop_start = town
        break
    l.append(town)
    s.add(town)


loop_cnt = l.index(loop_start)
loop = l[loop_cnt:]
loop_len = len(loop)
k -= loop_cnt
print(l[loop_cnt:][k%loop_len-1])


Measured memory_bytes: 114984
from collections import defaultdict
h, w, m = map(int, input().split())
targets = []
targets_count_w = defaultdict(int)
targets_count_h = defaultdict(int)
for _ in range(m):
    y, x = map(int, input().split())
    y -= 1
    x -= 1
    targets_count_w[x] += 1
    targets_count_h[y] += 1
    targets.append((y, x))

max_w = max(targets_count_w.values())
max_h = max(targets_count_h.values())
y_idx = defaultdict(bool)
x_idx = defaultdict(bool)
max_count_x = 0
max_count_y = 0
for i in range(w):
    if targets_count_w[i] == max_w:
        x_idx[i] = True
        max_count_x += 1
for i in range(h):
    if targets_count_h[i] == max_h:
        y_idx[i] = True
        max_count_y += 1


ans = max_w + max_h
kumi = max_count_x*max_count_y
for ty, tx in targets:
    if y_idx[ty] and x_idx[tx]:
        kumi -= 1
    if kumi == 0:
        break

if kumi == 0:
    print(ans-1)
else:
    print(ans)



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

int N;
int p[100010];
int res;

void solve()
{
	int i;
	for(i=0; i<N-1; i++){
		if(p[i] == i+1){
			swap(p[i], p[i+1]);
			res ++;
		}
	}
	if(p[N-1] == N)
		res ++;
	printf("%d\n", res);
}

int main()
{
	int i;
	scanf("%d", &N);
	for(i=0; i<N; i++)
		scanf("%d", &p[i]);
	solve();
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

ll yaku(ll a, ll b){
    if(a>b) return yaku(b,a);
    else{
        if(b%a==0) return a;
        else return yaku(b%a,a);
    }
}

int main(){
    ll N; cin>>N;
    vector<ll> d(N);
    for(int i=0;i<N;i++) cin>>d.at(i);

    vector<ll> L(N), R(N);
    L.at(0)=d.at(0);
    R.at(N-1)=d.at(N-1);
    for(int i=1;i<N;i++) L.at(i)=yaku(L.at(i-1),d.at(i));
    for(int i=N-2;i>=0;i--) R.at(i)=yaku(R.at(i+1),d.at(i));
    ll ans=max(L.at(N-2),R.at(1));
    if(N>2){
        for(int i=1;i<N-1;i++) ans=max(ans,yaku(L.at(i-1),R.at(i+1)));
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 2560
#include <iostream>
 
using namespace std;
 
int N,A,B,C,D;
int x , y , xsum , ysum;

int main(){
cin>>N>>A>>B>>C>>D;
x=N/A;
   if(N%A>0) x=x+1;
y=N/C;
   if(N%C>0) y=y+1;
xsum=B*x;
ysum=D*y;
   if(xsum<ysum)cout<<xsum<<endl;
   else
   cout<<ysum<<endl;

return 0;
}


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

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> a(H);
	for (int i = 0; i < H; i++) {
		cin >> a[i];
	}

	vector<bool> row(H, false);
	vector<bool> col(W, false);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (a.at(i).at(j) == '#') {
				row.at(i) = true;
				col.at(j) = true;
			}
		}
	}

	for (int i = 0; i < H; i++) {
		if (row.at(i)) {
			for (int j = 0; j < W; j++) {
				if (col.at(j)) {
					cout << a.at(i).at(j);
				}
			}
			cout << endl;
		}
	}
}

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

const int N=100100;
int n,val[N],m,vis[N];
vector<int>g[N];
priority_queue<pair<int,int> >pq;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<n;++i){
		int x,y;cin>>x>>y;
		g[x].push_back(y);g[y].push_back(x);
	}
	for(cin>>m;m --> 0;){
		int x,y;cin>>x>>y;
		val[x]=y;vis[x]=1;pq.emplace(y,x);
	}
	for(;!pq.empty();){
		auto x=pq.top();pq.pop();
		int u=x.second;
		for(int i:g[u])if(!vis[i])vis[i]=1,pq.emplace(val[i]=val[u]-1,i);
	}
	for(int i=1;i<=n;++i)
		for(int j:g[i])if(abs(val[i]-val[j])!=1){cout<<"No\n";return 0;}
	cout<<"Yes\n";
	for(int i=1;i<=n;++i)cout<<val[i]<<'\n';
	return 0;
}


Measured memory_bytes: 8308
#include <iostream>

using namespace std;
 
void res(int, int, int);
 
int main()
{
    int n, pm, pe, pj;
 
    while (cin >> n, n) {
	for (int i = 0; i < n; i++) {
	    cin >> pm >> pe >> pj;
	    res(pm, pe, pj);
	}
    }
    return 0;
}
 
void res(int pm, int pe, int pj)
{
    double ave, meave;
 
    ave = (double)(pm + pe + pj) / 3;
    meave = (double)(pm + pe) / 2;
 
    if (pm == 100 || pe == 100 || pj == 100 || meave >= 90 || ave >= 80) {
	cout << 'A' << endl;
    } else if (ave >= 70 || ( ave >= 50 && ( pm >= 80 || pe >= 80))) {
	cout << 'B' << endl;
    } else {
        cout << 'C' << endl;
    }
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MAX_N = 200005;
const ll MAX_M = 100000;
ll ans[MAX_N];
ll e[MAX_M];

int main() {
	ll n, m;
	cin >> n >> m;
	map<ll,ll> mp;
	stack<ll> q;
	vector<bool> b(n+5, false);
	for(int i=0;i<m;i++) {
		cin >> e[i];
	}
	ll itr = 0;
	for(int i=m-1;i>=0;i--) {
		ll tmp = e[i];
		if(mp[e[i]]==0) {
			ans[itr++] = e[i];
		}
		mp[e[i]]++;
		b[e[i]] = true;
	}
	for(int i=1;i<=n;i++) {
		if(b[i] == false) ans[itr++] = i;
	}
	for(int i=0;i<n;i++) {
		cout << ans[i] << endl;
	}
}


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

using namespace std;
int main()
{
    string s;
    int n,i,p=0;
    cin>>n>>s;

    for(i=0;i<n; i++)
    {
        if(s[i]=='A'  && s[i+1]=='B' && s[i+2]=='C')
        {
            p++;
        }
    }
    cout<<p<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
	
	void run() {
		long r = sc.nextInt();
		long d = sc.nextInt();
		long x = sc.nextInt();
		
		
		for(int i = 0; i < 10;i++) {
			x = r * x - d;
			
			System.out.println(x);
		}
	}
}


Measured memory_bytes: 21588
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Program {
    static Scanner sc = new Scanner();

    internal static void Main(string[] args) {
        var N = sc.nextInt();
        var M = sc.nextInt();

        if (Math.Abs(N-M) > 1) {
            WriteLine(0);
            return;
        }

        long inu = 1;
        var n = N;
        var m = M;
        for (int i = 0; i < N+M; i++) {
            if (i % 2 == 0) {
                inu *= m--;
            } else {
                inu *= n--;
            }
            inu %= 1000000007;
        }

        long saru = 1;
        n = N;
        m = M;
        for (int i = 0; i < N + M; i++) {
            if (i % 2 == 1) {
                saru *= m--;
            } else {
                saru *= n--;
            }
            saru %= 1000000007;
        }

        WriteLine((inu + saru) % 1000000007);
    }
}




class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N, M;
  int a[3] = {10, 10, 10} ;
  int res=0;
  cin >> N >> M;

  bool flag = true;
  rep(i,M){
    int s, c;
    cin >> s >> c;
    if ( a[s-1] == 10 ) a[s-1] = c;
    else if(a[s-1] != c ) flag = false;
  }

  if(N!=1 && a[0]==0) flag = false;

  if(flag) {
    rep(i,N){
      if(a[i]==10 && i == 0 && N>1) cout << 1;
      else if(a[i]==10) cout << 0;
      else cout << a[i];
    }
    cout << endl;
  }
  else cout << -1 << endl;
}



Measured memory_bytes: 256
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<char, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        string s;
        cin >> s;
        rep(i, s.size()) {
            mp[s[i]]++;
        }
        for (char j = 'a'; j <= 'z'; ++j) {
            if (mp[j] == 0) {
                cout << j << endl;
                return 0;
            }
        }
        cout << "None" << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main()
{
    int n, m; cin>>n>>m;
    int s[100010]={};
    for(int i=0; i<m; i++){
        int l, r; cin>>l>>r;
        s[l]++;
        s[r+1]--;
    }
    int ans=0;
    for(int i=1; i<=n; i++){
        s[i]+=s[i-1];
        if(s[i]==m) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    string s,t; cin>>s>>t;
    int ans = 0;
    rep(i,3) if (s[i]==t[i]) ans++;
    cout << ans << endl;
    return 0;
}


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

namespace Tree
{
    class Rooted_Trees
    {
        struct Node
        {
            public int id;
            public int parent;
            public int depth;
            public int[] childlen;
            public int type;
            public string GetNodeType()
            {
                switch (type)
                {
                    case 0: return "root";
                    case 1: return "internal node";
                    case 2: return "leaf";
                    default: return null;
                }
            }
        }
        static void Main(string[] args)
        {
            int size = int.Parse(Console.ReadLine());
            var nodes = new Node[size];

            for (int i = 0; i < size; i++)
                nodes[i].parent = -1;

            for (int i = 0; i < size; i++)
            {
                var token = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                var id = token[0];
                nodes[id].id = id;

                var k = token[1];
                if (k == 0) nodes[id].type = 2;
                else nodes[id].type = 1;
                nodes[id].childlen = new int[k];
                for (int j = 0; j < k; j++)
                {
                    nodes[id].childlen[j] = token[2 + j];
                    nodes[token[2 + j]].parent = id;
                    nodes[token[2 + j]].depth = nodes[id].depth + 1;
                }
            }

            for (int i = 0; i < size; i++)
                if (nodes[i].parent == -1)
                {
                    nodes[i].type = 0;
                    //SetDepth(nodes, i, 0);
                    //break;
                }
                else nodes[i].depth = nodes[nodes[i].parent].depth + 1;

            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            for (int i = 0; i < size; i++)
            {
                Console.Write("node {0}: parent = {1}, depth = {2}, {3}, [", nodes[i].id, nodes[i].parent, nodes[i].depth, nodes[i].GetNodeType());
                Console.Write(string.Join(", ", Array.ConvertAll(nodes[i].childlen, n => n.ToString())));
                Console.WriteLine("]");
            }

            Console.Out.Flush();
        }

        static void SetDepth(Node[] nodes, int id, int depth)
        {
            nodes[id].depth = depth;
            for (int i = 0; i < nodes[id].childlen.Length; i++)
                SetDepth(nodes, nodes[id].childlen[i], depth + 1);
        }
    }
}

Measured memory_bytes: 23064
import java.util.*;
public class Main {
	public static void main(String[] args){
		// 文字列の入力
		Scanner sc = new Scanner(System.in);
        String someString = sc.next();
		char rChar = 'R';
        int rCount = 0;
      
		for (int i = 0; i < someString.length(); i++) {
        if(rCount==0 && someString.charAt(i) == rChar){
          rCount = 1;
        }
        if (someString.charAt(i) == rChar) {
          if(i>0 && someString.charAt(i-1) == rChar){
           rCount++;
          }
        }         
        }
      
      System.out.println(rCount);
      
	}
}

Measured memory_bytes: 35772
import java.util.Scanner;
import java.util.TreeSet;
import java.util.Arrays;
public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
            while(true){
                int h,w;
                h=sc.nextInt();
                w=sc.nextInt();
                if(h==0&&w==0)break;
                for(int i=0;i<h;i++){
                    for(int j=0;j<w;j++){
                    if((i+j)%2==0)System.out.print("#");
                    else System.out.print(".");
                    } 
                    System.out.println("");
                }
                System.out.println("");
            }
        
}
}



Measured memory_bytes: 33172
#include<bits/stdc++.h>
using namespace std;
const int M=1e6;
int n;
long long a[M],sum;
int main(){
//	freopen("cake.in","r",stdin);
//	freopen("cake.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		if(a[i]<a[i-1]){
			sum+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 5268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp18
{
    class Program
    {
        static void Main(string[] args)
        {
            var numbers = Console.ReadLine().Split(' ').Select(c => int.Parse(c))
                .ToArray();
            int A = numbers[0];
            int B = numbers[1];
            int C = numbers[2];

            //Cと、B/A(切り捨て)の、小さいほうを出す

            Console.WriteLine(Math.Min(B / A, C));
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>

int main(){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0)
      break;
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
#define k first
#define u second
using namespace std;
set <int> s;
int n,i,a[100001],kq[100001],deg[100001],b[100001],m;
struct pt { int u,k; };
set <pair <int,int> > s2;
int main()
{
   // freopen("a.inp","r",stdin);
    //freopen("a.out","w",stdout);
    cin>>n;
    for(i=1;i<=n;i++) s.insert(i);
    for(i=1;i<=n;i++) { cin>>a[i]; deg[a[i]]++; }
    for(i=1;i<=n;i++) s2.insert({ deg[i],i });
    for(i=1;i<=n;i++)
    {
        if(n-i+1<=10)
        {
            m=0;
            for(set <int>::iterator it=s.begin();it!=s.end();it++) b[++m]=*it;
            do
            {
                bool kt=1;
                for(int j=1;j<m;j++)
                    if(a[b[j]]==b[j+1]) { kt=0; break; }
                if(a[kq[i-1]]==b[1]) kt=0;
                if(kt==1)
                {
                    for(int j=1;j<=m;j++) kq[i+j-1]=b[j];
                    break;
                }
            }
            while(next_permutation(b+1,b+m+1));
            if(kq[n]==0) { cout<<-1; return 0; }
            for(i=1;i<=n;i++) cout<<kq[i]<<" ";
            return 0;
        }
        set <pair <int,int> >::iterator it=s2.end(); it--;
        if((*it).k==n-i) 
        {
            kq[i]=(*it).u;
            if(a[kq[i-1]]==kq[i]) { cout<<-1; return 0; }
        }
        else
        {
            set <int>::iterator it=s.begin();
            if((*it)==a[kq[i-1]])
            {
                it++;
                if(it==s.end()) { cout<<-1; return 0; }
            }
            kq[i]=*it;
        }
        s.erase(kq[i]); s2.erase({ deg[kq[i]],kq[i] });
        int v=a[kq[i]];
        if(s.find(v)!=s.end())
        {
            s2.erase({ deg[v],v });
            s2.insert({ deg[v]-1,v });
            deg[v]--;
        }
    }
    for(i=1;i<=n;i++) cout<<kq[i]<<" ";
}


Measured memory_bytes: 11392
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

public class Main {
	private static int counter;

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);
		counter = scanner.nextInt();
		ArrayList<Integer> list = new ArrayList<>();
		get(list, 0);
		
		Iterator<Integer> iterator = list.iterator();
		
		while(iterator.hasNext()) {
			Integer aInteger = iterator.next();
			if(!(aInteger.toString().contains("3")
					&& aInteger.toString().contains("5")
					&& aInteger.toString().contains("7"))) {
				iterator.remove();
			}
		}
		System.out.println(list.size());
	}

	public static void get(ArrayList<Integer> list,int a) {
		if(a <= counter && a >= 0) {
			list.add(a);
		}else {
			return;
		}
			
		get(list, a * 10 + 3);
		get(list, a * 10 + 5);
		get(list, a * 10 + 7);
	}
}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
#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 fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 10;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	for(auto it:s)
		cout << (it == '?'?'D':it);
	return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll n, m;
  cin >> n >> m;

  vector<vector<ll>> g(n);
  for(ll i = 0; i < m; i++){
    ll a, b;
    cin >> a >> b;
    a--, b--;
    g[a].pb(b), g[b].pb(a);
  }

  vector<ll> dist(n, -1);
  queue<ll> que;
  dist[0] = 0;
  que.push(0);

  vector<ll> ans(n);
  while(!que.empty()){
    ll v = que.front();
    que.pop();

    for(ll nv : g[v]){
      if(dist[nv] != -1){
        continue;
      }
      ans[nv] = v;
      dist[nv] = dist[v]+1;
      que.push(nv);
    }
  }

  for(ll i = 1; i < n; i++){
    if(dist[i] == -1){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  for(ll i = 1; i < n; i++){
    cout << ans[i] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 13684
n,m=map(int,input().split())
a=[]
for i in range(m):
  a_=int(input())
  a.append(a_)
  
dp=[-1]*(n+1)
dp[0]=1
dp[1]=1
for i in a:
  dp[i]=0

for i in range(2,n+1):
  if dp[i]==-1:
    dp[i]=dp[i-1]+dp[i-2]
#print(dp)
print(dp[n]%(1000000007))

Measured memory_bytes: 470264
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int area = a * b;
int length = (a+b)*2;
System.out.println(area+" "+length);
sc.close();
    }   
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

ll calc(ll a, ll b) {
    ll mn = a * b;
    ll t = a / 3;

    if (b % 2 == 0) {
        mn = min(mn, abs(t * b - ((a - t) * (b / 2))));
        mn = min(mn, abs((t + 1) * b - ((a - (t + 1)) * (b / 2))));
    } else {
        ll x = t * b;
        ll y = (a - t) * (b / 2);
        ll z = (a - t) * (b / 2 + 1);
        mn = min({mn, max({abs(x - y), abs(x - z), abs(y - z)})});
        x = (t + 1) * b;
        y = (a - (t + 1)) * (b / 2);
        z = (a - (t + 1)) * (b / 2 + 1);
        mn = min({mn, max({abs(x - y), abs(x - z), abs(y - z)})});
    }

    return mn;
}

int main() {
    ll h, w;
    cin >> h >> w; 

    if (h % 3 == 0 || w % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }

    cout << min({h, w, calc(h, w), calc(w, h)}) << endl;

}


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

int main(){
  string s;
  int n,k;
  cin >> n >> s >> k;

  char sk = s[k-1];

  for(int i = 0; i < n; i++)
  {
      if(s[i]!=sk){
          s[i]='*';
      }
  }

  cout << s << endl;  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  
  char s[200]={};
  int n[101],i=1;
  while(scanf("%s ",s) != EOF){
    if(s[0]=='+'){
      n[i-2]=n[i-2]+n[i-1];    
      i--;
    }
    else if(s[0]=='-'){
      n[i-2]=n[i-2]-n[i-1];    
      i--;
    }
    else if(s[0]=='*'){
      n[i-2]=n[i-2]*n[i-1];    
      i--;
    }
    else {
      n[i]=atoi(s);
      i++;
    }
  }
  printf("%d\n",n[1]);
  return 0;
}

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

int main(){
    int s, w;
    cin >> s >> w;
    if(w>=s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}


Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			var inputArray = retreiveLongArray();
			var inputCount = 5;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			var A = (int)inputArray[1]-1;
			var B = (int)inputArray[2]-1;
			var C = (int)inputArray[3]-1;
			var D = (int)inputArray[4]-1;

			var inputStr = retreiveStringArray()[0];
			//通れる=0　通れない=1の配列に変換

			var raceArray = inputStr.Select(x => {
				if (x == '.') {
					return 0;
				}
				else {
					return 1;
				}
			}).ToArray();


			//追い抜きが必要かどうか判定の場合
			var oinuki = (A > B && C < D) | (A < B && C > D);

			if (!oinuki) {
				var ACroot = rootCheck(A, C, raceArray);
				var BDroot = rootCheck(B, D, raceArray);

				if(ACroot && BDroot) {
					Console.WriteLine("Yes");
					return;
				}
				Console.WriteLine("No");
				return;
			}
			else {

				var ACroot = rootCheck(A, C, raceArray);
				var BDroot = rootCheck(B, D, raceArray);

				var oinukiPossible = false;
				var start = Math.Max(A, B);
				var end = Math.Min(C, D);


				for (int i = start; i <= end; i++) {
					var previous = raceArray[i - 1];
					var current = raceArray[i];
					var post = raceArray[i +1];
					if(previous==0 && current==0 &&post == 0) {
						oinukiPossible = true;
						break;
					}
				}

				if (ACroot && BDroot && oinukiPossible) {
					Console.WriteLine("Yes");
					return;
				}
				Console.WriteLine("No");
				return;


			}




		}

		/// <summary>
		/// startからgoalまで通れるか判定
		/// </summary>
		/// <param name="start"></param>
		/// <param name="goal"></param>
		/// <param name="cource"></param>
		/// <returns></returns>
		private static bool rootCheck(int start, int goal,int[] cource) {
			var previous = 0;

			for (int i = start; i < goal; i++) {
				var current = cource[i];

				if(previous==1 && current == 1) {
					return false;
				}
				previous = current;
			}
			return true;
		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

Measured memory_bytes: 17248
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[][][] data = new int[4][3][10];
         
        for(int i = 0; i < n; i++) {
            int b = stdIn.nextInt();
            int f = stdIn.nextInt();
            int r = stdIn.nextInt();
            int v = stdIn.nextInt();
             
            data[b-1][f-1][r-1] += v;
        }
         
        for(int i = 0; i < 4; i++) {
            for(int j = 0; j < 3; j++) {
                for(int k = 0; k < 10; k++) {
                    System.out.print(" " + data[i][j][k]);
                }
                System.out.println();
            }
            if(i != 3) {
            System.out.println("####################");
            }
        }
    }
}



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

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    unordered_set<int> s;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        s.insert(x);
    }
    if (s.size() == n) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}

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

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

  ll N; cin >> N;
  vector<vector<ll>> cells(1010, vector<ll>(1010, 0));
  for (ll i = 0; i < N; i++) {
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cells[x1][y1]++;
    cells[x1][y2]--;
    cells[x2][y1]--;
    cells[x2][y2]++;
  }
  for (ll i = 0; i < 1005; i++) {
    for (ll j = 0; j < 1005; j++) {
      cells[i][j + 1] += cells[i][j];
    }
  }
  for (ll i = 0; i < 1005; i++) {
    for (ll j = 0; j < 1005; j++) {
      cells[i + 1][j] += cells[i][j];
    }
  }

  ll ans = -1;
  for (ll i = 0; i < 1005; i++) {
    for (ll j = 0; j < 1005; j++) {
      ans = max(ans, cells[i][j]);
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 10800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define INF 1e9

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

    int N;
    int T;
    int c[110], t[110];
    cin >> N >> T;
    REP(i,N) {
        cin >> c[i] >> t[i];
    }

    int mincost = 1001;
    int mint;
    REP(i,N) {
        if (c[i] < mincost && t[i] <= T) {
            mincost = c[i];
        }
    }

    if(mincost <= 1000) {
        cout << mincost << endl;
    } else {
        cout << "TLE" << endl;
    }
}

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

#define MAX 2002

long long int dp[MAX][2];
bool use[MAX][2];
int n;
long long int val[MAX];
long long int dfs(int a, int b,long long int z,long long int w) {	
	if (a == n) {
		return labs(z - w);
	}
	if (use[a][b]) {
		return dp[a][b];
	}
	use[a][b] = true;
	if (b == 0) {
		dp[a][b] = -1;
	}
	else {
		dp[a][b] = LLONG_MAX;
	}
	for (int j = a; j < n; j++) {
		if (b == 0) {
			long long int nex = dfs(j + 1, b ^ true, val[j], w);
			dp[a][b] = max(dp[a][b], nex);
		}
		else {
			long long int nex = dfs(j + 1, b ^ true, z, val[j]);
			dp[a][b] = min(dp[a][b], nex);
		}
	}
	return dp[a][b];
}
int main() {
	int a, b;
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) {
		scanf("%lld", &val[i]);
	}
	long long int w=dfs(0, 0,a,b);
	printf("%lld\n", w);
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
//import java.lang.Math;

class Main{
	
	public static void main(String[] arg){
	
		
		
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] x =new int[n];
		int[] y =new int[n];
		
		for(int i=0;i<n;i++){
			
			x[i]=sc.nextInt();
		}
         for(int i=0;i<n;i++){
			
			y[i]=sc.nextInt();
		}
         
         double sum=0;
         double sum2=0;
         double sum3=0;
        
         double X=0;
         
         for(int i=0;i<n;i++){
        	 
        	
        	sum+=Math.abs(x[i]-y[i]);
        	sum2+=Math.pow(Math.abs(x[i]-y[i]),2);//P=2
        	sum3+=Math.pow(Math.abs(x[i]-y[i]),3);//P=3
        	X=Math.max(X, Math.abs(x[i]-y[i]));//P=無限
        	
        	
        	
         }      double smt=Math.sqrt(sum2);
        	double smt2=Math.cbrt(sum3);
        	
        	System.out.printf("%f\n",sum);
        	System.out.printf("%f\n",smt);
        	System.out.printf("%f\n",smt2);
        	System.out.printf("%f\n",X);
        	
        	
        	
        	
        	
        	}
}


Measured memory_bytes: 26592
n = int(input())
a = list(map(int, input().split()))

a.sort()

large = max(a)
a.remove(large)
min_list = [0, large/2]
for i in a:
    if abs(i - large/2) < min_list[1]:
        min_list = [i, abs(i - large/2)]

print(large, min_list[0])

Measured memory_bytes: 14432
#include<stdio.h>


main()
{

  int x,y,d;

  scanf("%d%d",&x,&y);
  while((d = x%y) !=0)
    {  

	  x = y; // ????????§y???x?????£??\??????
	  y = d;  
	
	 /* ?????????????????¨??§??????while?????????????°??????????????????¨?????§?????? */
    }
     	 printf("%d\n",y);
	
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {
    int H,W,num;
    cin >> H >> W;
    int DP[H][W];
    int Max = 0;
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            cin >> num;
            if(num == 1)DP[i][j] = 0;
            else DP[i][j] = 1;
            Max = max(DP[i][j],Max);
        }
    }
    for(int i = 1;i < H;i++){
        for(int j = 1;j < W;j++){
            if(DP[i][j] != 0){
                DP[i][j] = min(DP[i-1][j-1],min(DP[i-1][j], DP[i][j-1])) + 1;
                Max = max(Max,DP[i][j]);
            }
        }
    }
    cout << Max*Max << endl;
    return 0;
}

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

const long long MOD = 1000000007;

void solve(long long N, long long M, std::vector<long long> S, std::vector<long long> T){
    vector<vector<long long>> dp(N, vector<long long>(M));
    for (long long i = 0; i < N; i++) {
      for (long long j = 0; j < M; j++) {
	  long long top = (i > 0) ? dp[i-1][j] : 0;
	  long long side = (j > 0) ? dp[i][j-1] : 0;
	  long long diag = (i > 0 and j > 0) ? dp[i-1][j-1] : 0;
	  long long res = top + side - diag + MOD;
          if (S[i] == T[j]) {
	      res += 1 + diag;
          }
	  dp[i][j] = res % MOD;
      }
    }
    cout << (dp.back().back()+1)%MOD << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> S(N);
    for(long long i = 0 ; i < N ; i++){
        scanf("%lld",&S[i]);
    }
    std::vector<long long> T(M);
    for(long long i = 0 ; i < M ; i++){
        scanf("%lld",&T[i]);
    }
    solve(N, M, std::move(S), std::move(T));
    return 0;
}


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

int main()
{
    string str;
    cin >> str;
    int len = str.length();
    long long ans =0;
    long long box[2019]={};
    long long box2[2019]={};
    for(int i=0;i<len;i++){
        int tmp = stoi(str.substr(i,1));
        if(i%2==0){
            for(int j=0;j<2019;j++){
                box2[(j*10+tmp)%2019]=box[j];
            }
            box2[tmp]++;
            ans += box2[0];
        }else{
            for(int j=0;j<2019;j++){
                box[(j*10+tmp)%2019]=box2[j];
            }
            box[tmp]++;
            ans += box[0];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3492
from math import degrees, atan, radians
a, b, x = map(int, input().split())

if(x <= 0.5*a*a*b):
    y = x/(0.5*b*a)
    ans = 90-degrees(atan(y/b))
    print(ans)
elif(x == a*a*b):    
    print(0)
else:
    y = x/(0.5*a**2)-b
    ans = 90-degrees(atan((a/(b-y))))
    print(ans)

Measured memory_bytes: 3188
#include <stdio.h>

int pairs[3000][2];

int main(){
    int x, y, count = 0;
    for(;;){
        scanf("%d %d", &x, &y);
        
        if(x == 0 && y == 0)
            break;
            
        pairs[count][0] = x;
        pairs[count++][1] = y;
    }
    
    for(int i = 0; i < count; i++){
        if(pairs[i][1] < pairs[i][0])
			printf("%d %d\n", pairs[i][1], pairs[i][0]);    
		else
			printf("%d %d\n", pairs[i][0], pairs[i][1]);    
    }
    
    return 0;
}


Measured memory_bytes: 1976
#include<iostream>
using namespace std;
int main (){
  int N,M,A;
  cin >> N >> M ;
  int sum=0;
  for(int i=0; i<M; i++){
    cin >> A;
    sum+=A;
  }

  if(N-sum>=0){
    cout<<N-sum<<endl;
  }else{
    cout <<"-1"<<endl; 
  }
}


Measured memory_bytes: 3632
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author YahiaAshraf74
 */

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <complex>
#include <string>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <iomanip>
#include <assert.h>

using namespace std;
#define el  '\n'
#define ll long long
#define clr(a, b)memset(a,b,sizeof(a))
#define sz(a) (int)(a).size()
const long long N = (int) 2e5 + 74, OO = 0x3f3f3f3f, MOD = (int) 1e9 + 7;

int h[N];
int dp[N];

class BFrog2 {
public:
    void init() {
        clr(dp, OO);
    }

    void solve(istream &cin, ostream &cout) {
        init();
        int n, k;
        cin >> n >> k;
        for (int i = 0; i < n; i++) {
            cin >> h[i];
        }
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
            for (int j = i - 1, kk = k; j >= 0 && kk; kk--, j--) {
                dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
            }
        }
        cout << dp[n - 1] << el;
    }
};
int main() {
	ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	BFrog2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

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



Measured memory_bytes: 26356
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var abc = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int a = abc[0];
			int b = abc[1];
			int c = abc[2];

			for (int i = 1; i <= b * 2; i++) {
				if ((a * i) % b == c) {
					Console.WriteLine("YES");
					return;
				}
			}

			Console.WriteLine("NO");
		}
	}
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

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

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll a,b,n; cin>>a>>b>>n;
  ll x = min<ll>(n, b-1);
  cout<<a*x/b<<endl;

  return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<vector<int>> graph(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    int res = 0;
    for (int j = 0; j < a; j++) {
      int x, y; cin >> x >> y;
      graph[i][x-1] = y + 1;
    }
  }

  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    bitset<1001> res(i);
    bool flag = false;
    for (int j = 0; j < n; j++) {
      if (!res[j]) continue;
      for (int k = 0; k < n; k++) {
        int vote = graph[j][k];
        if ((res[k] && vote == 1) or (!res[k] && vote == 2)) {
          flag = true;
          break;
        }
      }
      if (flag) break;
    }
    if (!flag) ans = max(ans, (int)res.count());
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
main(){
  int a,b,c;
  double xa,ya,xb,yb,xc,yc;
  int i,n;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d%d%d",&a,&b,&c);

    xa=a*a;
    ya=b*b+c*c;
    xb=b*b;
    yb=a*a+c*c;
    xc=c*c;
    yc=a*a+b*b;

    if(xa==ya || xb==yb || xc==yc){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }
  }

  return 0;

}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
int s[5],c[5];

void solve(){
	for(int i=0;i<=999;i++){
		int ii=i;
		int dig=0;
		deque<int> deq;
		if(ii==0){
			dig=1;
			deq.push_back(0);
		}
		while(ii>0){
			dig++;
			deq.push_front(ii%10);
			ii/=10;
		}
		if(dig!=n)continue;
		bool flag=true;
		for(int j=0;j<m;j++){
			if(deq[s[j]-1]!=c[j]){
				flag=false;
			}
		}
		if(flag){
			printf("%d\n",i);
			return;
		}
	}
	printf("-1\n");
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&s[i],&c[i]);
	}
	solve();
	return 0;
}


Measured memory_bytes: 256
(defun sum-of-divisor (n)
  (loop :for i :from n :downto 1
        :with basis = 1 and prev-div = 1 and sum = 0 
        :do (progn
              (unless (= prev-div (floor n i))
                (let ((tmp (floor n i)))
                  (loop :for i :from (+ prev-div 1) :to tmp
                        :do (incf basis i))
                  ;(format t "prev-div: ~A,tmp: ~A~%" prev-div tmp)
                  (setq prev-div tmp)))
              (incf sum (* basis i)))
              ;(format t "index:~A, basis:~A, sum:~A~%" i basis sum))
        :finally (return sum)))

(format t "~A~%" (sum-of-divisor (read)))


Measured memory_bytes: 24244
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	N := ReadInt()
	vs := ReadInts(N)

	ns := []float64{}
	for _, v := range vs {
		ns = append(ns, float64(v))
	}

	for len(ns) >= 2 {
		sort.Float64s(ns)
		ns[1] = (ns[0] + ns[1]) / 2.0
		ns = ns[1:]
	}
	fmt.Println(ns[0])
}

func ReadInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = ReadInt()
	}
	return ret
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


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

using namespace std;


int main() {
	int n;
    cin>>n;
    n=n%10;
    if(n==2||n==4||n==5||n==7||n==9)cout<<"hon";
    else if(n==0||n==1||n==6||n==8)cout<<"pon";
    else cout<<"bon";
}


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

int main(){
	int n;	//参加者数
	cin >> n;

	int* a; //参加者番号
	int* v; //匹数
	a = new int[n];
	v = new int[n];
	for (int i = 0; i < n; i++){
		cin >> a[i] >> v[i];
	}

	int winner = a[0];
	int max = v[0];

	for (int i = 1; i < n; i++){
		if (v[i]>max){
			winner = a[i];
			max = v[i];
		}
		else if (v[i] == max && a[i] < winner){
			winner = a[i];
		}
	}

	cout << winner << " " << max << endl;
	return 0;
}

Measured memory_bytes: 1192