akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
 int N,M;
 cin>>N>>M;
 vector<int> A(M);
 rep(i,M)cin>>A[i];
 int Asum=0;
 rep(i,M)Asum+=A[i];
 if(N-Asum>=0)cout<<N-Asum<<endl;
 else cout<<-1<<endl;
 }

Measured memory_bytes: 3704
#include<stdio.h>
#define max 10000
#define nil -1
#define min(x,y) (((x)>(y)) ?(x):(y))

struct node {int parent;int left;int right;};

struct node t[max];
int n,d[max],h[max];

void setdepth(int u,int a){
  if(u==nil) return;
  d[u]=a;
  setdepth(t[u].left,a+1);
  setdepth(t[u].right,a+1);
}

int setheight(int u){
  int h1=0,h2=0;
  if(t[u].left!=nil) h1=setheight(t[u].left)+1;
  if(t[u].right!=nil) h2=setheight(t[u].right)+1;
  return h[u]=min(h1,h2);
}

int getsibling(int u){
  if(t[u].parent==nil) return nil;
  if(t[t[u].parent].left!=u&&t[t[u].parent].left!=nil) return t[t[u].parent].left;
  if(t[t[u].parent].right!=u&&t[t[u].parent].right!=nil) return t[t[u].parent].right;
  return nil;
}

void print(int u){
  printf("node %d: parent = %d, sibling = %d, ",u,t[u].parent,getsibling(u));
  int deg =0;
  if(t[u].left!=nil) deg++;
  if(t[u].right!=nil) deg++;
  printf("degree = %d, depth = %d, height = %d, ",deg,d[u],h[u]);

  if(t[u].parent==nil) printf("root\n");
  else if(t[u].left==nil&&t[u].right==nil) printf("leaf\n");
  else printf("internal node\n");
}

int main(){
  int v,l,r,root=0,i;

  scanf("%d",&n);

  for(i=0;i<n;i++) t[i].parent=nil;
  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    t[v].left=l;
    t[v].right=r;
    if(l!=nil) t[l].parent=v;
    if(r!=nil) t[r].parent=v;
  }

  for(i=0;i<n;i++) if(t[i].parent==nil) root=i;

  setdepth(root,0);
  setheight(root);

  for(i=0;i<n;i++) print(i);

  return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x;
  int y;
  int i = 0;
  int flag = 0;
  
  cin >>  x;
  cin >>  y;
   

      if( y <= 4*x && 2*x <= y ){
        if((y % 2) == 0){
          flag = 1;
        }
      }
      else{
          flag = 0;
      }
  if(flag == 1){
      cout <<  "Yes";
  }
  else{
      cout <<  "No";
  }
  
}  

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define int long long
using namespace std;

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

signed main() {
  int N, K;
  cin >> N >> K;
  
  int big = 0;
  vector<int> A(N);
  for( int i = 0; i < N; i++ ){
    cin >> A.at(i);
    if( A.at(i) == K ){
      cout << "POSSIBLE" << endl;
      return 0;
    }
    if( A.at(i) > big ){
      big = A.at(i);
    }
  }
  
  if( N == 1 || K > big ){
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  
  int koyaku = gcd(A.at(0), A.at(1));
  for( int i = 2; i < N; i++ ){
    koyaku = gcd(koyaku, A.at(i));
  }
  
  int cnt = 0;
  if( koyaku == 1 ){
    cout << "POSSIBLE" << endl;
    return 0;
  }else{
    for( int i = 0; i < N; i++ ){
      if( A.at(i) - K > 0 && (A.at(i) - K) % koyaku == 0 ){
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
  }
  
  cout << "IMPOSSIBLE" << endl;

}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long a, b, c;
	cin >> a >> b;
	for (int i = max(a, b); i >= 0; i--) {
		if (a%i==0 && b%i==0) {
			c = i;
			break;
		}
	}
	cout << a * b / c;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
X=[[0,0,0]]
for i in range(n):
    t,x,y=map(int,input().split())
    X.append([t,x,y])
ans='Yes'
for i in range(n):
    if (X[i+1][0]-X[i][0]-abs(X[i+1][1]-X[i][1])+abs(X[i+1][2]-X[i][2]))%2==1 or (X[i+1][0]-X[i][0]-abs(X[i+1][1]-X[i][1])-abs(X[i+1][2]-X[i][2]))<0:
        ans='No'
print(ans)
        

Measured memory_bytes: 19672
#include <iostream>
using namespace std;
int main(){
	char a[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	cout<<a[0][0]<<a[1][1]<<a[2][2]<<endl;
    return 0;
}

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

int main()
{
  int H , W ;
  while (true) {
      cin >> H >> W;
      if (H == 0 && W == 0) {
          break;
      }
      for(int i = 0; i < H; i++) {
        for(int j= 0; j<W; j++){
          cout << '#';
      }      
      cout << endl;
    }
  cout << endl;
      
  }
}



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

int main(){
  int n;
  cin >> n;
  int i;
  vector<int> t(2, 0);
  vector<int> x(2, 0);
  vector<int> y(2, 0);
  for(i = 0; i < n; i++){
    cin >> t[1] >> x[1] >> y[1];
    int d_t = t[1] - t[0];
    int d_x = abs(x[1] - x[0]);
    int d_y = abs(y[1] - y[0]);
    int a = d_t - (d_x + d_y);
    if(a >= 0 && a%2 == 0){
      t[0] = t[1];
      x[0] = x[1];
      y[0] = y[1];
    }else{break;}
  }
  if(i == n){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>


using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SRTVG(v) sort(v.begin(),v.end(),greater<>())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007
#define INF INT_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}


int atcoder() {
    int n,m,match[]={0,2,5,5,4,5,6,3,7,6};
    cin >> n >> m;
    vector<pair<int,int>> a(m);
    vector<int> dp = vector<int>(n+1,-INF);
    vector<string> dps = vector<string>(n+1,"");
    REP(i,0,m){
        int tmp;
        cin >> tmp;
        a[i]=make_pair(tmp,match[tmp]);
    }
    sort(a.begin(),a.end());
    
    
    dp[0]=0;
    dps[0]="";
    
    REP(i,1,n+1){
        REP(j,0,m){
            if(i-a[j].second>=0){
                if(dp[i]<=dp[i-a[j].second]+1){
                    dp[i]=dp[i-a[j].second]+1;
                    dps[i] = to_string(a[j].first) + dps[i-a[j].second];
                }
            }
        }
    }
    cout << dps[n];
    return 0;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 32512
function Main(input) {
  var ab = input.split(" ");
  var f = (ab[0] / ab[1]).toFixed(5);
  var d = Math.floor(f);
  var r = ab[0] - ab[1] * d;
  console.log(d + ' ' + r + ' ' + f);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15384
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
ll dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
int main()
{
    ll h, w;
    cin >> h >> w;
    string s[h];
    rp(i, 0, h) cin >> s[i];
    ll d[h][w];
    rp(i, 0, h) rp(j, 0, w) d[i][j] = inf;
    d[0][0] = 0;
    rp(ad, 0, 1000)
    {
        rp(i, 0, h)
        {
            rp(j, 0, w)
            {
                rp(k, 0, 4)
                {
                    if (i + dx[k] >= 0 && i + dx[k] < h && j + dy[k] >= 0 && j + dy[k] < w && s[i + dx[k]][j + dy[k]] == '.')
                    {
                        d[i + dx[k]][j + dy[k]] = min(d[i + dx[k]][j + dy[k]], 1 + d[i][j]);
                    }
                }
            }
        }
    }

    ll ww = 0;
    rp(i, 0, h) rp(j, 0, w) if (s[i][j] == '.') ww++;
    if (d[h - 1][w - 1] < inf)
        ce(ww - d[h - 1][w - 1] - 1);
    else
        ce(-1);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
bool primes[300000];
int main(){
  for(int i = 2; i < 300000; i++){
    primes[i] = true;
  }
  for(int i = 2; i < sqrt(300000) + 1; i++){
    if(primes[i] && (i % 7 == 1 || i % 7 == 6)){
      int cur = 2 * i;
      while(cur < 300000){
        primes[cur] = false;
        cur += i;
      }
    }
  }
  while(true){
    int N;
    cin >> N;
    if(N == 1){
      break;
    }

    vector <int> ans;
    for(int i = 2; i < N + 1; i++){
      if(primes[i] && (i % 7 == 1 || i % 7 == 6) && N % i == 0){
        ans.push_back(i);
      }
    }

    cout << N << ": ";
    for(int i = 0; i < ans.size(); i++){
      if(i != ans.size() - 1){
        cout << ans[i] << " ";
      } else {
        cout << ans[i] << endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3468
public class Main{
  static int mod = 100000007;
  static int T = 2001;
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int r, c, a1, a2, b1, b2;
    int nr, nc, i, times;
    long[] p, pinv;

    p = new long[T]; pinv = new long[T];
    p[0] = 1; pinv[0] = 1;
    for(i = 1;i < T;i++){
      p[i] = p[i - 1] * i;
      if(p[i] > mod)p[i] %= mod;
      pinv[i] = getinverse((int)p[i]);
    }

    r = sc.nextInt(); c = sc.nextInt();
    a1 = sc.nextInt(); a2 = sc.nextInt();
    b1 = sc.nextInt(); b2 = sc.nextInt();

    nr = b1 - a1; nc = b2 - a2;
    if(nr < 0)nr *= -1;
    if(nc < 0)nc *= -1;
    times = 1;
    if(nr > (r - nr))nr = r - nr;
    else if(nr == (r - nr))times *= 2;
    if(nc > (c - nc))nc = c - nc;
    else if(nc == (c - nc))times *= 2;

    out.println(times * (p[nr + nc] * pinv[nr] % mod) * pinv[nc] % mod);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static int getinverse(int a){
    int[] x, y;
    x = new int[1]; y = new int[1];
    extgcd(a, mod, x, y);
    if(x[0] < 0)x[0] += mod;
    return x[0];
  }
  private static void extgcd(int a, int b, int[] x, int[] y){
    int tmp;
    x[0] = 1; y[0] = 0;
    if(b != 0){
      extgcd(b, a % b, y, x);
      y[0] -= (a / b) * x[0];
    }
    return;
  }
}

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

#define PI 4*atan(1)
#define INF 1e8

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

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

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
  }
  int ans = 0, cnt_o = 0, cnt_e = 0;
  REP(i, N){
    if(A[i] % 2 == 0){
      ans += pow(3, N - 1 - i) * pow(2, cnt_e);
      cnt_e++;
    }else{
      ans += 2 * pow(3, N - 1 - i) * pow(2, cnt_e);
      cnt_o++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

int bit(int s, int i){
    return (s >> i) & 1;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    vector<vector<int>> a(N,VI(N));
    REP(i,N) REP(j,N) cin >> a[i][j];
    vector<int> dp(1<<N);

    dp[0] = 1;
    FOR(mask,1,(1<<N)){
        int i = __builtin_popcount(mask);
        REP(j,N){
            if(bit(mask,j) == 1 && a[i-1][j] == 1){
                dp[mask] = (dp[mask] + dp[mask^(1<<j)]) % MOD;
            }
        }
    }
    cout << dp[(1<<N)-1] << endl;

}


Measured memory_bytes: 8448
#
n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    s.append(sorted(input())) # !!!
    #s += [''.join(sorted(input()))]
    #''.join(sorted((sorted(input()))
s = sorted(s)
#print(s)

a = []
x = 1
for i in range(1,n):
    if s[i] == s[i-1]:
        x += 1
    else:
        a.append(x)
        x = 1
else:
    a.append(x)
#print(a)

y = 0
for j in a:
    y += j*(j-1)/2

print(int(y))


Measured memory_bytes: 25420
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int k;
string s;
vector<string> t;
int main(){
    cin>>s>>k;
    for(int j=0;j<k;j++){
        for(int i=0;i<s.size()-j;i++){
            t.push_back(s.substr(i,j+1));
        }
    }
    sort(t.begin(),t.end());
    unique(t.begin(),t.end());
    cout<<t[k-1]<<endl;
}

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

int main() {
    int N;
    cin >> N;
    long long int a[3*N];
    for (int i=0; i<3*N; ++i) cin >> a[i];

    sort(a, a+3*N, greater<int>());
    long long int ans = 0;
    for (int i=0; i<2*N; ++i) {
        if (i % 2 == 1) ans += a[i];
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	if(abs(a-b)%2==1)
		cout << "Borys" << endl;
	else
		cout << "Alice" << endl;	
	return 0;
}


Measured memory_bytes: 256
import sys
def getinputdata():

    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])
c = int(arr_data[0][2])

chkflg = True
cnt = 0

if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:

     chkflg = False

while chkflg:

    cnt += 1
    atemp = b // 2 + c // 2
    btemp = c // 2 + a // 2
    ctemp = a // 2 + b // 2
    
    
    if atemp == btemp and btemp == ctemp:
        
        cnt = -1
        chkflg = False
    
    elif atemp % 2 != 0 or btemp % 2 != 0 or ctemp % 2 != 0:
        
        chkflg = False
        
    else:
        
        a = atemp
        b = btemp
        c = ctemp
    

    
print(cnt)

Measured memory_bytes: 3064
#include <stdio.h>

#define N 100

int main()
{

  int n,k=0,f;
  int A[N];
  int i,j;
  int mini;
  
  
  scanf("%d",&n);

  k = 0;
  for(i = 0; i < n; i++){
    
    scanf("%d",&A[i]);
    
  }
  for(i = 0; i <= n-1; i++){
    mini = i;
    for(j = i; j <= n-1; j++){
     
      if(A[j] < A[mini]){
	mini = j;
      }
    } 
    
    f = A[i];      
    A[i] = A[mini]; 
    A[mini] = f; 

    if(mini != i){
      k++;
    } 
  
  }
  

  
  for(i = 0; i < n; i++){
    
    if(i != 0){
      printf(" ");
    }
    
    printf("%d",A[i]);
    
    }
  
  printf("\n");
  printf("%d\n",k);
  
  return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    int n;cin>>n;
    V v(n),c(n);
    rep(i,n)cin>>v[i];
    rep(i,n)cin>>c[i];
    //bit全探索
    int ans=-inf;
    for(int bit=0;bit<(1<<n);bit++){
        int sumval=0;
        int sumcos=0;
        int tmp;
        rep(i,n){
            if(bit&(1<<i)){
                sumval+=v[i];
                sumcos+=c[i];
            }
        }
        tmp=sumval-sumcos;
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> a(n);
	int sum = 0;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	sum = -a[0] + a[n - 1];
	for(int i = 1; i < n - 1; ++i) {
		sum += abs(a[i]);
	}
	int x = a[0], y = a[n - 1];
	cout << sum << '\n';
	for(int i = 1; i < n - 1; ++i) {
		if(a[i] > 0) {
			cout << x << ' ' << a[i] << '\n';
			x -= a[i];
		} else {
			cout << y << ' ' << a[i] << '\n';
			y -= a[i];
		}
	}
	cout << y << ' ' << x << '\n';
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
using pl = pair<ll,ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

const int M=10000;

int main(int argc,char* argv[])
{
    int mi=INF;
    string s;
    cin>>s;
    rep(i,s.size()-2)mi=min(mi,abs(753-stoi(s.substr(i,3))));
    cout<<mi<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    while (true){
        cin>>s;
        if (s=="0"){
            break;
        }
        int sum=0;
        for (int i=0; i<s.size();i++){
            int n=s[i]-48;
            sum+=n;
        }
        cout<<sum<<endl;
    }
}



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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
typedef long long ll;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll p)
{
    if (p == 0)
        return 1;
    if (!(p % 2))
    {
        ll halfP = p / 2;
        ll half = modpow(a, halfP);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}

ll comb(int a, int b)
{
    if (b > a - b)
        return comb(a, a - b);
    ll ansMul = 1;
    ll ansDiv = 1;
    for (int i = 0; i < b; i++)
    {
        ansMul *= a - i;
        ansDiv *= i + 1;
        ansMul %= mod;
        ansDiv %= mod;
    }
    ll ans = ansMul * modpow(ansDiv, mod - 2) % mod;
    return ans;
}

/*
int num = 200010;
vector<ll> fact(num), ifact(num);
fact[0] = 1;
fact[1] = 1;
for (int i = 2; i < num; i++) {
    fact[i] = fact[i-1] * i;
    fact[i] %= mod;
}
for (int i = 0; i < num; i++) {
    ifact[i] = modpow(ifact[i], mod-2);
    ifact[i] %= mod;
}
*/

int main() {
    int N; cin >> N;
    string s; cin >> s;
    vector<string> pos{
        "SS", "SW", "WS", "WW"
    };
    rep(k, 4) {
        string t = pos[k];
        rep(i, N) {
            if (i == N-1) s += s[0];
            if (t[i+1] == 'S') {
                if (t[i] == 'S' && s[i+1] == 'o') t += 'S';
                if (t[i] == 'S' && s[i+1] == 'x') t += 'W';
                if (t[i] == 'W' && s[i+1] == 'o') t += 'W';
                if (t[i] == 'W' && s[i+1] == 'x') t += 'S';
            }
            else if (t[i+1] == 'W') {
                if (t[i] == 'S' && s[i+1] == 'o') t += 'W';
                if (t[i] == 'S' && s[i+1] == 'x') t += 'S';
                if (t[i] == 'W' && s[i+1] == 'o') t += 'S';
                if (t[i] == 'W' && s[i+1] == 'x') t += 'W';
            }
        }
        if (t[N] == t[0] && t[N+1] == t[1]) {
            cout << t.substr(0, N) << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 776
# -*- coding: utf-8 -*-
#ABC144A
import sys
import math
import collections
#sys.setrecursionlimit(100000)


#n=int(input())

tmp = input().split()
a,b = list(map(lambda a: int(a), tmp))


if((a>9)or(b>9)):
	print(-1)
else:
	print(a*b)


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

int Flag(char t, char h){
	int Flag = 0;
	if(t > h) Flag = 1;
	if(t < h) Flag = -1;
	return Flag;
}

int Judge(string WordT, string WordH){
	int i = 0;
	int Judge = 0;
	while(i < WordT.size() && i < WordH.size()){
		Judge = Flag(WordT[i], WordH[i]);
		if(WordT[i] != WordH[i]) break;
		i++;
	}
	if(Judge == 0 && WordT.size() > WordH.size()) Judge = 1;
	if(Judge == 0 && WordT.size() < WordH.size()) Judge = -1;
	return Judge;
}

int main(){
	//???????????????????????°n????????????
	int n;
	cin >> n;
	//??????????????????????????????????????????
	vector<string> T;
	vector<string> H;
	for(int i = 0; i < n; i++){
		string WordT;
		string WordH;
		cin >> WordT;
		cin >> WordH;
		T.push_back(WordT);
		H.push_back(WordH);
	}
	//????¨???????????¨??????????
	int PointT = 0;
	int PointH = 0;
	for(int i = 0; i < n; i++){
		if(Judge(T[i], H[i]) == 1) PointT +=3;
		if(Judge(T[i], H[i]) == 0) PointT++, PointH++;
		if(Judge(T[i], H[i]) == -1) PointH +=3;
	}
	//????¨????????????¨?????????
	cout << PointT << " " << PointH << endl;
//	system("pause");
	return 0;
}

Measured memory_bytes: 1324
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int n, m, k; cin >> n >> m >> k;
  for (int a = 0; a <= n; a++) {
    for (int b = 0; b <= m; b++) {
      if (a * m + b * n - 2 * a * b == k) {
        Yes();
        return;
      }
    }
  }
  No();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(),x.end()
#define input(arr,n) for(ll c1=0;c1<n;c1++)cin>>arr[c1];
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
//cout<<"Case #"<<v1+1<<": ";
 
ll power(ll base,ll pow, ll mo)
{
   ll res=1;
   while(pow)
   {     
        if (pow%2!=0)  res=(res*base)%mo;
        base=(base*base)%mo;
        pow/=2;
   }
   return res;
}
 
 
int main()
{
    fastio
	
	ll i,n,k,a,b;
	cin>>a>>b>>n;
	
	if(b-1<=n)
	{
	    cout<<(a*(b-1))/b-a*((b-1)/b);
	}
	else
	{
	    cout<<(a*(n))/b-a*((n)/b);
	}
    return 0;
}

Measured memory_bytes: 3600
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
 
 
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a;
	cin>>a;
	cout<<a*a*3<<endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

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

int main() {
  int N, M = 500, K; cin >> K;
  if (K <= M) {
    N = K;
    cout << N << endl;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        int num = (i + j) % N;
        cout << num + 1 << " \n"[j==N-1];
      }
    }
  } else {
    N = M;
    cout << N << endl;;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        int num = (i + j) % N;
        if ((num < K-M) && !(i & 1)) num += M;
        cout << num + 1 << " \n"[j==N-1];
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int n, m;
vector<pair<int, int>> iland;

bool compare_b(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main() {
  cin >> n >> m;
  int a, b;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    iland.push_back(make_pair(a, b));
  }
  int crnt_pos = 0;
  int cnt = 0;
  sort(iland.begin(), iland.end(), compare_b);
  for (int i = 0; i < m; ++i) {
    a = iland[i].first;
    b = iland[i].second;

    if (crnt_pos <= a) {
      cnt += 1;
      crnt_pos = b;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1400
N = int(input())
tuplea = tuple(map(int, input().split()))
ans = 0
for n in range(N):
    if tuplea[n]%2 == 1:
        pass
    else:
        if tuplea[n]%3 == 0 or tuplea[n]%5 == 0:
            pass
        else:
            ans = 1
if ans == 0:
    print('APPROVED')   
else:
    print('DENIED')             
       

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

using namespace std;

const int P = 998244353;

long long power(long long x, long long t) {
	long long ret = 1;
	for(; t; t >>= 1, x = x * x % P) {
		if(t & 1) {
			ret = ret * x % P;
		}
	}
	return ret;
}

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

	vector<long long> fac(n + 1);
	fac[0] = 1;
	for(int i = 1; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % P;
	}

	vector<long long> inv(n + 1);
	inv[n] = power(fac[n], P - 2);

	for(int i = n; i >= 1; --i) {
		inv[i - 1] = inv[i] * i % P;
	}

	auto C = [&] (int n, int m) {
		if(m > n) {
			return 0LL;
		}
		return fac[n] * inv[m] % P * inv[n - m] % P;
	};

	long long ans = 0;

	for(int i = n - k - 1; i < n; ++i) {
		ans = (ans + C(n - 1, i) * power(m - 1, i) % P * m % P) % P;
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 6376
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

VI a;
int ret, n;
void dfs(int b, int c, int d) {
	//cout << b << " " << c << " " << d << endl;
	if(b == 0) {ret++; /*cout << "------" << endl;*/ return;}
	if(d == 4) return;

	for(int i=c; i*i<=n; ++i) {
		dfs(b-i*i, i, d+1);
	}
}

signed main(void)
{
	int c = 1;
	double p = pow(2, 15);
	while(c*c < p) {
		a.PB(c*c);
		c++;
	}

	while(true) {
		cin >> n;
		if(!n) break;

		ret = 0;
		dfs(n, 1, 0);
		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 3024
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W, K = map(int, readline().split())

    dp = [0] * W
    dp[0] = 1

    for _ in range(H):
        dp, dp_prev = [0] * W, dp
        for mask in range(1 << (W - 1)):
            ok = True
            for i in range(W - 2):
                if mask & (1 << i) and mask & (1 << (i + 1)):
                    ok = False
                    break
            if not ok:
                continue
            for i in range(W):
                if i > 0 and mask & (1 << (i - 1)):
                    dp[i - 1] = (dp[i - 1] + dp_prev[i]) % MOD
                elif i < W - 1 and mask & (1 << i):
                    dp[i + 1] = (dp[i + 1] + dp_prev[i]) % MOD
                else:
                    dp[i] = (dp[i] + dp_prev[i]) % MOD

    print(dp[K - 1])

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9136
#include <stdio.h>

int main(void) {
	int H, W, N;
	int mimorinn;
	if (scanf("%d", &H) != 1) return 1;
	if (scanf("%d", &W) != 1) return 1;
	if (scanf("%d", &N) != 1) return 1;
	mimorinn = W >= H ? W : H;
	printf("%d\n", (N + mimorinn - 1) / mimorinn);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using  namespace std;
int n,a,b,c;
string s[100005];
char ans[100005];

bool ok;
void dfs(int ind,int a,int b,int c){
	if(a<0 || b<0 || c<0) return;
	if(ind==n){
		puts("Yes");
		for(int i = 0;i < n;i++){
			cout<<ans[i]<<endl;
		}
		exit(0);
	}
	else{
		if(s[ind]=="AB"){
			ans[ind]='A';
			dfs(ind+1,a+1,b-1,c);
			ans[ind]='B';
			dfs(ind+1,a-1,b+1,c);
		}
		else if(s[ind]=="AC"){
			ans[ind]='A';
			dfs(ind+1,a+1,b,c-1);
			ans[ind]='C';
			dfs(ind+1,a-1,b,c+1);
		}
		else{
			ans[ind]='B';
			dfs(ind+1,a,b+1,c-1);
			ans[ind]='C';
			dfs(ind+1,a,b-1,c+1);
		}
	}
	
}
int main(){
	cin>>n>>a>>b>>c;
	
	for(int i = 0;i<n;i++) cin>>s[i];
	dfs(0,a,b,c);
	
		puts("No");
	
	return 0;
}


Measured memory_bytes: 14676
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  [n, m, x] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    tests = sequence . replicate n $ [False, True] :: [[Bool]]
  cas <- sequence . replicate n $ map unsafeTextToInt . T.words <$> T.getLine :: IO [[Int]]
  let
    cs = map head . filter (all (x <=) . tail) . map (foldl (zipWith (+)) (replicate (succ m) 0) . map fst . filter snd . zip cas) $ tests :: [Int]
  print $ if null cs then (-1) else minimum cs

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 5120
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;

int main()
{
	string s;

	cin >> s;

	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;


	return 0;
}

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

const int64_t MOD = 1e9+7;
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int main(){
    int N, X[100000];
    cin >> N;
    for(int i=0; i<N; i++) cin >> X[i];

    vector<int> num(100000, 0);
    int lim = 0;
    for(int i=0; i<N; i++){
        num[lim]++;
        lim = max(lim, i+1 - (X[i]+1)/2);
    }

    int sum = 0;
    int64_t ans = 1;
    for(int i=0; i<N; i++){
        sum += num[i];
        mul(ans, sum);
        sum--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

template <typename T> bool chmin(T &a, const T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T> bool chmax(T &a, const T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    const int mx = 410;
    
    int n, ma, mb;
    cin >> n >> ma >> mb;
    vector<int> a(n), b(n), c(n);
    REP(i, n) cin >> a[i] >> b[i] >> c[i];
    
    vector<vector<int>> dp(n + 1, vector<int>(mx * mx, 1000000000));
    dp[0][0] = 0;
    REP(i, n) REP(j, mx * mx) {
        int aa = j / mx, bb = j % mx;
        chmin(dp[i + 1][j], dp[i][j]);
        if (aa + a[i] < mx && bb + b[i] < mx) chmin(dp[i + 1][(aa + a[i]) * mx + (bb + b[i])], dp[i][j] + c[i]);
    }
    
    int ans = 1000000000;
    int aa = ma, bb = mb;
    while (aa < mx && bb < mx) {
        chmin(ans, dp[n][aa * mx + bb]);
        aa += ma; bb += mb;
    }
    
    if (ans == 1000000000) cout << -1 << "\n";
    else cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 30960
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; scanf("%lf",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
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;}

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

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>

int main()
{
    int n{}, m{};
    std::cin >> n >> m;

    if (n >= m) {
        std::cout << std::string(n, '0' + m) << std::endl;
    } else {
        std::cout << std::string(m, '0' + n) << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
long long ans,As;
int main(){
    string s;
    cin>>s;
    s = '#'+s+"###";
    for(int i=1;i<=s.length();i++){
        if(s[i] == 'A'){
            As++;
        }else if(s[i] == 'B' && s[i+1]=='C'){
            ans+=As;
            i++;
        }else{
            As = 0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 772
#include <iostream>

int main(){
  int A, B;
  std::cin>>A>>B;
  int result[3];
  result[0] = 2*A -1;
  result[1] = A+B;
  result[2] = 2*B-1;
  int max = result[0];
  for(int i = 0 ; i < 3 ; i++){
    if(result[i]>=max){
      max = result[i];
    }
  }
  std::cout<<max<<std::endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
R = []
for i in range(n):
    R.append(int(input()))
buying = R[0]  # 初期買値
maximumProfit = -10 ** 18  # 初期利益
for i in range(1, n):
    maximumProfit = max(maximumProfit, R[i] - buying)
    buying = min(buying, R[i])
print(maximumProfit)



Measured memory_bytes: 13588
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
int main(){
    map<char,char>bin;
    bin['T']='a',bin['L']='i',bin['U']='u',bin['R']='e',bin['D']='o';
    string sin="  kstnhmyr";
    string ipt;
    cin>>ipt;
    for(int i=0;i<ipt.length();i+=2){
        if(ipt[i]!='0'){
            if(ipt[i]!='1')cout<<sin[ipt[i]-'0'];
            cout<<bin[ipt[i+1]];
        }
        else{
            switch(ipt[i+1]){
            case 'T':
                cout<<"wa";
                break;
            case 'D':
                cout<<"wo";
                break;
            default:
                cout<<"nn";
            }
        }
    }
    cout<<endl;
    return 0;
}

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

// main.cpp

int main() {
  std::int_fast64_t k, t;
  std::cin >> k >> t;
  std::vector<std::int_fast64_t> a;
  a.reserve(t);
  std::copy_n(std::istream_iterator<std::int_fast64_t>(std::cin), t, std::back_inserter(a));

  auto calc_next = [&t, &a](const std::int_fast64_t ng) {
    std::int_fast64_t result = -1;
    std::int_fast64_t max = -1;
    for (std::int_fast64_t i = 0; i < t; ++i) {
      if (i == ng) continue;
      if (a[i] == 0) continue;
      if (max < a[i]) {
        max = a[i];
        result = i;
      }
    }
    if (result > -1) return result;
    return a[ng] > 0 ? ng : -1;
  };

  std::int_fast64_t answer = 0;
  std::int_fast64_t prev = -1;
  std::int_fast64_t next;
  while ((next = calc_next(prev)) > -1) {
    if (prev == next) ++answer;
    --a[next];
    prev = next;
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    int d[100001];
    cin >> N;
    for(int i=0; i < N; i++)    cin >> d[i];
    sort(d, d+N);
    int idx = N / 2;
    cout << d[idx] - d[idx-1] << endl;
    return 0;
}


Measured memory_bytes: 640
#include "stdio.h"

int H,W;
char campus[30][30];

#define abs(a) ((a)>0?(a):-(a))

int main(){

  scanf("%d%d\n",&H,&W);

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      campus[i][j]=getchar();
    }
    getchar();
  }

  

  int max=0;

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(campus[i][j]=='B'){
	for (int k=0;k<H;k++){
	  for (int h=0;h<W;h++){
	    if(campus[k][h]=='B'){
	      int dist=abs(i-k)+abs(j-h);
	      //printf("%d\n",dist);
	      max=max<dist?dist:max;
	    }
	  }
	}
      }
    }
  }

  printf("%d\n",max);

  return 0;
}



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

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

int main(){
	int N;
	scanf("%d",&N);
	int A[N];

	for(int i=0;i<N;i++)
		scanf("%d",&A[i]);
	qsort(A,N,sizeof(int),comp);

	int ans=0;
	for(int i=0;i<N;i++){
		if(A[i]==A[i+1])
			i++;
		else
			ans++;

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

Measured memory_bytes: 892
amida = []

def main():
	num_vlines = int(raw_input());
	num_wlines = int(raw_input());

	init_amida(num_vlines)

	count = 0;
	while count < num_wlines :
		ab = raw_input().strip().split(',')
		# print "--- input keys ---"
		# pprint.pprint(ab)
		transposition(int(ab[0]), int(ab[1]))
		# print "--- dump amida ---"
		# print amida.items()
		count += 1

	for i in range(1, num_vlines + 1):
		print amida[i]


def init_amida(num_vlines):
	for i in range(num_vlines + 1):
		amida.append(i)

	# pprint.pprint(amida)

def transposition(a, b):
	tmp = amida[a]
	amida[a] = amida[b]
	amida[b] = tmp

main()

Measured memory_bytes: 4240
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pq = priority_queue<int>;
using q = queue<int>;
 
int main() {
    int k;
  string s;
  cin >> k >> s;


 if(s.size() <= k){
     cout << s << endl;
 }else {
     cout << s.substr(0,k) + "..." << endl;
 }
  return 0;
}
     

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N, M;
    cin >> N;
    vll D(N);
    rep(i, N) cin >> D[i];
    cin >> M;
    vll T(M);
    rep(i, M) cin >> T[i];
    map<int, int> cnt;
    for (int i = 0; i < N; i++)
    {
        cnt[D[i]]++;
    }
    bool ok = true;
    for (int i = 0; i < M; i++)
    {
        if (cnt.find(T[i]) == cnt.end() or cnt[T[i]] == 0)
        {
            ok = false;
        }
        else
        {
            cnt[T[i]]--;
        }
    }
    cout << (ok ? "YES" : "NO");

    return 0;
}

Measured memory_bytes: 12800