akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), space, pos, cnt = 0;
		char[] bar = sc.next().toCharArray();
		for(int i = 0; i < n; i++){
			boolean flg = false;
			char[] board = sc.next().toCharArray();
			for(int j = 0; j < board.length; j++){
				if(bar[0] == board[j]) {
					for(int k = j + 1; k < board.length; k++){
						if(bar[1] == board[k]) {
							space = k - j;
							if( board.length <= space * (bar.length - 1) + j) break; // ??????????????§???????????°
							pos = k;
							for(int l = 2; l < bar.length; l++){
								pos += space;
								if(bar[l] != board[pos]){
									break;
								} else if(l == bar.length - 1) {
									flg = true;
									cnt++;
								}
							}
							if(flg) break;
						}
					}
				}
				if(flg) break;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 27412
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,c=INTM()
    if abs(a-b)>=abs(a-c):
        print('B')
    else:
        print('A')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    // m がaから作れるかを調べる
    public static boolean check(ArrayList<Integer> a, int m) {
        ArrayList<Integer> buf = new ArrayList<Integer>();
        buf.add(0);
        if (m == 0) {
            return true;
        }
        for (int i = 0; i < a.size(); i++) {
            int bufLength = buf.size();
            for (int j = 0; j < bufLength; j++) {
                int x = buf.get(j) + a.get(i);
                if (x == m) {
                    return true;
                } else if (x < m && !buf.contains(x)) {
                    buf.add(x);
                }
            }
        }
        return false;
    }

    public static void main(String[] args) {
        // Input
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        ArrayList<Integer> a = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            a.add(scanner.nextInt());
        }

        int q = scanner.nextInt();
        for (int i = 0; i < q; i++) {
            if (check(a, scanner.nextInt())) {
                System.out.println("yes");
            } else {
                System.out.println("no");
            }
        }
        scanner.close();
    }
}



Measured memory_bytes: 41800
N=int(input())
L=sorted(list(map(int,input().split())))
ans=0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if len(set([L[i],L[j],L[k]]))==3 and L[i]+L[j]>L[k]:
        ans+=1
print(ans)


Measured memory_bytes: 9172
import java.util.Scanner;
import java.util.*;
public class Main {
    static int INF = 1000000000;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] cost = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                cost[i][j] = INF;
            }
        }

        int[] a = new int[m];
        int[] b = new int[m];
        int[] c = new int[m];
        for (int i = 0; i < m; i++) {
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
            c[i] = sc.nextInt();
            cost[a[i]][b[i]] = c[i];
            cost[b[i]][a[i]] = c[i];
        }

        int[][] dist = new int[n][n];
        for (int i = 0; i < n; i++) {
            int[] d = dijkstra(i, n, cost);
            for (int j = 0; j < n; j++) {
                dist[i][j] = d[j];
            }
        }
        int ans = solve(n, m, dist, a, b, c);
        System.out.println(ans);
    }
    public static int solve(int n, int m, int[][] dist, int[] a, int b[], int c[]) {
        int ans = m;
        for (int i = 0; i < m; i++) {
            boolean ok = false;
            for (int j = 0; j < n; j++) {
                if (dist[j][a[i]] + c[i] == dist[j][b[i]]) {
                    ok = true;
                }
            }
            if (ok) {
                ans--;
            }
        }
        return ans;
    }
    public static int[] dijkstra(int from, int n, int[][] cost) {
        int[] d = new int[n];
        d[from] = 0;
        for (int i = 0; i < n; i++) {
            if (i == from) {
                continue;
            }
            d[i] = INF;
        }

        boolean[] visited = new boolean[n];
        while (true) {
            int v = -1;
            for (int u = 0; u < n; u++) {
                if (!visited[u] && (v == -1 || d[u] < d[v])) {
                    v = u;
                }
            }
            if (v == -1) {
                break;
            }
            visited[v] = true;

            for (int u = 0; u < n; u++) {
                d[u] = Math.min(d[u], d[v] + cost[v][u]);
            }
        }
        return d;
    }
}


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

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }

    class Program
    {
        private int X, Y, Z;
        private void Scan()
        {
            var sc = new Scanner();
            X = sc.NextInt();
            Y = sc.NextInt();
            Z = sc.NextInt();
        }

        public void Solve()
        {
            Scan();
            Console.WriteLine((X - Z) / (Y + Z));
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>

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

namespace adaptor = boost::adaptors;
using namespace std;
using boost::irange;
using boost::algorithm::split;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

void	Main()
{
	string a, b;
	cin >> a >> b;
	int total = stoi(a + b);
	int sq = sqrt(total);
	if (sq * sq == total)
			cout << "Yes" << endl;
	else
			cout << "No" << endl;
}

















int		main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
from sys import stdin
def cnt(n):
 if n%2==0:
  return 0
 ans = 0
 for i in xrange(1,n+1):
  if n%i==0:
   ans+=1
 return ans
n = int(stdin.readline())
res = 0
for i in xrange(1,n+1):
 if cnt(i)==8:
  res+=1
print res

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
int main() {
    int M=1000000007;
    int n,m;
    cin>>n>>m;
    char arr[n][m];
    long long int dp[n][m];

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>arr[i][j];
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            dp[i][j]=0;
        }
    }

    dp[n-1][m-1]=1;
    for(int i=n-2;i>=0;i--){
        if(arr[i][m-1]=='#' || dp[i+1][m-1]==-1) dp[i][m-1]=-1;
        else {
            dp[i][m-1]=1;
        }
    }

    for(int i=m-2;i>=0;i--){
        if(arr[n-1][i]=='#' || dp[n-1][i+1]==-1) dp[n-1][i]=-1;
        else {
            dp[n-1][i]=1;
        }
    }

    for(int i=n-2;i>=0;i--){
        for(int j=m-2;j>=0;j--){
            if(arr[i][j]=='#') dp[i][j]=-1;
            else{
                if(dp[i+1][j]!=-1){
                    dp[i][j]=(dp[i][j]%M+dp[i+1][j]%M)%M;
                }
                if(dp[i][j+1]!=-1){
                    dp[i][j]=(dp[i][j]%M+dp[i][j+1]%M)%M;
                }
            }
            dp[i][j]=dp[i][j]%M;
        }
    }

    cout<<dp[0][0];
}


Measured memory_bytes: 12412
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int x[2020];
int main(void){
  int n,m;
  scanf("%d",&n);
  int a[n];
  FOR(n){
    scanf("%d",&a[i]);
    x[a[i]]=1;
  }
  scanf("%d",&m);
  int b;
  FOR(m){
    scanf("%d",&b);
    int c=a[b-1];
    if(c<2019){
      if(!x[c+1]){
        x[c]=0;
        x[c+1]=1;
        a[b-1]++;
      }
    }
  }
  FOR(n)PRN(a[i]);
  return 0;
}



Measured memory_bytes: 2104
import sys
sys.setrecursionlimit(2000000000)
n,m=map(int,input().split())
v=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  v[a-1].append(b-1)

memo=[-1]*n
def dp(x):
  if memo[x]!=-1:return memo[x]
  r=0
  for i in v[x]:
    r=max(r,dp(i)+1)
  memo[x]=r
  return r
print(max(dp(i) for i in range(n)))

Measured memory_bytes: 59056
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  long ans = 0;
  cin>>N;
  vector <long long> num(N);
  for(int i = 0;i<N;i++){
    cin >> num.at(i);
    while(1){
      if(num.at(i)%2 == 0){
        ans++;
        num.at(i) = num.at(i)/2;
      }
      else{break;}
    }
  }
  cout << ans << endl;
}
  
  


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>

int main()
{
    const std::string w[] = {"Sunny", "Cloudy", "Rainy"};
    std::string today;
    int i = 2;;

    std::cin >> today;
    while (i >= 0)
    {
       if ( today.compare(w[i]) == 0)
       {
           break;
       }
       --i;
    }
    i = (i + 1) % 3;
    // Output
    printf("%s\n", w[i].c_str());
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define method(name,res,...) function<res (__VA_ARGS__) > name = [&](__VA_ARGS__) -> res
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int d = in();
  int ans = 0;
  for(int i=360;;i+=360){
    if(i%d==0){
      ans = i / d;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3760
from collections import Counter

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

c = Counter(a)
dic = {}

for x in a:
    if x not in dic:
        ex = (c[x] - 1) * (c[x] - 2) / 2
        no = (c[x]) * (c[x] - 1) / 2
        dic[x] = (int(no), int(ex))

su = sum([int(x[0]) for x in dic.values()])

for i,x in enumerate(a):
    print(su - (dic[x][0] - dic[x][1]))

Measured memory_bytes: 35256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  ll k,n;
  cin>>n>>k;
  ll sum=0;
  ll ar[n];
  for(int i=0;i<n;i++)
  {
    ll x;
    cin>>ar[i];
  }
  sort(ar,ar+n);
  for(int i=0;i<n-k;i++)
  sum+=ar[i];
  cout<<sum;
}


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

int main() {
  int n, h;
  cin>>n>>h;
  int a[n], b[n];
  for (int i=0; i<n; i++) cin>>a[i]>>b[i];
  sort(a, a + n);
  reverse(a, a + n);
  sort(b, b + n);
  reverse(b, b + n);
  int i = 0;
  int ans = 0;
  while (i < n && a[0] < b[i] && 0 < h) {
    h -= b[i];
    ++i;
    ++ans;
  }
  if (h > 0) {
    ans += (h - 1) / a[0] + 1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N;
    vec a(N);
    rep(i,N) {
        cin>>a[i];
        a[i] -= i+1;
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    B = a[N/2];
    rep(i,N){
        ans += abs(a[i] - B);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
# aBC092 C - Traveling Plan
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]
l = [abs(a[i+1]-a[i]) for i in range(n+1)]
ans = sum(l)

for i in range(1,n+1):
    print(ans+abs(a[i+1]-a[i-1])-abs(a[i]-a[i-1])-abs(a[i]-a[i+1]))

Measured memory_bytes: 13920
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define line cout<<"----------------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int n,m;
int cnt[100009];
int  main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        cnt[a]++;
        cnt[b+1]--;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        cnt[i]=cnt[i-1]+cnt[i];
        if(cnt[i]==m) ans++;
    }
    printf("%lld\n",ans);

}



Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#define INF 1e12+1
using namespace std;
long long int A[301][301],B[301][301],C[301][301];
int N;
long long int ans=0;
void wf(){
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
	B[j][k]=min(B[j][k],B[j][i]+B[i][k]);
      }
    }
  }
}
int main(){
  
  cin >> N;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      A[i][j]=INF;B[i][j]=INF;
      if(i==j){A[i][j]=0;B[i][j]=0;}
      long long int x;
      cin >> x;
      A[i][j]=x;B[i][j]=x;C[i][j]=1;
    }
  }
  wf();
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(A[i][j]!=B[i][j]){
	cout << "-1" << endl;
	return 0;
      }
    }
  }
  
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      for(int k=0;k<N;k++){
	if(k==i || k==j)continue;
	if(A[i][j] == A[i][k]+A[k][j]){
	  C[i][j]=0;
	}
      }
    }
  }
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      ans+=C[i][j]*A[i][j];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2304
def f1(s,a,b):
	print(s[a:b+1])
	return s

def f2(s,a,b):
	temp = s[a:b+1]
	return s[:a] + temp[::-1] + s[b+1:]

def f3(s,a,b,p):
	return s[:a] + p + s[b+1:]

data = input()
q = int(input())
functions = {'print':f1, 'reverse':f2, 'replace':f3}

for i in range(q):
	temp = [s if s.isalpha() else int(s) for s in input().split(' ')]
	f = temp.pop(0)
	data = functions[f](data,*temp)

Measured memory_bytes: 7776
#include "bits/stdc++.h"

using namespace std;


int main(int argc, char* argv[]){
	int N, f, s, c, df=0, ds=0, dc=0;
	scanf("%d", &N);
	scanf("%d", &f);
	scanf("%d", &s);
	ds = abs(s - f);

	for (int i=0; i < N - 2; i++) {
		scanf("%d", &c);
		dc = min(abs(c - f) + df, abs(c - s) + ds);
		f = s; df = ds;
		s = c; ds = dc;
	}

	printf("%d\n", ds);
	return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;

  int x1, x2, x4, x5;
  int count = 0;
  for(int i = A; i <= B; i++) {
    x5 = (i / 10000) % 10;
    x4 = (i / 1000) % 10;
    x2 = (i / 10) % 10;
    x1 = (i / 1) % 10;
    if((x5 == x1) && (x4 == x2)) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).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;}

int main(){
    string s;cin>>s;
    int n = s.size();
    vector<int> a(n+1);
    for(int i=0;i<n;i++){
        if(s[i]=='<'){
            a[i+1]=a[i]+1;
        }
    }
    for(int i=n-1;i>=0;i--){
        if(s[i]=='>'){
            a[i]=max(a[i], a[i+1]+1);
        }
    }
    ll ans = 0;
    for(int i=0;i<=n;i++){
        ans += a[i];
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 2948
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<bool> seat(20);
    string fir, las;
    cout << 0 << endl;
    cin >> fir;
    if(fir == "Vacant") return 0;
    cout << n-1 << endl;
    cin >> las;
    if(las == "Vacant") return 0;
    int l = 0, r = n - 1;
    rep(i,18){
        int mid = (l + r) / 2;
        cout << mid << endl;
        string s;
        cin >> s;
        if(s == "Vacant") return 0;
        if((s == las) ^ ((r - mid)%2 == 0)){
            l = mid;
            fir = s;
        }
        else{
            r = mid;
            las = s;
        }
    }
    return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

long long extgcd(long long a, long long b, long long& x, long long& y) {
  long long d = a;
  if(b!=0){
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1; y = 0;
  }
  return d;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b;
  cin >> a >> b;
  ll x,y;
  extgcd(a,b,x,y);
  cout << x << " " <<  y << endl;
  return 0;
}



Measured memory_bytes: 3208
#include<stdio.h>
#include<stdlib.h>
int MIN(int a,int b){return a<b?a:b;}
int main(){
  char s[20];
  int min=1e9,i;
  scanf("%s",s);
  for(i=2;s[i];i++){
    min=MIN(abs((s[i-2]-'0')*100+(s[i-1]-'0')*10+(s[i]-'0')-753),min);
  }
  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 128
'''
Created on 2020/08/19

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  a,b=map(int,pin().split())
  if a<0 and b<0:
    if (abs(b-a)+1)%2==0:
      print("Positive")
    else:
      print("Negative")
  elif a>0 and b>0:
    print("Positive")
  else :
    print("Zero")
  return

main()


Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
const int maxN = 3e5 + 13;
int n, x, arr[maxN], cnt = 1;
int main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> x;
    if (x == 1 || x == 2 * n - 1)
	return cout << "No" << endl, 0;
    cout << "Yes" << endl, 0;
    arr[n - 1] = x;
    arr[n - 2] = x - 1;
    arr[n] = x + 1;
    for (int i = 0; i < 2 * n - 1; i++) {
	
	if (cnt == x - 1)
	    cnt = x + 2;
    
	if (arr[i] == 0)
	    arr[i] = cnt++;
    }
    for (int i = 0; i < 2 * n - 1; i++)
	cout << arr[i] << '\n';
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    vector<ll> A(3);
    for (auto & a : A) cin >> a;
    sort(A.begin(), A.end());
    cout << A[2] - A[0] << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,ans=-INF; cin>>n;
    set<pair<ll,ll>> ls,rs;
    vector<ll> a(3*n,0),l(n+1,0),r(n+1,0);
    rep(i,3*n) cin>>a[i];
    ll lcnt=0,rcnt=0;
    rep(i,n){
        lcnt+=a[i]; ls.insert(mk(a[i],i));
        rcnt+=a[3*n-1-i]; rs.insert(mk(a[3*n-1-i],3*n-1-i));
    }
    l[0]=lcnt; r[0]=rcnt;
    rep(i,n){
        ls.insert(mk(a[n+i],n+i));
        lcnt+=a[n+i]-(*begin(ls)).first;
        ls.erase(*begin(ls));
        l[i+1]=lcnt;

        rs.insert(mk(a[2*n-1-i],2*n-1-i));
        rcnt+=a[2*n-i-1]-(*rbegin(rs)).first;
        rs.erase(*rbegin(rs));
        r[i+1]=rcnt;
    }
    rep(i,n+1){
        ans=max(ans,l[i]-r[n-i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 19556
#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 argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b;
    cin>>a>>b;
    if(a+b>=10)cout<<"error"<<endl;
    else cout<<a+b<<endl;

    return 0;
}


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

using namespace std;

const int N = 3005;
long long n, dp[N][N], a[N];

// dp[i][j] -> maximum score possible;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];

	for(int len = 1;len <= n;++len)
		for(int i=1;i<=n;++i){
			if(len == 1)dp[i][i] = a[i];
			else{
				int j = i + len - 1;
				dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);
			}
		}
	cout<<dp[1][n]<<"\n";
	return 0;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define lll pair<ll,ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vi vector<int>
#define ff first
#define ss second
#define pb(a) push_back(a)
#define ppb() pop_back()
#define mkp(a,b) make_pair(a,b)
#define vs vector<string>
#define vc vector<char>
#define deb1(a) cout<<#a<<" "<<a<<"\n"
#define deb2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<"\n";
#define deb3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<"\n"
#define mms0(a) memset(a,0,sizeof(a))
#define mms1(a) memset(a,-1,sizeof(a))
#define FOR(a,b,c) for(int i=(a);i<(b);i+=(c))
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define _ 0
using namespace std;




void solve(){
   int N,W;
   cin>>N>>W;
   vii data;
   FOR(_,N,1){
      ii p;
      cin>>p.ff>>p.ss;
      data.pb(p);
   }

   ll dp[W+1] = {0};
   //for(int k=0;k<=W;k++) cout<<dp[k]<<" ";cout<<"\n";
   for(int i=1;i<=N;i++){
      for(int j=W;j>=1;j--){
         if(j >= data[i-1].ff){
            dp[j] = max(dp[j],data[i-1].ss + dp[j-data[i-1].ff]);
         }else{
            dp[j] = dp[j];
         }
      }
     // for(int k=0;k<=W;k++) cout<<dp[k]<<" ";cout<<"\n";
   }
   cout<<dp[W];
}




int main(){
   int t = 1;
  // cin>>t;
   while(t--){
      solve();
   }
   return 0;
}

Measured memory_bytes: 4388
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vi2;
typedef vector<vi2> vi3;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vll> vll2;
typedef vector<vll2> vll3;
typedef vector<bool> vb;

#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define umap unordered_map
#define uset unordered_set
#define vec vector
#define loop(a) for (auto &x : a)
#define all(a) a.begin(), a.end()
#define mp make_pair

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

    int n;
    cin >> n;
    vi a(n);
    loop(a) {
        cin >> x;
    }
    map<int, int> cnt;
    ll ans = 0;
    rep(i, 0, n) {
#ifdef LOCAL
        cout << "look for " << a[i] - i << ":" << cnt[a[i] - i] << el;
#endif
        ans += cnt[i - a[i]];
        cnt[a[i] + i]++;
#ifdef LOCAL
        cout << "cnt-----------" << el;
        loop(cnt) {
            cout << x.first << ' ' << x.second << el;
        }
#endif
    }
    cout << ans;
}


Measured memory_bytes: 21056
N,M,C = map(int,input().split(' '))
B=list(map(int,input().split(' ')))

ans =0
for _ in range(N):
    A=list(map(int,input().split(' ')))
    AB = [x * y for (x, y) in zip(A, B)]
    if sum(AB) + C >0 :
        ans+=1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,x,ans=0;
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>x;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int z=0;z<=c;z++){
				if(500*i+100*j+50*z==x){
					ans=ans+1;
				}
			}
		}
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
	string str;
	cin >> str;
	int cnt = 0;
  for(int i = 0; i < 3; ++i){
    if(static_cast<int>((str[i] - '0')) == 1)++cnt;
  }
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,x[1000],e[1000];
    while(cin>>n>>m,n!=0||m!=0)
    {for(int i=0;i<n;i++)
        cin>>x[i];
    int tmp=0;
    for(int i=0;i<m;i++)
        cin>>e[i];
    for(int i=0;i<m;i++){
        tmp+=e[i];
        if(tmp>=n-1){
            cout<<i+1<<endl;
            break;
        }
        tmp+=x[tmp];
        if(tmp>=n-1){
            cout<<i+1<<endl;
            break;
        }
    }
    }
}



Measured memory_bytes: 3000
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int n;
float N, sum, avg, sd, d;
int main() {
    do {
        sum = 0;
        scanf("%d", &n);
        if (n == 0) {
            exit(0);
        }
        float s[n];
        N = n;
        for (int i = 0; i < n; i++){
            scanf("%f", &s[i]);
            sum += s[i];
        }
        avg = sum/N;
        d = 0;
        for (int i = 0; i < n; i++) {
            d += ((s[i] - avg)*(s[i]- avg));
        }
        sd = sqrt(d/N);
        printf("%f\n", sd);
    } while (n != 0);
}


Measured memory_bytes: 2108
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
#include <map>
#include <math.h>



using namespace std;

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

	int s, w; cin >> s >> w;
	if (w >= s) cout << "unsafe" << endl;
	else cout << "safe" << endl;




	return 0;
}


Measured memory_bytes: 3576
x, y = list(map(int, input().split()))
if x*y == 0:
    if x <= y:
        print(abs(y-x))
    else:
        print(abs(y-x)+1)
elif x*y < 0:
    print(abs(x+y)+1)
else:
    if x < y:
        print(y-x)
    else:
        print(x-y+2)

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

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define forv(i,v) for (auto i = v.begin(); i != v.end(); ++i)
#define forr(i,v) for (auto i = v.end(); i != v.begin() && (--i, 1); )
#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T> inline T abs (T x) {return x > T() ? x : -x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

int main () {
	//std::ios::sync_with_stdio(false);
    //std::cin.tie(nullptr);
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
	int n, m, a, b;
	cin >> n >> m >> b >> a;
	forn(i, n) {
		forn(j, m) {
			int res = (i < a) ^ (j < b);
			cout << res;
		}
		cout << '\n';
	}


	return 0;
}


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

typedef long long ll;
#define MOD = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
template<class T> inline bool is_overlap(const T& as, const T& ae, const T& bs, const T& be)
{ return bs <=ae && as <= be; }
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N, D;
    cin >> N >> D;
    cout << (N + 2 * D) / (2 * D + 1) << endl;
}


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

int main() {
  string s;cin>>s;
  if(s[0]!='A') {
    cout<<"WA"<<endl;
    return 0;
  }
  int c=0;
  for(int i=2; i<=s.size()-2; i++) {
    if(s[i]=='C')c++;
  }
  if(c!=1) {
    cout<<"WA"<<endl;
    return 0;
  }
  const int a=(int)'a';
  const int z=(int)'z';
  c=0;
  for(int i=0; i<s.size(); i++) {
    if(!islower(s[i])) c++;
  }
  if(c==2) cout<<"AC"<<endl;
  else cout<<"WA"<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = sorted([int(Ai) for Ai in input().split()], reverse=True)
x, y = 0, 0
current = A[0]
for Ai in A[1:]:
    if current is None or current != Ai:
        current = Ai
    else:
        if x == 0:
            x = current
            current = None
        else:
            y = current
            break
print(x * y)

Measured memory_bytes: 14252
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int H, W;
string S[400];

ll b[400*400]={}, w[400*400]={};
bool vis[400][400] ={};

signed main(){
    cin >> H >> W;
    rep(i, H) cin >> S[i];

    int cnt = 0;
    rep(i, H){
        rep(j, W){
            if(vis[i][j]) continue;
            vis[i][j] = true;
            queue<pair<int, int>> que;
            que.push({ i,j });
            if(S[i][j] == '#') b[cnt]++;
            else w[cnt]++;
            while(!que.empty()){
                int y = que.front().first;
                int x = que.front().second;
                que.pop();
                rep(k, 4){
                    if(y+dy[k] < 0 || H <= y+dy[k] || x+dx[k] < 0 || W <= x+dx[k]) continue;
                    if(vis[y+dy[k]][x+dx[k]]) continue;
                    if(S[y][x] == S[y+dy[k]][x+dx[k]]) continue;
                    vis[y+dy[k]][x+dx[k]] = true;
                    que.push({ y+dy[k], x+dx[k] });
                    if(S[y+dy[k]][x+dx[k]] == '#') b[cnt]++;
                    else w[cnt]++;
                }
            }
            cnt++;
        }
    }

    ll ans = 0;
    rep(i, cnt){
        ans += b[i]*w[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5032
#!/usr/bin/python3
import sys
from collections import Counter
input = lambda: sys.stdin.readline().strip()
n = int(input())
a = [int(x) for x in input().split()]
c = Counter(a)
def c2(n):
    return n * (n - 1) // 2

ans = sum(c2(v) for v in c.values())

for x in a:
    print(ans - (c[x] - 1))


Measured memory_bytes: 109936
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long int
#define mkp make_pair
#define maxN 10000007
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
}
void printMp(mp m)
{
  mp ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printUmp(ump m)
{
  ump ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printSt(st s)
{
  st ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printMst(mst s)
{
  mst ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printVec(vector<int>v)
{
for(int i=0;i<v.size();i++)cout<<v[i]<<' ';
}
void printVec2(vector<int>v[],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<v[i].size();j++)
            cout<<v[i][j]<<' ';
        cout<<endl;
    }
}
 set<pair<int,int>> primeset;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primeset.insert(mkp(p,1));
}

int32_t main()
{
fastio;
string s;in s;
rep(i,s.size()){
    if(s[i]=='R')
        {
            if((i+1)%2!=1)
                {
                    out "No";
                    exit(0);
                }
        }
    else if(s[i]=='L'){
        if((i+1)%2!=0){
            out "No";
            exit(0);
        }
    }
}
out "Yes";
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const int inf = 1<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

int main () {
  int A, B; cin >> A >> B;
  if ((A+B)%2==0) {
    cout << (A+B)/2 << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int A, B, K;
    cin >> A >> B >> K;
    int i;
    for (i = A; i <= A + K - 1; i++)
    {
        if (i > B) return 0;
        cout << i << endl;
    }
    if (B - K + 1 > i) i = B - K + 1;
    for (; i <= B; i++)
    {
        cout << i << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

int n,k;

signed main(){
  cin>>n>>k;
  cout << n-k+1 << endl;
}


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

using namespace std;

long long int gcd(long long int a,long long int b) {
    return b == 0 ? a : gcd(b, a % b);
}

int main()
{

    long long int K,N;
    cin >> N >> K;

    long long int A[N+1];

    for (long long int i = 0;i<N;i++)
    {

        cin >> A[i];
    }

    A[N] = 200005;

    sort(A,A+N+1);

    long long int B[N];

    for (long long int i=0;i<N;i++)
    {
        B[i] = 200005;
    }

    long long int it = 1;
    long long int im = 0;


    for (int i=0;i<N;i++)
    {
        if (A[i] == A[i+1])
        {
            it++;
        }
        else
        {
            B[im] = it;
            it = 1;
            im++;
        }
    }

    sort(B,B+N);

    if (K>=im)
    {
        cout << "0" << "\n";
    }
    else
    {
        long long int in = 0;
        long long int total = 0;
        while(im!=K)
        {
            long long int temp = B[in];
            total+= temp;
            im--;
            in++;

        }

        cout << total << "\n";
    }
return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
int hx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
int hy[8] = {1, -1, 0, 0, 1, 1, -1, -1};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<string> mp(h);
  for (int i = 0; i < h; i++) cin >> mp[i];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (mp[i][j] == '.') {
        int c = 0;
        for (int k = 0; k < 8; k++) {
          int ni = i + hx[k], nj = j + hy[k];
          if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
          if (mp[ni][nj] == '#') c++;
        }
        mp[i][j] = '0' + c;
      }
    }
  }
  for (int i = 0; i < h; i++) cout << mp[i] << endl;

  return 0;
}


Measured memory_bytes: 256
def cmb(n,r):
  if n<0:
    return 0
  if n==0:
    if r!=0:
      return 0
    else:
      return 1
  elif r<0:
    return 0
  elif r>n:
    return 0
  elif r==0:
    return 1
  elif r==n:
    return 1
  else:
    return A[n]*B[r]*B[n-r]%mod
mod=998244353
A=[1,1]
B=[1,1]
for i in range(2,4005):
  A.append(A[-1]*i%mod)
  B.append(B[-1]*pow(i,mod-2,mod)%mod)
k,n=map(int,input().split())
if k==1:
  print(0)
  exit()
ans=[0]*(2*k+1)
for i in range(2,k+3):#i,i+1(i%2=0,i<k(くらい))で同じとか自明か？？？？？
  if i%2==0:
    i=i+1
    for j in range(min(n+1,i//2+1)):
      ans[i-1]=(ans[i-1]+cmb(n+k-i,k-i+j)*cmb(i//2,j)*pow(2,j,mod))%mod
  else:
    ans[i]=ans[i-1]
for i in range(k+2,2*k+1):
  ans[i]=ans[2*k+2-i]
for i in range(2,2*k+1):
  print(ans[i])

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

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

    rep(i,0,(1<<3)){
        bitset<3> b(i);

        int num=s.at(0)-'0';
        rep(j,0,3){
            if(b.test(j)) num+=s.at(j+1)-'0';
            else num-=s.at(j+1)-'0';
        }
        if(num==7){
            cout<<s.at(0);
            rep(j,0,3){
                if(b.test(j)) cout<<'+'<<s.at(j+1);
                else cout<<'-'<<s.at(j+1);
            }
            cout<<"=7"<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int jud_YN(void){
  char str[101];
  scanf("%s",str);
  int len=strlen(str);
  for(int i=0;i<len;i++){
    if(str[i]!=str[len-i-1]){
      return 0;
    }
  }
  for(int i=0;i<len/2;i++){
    if(str[i]!=str[len/2-i-1]){
      return 0;
    }
  }
  return 1;
}
int main(void){
  if(jud_YN()){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

const int limit = 50;

int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

bool dfs(int v) {
	visited[v] = true;
	for (int v2 = 0; v2 < n; v2++) {

		//次の頂点とつながってるか、つながってなければ省く
		if (graph[v][v2] == false)continue;

		//訪問済みの頂点にいくとループするので省く。
		if (visited[v2] == true)continue;

		//次の頂点へ。
		dfs(v2);
	}
}

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

	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}

	int ans = 0;

	for (int i = 0; i < m; i++) {

		//探索前にi番目の辺を無効にして、探索後に戻す。
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

		//訪問済みフラグを初期化
		for (int j = 0; j < n; j++)visited[j] = false;

		//連結かどうかだから毎回0からスタートして良い。
		dfs(0);

		//dfsから返ってきた。
		//すべて訪問済み→連結
		//訪問済みでない頂点がある。→非連結。
		bool bridge = false;
		for (int j = 0; j < n; j++)if (visited[j] == false)bridge = true;
		if (bridge)ans++;

		//探索前にi番目の辺を無効にして、探索後に戻す。
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int A = sc.nextInt();
      int B = sc.nextInt();
      if(N*A>=B){
      System.out.println(B);
    }else{
      System.out.println(N*A);
      }
    }
}

Measured memory_bytes: 35780