akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a, const void *b){
    return *(int *)b - *(int *)a;
}
int main(void)
{
    int N;
    int A[200010],B[200010];
    scanf("%d", &N);
    for(int i=0;i<N;i++){
        scanf("%d", &A[i]);
        B[i]=A[i];
    }
    qsort(A,N,sizeof(int),cmp);
    
    for(int i=0;i<N;i++){
        //A[i]と最大値が異なる場合
        if(A[0]!=B[i]) printf("%d\n",A[0]);
        //A[i]が最大値と同じ場合、2番目に大きい値を表示
        else printf("%d\n",A[1]);
    }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
const int mod = 1e9 + 7;
int main() {
     int n,k,s;
     cin >> n >> k >> s;
     int tmp;
     if (s != 1e9)tmp = s + 1;
     else tmp = 1;
     for (int i = 0 ; i < n; ++i) {
        if (i < k) cout << s << " ";
        else cout << tmp << " ";
     }
     cout << endl;
}


Measured memory_bytes: 1280
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>
using namespace std;

int main()
{
    int n;
    int sum = 1;
    string s;
   // int d[100];
    cin >> n;
    cin >> s;
    for (int i = 0; i < n-1; i++) {
        if (s[i] != s[i + 1])sum++;
    }
    cout << sum << endl;

    return 0;
}



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

struct RSQ{
 struct Node{ ULL x,s; };
 UL N;
 vector<Node> V;
 void init(UL n){
  N=1; while(N<n) N<<=1;
  V.resize(N*2);
 }
 ULL sum(UL l,UL r,UL a=0,UL b=0,UL i=~0u){
  if(i==~0u){ a=0; i=1; b=N; }
  if(r<=a || b<=l) return 0;
  if(l<=a && b<=r) return V[i].s;
  ULL q1=sum(l,r,a,(a+b)>>1,i<<1);
  ULL q2=sum(l,r,(a+b)>>1,b,(i<<1)+1);
  return q1+q2+V[i].x*(min(r,b)-max(l,a));
 }
 void add(UL l,UL r,ULL x,UL a=0,UL b=0,UL i=~0u){
  if(i==~0u){ a=0; i=1; b=N; }
  if(r<=a || b<=l) return;
  if(l<=a && b<=r){ V[i].x+=x; V[i].s+=x*(b-a); return; }
  add(l,r,x,a,(a+b)>>1,i<<1);
  add(l,r,x,(a+b)>>1,b,(i<<1)+1);
  V[i].s = V[i<<1].s + V[(i<<1)+1].s + V[i].x*(b-a);
 }
};

UL N;
vector<UL> E[100000];
UL hlZ[100000];
UL hlL[100000];
UL hlH[100000];
UL hlP[100000];
UL hlR[100000];
UL hlRP = 0;

RSQ G;

void DFS(UL p){
 UL x=~0u;
 for(UL e:E[p]){
  if(hlP[p]==e) continue;
  hlP[e]=p;
  DFS(e);
  hlZ[p]+=hlZ[e];
  if(x==~0u) x=e; else if(hlZ[x]<hlZ[e]) x=e;
 }
 if(x!=~0u){ hlH[x]=p; hlL[p]=hlL[x]+1; }
}

void hlDFS(UL p){
 if(hlH[p]!=p){
  hlR[p]=hlR[hlP[p]]+1;
  hlH[p]=hlH[hlP[p]];
 }
 else{
  hlR[p]=hlRP;
  hlRP+=hlL[p]+1;
 }
 for(UL e:E[p]){
  if(hlP[p]==e) continue;
  hlDFS(e);
 }
}

int main(){
 scanf("%u",&N);
 rep(u,N){
  UL K; scanf("%u",&K);
  rep(k,K){
   UL v; scanf("%u",&v);
   E[u].push_back(v);
   E[v].push_back(u);
  }
 }
 rep(i,N){ hlH[i]=i; hlP[i]=~0u; hlZ[i]=1; hlL[i]=0; }
 DFS(0);
 hlDFS(0);
 G.init(N);
 UL Q; scanf("%u",&Q);
 rep(q,Q){
  UL c; scanf("%u",&c);
  if(c==0){
   UL p,x; scanf("%u%u",&p,&x);
   while(p!=~0u){
    G.add(hlR[hlH[p]],hlR[p]+1,x);
    p=hlP[hlH[p]];
   }
  }
  if(c==1){
   UL p; scanf("%u",&p);
   ULL ans=0;
   while(p!=~0u){
    ans += G.sum(hlR[hlH[p]],hlR[p]+1);
    p=hlP[hlH[p]];
   }
   ans -= G.sum(hlR[0],hlR[0]+1);
   printf("%llu\n",ans);
  }
 }

 return 0;
}



Measured memory_bytes: 22076
given_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(given_list[K - 1])

Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#pragma warning(disable:4996)

int power(int num) {
	int result = 1;
	for (int i = 0; i < 3; i++) {
		result = result * num;
	}
	return result;
}
int main() {
	int num = 0;
	scanf("%d", &num);
	if (num >= 1 && num <= 9) {
		printf("%d\n", power(num));
	}
	return 0;
}

Measured memory_bytes: 128
while True:
    n = int(input())
    if n == 0:
        break
    save_list=[0]*4001
    display_list = []
    for i in range(n):
        a,b,c =  map(int, input().split())
        save_list[a] += b * c
        if a not in display_list:
            display_list.append(a)
    ans = []
    for i in display_list:
        if save_list[i] >= 1000000:
            ans.append(i)
    if not ans:
        print("NA")
    else:
        for i in ans:
            print(i)


Measured memory_bytes: 5832
awk 'NR == 1 {
    ok = "Yes"
    RS = FS
    FS = "@"
    last = -100
}
NR > 1 {
    if (last <= ($1 - 1)) {
        last = $1 - 1
    } else if (last <= $1) {
        last = $1
    } else {
        ok = "No"
    }
}
END {
    print ok
}'


Measured memory_bytes: 552
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int INF=INT_MAX;
const ld PI=3.1415926535897932384626433;
const ld E=2.71828183;
const int MOD=1e9+7;
vi bfs(vector<vi>adj,int src){
    //adjacency list, not-weighted, possibly directed ,src is 1-indexed, adj[0].size()=0!!!
    //for n vertices, adj.size()=n+1. (constructed via push_back() ).

    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return dst;
}
vi bfsParents(vector<vi>adj,int src){
    vi parents=vi(adj.size(),INF);
    parents[src]=-1;
    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                parents[nbr]=c;
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return parents;
}
int powMod(int base,int exp,int mod){
    //base^exp %mod
    int ans=1;
    for(int i=0; i<exp; i++)
        ans=((ans%mod)*(base%mod))%mod;
    return ans;
}
vi divisorsOf(int n){
    //vector of divisors of n (inc. 1 , excl.n)
    vi ans;
    for(int i=1; i*i<=n; i++){
        if(n%i==0)
            ans.push_back(i);
        if(i*i!=n && i!=1)
            ans.push_back(n/i);
    }
    return ans;
}

void solve();

int main() {
    //  int t;
    //cin >> t;
    //while(t--)
    solve();
}
void solve(){
    int n,m;
    cin >> n >> m;
    int sum=0;
    for(int i=0; i<m; i++){
        int x;
        cin >> x;
        sum+=x;
    }
    if(sum<=n)
        cout << n-sum << "\n";
    else
        cout << "-1\n";
}

Measured memory_bytes: 3632
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
def avg_tmp(t, x):
  return t- x*0.006
ans, ans_index = 10000000, 0
for i in range(n):
  if abs(avg_tmp(t, h[i]) -a) < abs(ans-a):
         ans = avg_tmp(t, h[i])
         ans_index = i+1
print(ans_index)

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	string s;
	ll ans=0,cnt=0;
	cin >> s;
	rep(i,SIZE(s)){
		if(s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C') cnt++;
		else{
			chmax(ans,cnt);
			cnt=0;
		}
		if(i==SIZE(s)-1) chmax(ans,cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        while(true){
        	String in=br.readLine();
			if(in.equals("0 0")) break;
            String[] a=in.split(" ");
            int n=Integer.parseInt(a[0]);
            int x=Integer.parseInt(a[1]);
            List<String> l=new ArrayList<String>(); 
        	for(int i=1;i<=n;i++){
            	for(int j=1;j<=n;j++){
                	for(int k=1;k<=n;k++){
                		if(i!=j&&j!=k&&k!=i&&i+j+k==x){
                			int[] q={i, j, k};
                			Arrays.sort(q);
                			String s=Arrays.toString(q);
                			if(l.indexOf(s)==-1) l.add(s);
                		}
                	}
            	}
        	}
        	System.out.println(l.size());
        }
	}
}

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

int main() {
  while (true) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 0 && b == 0 && c == 0) {
      break;
    }
    int n;
    cin >> n;
    int data[n][4];
    int i, j;
    for (i = 0; i < n; i++) {
      for (j = 0; j < 4; j++) {
        cin >> data[i][j];
      }
    }
    int sum = a + b + c;
    int res[sum] = {};
    for (i = 0; i < n; i++) {
      if (data[i][3] == 1) {
        for (j = 0; j < 3; j++) {
          res[data[i][j] - 1] = 1;
        }
      }
    }

    for (i = 0; i < n; i++) {
      if (res[data[i][0] - 1] + res[data[i][1] - 1] + res[data[i][2] - 1] == 2) {
        for (j = 0; j < 3; j++) {
          if (res[data[i][j] - 1] == 0) {
            res[data[i][j] - 1] = 4;
          }
        }
      }
    }

    for (i = 0; i < sum; i++) {
      if (res[i] == 0) {
        res[i] = 2;
      } else if (res[i] == 4) {
        res[i] = 0;
      }
    }

    for (i = 0; i < sum; i++) {
      cout << res[i] << endl;
    }

  }
  return 0;
}



Measured memory_bytes: 3024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		int i, ans = 1;
		for(i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		long sum = a[0];
		for(i = 1; i < n; i++){
			if((2 * sum) >= a[i]){
				ans++;
			}else{
				ans = 1;
			}
			sum += a[i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 50636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n,m;  cin>>n>>m;
    ll arr[n]; for(auto &x:arr) cin>>x;
    ll ct=n; set<ll>s; //track of bad observ...
    while(m--)
    {
         ll a,b;cin>>a>>b;
         if(arr[a-1]>arr[b-1]){
              if(s.find(b)==s.end()){
                   ct--; s.insert(b);
              }
         }
         else if(arr[a-1]<arr[b-1] ){
              if(s.find(a)==s.end()){
                   ct--; s.insert(a);
              }
         }
         else {
              if(s.find(a)==s.end()){
                   ct--; s.insert(a);
              }
              if(s.find(b)==s.end()){
                   ct--; s.insert(b);
              }
         }
    }
    cout<<ct;
    return 0;
}


Measured memory_bytes: 7104
#include<stdio.h>
int f(int);
int main(void)
{
  int an[1000000],ans,i,j;
  scanf("%d",&an[0]);
  for(i=1;i<1000000;i++)
  {
    an[i]=f(an[i-1]);
    for (j=0;j<i;j++)
    {
      if(an[i]==an[j]) 
      {
        ans=i;
        goto end;
      }
    }
  }
  end:
  printf("%d",ans+1);
  return 0;
}

  
  
  

int f(int n)
{
  int num;
  if(n%2==0) num=n/2;
  else num=3*n+1;
  return num;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    int n;
    cin >> n;
    vector<int> b(n-1);
    REP(i,n-1) cin >> b[i];
    vector<int> a(n,-1);

    REP(i,n-1){
        a[i] = b[i];
    }
    int tmp = b[n-2];
    a[n-1] = b[n-2];
    REP(i,n-1){
        if(a[i] > a[i+1]){
            a[i+1] = min(b[i+1],a[i]);
        }
        else{
            a[i+1] = min(b[i],b[i+1]);
        }
        
    }
    a[n-1] = tmp;

    int sum = 0;
    REP(i,n){
        sum += a[i];
    }

    cout << sum << endl;

    return 0;
}

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

int main()
{
    string S, T;
    cin >> S >> T;
    vector<int> N(S.size() - T.size() + 1);
    for (int i = 0; i <= S.size() - T.size(); i++)
    {
        for (int j = 0, k = i; j < T.size(); j++, k++)
        {
            if (S.at(k) != T.at(j))
            {
                N.at(i)++;
            }
        }
        //cout << N.at(i) << endl;
    }
    sort(N.begin(), N.end());
    if (S.size() - T.size() != 0)
    {
        cout << N.at(0) << endl;
    }
    else
    {
        cout << N.at(0) << endl;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#define endl '\n'
using namespace std;
const int N=2e5+100;
ll a[N];
int32_t main(){
    ll n,m;
    cin >> n >> m;
    vector <int> b;
    for (int i=0;i<m;i++){
        cin >> a[i];
        if (a[i]%2==1) b.pb(a[i]);
    }
    if (b.size()>2){
        cout << "Impossible" << endl;
        return 0;
    }
    if (b.size()==2){
        b.pop_back();
        for (int i=0;i<m;i++){
            if (a[i]%2==0) b.pb(a[i]);
        }
        for (int i=n-1;i>-1;i--){
            if (a[i]%2==1){
                b.pb(a[i]);
                break;
            }
        }
        for (int i=0;i<b.size();i++){
            cout << b[i] << " ";
        }
        cout << endl;
        if (b[0]!=1){
            cout << m << endl;
            cout << b[0]-1 << " ";
        }
        else{
            cout << m-1 << endl;
        }
        for (int i=1;i<b.size()-1;i++){
            cout << b[i] << " ";
        }
        cout << b.back()+1 << endl;
        return 0;
    }
        for (int i=0;i<m;i++){
            if (a[i]%2==0) b.pb(a[i]);
        }
        for (int i=0;i<b.size();i++){
            cout << b[i] << " ";
        }
        cout << endl;
        if (b[0]!=1){
            cout << m+1 << endl;
            cout << b[0]-1 << " ";
        }
        else{
            cout << m << endl;
        }
        for (int i=1;i<b.size();i++){
            cout << b[i] << " ";
        }
        cout <<1  << endl;
        return 0;


}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
    int r, c;

    cin >> r >> c;

    int A[r + 1][c + 1];

    int sum_x;
    
    for(int y = 0; y < r; y++){
        sum_x = 0;
        for(int x = 0; x < c + 1; x++){
            if(x < c){
            cin >> A[y][x];
            sum_x = sum_x +  A[y][x];
            }
            else{
                A[y][x] = sum_x;
            }
        }
    }

    int sum_y;

    for(int x = 0; x < c + 1; x++){
        sum_y = 0;
        for(int y = 0; y < r; y++){
            sum_y = sum_y + A[y][x];
        }
        A[r][x] = sum_y;
    }

    for(int y = 0; y < r + 1; y++){
        for(int x = 0; x < c + 1; x++){
            if(x > 0){
                printf(" %d", A[y][x]);
            }
            else{
                printf("%d", A[y][x]);
            }
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//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(){
    ll s, w; cin >> s >> w;
    if(w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

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

Measured memory_bytes: 3644
def main():
  n = int(input())
  sdic = {}
  for _ in range(n):
    s = [_s for _s in sorted(input().strip())]
    s = ''.join(s)
    if s in sdic:
      sdic[s] += 1
    else:
      sdic[s] = 1
  ans = 0
  for k, v in sdic.items():
    ans += v*(v-1)//2
  print(ans)


if __name__ == '__main__':
  main()


Measured memory_bytes: 17852
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  string s;
  string temp;
  vector<vector<int> > index('z' - 'a' + 1);
  vector<string> koho;
  int k;
  cin >> s;
  cin >> k;
  for (size_t i = 0; i < s.length(); i++) {
    index[s[i] - 'a'].push_back(i);
  }
  for (size_t i = 0; i < 'z' - 'a' + 1; i++) {
    if (!index[i].empty()) {
      for (size_t p = 0; p < index[i].size(); p++) {
        for (size_t j = 0; j < 5; j++) {
          temp.clear();
          for (size_t k = 0; k <= j; k++) {
            if (index[i][p] + k == s.length()) {
              break;
            }
            temp.push_back(s[index[i][p] + k]);
          }
          koho.push_back(temp);
        }
      }
      sort(koho.begin(), koho.end());
      koho.erase(unique(koho.begin(), koho.end()), koho.end());
      if (koho.size() >= 5) {
        cout << koho[k-1] << endl;
        return 0;
      }
    }
  }
  cout << koho[k-1] << endl;
  return 0;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	int mx = (N - 2) * (N - 1) / 2;
	if (mx < K) {
		cout << -1 << endl;
		return 0;
	}
	cout << N - 1 + mx - K << endl;
	for (int i = 0;i < N - 1;i++) {
		cout << N << " " << i + 1 << endl;
	}
	ll cnt = mx - K;
	for (int i = 0;i < N - 1 && cnt;i++) {
		for (int j = i + 1;j < N - 1 && cnt;j++) {
			cout << i + 1 << " " << j + 1 << endl;
			cnt--;
		}
	}
}

Measured memory_bytes: 256
N,C,K=map(int,input().split())
import heapq
T=[]
heapq.heapify(T)
for i in range(N):
    heapq.heappush(T,int(input()))

ans=1
p=1
start=heapq.heappop(T)

for i in range(N-1):
    t=heapq.heappop(T)
    p+=1
    if p<=C and t<=start+K:
        continue
    else:
        start=t
        ans+=1
        p=1

print(ans)

Measured memory_bytes: 7116
using System;

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

            int c = time / 3600;
            int b = time / 60 % 60;
            int a = time % 60;

            Console.WriteLine(c + ":" + b + ":" +a);

        }
    }
}

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

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n)
    cin >> a.at(i);
  double sum=0;
  rep(i,n)
    sum += 1.0/a.at(i);
  cout << 1.0/sum << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

# mod = 10**9+7

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

# max_digit = 61

# count_0 = [0 for _ in range(max_digit)]
# count_1 = [0 for _ in range(max_digit)]

# for i in range(len(a)):
#     num_str = bin(a[i])[2:]
#     # print(num_str)
#     for j in range(len(num_str)):
#         # print(num_str[-j-1])
#         if num_str[-j-1] == "1":
#             count_1[-j-1] += 1

# # for i in range(max_digit):
# #     count_0[i] = n-count_1[i]

# ans = 0
# count = 1
# for i in range(61):
#     # tmp = count_0[-i-1]*count_1[-i-1]
#     tmp = count_1[-i-1]*(n-count_1[-i-1])
#     ans += tmp*count
#     count = (count*2) % mod
# print(ans % mod)


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

mod = 10**9+7
max_digit = 61

ans = 0
m = 1
for _ in range(max_digit):
    bit = sum(x&m for x in a)
    bit //= m
    non_bit = n - bit
    ans = (ans+bit*non_bit*m)%mod
    m <<= 1
print(ans)

Measured memory_bytes: 42212
#include<stdio.h>
#include<math.h>


int main(){

  int n, i;
  double x[100], y[100], max=0, d1=0, d2=0, d3=0;
  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%lf", &x[i]);
  for(i=0;i<n;i++) scanf("%lf", &y[i]);

  for(i=0;i<n;i++){
    d1+=fabs(x[i]-y[i]);
    d2+=pow(fabs(x[i]-y[i]), 2);
    d3+=pow(fabs(x[i]-y[i]), 3);
    if(max<fabs(x[i]-y[i])) max=fabs(x[i]-y[i]);
  }

  printf("%f\n%f\n%f\n%f\n", d1, sqrt(d2), cbrt(d3), max);

  return 0;
}

Measured memory_bytes: 728
def gcd(a, b):
  if(a == b):
    return a
  elif(a % b == 0):
    return b
  elif(b % a == 0):
    return a
  elif(a == 1 or b == 1):
    return 1
  elif(a > b):
    return gcd(a- a// b* b, b)
  elif(a < b):
    return gcd(a, b- b// a* a)

def ggcd(lista):
  if(len(lista) == 1):
    return lista.pop()
  else:
    l = lista.pop()
    for i in range(1, len(lista)):
      l = gcd(l, lista.pop())
    return l

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
d = []
gcds = set()
x.sort()

for i in range(N):
  d.append(x[i+ 1]- x[i])

gcds.add(d[0])

for i in range(N- 1):
  if(d[i+ 1] != d[i]):
    gcds.add(d[i+ 1])

print(ggcd(gcds))

Measured memory_bytes: 14480
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

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

    int A[4];
    REP(0, i, 4) {
        A[i] = N % 10;
        N /= 10;
    }

    REP(0, i, 2) {
        int cnt = 0;

        REP(i, j, i + 2) {
            if (A[j] == A[j + 1]) {
                cnt++;
            }
        }

        if (cnt == 2) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scan(&M, &N)
	d := []int{-1, -1, -1}
	out := false
	for N > 0 {
		N--
		var s, c int
		fmt.Scan(&s, &c)
		if out {
			continue
		}
		if d[M-s] >= 0 && d[M-s] != c {
			out = true
			continue
		}
		d[M-s] = c
	}
	if out || (M > 1 && d[M-1] == 0) {
		fmt.Println("-1")
	} else {
		ans := 0
		switch M {
		case 1:
			if d[0] == -1 {
				ans = 0
			} else {
				ans = d[0]
			}
		case 2:
			if d[0] == -1 {
				d[0] = 0
			}
			if d[1] == -1 {
				d[1] = 1
			}
			ans = d[1]*10 + d[0]
		case 3:
			if d[0] == -1 {
				d[0] = 0
			}
			if d[1] == -1 {
				d[1] = 0
			}
			if d[2] == -1 {
				d[2] = 1
			}
			ans = d[2]*100 + d[1]*10 + d[0]
		}

		fmt.Printf("%d\n", ans)
	}

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3010;
const int MOD = 998244353;
int a[N],n,m,dp[N][N];

int main(){
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j) dp[i][j]=dp[i-1][j];
        dp[i][a[i]]=(dp[i][a[i]]+i)%MOD;
        for(int j=a[i]+1;j<=m;++j){
            dp[i][j]=(dp[i][j]+dp[i-1][j-a[i]])%MOD;
        }
    }
    int ans=0;
    for(int i=1;i<=n;++i) ans=(ans+dp[i][m])%MOD;
    printf("%d\n",ans);
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
int fac[5001000],nifac[5001000],dp[2010][2010];
int getmi(int a,int x)
{
	int ans=1;
	while (x)
	{
		if (x&1) ans=(long long)ans*a%mo;
		a=(long long)a*a%mo;
		x>>=1;
	}
	return ans;
}
int C(int n,int m){return (long long)fac[n]*nifac[m]%mo*nifac[n-m]%mo;}
int main()
{
	int n,k;scanf("%d%d",&n,&k);
	if (k==1) {puts("1");return 0;}
	fac[0]=1;for (int i=1;i<=n*k;i++) fac[i]=(long long)fac[i-1]*i%mo;
	nifac[n*k]=getmi(fac[n*k],mo-2);
	for (int i=n*k-1;i>=0;i--) nifac[i]=(long long)nifac[i+1]*(i+1)%mo;
	dp[0][0]=1;
	for (int i=0;i<=n;i++)
	for (int j=0;j<=n;j++)
	{
		if (i) dp[i][j]=dp[i-1][j];
		if ((i!=j)&&(j)) dp[i][j]=(dp[i][j]+(long long)dp[i][j-1]*C(i+j*(k-1)-1,k-2))%mo;
	}
	printf("%lld\n",(long long)fac[n]*dp[n][n]%mo);
}

Measured memory_bytes: 49408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set> 
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

bool dp[2][10001];
 
int main(){
  int n;
  cin >> n;
  dp[0][0] = true;
  dp[1][0] = true;
  int one = 0;
  int two = 1;
  for (int i = 0; i < n;i++){
    int tmp;
    cin >> tmp;
    for (int j = 0; j < 10001;j++){
      if (j+tmp <= 10000 && dp[one][j]) {
        dp[two][j+tmp] = true;
        dp[two][j] = true;
      }
    }
    swap(one,two);
  }
  int ans = 0;
  for (int i = 0; i < 10001;i++){
    if (i%10 != 0 && dp[one][i]) ans = i;
  }
  cout << ans << endl;
  
  
  return 0; 
}



Measured memory_bytes: 256
#ifndef VS
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<math.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {
	cww() { CIN_ONLY{ ios::sync_with_stdio(false); cin.tie(0); } }
}star;
#define DEBUG if(0)
#endif

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r) { bool a = l>r; if (a)l = r; return a; }
template <typename T>inline bool chmax(T &l, T r) { bool a = l<r; if (a)l = r; return a; }
namespace _DSU {
	const int BUF = 112345 * 2;
	int ptr = 0;
	int mem[BUF];
	int* get(int size) {
		ptr += size;
		return mem + ptr - size;
	}
	void reset() {
		ptr = 0;
	}
}
class UF {
public:
	int *par, *rank;
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	UF(int n) :par(_DSU::get(n + 10)), rank(_DSU::get(n + 10)) {
		REP(i, n)par[i] = i, rank[i] = 0;
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return false;
		par[y] = x;
		return true;
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int N, Q;
typedef vector<int> V;
typedef vector<V> VV;
VV g;
int query[112345][2];
int m[112345];
int p[112345];
const int MARK = 0;
const int QUERY = 1;
void dfs(int v,int near,UF& uf) {
	if (m[v] == 1) {
		near = v;
		m[v] = near;
	}
	else {
		m[v] = -1;
	}
	uf.unite(near, v);
	int ch = g[v].size();
	REP(i, ch)dfs(g[v][i], near, uf);
}
 void solve() {
	_DSU::reset();
	g=VV(N);
	FOR(i, 1, N) {
		cin >> p[i]; p[i]--;
		g[p[i]].push_back(i);
		m[i] = 0;
	}
	m[0] = 1;
	REP(i, Q) {
		string s; int v;
		cin >> s >> v;
		v--;
		if (s[0] == 'Q')query[i][0] = QUERY;
		else {
			if (m[v] == 1)query[i][0] = -1;
			else {
				query[i][0] = MARK;
				m[v] = 1;
			}
		}
		query[i][1] = v;
	}
	UF uf(N);
	dfs(0, 0, uf);

	LL ret = 0;
	for (int i = Q - 1; i >= 0; i--) {
		//cout << i << " " << uf.find(32999) << " " << uf.find(88725) << endl;
		if (query[i][0] == -1)continue;
		if (query[i][0] == MARK) {
			int v = query[i][1];
			int u = p[v];
			//cout << m[uf.find(u)] << " " << m[uf.find(v)] << endl;
			m[uf.find(v)] = -1;
			uf.unite(u, v);
			//assert(m[uf.find(v)] != -1);
		}
		else {
			int v = query[i][1];
			//assert(m[uf.find(v)]!=-1);
			ret+= m[uf.find(v)]+1;
			//cout << m[uf.find(v)]+1;
		}
	}
	cout << ret << endl;
}
int main() {
	while (cin >> N >> Q, N + Q)solve();

}

Measured memory_bytes: 27004
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

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

#define rep(i,x) for(Int i = 0; i < (Int)(x); i++)
#define rrep(i,x) for(Int i = ((Int)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back


template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

Int dx[4] = {1,0,-1,0};
Int dy[4] = {0,1,0,-1};
const Int INF = 1001002003004005006ll;
const Int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//






Int fact[100000000];


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

        Int tmp = max(n,m);
        fact[0] = 1;
        for(Int i = 1; i <= tmp; i++){
                fact[i] = fact[i-1] * i;
                fact[i] %= mod;
        }

        if(n == m){
                Int tmp = fact[n];
                tmp *= tmp;
                tmp %= mod;
                tmp *= 2;
                tmp %= mod;
                cout << tmp << endl;
                return 0;
        }

        if(abs(m-n) > 1){
                cout << 0 << endl;
                return 0;
        }

        Int tmp1 = fact[n];
        Int tmp2 = fact[m];

        Int ans = tmp1 * tmp2 % mod;

        cout << ans << endl;
        return 0;
}



















Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0;
	if(n == 1) {
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1; i < n; i++) {
		if(s[i] != s[i-1]) ans++;
	}
	cout << ans << endl;
}


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

int main(){
  int L, R;
  scanf("%d %d", &L, &R);
  int surp = 2018;                 //考えられる剰余の最大値

  if(R - L >= 2019 || (L / 2019  + 1) * 2019 >= L && (L / 2019 + 1) * 2019 <= R){
    cout << 0 << endl;           //範囲内2019の倍数の存在
    return 0;
  }else{
    for(int j = L + 1; j <= R; j++){         //計算量はO(1) (条件分岐から明らか)
      for(int i = L; i < j; i++){
        if( ((i % 2019) * (j % 2019)) % 2019 < surp)
          surp =  (i % 2019) * (j % 2019) % 2019;
      }
    }
  }

  cout << surp << endl;
  
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int A, B, C, X; cin >> A >> B >> C >> X;

    int cnt = 0;
    for (int i = 0; i <= A; i++) {
      for (int j = 0; j <= B; j++) {
	for (int k = 0; k <= C; k++) {
	  if (500*i+100*j+50*k == X) {
	    cnt++;
	  }
	}
      }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
// --------------
// Tejas Pandey  |
// 21 - 03 - 20  |
// AtCoder BC 159|
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 998244353
#define vi vector<int>
typedef long long int ll;

int main (void)
{
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  int l;
  cin >> l;
  double f = l/3.0;
  cout << fixed << setprecision(10) << f*f*f << "\n"; 
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut ans = 0;
    for i in 0..s.len()/2 {
        if s[i] != s[s.len()-i-1] {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;
const ll inf = 10e17;
const ld eps = 10e-9;

ll solve(void);
ll gcd(ll x, ll y);

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

ll gcd(ll x, ll y)
{
	if (y == 1) { return 1;}
	if (x % y == 0) { return y; }
	return gcd(y, x % y);
}

ll n;
vector<ll> h;

ll solve(void)
{
	cin >> n;
	h.resize(n);
	for(auto&v :h)
		cin >> v;

	ll ans = 0, cnt = 0;

	for (ll i = 0; i < n - 1; i++)
	{
		if(h[i+1] <= h[i])
			cnt++;
		else
			cnt = 0;
		ans = max(ans, cnt);
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 1024
import sys
import math
input = sys.stdin.readline

def main():
    k = int(input())
    ans = 0

    for a in range( 1 , k+1 ):
        for b in range( a , k+1 ):
            x = math.gcd( a , b )
            for c in range( b , k+1 ):
                y = math.gcd( x , c )
                if a == b == c:
                    ans += y
                elif a==b or b==c or c==a:
                    ans += 3 * y
                else:
                    ans += 6 * y

    print(ans)



main()

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Yheeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
    int N;
    cin >> N;
    cout << (800 * N) - (N / 15 * 200) << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}


int main()
{
    int n, k;    
    cin >> n;
    vector<int> a(n);
    priority_queue<pair<int, int>> pq;
    rep(i,n) {
        cin >> a[i];
        pq.push(make_pair(a[i], i));
    }

    rep(i,n) {
        a[i] = pq.top().second + 1;
        pq.pop();
    }
    reverse(a.begin(), a.end());
    rep(i,n) cout << a[i] << " ";
    cout << endl;

    return 0;
}


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

int main() {
	long long H, W;
	cin >> H >> W;
	long long ans = H * W;
	if (H == 1 || W == 1) {
		cout << "1" << endl;
		return 0;
	}
	if (ans % 2 == 0) {
		cout << ans / 2 << endl;
	} else {
		cout << (ans / 2) + 1 << endl;
	}
}

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

int N;
int X[1<<18], s[1<<18];

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

	for (int i = 0; i < N; ++i) {
		scanf("%d", X+i);
		s[i] = X[i];
	}

	sort(s, s + N);
	for (int i = 0; i < N; ++i) {
		int a = s[(N+1)/2-1], b = s[(N+1)/2];
		printf("%d\n", X[i] >= b ? a : b);
	}
}

Measured memory_bytes: 3712
#!/usr/bin/env python3
import sys


def solve(N: int, S: str, T: str):
    s = ""
    for i in range(N):
        s += S[i]
        s += T[i]
    
    print(s)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(N, S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main () {
    int h, w;
    cin >> h >> w;
    int k = 0;
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        if (s[k] != '#') {
            puts("Impossible");
            return 0;
        }
        for (int j = k; j < w; j++) {
            if (s[j] == '#') {
                s[j] = '.';
                k = j;
            }
            else {
                break;
            }
        }
        for (int j = 0; j < w; j++) {
            if (s[j] == '#') {
                puts("Impossible");
                return 0;
            }
        }
    }
    puts("Possible");
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	string s;

	cin>>s;

	if(s[0]=='A'){
		ll count_c=0, ptr=0;
		repr(i, 2, s.size()-1){
			if(s[i]=='C'){
				count_c++;
				ptr=i;
			}
		}
		bool flag=true;
		repr(i, 1, s.size()){
			if(i!=ptr&&s[i]>='A'&&s[i]<='Z') flag=false;
		}
		if(count_c==1&&flag){
			cout<<"AC"<<endl;
		} else{
			cout<<"WA"<<endl;
		}
	} else{
		cout<<"WA"<<endl;
	}
}


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

int main() {
  int a, b; cin >> a >> b;
  if (a * b % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b,c,count = 0;
    scanf("%d %d %d",&a,&b,&c);
    for(int i = a; i <= b; i++){
        if(c%i == 0) count++;
    }
    printf("%d\n",count);
}


Measured memory_bytes: 2736
a,b,c,x,y = map(int,raw_input().split())

money = 0
if a + b > c * 2 :

	c_num = y * 2 if x > y else x * 2 #x > y ? y*2 : x*2
	money += c * c_num

	rest_money = a if x > y else b #x > y ? a : b
	rest_num = x-y if x > y else y-x #x > y ? x-y : y-x
	
	money += c * 2 * rest_num if rest_money > c*2 else rest_money * rest_num

else :
	money += a * x + b * y

print money 


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

using namespace std;
const int N = 1e6 + 6;
int a[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a+i);
  }
  sort(a, a+n);
  long long x = -1, y = -1;
  for (int i = n-2; i >= 0; i--) {
    if (a[i] == a[i+1]) {
      if (x == -1) {
        x = a[i];
        a[i] = -1;
      }
      else {
        printf("%lld\n", x * a[i]);
        return 0;
      }
    }
  }
  printf("%lld\n", 0);
  return 0;
}

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

int main() {
  double W, H;
  double x, y;
  cin >> W >> H >> x >> y;
  cout << W * H / 2 << " ";
  if(2 * x == W && 2 * y == H) {
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
int a, b;
int main() {
    cin >> a >> b;
    if (a > 0 && b > 0) {//都为正数
        cout << "Positive" << endl;
    } else if (max(a, b) >= 0 && min(a, b) <= 0 || a == 0 || b == 0) {
        //这里条件写的有点繁琐，可以略加修改
        cout << "Zero" << endl;
    } else {
        if ((abs(min(a, b)) - abs(max(a, b))) % 2 == 0) {
            //有偶数个因数
            cout << "Negative" << endl;
        } else {
            //奇数个因数
            cout << "Positive" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int h, w; cin >> h >> w;
  int c[10][10];
  REP(i,10) REP(j,10) cin >> c[i][j];

  REP(i,10) { // 経由する頂点
    REP(j,10) { // 開始頂点
      REP(k,10) { // 終端
        c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
      }
    }
  }

  int ans = 0;
  REP(i,h) REP(j,w) {
    int a; cin >> a;
    if (a != -1) ans += c[a][1];
  }

  COUT(ans);
  return 0;
}


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

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];

    int four, two, other;
    four = two = other = 0;
    for (auto x : a) {
        if (x%4 == 0) four++;
        else if (x%2 == 0) two++;
    }
    other = n - (two + four);
    if (two) {
        cout << (other <= four ? "Yes" : "No") << endl;
    } else {
        cout << (other <= four + 1 ? "Yes" : "No") << endl;
    }

    return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
const int mxn = 2e5 + 1;
ll arr[mxn], dp[mxn], pref[mxn];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;cin>>n;
	for(int i = 1; i<=n; ++i) cin>>arr[i];
	dp[0] = 0;
	pref[0] = 0;
	pref[1] = arr[1];
	for(int i = 2; i <=n; ++i) pref[i] = pref[i-2] + arr[i];
	dp[1] = 0;
	for(int i = 2; i <=n; ++i){
		if(i&1){
			dp[i] = max(dp[i-1], dp[i-2] + arr[i]);
		} else{
			dp[i] = max(dp[i-2] + arr[i], pref[i-1]);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}



Measured memory_bytes: 8328
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

const double pi = acos(-1);

double r;

int main(){
    cin>>r;
    printf("%.7lf %.7lf\n",pi*r*r,2*pi*r);
    return 0;
}


Measured memory_bytes: 3204
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 1e18
using namespace std;
typedef long long int ll;

int main(){
  string s; cin >> s;
  ll n;  cin >> n;
  int ans = 1;
  for(auto c:s){
    if(c != '1' || n<=1){
      ans = c-'0';
      break;
    }
    else{
      n--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    long long int i,j,x,p,k,mn;
    int c=0;
    double N;

    long long int A[10000];
    scanf("%lf",&N);

    x=sqrt(N);

    for(int i=1,k=0; i<=x; i++)
    {
        if( fmod(N,i)==0)
        {


                j=N/i;
                p=i+j-2;
                c=c+1;


                A[k]=p;


                k++;

        }

    }




    mn=A[0];
    for(int k=1; k<c; k++)
    {
        if(A[k]<mn)
        {
            mn=A[k];

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



    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int k = sc.nextInt();
    int s = sc.nextInt();
    int ans = 0, sum = 0;
    for(int i=0; i<=k; i++){
      for(int j=0; j<=k; j++){
        sum = s-i-j;
        if(0 <= sum && sum <= k){
          ans++;
        }
      }
    }
    System.out.println(ans);

    sc.close();
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
    cin>>n;
    if(n%1000==0)
        cout<<"0"<<endl;
    else
    {
        d=n%1000;
        cout<<1000-d<<endl;
    }
    return 0;
}


Measured memory_bytes: 3628
n, k= map(int, input().split())

A = list(map(int, input().split()))

genzaiti=0
visited=[-1]*n
visited[0]=0
nikaime=0
for i in range(k):
    genzaiti=A[genzaiti]-1
    if visited[genzaiti]==-1:
        visited[genzaiti]=i+1 # i+1回目で訪れた
    else:
        nikaime=i+1
        break

if nikaime==0:
    print(genzaiti+1)
else:
    k=k-nikaime # nokori
    idx=[i for i, v in enumerate(visited) if v>=visited[genzaiti]]
    aaa=[]
    for i in idx:
        aaa.append([i,visited[i]])
    aaa.sort(key=lambda x:x[1])
    finalidx=k%len(aaa)
    
    print(aaa[finalidx][0]+1)

Measured memory_bytes: 46172