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

class Main{
        public static void main(String[] args){
                Scanner scan = new Scanner(System.in);
                int count = scan.nextInt();
                for(int i=0;i<count;i++){
                        int a,b,c;
                        int one = scan.nextInt();
                        int two = scan.nextInt();
                        int three = scan.nextInt();
                        
                        if(one > two && two > three){
                                c = one;
                                b = two;
                                a = three;
                        }
                        else if(one > three && three > two){
                                c = one;
                                b = three;
                                a = two;
                        }
                        else if(two > one && one > three){
                                c = two;
                                b = one;
                                a = three;
                        }
                        else if(two > three && three > one){
                                c = two;
                                b = three;
                                a = one;
                        }
                        else if(three > one && one >two){
                                c = three;
                                b = one;
                                a = two;
                        }
                        else{
                                c = three;
                                b = one;
                                a = two;
                        }

                        if(a*a+b*b==c*c){
                                System.out.println("YES");
                        }
                        else{
                                System.out.println("NO");
                        }
                }

        
        }
}

Measured memory_bytes: 23376
#!/usr/bin python3
# -*- coding: utf-8 -*-

h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

#DP[i] = i までの魔法でモンスターの体力を減らすため消耗する魔力の最小値
dp = [0] * 20001

for i in range(h):
    dp[i] = min(dp[i-a] + b for a, b in ab)
print(dp[h-1])


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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while(a >= b && k--) b *= 2;
    while(k--) c *= 2;
    cout << (a < b && b < c ? "Yes" : "No") << '\n';
    return 0;
}


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

using ll = long long;

int N, P;
string S;

void solve(){
    ll ans = 0;
    if(P == 2 || P == 5) {
        for(int i = N - 1; i >= 0; --i){
            if((ll)(S[i] - '0') % P == 0) ans += i + 1;
        }
        cout << ans;
        return;
    }
    vector<int> r(P, 0);
    r[0] = 1;
    ll u = 0;
    ll c = 1;
    for(int i = N - 1; i >= 0; --i){
        u = (u + c * (ll)(S[i] - '0')) % P;
        ans += r[u]++;
        c = (c * 10) % P;
    }
    cout << ans;
}

int main(){
    cin >> N >> P;
    cin >> S;
    solve();
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
using namespace std;

int main()
{
  char s[100000];
  cin>>s;
  int a[100000];
  int l=strlen(s);
  int ans=0;
  for(int i=0;i<l;i++)
  {
      if(s[i]!=s[i+1])
      {
          a[ans]=max(i+1,l-i-1);
          ans++;
      }
  }
  cout<<endl;
  int mini=l;
  for(int i=0;i<ans;i++)
  {
    mini=min(mini,a[i]);
  }
  cout<<mini<<endl;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    int n, x;
    
    while(1){
        cin >> n >> x;
        int ans = 0;
        if(n == 0 && x == 0){
            break;
        }
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                if(i == j){
                    continue;
                }
                for(int k = 1; k <= n; k++){
                    if(i == k || j == k){
                        continue;
                    }else if((i + j + k == x) && (i < j) && (j < k)){
                        ans += 1;
                    }
                    
                }    
            }
        }
        cout << ans << endl;
        
    }
    
    return 0;
    
}


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


int x1,yy,x2,y2;

int main(){
    std::cin>>x1>>yy>>x2>>y2;
    int x = x2-x1, y = y2-yy;
    std::cout<<x2-y<<" "<<y2+x<<" "<<x1-y<<" "<<yy+x<<std::endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

string N;

int main(){
    cin>>N;

    int ans=9*(N.size()-1);
    ans+=N[0]-'0'-1;
    repn(i,N.size()-1){
        if(N[i]!='9'){
            goto a;
        }
    }
    ans++;
    a:;

    cout<<ans<<endl;
}

Measured memory_bytes: 3612
N = int(input())
l = [[0] for _ in range(N)]
for i in range(N):
    l[i] = list(map(int, input().split()))

l.sort(key=lambda x: x[1])
#print(l)

check = 0
tmp = 0
for i in range(N):
    tmp += l[i][0]
    if tmp > l[i][1]:
        check = 1

if check == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 53528
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#d,t,s = map(int,read().split())
s = input()
t = input()

ans = 1000000

ls = len(s)
lt = len(t)

for i in range(ls-lt+1):
    ss = s[i:i+lt]
    #print(ss)
    r = sum(a!=b for a,b in zip(ss,t))
    
    ans = min(ans,r)

print(ans)





Measured memory_bytes: 9072
#include<stdio.h>
#define AAA 500000
#define BBB 1000000000

int count;
int L[AAA/2+2];
int R[AAA/2+2];

void mergeSort(int [],int ,int ,int );
void merge(int [],int ,int ,int ,int);


int main()
{
  int ori[AAA],n,i;
  
   scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&ori[i]);
  }

  mergeSort(ori,n,0,n);

  for(i=0;i<n-1;i++){
    printf("%d",ori[i]);
    printf("%c",' ');
  }

  printf("%d\n",ori[n-1]);
  printf("%d\n",count);

  return 0;
}

void mergeSort(int ori[],int n, int left, int right)
{
  if(left+1<right){
    int mid=(left+right)/2;
    mergeSort(ori,n,left,mid);
    mergeSort(ori,n,mid,right);
    merge(ori,n,left,mid,right);
  }
}

void merge(int ori[],int n,int left,int mid,int right)
{
  int i=mid-left;
  int j=right-mid;
  int k,l=0,m=0,o;

  for(k=0;k<i;k++) L[k]=ori[left+k];
  for(k=0;k<j;k++) R[k]=ori[mid+k];

  L[i]=R[j]=BBB;

  for(o=left;o<right;o++){
    count++;
    if(L[l]<=R[m]){
      ori[o]=L[l];
      l++;
    }
    else {
      ori[o]=R[m];
      m++;
    }
  }
}
  


Measured memory_bytes: 5672
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int N, Y;
    cin >> N >> Y;
    for (int x = 0; x <= N; x++)
    {
        for (int y = 0; y <= N - x; y++)
        {
            int z = N - x - y;
            if (10000 * x + 5000 * y + 1000 * z == Y)
            {
                printf("%d %d %d\n", x, y, z);
                return 0;
            }
        }
    }
    puts("-1 -1 -1");
    return 0;
}

Measured memory_bytes: 256
N,S = open(0).read().split()
ans = 0
ls = []
cnt = 1
p = S[0]
for c in S[1:]:
  if p!=c:
    p = c
    ls.append(cnt)
    cnt = 1
  else:
    cnt += 1
ls.append(cnt)
b = 0
w = 0
if S[0]=='.':
  w = sum(ls[i] for i in range(0, len(ls),2))
  ans = b+w
  for i in range(len(ls)):
    if i%2==0:
      w -= ls[i]
    else:
      b += ls[i]
    ans = min(ans,w+b)
else:
  w = sum(ls[i] for i in range(1,len(ls),2))
  ans = b+w
  for i in range(len(ls)):
    if i%2==0:
      b += ls[i]
    else:
      w -= ls[i]
    ans = min(ans,w+b)

print(ans)

Measured memory_bytes: 5356
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MOD2 100000000
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(v) v.begin(),v.end()
ll mod=MOD;
using namespace std;
long long int fast_exp(long long int base,long long int ex) {
    long long int res=1;
    while(ex>0) {
       if(ex%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       ex/=2;
    }
    return res%mod;
}
long long int gcd(long long int a, long long int b)
{
    if(b==0)return a;
     return gcd(b,a%b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
  cin>>n;
  ll ans;cin>>ans;
  for(int i=1;i<n;i++)
  {
  	ll a;cin>>a;
    ans=gcd(a,ans);
  }
  cout<<ans<<"\n";
   return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
int main() {
	int c, d,f, g;
	string a,b,e;
	cin >> a >> b;
	cin >> c >> d ;
	cin >> e;
	f = c - 1;
	g = d - 1;

	if (a == e) {

		cout << f << " " << d << endl;
	}
	else if (b == e) {

		cout << c << " " << g << endl;
	}
		
	else{

		cout << c  << " " << d << endl;
	}

	return 0;
}

  

Measured memory_bytes: 256
def main():
    n = int(input())
    hpy = []
    for _ in range(n):
        tmp = list(map(int,input().split()))
        hpy.append(tmp)
    # a:0, b:1, c:2
    dp = [[0] * 3 for i in range(n) ]
    dp[0][0] = hpy[0][0]
    dp[0][1] = hpy[0][1]
    dp[0][2] = hpy[0][2]
    for i, abc in enumerate(dp):
        if i ==n-1:
            break
        a = max(abc[1], abc[2]) + hpy[i+1][0]
        b = max(abc[2], abc[0]) + hpy[i+1][1]
        c = max(abc[0], abc[1]) + hpy[i+1][2]
        dp[i+1][0] = a
        dp[i+1][1] = b
        dp[i+1][2] = c
    print(max(dp[n-1]))


if __name__=='__main__':
    main()


Measured memory_bytes: 47388
n=int(input())
B=list(map(int,input().split()))
A=[0]*n
A[0]=B[0]
A[1]=B[0]
for i in range(1, n-1):
  if B[i]>=B[i-1]:
    A[i+1] = B[i]
  else:
    A[i]=B[i]
    A[i+1]=B[i]
print(sum(A))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  string s; cin >>s;
  int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
  bool ok1=1,ok2=1;
  if(a>1||(a==1&&b>2)||(!a&&!b)) ok1=0;
  if(c>1||(c==1&&d>2)||(!c&&!d)) ok2=0;
  if(ok1&&ok2) cout <<"AMBIGUOUS";
  else if(ok1) cout <<"MMYY";
  else if(ok2) cout <<"YYMM";
  else cout <<"NA";
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3552
N, K = map(int, input().split())
p=list(map(int,input().split()))

for i in range(N):
  p[i]=(1+p[i])/2
  
ans=[0]*(N-K+1)
ans[0]=sum(p[:K])
for i in range(1, N-K+1):
  ans[i]=ans[i-1]-p[i-1]+p[i+K-1]

print(max(ans))

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

void check(vector<int> &ans,vector<int> &s, int p,int l,int n){
  int i,j,count,buf,bufa;
  vector<bool> sw(n);
  for(i=0;i<ans.size();i++){
    count=0;
    buf=l;
    bufa=ans[i];
    for(j=0;j<n;j++){
      if(bufa>=buf){
        bufa-=buf;
        sw[j]=1;
      }
      else sw[j]=0;
      buf=buf/2;
    }

    for(j=0;j<s.size();j++){
      if(sw[s[j]]) count++;
    }
    if(count%2!=p){
      buf=ans[ans.size()-1];
      ans[i]=buf;
      ans.pop_back();
      i--;
    }
        
  }
}
int main(){
  int n,m,i,j,k,l;
  cin>>n>>m;

  vector<int> s[m];
  vector<int> p(m);

  for(i=0;i<m;i++){
    cin>>k;
    for(j=0;j<k;j++){
      cin>>l;
      l--;
      s[i].push_back(l);
    }
  }
  for(i=0;i<m;i++) cin>>p[i];

  vector<int> ans;
  l=1;
  for(i=0;i<n;i++) l=l*2;
  for(i=0;i<l;i++) ans.push_back(i);

  l=l/2;

  for(i=0;i<m;i++){
    check(ans,s[i],p[i],l,n);
    if(ans.size()==0) break;
  }

  cout<<ans.size()<<endl;

  return 0;
}

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

#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int r, d, x;
    cin >> r >> d >> x;
    ll ans = x;
    rep(i, 10){
        ans = r * ans - d;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#define ll  long long 
using namespace std;
int n, a[1005], t, inf = 3000;
int u[3005], g[3005];
bool get()
{
	memset(u, 0, sizeof(u));
	memset(g, 0, sizeof(g));
	int mx = 1500;
	for (int i = 1; i <= 2 * mx; i++)
		u[i] = inf;
	for (int i = 0; i < n; i++)
		u[a[i]] = 1;
	for (int i = 1; i <= 2 * mx; i++)
	{
		if (u[i] != inf)	continue;
		for (int j = 1; j < i; j++)
		{
			u[i] = min(u[i], u[i - j] + u[j]);
		}
	}
	for (int i = 1; i <= 2 * mx; i++)
	{
		int cur = i;
		for (int j = n - 1; j >= 0; j--)
		{
			g[i] += cur / a[j];
			cur %= a[j];
			if (!cur) break;
		}
	}
	for (int i = 1; i <= 2 * mx; i++)
	{
		if (u[i] < g[i])
		return true;
	}
	return false;
}
signed main()
{
	while (~scanf("%d", &n) && n)
	{
		++t;
		printf("Case #%d: ", t);
		for (int i = 0; i < n; i++)	scanf("%d", &a[i]);
		sort(a, a + n);
		if (a[0] != 1)	printf("Cannot pay some amount\n");
		else if (get())	printf("Cannot use greedy algorithm\n");
		else	printf("OK\n");
	}
}



Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 2000001;

int n, k, fact[N], inv[N], mod = 1e9 + 7;
string s;

int powlog(int a, int b) {
	if (b == 0) return 1;
	int ret = powlog(a, b / 2);
	if (b % 2) return 1LL * ret * ret % mod * a % mod;
	return 1LL * ret * ret % mod;
}
int C(int n, int r) {
	if (r > n) return 0;
	return 1LL * fact[n] * inv[n - r] % mod * inv[r] % mod;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	fact[0] = 1;
	for (int i = 1 ; i < N ; i++) {
		fact[i] = 1LL * i * fact[i - 1] % mod;
	}
	inv[N - 1] = powlog(fact[N - 1], mod - 2);
	for (int i = N - 2 ; i >= 0 ; i--) {
		inv[i] = 1LL * (i + 1) * inv[i + 1] % mod;
	}
	cin >> k >> s;
	n = s.size();
	int ans = 0;
	for (int i = 0 ; i <= k ; i++) {
		ans = (ans + 1LL * powlog(25, k - i) * powlog(26, i) % mod * C(n - 1 + k - i, n - 1)) % mod;
	}
	cout << ans << endl;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define FOR(i, a, b) for (int i=a; i<b; i++)

using namespace std;

signed main() {
  IOS;
  int r,D,x;
  cin >> r >> D >> x;
  FOR(i, 0, 10) {
    x = r * x - D;
    cout << x << endl;
  }
  return 0;
}

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

using namespace std;

//#define FILE_IO

int N;
char s[100005];
int v[100005];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d\n", &N);
    scanf("%s", &s);
    for(int i = N; i >= 1; i--)
    {
        if(s[i - 1] == 'o')
            s[i] = 0;
        else
            s[i] = 1;
    }

    for(v[1] = 0; v[1] <= 1; v[1]++)
        for(v[2] = 0; v[2] <= 1; v[2]++)
        {
            for(int i = 2; i < N; i++)
                v[i + 1] = v[i] ^ v[i - 1] ^ s[i];
            if(v[1] == v[N] ^ v[N - 1] ^ s[N] && v[N] == v[1] ^ v[2] ^ s[1])
            {
                for(int i = 1; i <= N; i++)
                {
                    if(v[i] == 0)
                        printf("S");
                    else
                        printf("W");
                }
                printf("\n");
                return 0;
            }
        }
    printf("-1\n");

    return 0;
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
using ll = long long;

int main(){
	int N,A;
	int x[51];
	cin >> N >> A;
	for(int i=0;i<N;i++){
		cin >> x[i] ;
	}
	
	ll dp[51][51][2501] = {};// j枚の中から i枚選んだ時の 合計s
	
	for(int i=0;i<51;i++){
		for(int j=0;j<51;j++){
			for(int k=0;k<2501;k++){
				dp[i][j][k] = 0;
			}
		}
	}
	
	dp[0][0][0] = 1;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			for(int k=0;k<2501;k++){
				if(dp[i][j][k] > 0){
					dp[i+1][j][k] += dp[i][j][k];
					dp[i+1][j+1][k+x[i]] += dp[i][j][k];
				}
			}
		}
	}
	
	ll answer = 0;
	for(int i=1;i<N+1;i++){
		answer += dp[N][i][i*A];
	}
	cout << answer << endl;
	
	return 0;
}


Measured memory_bytes: 51072
import math
S=input()
K=int(input())

ss=S*2

ss=[a for a in ss]
answer=0
N=len(ss)
for n in range(N-1):
    if ss[n]==ss[n+1]:
        answer+=1
        ss[n+1]=0

sss=S*3

sss=[a for a in sss]
suuji=0
N=len(sss)
for n in range(N-1):
    if sss[n]==sss[n+1]:
        suuji+=1
        sss[n+1]=0

number=0
s=[a for a in S]
N=len(s)
for n in range(N-1):
    if s[n]==s[n+1]:
        number+=1
        s[n+1]=0
if K==1:
    print(number)
else:
    if answer - number == suuji - answer:
        print(number + (answer - number) * (K - 1))
    else:
        if K % 2 == 0:
            print(number + (answer - number) * (K//2)+(suuji-answer)*(K//2-1))
        else:
            print(number + (answer - number) * (K//2)+(suuji-answer)*(K//2))



Measured memory_bytes: 62496
#include<bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define i2 (mod+1>>1)
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int a[3010],f[3010][3010];
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi(),q=gi();
	for(int i=1;i<=n;++i)a[i]=gi();
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			f[i][j]=a[i]<a[j];
	for(int _=0;_<q;++_){
		int x=gi(),y=gi();if(x==y)continue;
		f[x][y]=f[y][x]=1ll*i2*(f[x][y]+f[y][x])%mod;
		for(int i=1;i<=n;++i)if(i!=x&&i!=y)f[i][x]=f[i][y]=1ll*i2*(f[i][x]+f[i][y])%mod,f[x][i]=f[y][i]=1ll*i2*(f[x][i]+f[y][i])%mod;
	}
	int ans=0;
	for(int i=1;i<=n;++i)
		for(int j=1;j<i;++j)
			inc(ans,f[i][j]);
	printf("%d\n",1ll*pow(2,q)*ans%mod);
	return 0;
}


Measured memory_bytes: 35584
from collections import deque

N,M,*f = map(int, open(0).read().split())
uv = [f[i:i+2] for i in range(0, len(f)-2, 2)]
S = f[-2]
T = f[-1]
connected = [[] for _ in range(N+1)]
for u, v in uv:
    connected[u].append(v)
dist = [[-1] * 3 for _ in range(N+1)]
dist[S][0] = 0
ans = 0
d = deque([(S,0)])
while d:
    temp = d.popleft()
    for edge in connected[temp[0]]:
        if edge == T and temp[1] == 2:
            print((dist[temp[0]][2]+1)//3)
            break
        else:
            if dist[edge][(temp[1]+1)%3] < 0:
                dist[edge][(temp[1]+1)%3] = dist[temp[0]][temp[1]] + 1
                d.append((edge,(temp[1]+1)%3))
    else:
        continue
    break
else:
    print(-1)

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

int rem;

int main(){
	int k;
	cin >> k;
	rem = 0;
	for(int i = 1; i <= k; i++){
		rem = (rem * 10 + 7) % k;
		if(rem == 0){
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 3624
N,M = map(int, input().split())
if abs(N-M) > 1:
    print(0)
    exit()

mod = 10**9+7
import math
if N != M:
    tmp = math.factorial(min(N,M))
    print(tmp**2 * max(N,M) % mod)
else:
    tmp = math.factorial(N)
    print(tmp**2 * 2 % mod)

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 1000000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int main(){
  ll N,M,V,P;
  cin >> N >> M >> V >> P;
  vector<ll> A(N);
  for(ll i = 0;i < N;i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  ll num = 0;
  vector<ll> sum(N+1);
  for(ll i = 0;i < N;i++){
    if(i == P-1){
      num = A[i];
    }
    sum[i+1] = A[i] + sum[i];
  }
  //cout << num << endl;
  ll ans = P;
  if(0){
    for(ll i = P;i < N;i++){
      if(A[i] + M >= num){
        ans++;
      }else{
        break;
      }
    }
  }else{
    for(ll i = P;i < N;i++){
      if(P+N-i-1 >= V && num <= A[i] + M){
        ans++;
      }else{
        if(M+A[i] >= num){
          ll s = num * (i-P+1) - (sum[i] - sum[P]) - num;
          if(s >= M * (V-(P+N-i-1))){
            ans++;
          }else{
            if((sum[i]-sum[P] + num + M * (V-(P+N-i-1)) + (i-P))/(i-P+1) <= M + A[i]){
              ans++;
            }else{
              break;
            }
          }
        }else{
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	int a[1001];
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	for (int i =0 ; i < n; ++i){
		
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v){
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		for (int i2 = 0; i2 < n; i2++){
			if (i2 == n - 1)cout << a[i2] << endl;
			else cout << a[i2]<<" ";
		}
	}
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
int MOD = 1e9+7;
using ll = long long;
using namespace std;
ll All(int n,ll k,vector<ll> &dp,ll sum,ll usum){
    if(n==0)return sum+usum;
    k++;
    return All(n-1,k,dp,sum,usum*10+dp[k])+All(n-1,k,dp,usum+sum,0);
}
int main(){
    string s;
    cin >> s;
    vector<ll> vec(s.size());
    for(int i=0;i<s.size();i++){
        vec[i]=s[i]-'0';
    }
    cout<<All(s.size(),-1,vec,0,0)<<endl;
}

Measured memory_bytes: 256
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class Main {
	private final static Pattern regex_pattern = Pattern.compile("(\\d){4} \\/ (\\d){2} \\/ (\\d){2}", Pattern.COMMENTS);
	private final static Matcher regex_match = Main.regex_pattern.matcher("");	
	
	private final static SimpleDateFormat SF = new SimpleDateFormat("yyyy/MM/dd");
	public static String S;
	
	public static void main(String[] args) {		
		Date date2c = null;

		try {
			date2c = SF.parse("2019/04/30");
		}catch(Exception e) {
			e.printStackTrace();
		}
		
    	Scanner sc = new Scanner(System.in);
    	    	
    	S = sc.next().trim();
   
    	try {
        	if(!validateInput(S)) { throw new Exception(); }
        		

        	if(SF.parse(S).after(date2c)) {
        		System.out.println("TBD");
        	} else {
        		System.out.println("Heisei");
        	}
        	
        	sc.close();
    	} catch (Exception e) {
    		System.out.println("Invalid Input!");
    	}
    }
	
	private static boolean validateInput(String in) {
		regex_match.reset(in);
		
		if(regex_match.matches()) {
			return true;
		}
		
		return false;
	}
}


Measured memory_bytes: 23120
#include<iostream>
using namespace std;
string s[99];
int w,h;
string dp[99][99];
main()
{
	while(cin>>w>>h,w)
	{
		for(int i=0;i<h;i++)cin>>s[i];
		string ans="";
		for(int i=h;i--;)for(int j=w;j--;)
		{
			if(s[i][j]>'9')dp[i][j]="";
			else
			{
				string t1(1,s[i][j]),t2(1,s[i][j]);
				if(i<h-1)t1+=dp[i+1][j];
				if(j<w-1)t2+=dp[i][j+1];
				if(t1.size()<t2.size()||t1.size()==t2.size()&&t1<t2)dp[i][j]=t2;
				else dp[i][j]=t1;
			}
			if(s[i][j]!='0')
			{
				if(ans.size()<dp[i][j].size())ans=dp[i][j];
				else if(ans.size()==dp[i][j].size()&&ans<dp[i][j])ans=dp[i][j];
			}
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

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


Measured memory_bytes: 3648
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N;
const int MAX_N = int(1e5);
ll A[MAX_N];

int main() {
    cin >> N;
    int n_odd = 0, n_even = 0;
    REP(i, N) {
        cin >> A[i];
        if (A[i] % 2 == 0) n_even++;
        else n_odd++;
    }
    if (n_odd % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bitset>
#include <cmath>
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    while (true) {
        int mm;
        size_t nn;
        scanf("%d %ld", &mm, &nn);
        const auto m = mm;
        const auto n = nn;
        if (m == 0) {
            break;
        }
        constexpr auto l = 7368791 + 1;
        bitset<l> b;
        vector<int> s;
        const auto li = sqrt(l);
        for (auto i = 0; i < m; ++i) {
            b[i] = true;
        }
        auto head = m;
        while (true) {
            size_t nexthead = 0;
            for (size_t i = head; i < b.size(); i += head) {
                b[i] = true;
            }
            for (size_t j = head; true; ++j) {
                if (!b[j]) {
                    nexthead = j;
                    break;
                }
            }
            s.push_back(head);
            head = nexthead;
            if (s.size() == n) {
                break;
            }
            // if (li < head) {
            //    for (size_t i = head; i < b.size(); ++i) {
            //        if (!b[i]) {
            //            s.push_back(i);
            //        }
            //        if (s.size() > n) {
            //            break;
            //        }
            //    }
            //    break;
            //}
        }
        printf("%d\n", head);
    }
}

Measured memory_bytes: 7228
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){

  ll N;
  cin >> N;

  ll A,B;
  cin >> A >> B;

  ll ans;
  ans=A*(N/(A+B));
  if(A<=(N%(A+B))) ans+=A;
  else ans+=N%(A+B);
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  string S;
  cin >> S;
  bool flag=false;
  int ans=0,temp_ans=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='A' || S.at(i)=='C' || S.at(i)=='G' || S.at(i)=='T'){
      if(flag==false){
	temp_ans=1;
	flag=true;
      }
      else ++temp_ans;
    }
    else{
      if(flag==true){
	temp_ans=0;
	flag=false;
      }
    }
    ans=max(ans,temp_ans);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pci pair<char, int>
#define pic pair<int, char>
#define plvl pair<long long, vector<long long> >
#define pcvc pair<char, vector<char> >
#define mod 1000000007
#define newl "\n"

using namespace std;

ll gcd(ll a, ll b) {
	if(b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

template <typename T>
void show1(vector<T> dp) {
	for(auto d : dp) {
		cout << d << " ";
	}
	cout << "\n";
}

template <typename T>
void show2(vector<vector<T> > dp) {
	for(auto d : dp) {
		for(auto dd : d) {
			cout << dd << " ";
		}
		cout << "\n";
	}
}

void executeCode() {
	ll n, d, cnt = 0;
	cin >> n >> d;
	while(n--) {
		ll x, y;
		cin >> x >> y;
		if(sqrt((x * x) + (y * y)) <= d) {
			cnt++;
		}
	}
	cout << cnt << newl;
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int tt = 1;
	// cin >> tt;
	for(ll i = 1; i <= tt ; i++) {
	//	cout << "Case #" << i << ": ";
		executeCode();	
	}
	return 0;
}

Measured memory_bytes: 3668
import numpy as np

n = int(input())
A = np.array([int(i) for i in input().split()])
ans = 0
#print(A & 1)

# A_iは60ビットまで与えられる.
for i in range(60):
    #A&1は配列Aを1ビット目を表示する: [1,2,3]→[1,0,1]
    c = np.count_nonzero(A & 1) #配列Aの1ビット目が非ゼロのものをカウント
    #cは桁数nを超えないのでn-c>=0
    # c*(n-c)は(0の個数)*(1の個数)を表す.
    ans += 2**i*c*(n-c) #bit毎に計算したのち2**iをかけて10進数に戻す.
    # Aを1ビット右シフト
    A >>= 1 #一つ上の桁数でも同様. 大きな位では0なので値として出てこない.
print(ans%(10**9+7))

Measured memory_bytes: 48836
#include <bits/stdc++.h>
#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++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int c[100][100];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w,n;
  cin >> h >> w >> n;
  int h1 = 0;
  int w1 = 0;
  REP(i,n){
    int a;
    cin >> a;
    while(a>0){
      c[h1][w1] = i+1;
      a--;
      if((h1%2==0 && w1==w-1) || (h1%2==1&&w1==0)) h1++;
	  else if(h1%2==0) w1++;
      else if(h1%2==1) w1--;
    }
  }
  REP(i,h){ 
    REP(j,w){
   	  cout << c[i][j] << " ";
    }
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 384
import copy

def BubbleSort(C, N):
    stable = True

    for i in range(N):
        for j in range(i + 1, N)[::-1]:
            if C[j][2] < C[j - 1][2]:
                C[j], C[j - 1] = C[j - 1], C[j]

    
    AnswerPrint(C, IsStable(C))


def SelectionSort(C, N):
    stable = True

    for i in range(N):
        minj = i
        for j in range(i, N):
            if C[j][2] < C[minj][2]:
                minj = j

        C[i], C[minj] = C[minj], C[i]

    AnswerPrint(C, IsStable(C))


def IsStable(C):
    for index, c in enumerate(C):
        for i in range(index, len(C)):
            if (c[2] == C[i][2]) and (c[0] > C[i][0]):
                return False

    return True
                

def AnswerPrint(C, stable):
    out = ["{}{}".format(c[1], c[2]) for c in C]
    print(" ".join(out))

    if stable:
        print("Stable")
    else:
        print("Not stable")



N = int(input())
inp = input().split()
C = [[index, c[0], int(c[1])] for index, c in enumerate(inp)]

BubbleSort(copy.copy(C), N)
SelectionSort(copy.copy(C), N)


Measured memory_bytes: 6348
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int a; cin >> a;
    cout << 3 * a * a << endl;
    
    
    return 0;
}



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

int main() {
	string s;
	int K;
	cin >> s >> K;
	for (char& c : s) {
		if (c == 'a') continue;
		if ('z' - c + 1 <= K) {
			K -= 'z' - c + 1;
			c = 'a';
		}
	}
	K %= 26;
	while (K > 0) {
		s.back() = (s.back() == 'z' ? 'a' : s.back() + 1);
		K--;
	}
	cout << s << endl;
}


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

int main(){
int ans=0 ,max,N ;
  cin>>N;
  vector<int>vec(N);
  for(int i=0;i<N;i++){
  cin>>vec.at(i);
  }
  for(int i=0;i<N;i++){
  if(i==0){
  max=vec.at(i);
    ans++;
  }
    else{
    if(max<=vec.at(i)){
    max=vec.at(i);
      ans++;
    }
    }
  }
cout<<ans<<endl;
}

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

#define N 100
#define INFTY 1000000

int M[N][N],d[N];
int i,j,n,u,k,v;

void bfs(int s){

  queue <int> Q;

  for( i = 0; i < N; i++ ) d[i] = INFTY;
  

  d[s] = 0;
  Q.push(s);
    
  while ( !Q.empty() ){
    u = Q.front(); Q.pop();
    for( int v = 0; v < n; v++ ){
      if( M[u][v] == 0 ) continue;
      if( d[v] != INFTY ) continue;
	d[v] = d[u] + 1;
	Q.push(v);
      }
    }

  
  for( i = 0; i < n; i++ ){
    cout << i+1 << " ";
    if ( d[i] == INFTY ) cout << -1;
    else cout << d[i];
    cout << endl;
  }

}


int main(){
  for( i = 0; i < n; i++ ){
    for( j = 0; j < n; j++ ) M[u][v] = 0;
  }
  cin >> n;
  for( i = 0; i < n; i++ ){
    cin >> u;
    u--;
    cin >> k;
    for( j = 0; j < k; j++ ){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }
  bfs(0);
  
  return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <cmath>
#include <iomanip>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#define ll long long
         
using namespace std;
     
long long gcd(int x, int y){
     if ( x == 0 ) return y;
     
     return gcd(y%x, x);
}
     
long long lcm(int x, int y){
     if ( y == 0 ){
          return x;
     }
     
     return x*y/gcd(x, y);
}
     
int min(int a, int b){
     return a > b ? b : a;
}
     
double max(double a, double b){
     return a > b ? a : b;
}

int main()
{
     cin.sync_with_stdio( false );

     int n,k;
     cin>>n>>k;

     double a[n];
     for (int i=0;i<n;i++){
          cin>>a[i];
          a[i] = (a[i] + 1) / 2;
          //cout<<a[i]<<" ALO"<<endl;
     }

     vector <double> dp(n+5, 0);
     for (int i=1;i<=n;i++){
          dp[i]=dp[i-1] + a[i-1];
          //cout<<dp[i]<<" "; 
     }

     //cout<<endl;

     double res = 0;
     for (int i=0;i<=n-k;i++){
          //cout<<dp[i+k]<<" ALO "<<dp[i]<<endl;
          double buff=dp[i+k]-dp[i];
          //cout<<buff<<" ALO1"<<endl;
          res=max(res, buff);
          //cout<<i<<" "<<k<<" "<<res<<endl;
     }

     cout<<fixed<<setprecision(15)<<(double)(res)<<endl;
}

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

#define int long long
#define DEBUG(x) cerr <<#x<<":"<<x<<endl;
#define DEBUG2(x, y) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define DEBUG3(x, y, z) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define DEBUGVC(x) cerr <<#x<<": "; for(auto a:x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(x) cerr <<#x<<":"<<endl; for(auto a:x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (1000006)
#define INF (1LL << 60)
const int MOD = (int)1e9+7;


signed main() {
    while(1) {
        int n, m;
        cin >> n >> m;
        if(n==0&&m==0) break;
        vector<int> t, h;
        int sumt, sumh;
        sumt = sumh = 0LL;

        for(int i=0; i<n; i++){
            int s;
            cin >> s;
            sumt += s;
            t.push_back(s);
        }
        for(int i=0; i<m; i++){
            int s;
            cin >> s;
            sumh += s;
            h.push_back(s);
        }
        int v1, v2, mn=INF;
        bool f = false;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                //DEBUG2(t[i],h[j]);
                if(sumt-t[i]+h[j] == sumh-h[j]+t[i]){
                    if (t[i]+h[j] < mn) {
                        mn = t[i]+h[j];
                        v1 = t[i];
                        v2 = h[j];
                    }
                    f = true;
                }
            }
        }
        if(!f) cout << -1 << endl;
        else cout << v1 <<" "<< v2 << endl;
    }
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl



signed main(){
    int A[4];
    REP(i,4){cin >> A[i];}
    sort(A,A+4);
    YES(A[0]==1&&A[1]==4&&A[2]==7&&A[3]==9);
    
    return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    if (K == 0)
    {
        ans = N * N;
    }
    else
    {
        for (ll b = K + 1; b <= N; ++b)
        {
            ans += (N / b) * (b - K);
            ll res = N % b;
            if (res >= K)
            {
                ans += res + 1 - K;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
    using namespace std;
     
    long factrial(long n){
    	if(n == 1)
    		return 1;
    	return factrial(n - 1) * n % 1000000007;
    }
     
    int main(){
    	long n;
    	cin >> n;
    	cout << factrial(n)  <<endl;
     
    	return 0;
    }

Measured memory_bytes: 1792
import itertools
n,m,q=list(map(int,input().split()))
q_l=[list(map(int,input().split())) for _ in range(q)]
#bar_l = [(i,j,k) for i in range(0,m+1) for j in range(i,m+1) for k in range(j,m+1)]
bar_m = [i for i in range(m)]
bar_l = list(itertools.combinations_with_replacement(bar_m,n))
score = 0
for bar in bar_l:
    score_tmp=0
    for queue in q_l:
        if bar[queue[1]-1]-bar[queue[0]-1]==queue[2]:
            score_tmp+=queue[3]
    #print(score_tmp)
    if score<=score_tmp:
        score=score_tmp
        #print(bar)
print(score)


Measured memory_bytes: 21496
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int k;
	string s;
	cin >> k >> k >> s;
	--k;
	s[k] = s[k] - ('A' - 'a');
	cout << s << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    while (cin >> n && n){
        vector<pair<int, int>> v(n);
        rep(i, n){
            cin >> v[i].second;
            int t = 0;
            rep(j, 4){
                int m, s; cin >> m >> s;
                t += m * 60 + s;
            }
            v[i].first = t;
        }
        sort(v.begin(), v.end());
        cout << v[0].second << endl;
        cout << v[1].second << endl;
        cout << v[v.size() - 2].second << endl;
    }
}

Measured memory_bytes: 1236
// failed to generate code

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

long long N;
long long h[100000];
long long dp[100000];

int main(){
	scanf("%lld",&N);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&h[i]);
	}
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(int i = 2 ; i <= N-1 ; i++){
		dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
	}
	printf("%lld\n", dp[N-1]);
	return 0;
}


Measured memory_bytes: 1792
/* ANTHOR KUMAR DAS
KUET ECE 2K18*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sc(a) scanf("%d",&a)
#define sc1(n) scanf("%lld",&n)
#define sc2(b,c) scanf("%lld%lld",&b,&c)
#define f(a,b) for(a=0;a<b;a++)
#define pb(a) push_back(a)
#define br break
int main()
{
    string s;
    cin>>s;
    if(s=="SUN")
    {
        cout<<"7"<<endl;
    }
    else if(s=="MON")
    {
        cout<<"6"<<endl;
    }
    else if(s=="TUE")
    {
        cout<<"5"<<endl;
    }
    else if(s=="WED")
    {
        cout<<"4"<<endl;
    }
    else if(s=="THU")
    {
        cout<<"3"<<endl;
    }
    else if(s=="FRI")
    {
        cout<<"2"<<endl;
    }
    else{
        cout<<"1"<<endl;
    }



    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int dm[1100000];
int m[1100000];
int isp[1100000];
int prime[1100000];
int main(){
	int sz=0;
	isp[0]=isp[1]=-1;
	for(int i=2;i<1100000;i++){
		if(~isp[i]){
			isp[i]=1;
			prime[sz++]=i;
			for(int j=i+i;j<1100000;j+=i)isp[j]=-1;
		}
	}
	long long a,b;scanf("%lld%lld",&a,&b);
	long long L=max(1LL,a-b);
	long long R=a+b;
	int n=R-L+1;
	for(int i=0;i<n;i++)m[i]=9999999;
	for(int i=1;(long long)prime[i]*prime[i]<=R;i++){
		int E=prime[i-1];
		for(long long j=(L+E-1)/E*E;j<=R;j+=E){
			long long now=j;
			int time=0;
			while(now%E==0){
				now/=E;time++;
			}
			m[j-L]=min(m[j-L],time);
		}
		int D=prime[i];
		long long S=L/D/D*D*D;
		long long T=R/D/D*D*D;
		while(S<L)S+=(long long)D*D;
		while(T>R)T-=(long long)D*D;
		for(long long j=S;j<=T;j+=(long long)D*D){
			long long now=j;
			int time=0;
			while(now%D==0){
				now/=D;time++;
			}
			if(m[j-L]<time){
			//	printf("%lld %d\n",j,i);
				dm[j-L]=1;
			}
		}
	}
	int ret=n;
	if(L==1LL)dm[0]=1;
	for(int i=0;i<n;i++)if(dm[i])ret--;
	printf("%d\n",ret);
}

Measured memory_bytes: 14064
#include<iostream>
#include<cstdio>
#define INT_MAX 100000000
using namespace std;
int sentinel;
int Mi[1000][1000];

void calc(int p[]);

int main(){
  int p[1000],a,b;
  scanf("%d",&sentinel);
  for(int i=0;i<sentinel;i++){
    scanf("%d %d",&a,&b);
    p[i] = a;
    if(i == sentinel-1)p[i+1] = b;
  }

  sentinel = sentinel+1;
  calc(p);

  printf("%d\n",Mi[1][sentinel-1]);
  return 0;
}

void calc(int p[]){
  int n = sentinel-1,j,q,l,k;
  for(int i=1;i<=n;i++)Mi[i][i]=0;
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      j = i+l-1;
      Mi[i][j] = INT_MAX;
      for(int k=i;k<=j-1;k++){
        q = Mi[i][k] + Mi[k+1][j] + p[i-1]*p[k]*p[j];
        if(q<Mi[i][j]){
          Mi[i][j] = q;
        }
      }
    }
  }
}



Measured memory_bytes: 3524
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

x,y,a,b,c = inpm()
p = list(reversed(sorted(inpl())))
q = list(reversed(sorted(inpl())))
r = list(reversed(sorted(inpl())))
pp = x-1
qq = y-1
rr = 0

tmp = []
tmp.extend(p[:pp+1])
tmp.extend(q[:qq+1])
tmp.extend(r)

tmp = list(reversed(sorted(tmp)))
ans = sum(tmp[:x+y])
print(ans)

Measured memory_bytes: 53352
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigDecimal A = new BigDecimal(sc.next());
		BigDecimal B = new BigDecimal(sc.next());
		A = B.multiply(A);
		System.out.println(A.setScale(0, BigDecimal.ROUND_DOWN));
	}
}

Measured memory_bytes: 36004
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll mod=1000000007;

int main(){
  string s,t; cin>>s>>t;
  cout<<t<<s<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

typedef struct{
    int id;
    int trade1;
    int trade2;
} trio;

bool operator<( const trio& l, const trio& r ){
    return l.id < r.id;
}

trio gen(int id, int trade1){
    trio n;
    n.id = id;
    n.trade1 = trade1;
    n.trade2 = 0;
    return n;
}

typedef vector< trio > P;

int main(){
    int n, d;
    char command[32];
    P pp;
    while( fgets(command, 32, stdin)){
        if( command[0] == '\n' ) break;
        sscanf(command, "%d,%d", &n, &d);
        P::iterator it = pp.begin();
        for(; it != pp.end(); it++){
            if( it->id == n ){
                (it->trade1)++;
                break; 
            }
        }
        if( it == pp.end() ){
            pp.push_back( gen(n, 1) );
        }
        n = 0; d = 0;
    }
    while( scanf("%d,%d", &n, &d) != EOF ){
        P::iterator it = pp.begin();
        for(; it != pp.end(); it++){
            if( it->id == n ){
                (it->trade2)++;
                break; 
            }
        }
    }
    sort(pp.begin(), pp.end());
    for(P::iterator it = pp.begin(); it != pp.end(); it++){
        if( it->trade1 && it->trade2 ){
            printf("%d %d\n", it->id, it->trade1 + it->trade2);
        }
    }
    return 0;
}

Measured memory_bytes: 1064