akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>

using namespace std;

const int mod = 1'000'000'007;

int add(int a, int b) {
  a += b;
  return a >= mod ? a - mod : a;
}

int sub(int a, int b) {
  a -= b;
  return a < 0 ? a + mod : a;
}

int mul(int a, int b) {
  return (int)((long long)a * b % mod);
}

int pw(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return res;
}

int inv(int a) {
  return pw(a, mod - 2);
}

const int N = 100'009;

int f[N];
int rf[N];

int choose(int n, int k) {
  return mul(f[n], mul(rf[k], rf[n - k]));
}

int a[N];

int main() {
  f[0] = 1;
  rf[0] = 1;
  for (int i = 1; i < N; ++i) {
    f[i] = mul(f[i - 1], i);
    rf[i] = inv(f[i]);
  }
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  sort(a, a + n);
  for (int i = 0; i < n; ++i) {
    if (a[i] < 0) {
      a[i] += mod;
    }
  }
  int ans = 0;
  for (int i = k - 1; i < n; ++i) {
    ans = add(ans, mul(choose(i, k - 1), a[i]));
  }
  reverse(a, a + n);
  for (int i = k - 1; i < n; ++i) {
    ans = sub(ans, mul(choose(i, k - 1), a[i]));
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  ll a;
  double b;
  cin >> a >> b;
  ll ib = b * 100 + 0.1;
  a *= ib;
  a /= 100;
  cout << a << endl;
}

Measured memory_bytes: 3696
def ascan; gets.split.map(&:to_i); end
def scan; gets.to_i; end

gets
ss = gets.chomp

t = []
k = 0
rr = ""
ss.chars{|c|
    if c=='('
        k+=1
    else
        k-=1
    end
    if k < 0
        rr = '(' + rr
        k+=1
    end
    rr << c
}

while k>0
    rr << ')'
    k -= 1
end
puts rr

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
const int MX = 200005;
int n;
ll k, a[MX], f[MX], l = -1, r = 1e12;
int main(){
	scanf("%d%lld", &n, &k);
	rep(i,n) scanf("%lld", a+i);
	sort(a, a+n, greater<ll>());
	rep(i,n) scanf("%lld", f+i);
	sort(f, f+n);
	while(l+1 < r){
		ll m = (l+r) / 2, c, add = 0;
		rep(i,n){
			c = m / f[i];
			if(a[i] > c) add += a[i] - c;
		}
		(add <= k ? r : l) = m;
	}
	printf("%lld\n", r);
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long i = p; i < q; i++)
#define repd(i, p, q) for (long i = p; i >= q; i--)
#define sz(x) x.size()
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef long long int LLI;
typedef long int LI;
typedef int I;

int main() {
    int n;
    cin >> n;
    int flag = 0;
    for(int i = 0 ; i <= 25 ; i++) {
        for(int j = 0 ; j <= 15 ; j++) {
            if(i*4 + j*7 == n) {
                flag = 1;
            }
        }
    }
    if(flag == 1)cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main () {
  vector<char> s(3);
  vector<char> t(3);
  int cnt=0;
  rep(i, 3) cin >> s.at(i);
  rep(i, 3) cin >> t.at(i);
  rep(i, 3) {
    if (s.at(i)==t.at(i)) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
W,H,x,y,r = gets.split


if (x.to_i - r.to_i) >= 0 && (x.to_i + r.to_i) <= W.to_i
  if(y.to_i - r.to_i) >= 0 && (y.to_i + r.to_i) <= H.to_i
    puts "Yes"
  else puts "No"
  end
else puts "No"
end

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,m,cnt=0;
  cin>>n>>m;
  vector<int> v(m),w;
  if(n>=m){
    cout<<0<<endl;
    return 0;
  }
  
  
  rep(i,m) cin>>v[i];
  sort(v.begin(),v.end());
  if(n==1){
    cout<<v[m-1]-v[0]<<endl;
    return 0;
  }
  if(m==2){
    cout<<v[1]-v[0]<<endl;
    return 0;
  }
  rep(i,m-1){
    w.push_back(v[i+1]-v[i]);
  }
  sort(w.begin(),w.end(),greater<int>());
 
  rep(i,n-1){
    cnt+=w[i];
  }
  cout<<vec_sum(w)-cnt<<endl;
  
}
///////////////////////////





Measured memory_bytes: 1528
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>
#include <sstream>
#include <iomanip>

bool sort_pair( std::pair< int64_t, std::string > origin, std::pair< int64_t, std::string > another )
{
    return origin.first < another.first;
}


int main()
{

    int64_t n,a,b,c,d;
    
    std::cin>> n;
    std::cin>> a;
    std::cin>> b;
    std::cin>> c;
    std::cin>> d;

    std::string mas;

    std::cin>> mas;

    std::string result = "No";
    int kabe = 0;
    
    if( c < d )
    {
        result = "Yes";

        for( int i = 0; i < n; i++ )
        {
            if( mas[i] == '#' )
            {
                kabe += 1;
            }
            else
            {
                kabe = 0;
            }

            if( 1 < kabe )
            {
                if( ( i + 1 < d
                      && b < i + 1 )
                    || ( i + 1 < c
                         && a < i + 1 ) )
                {
                    result = "No";
                    break;
                }
            }
        }
    }
    else
    {
        int count = 0;
        
        for( int i = b - 2; i < n; i++ )
        {
            if( mas[i] == '.' )
            {
                count += 1;
                kabe = 0;
            }
            else
            {
                count = 0;
                kabe += 1;
            }

            if( 1 < kabe )
            {
                if( ( i + 1 < d
                      && b < i + 1 )
                    || ( i + 1 < c
                         && a < i + 1 ) )
                {
                    break;
                }
            }

            if( count >= 3 )
            {
                if( i + 1 <= d )
                {
                    result = "Yes";
                    break;
                }
            }
            else if( count == 2 )
            {
                if( i + 1 == d
                    && mas[i+1] == '.' )
                {
                    result = "Yes";
                    break;
                }
            }
        }
    }

    std::cout<< result;
}


Measured memory_bytes: 640
/*input
5
5 6 5 2 1
9817 1108 6890 4343 8704
*/
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;
int n, A[maxn], B[maxn];
queue<int>Q;
void tryPush(int i)
{
	int a = B[(i - 1 + n) % n];
	int b = B[(i + 1) % n];
	if(B[i] - a - b >= A[i])
		Q.push(i);
}
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> A[i];
	for(int i = 0; i < n; i++)
		cin >> B[i];
	for(int i = 0; i < n; i++)
		tryPush(i);
	ll ans = 0;
	while(sz(Q))
	{
		int i = Q.front();
		Q.pop();
		int pre = (i - 1 + n) % n, nxt = (i + 1) % n;
		int cnt = (B[i] - A[i]) / (B[pre] + B[nxt]);
		ans += cnt;
		B[i] -= cnt * (B[pre] + B[nxt]);
		tryPush(pre);
		tryPush(nxt);
	}
	bool chk = true;
	for(int i = 0; i < n; i++)
		chk &= (A[i] == B[i]);
	if(chk)
		cout << ans << "\n";
	else
		cout << "-1\n";
	return 0;
}

Measured memory_bytes: 2304
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    cnt=0
    N=int(input())
    for i in range(N):
        l,r=map(int,input().split())
        cnt+=r-l+1
    print(cnt)

resolve()

Measured memory_bytes: 38256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int atb,btc,atc;
    atb =abs(a-b);
    btc =abs(b-c);
    atc =abs(a-c);
    if (atc <= d) {
        cout << "Yes" << endl;
        return 0;
    }
    else if (atb <= d && btc <= d){
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[15];
int da;
int n;
void dfs(int pos,int now,int target)
{
  if(pos == n){if(now == target)da++;return;}
  dfs(pos+1,now^a[pos],target);
  dfs(pos+1,now,target);
}
int main()
{
   int k;
  while(cin>>n>>k)
  {
    memset(a,0,sizeof(a));
    for(int i = 0; i < k; ++i)
    {
      int num;cin>>num;
      for(int j = 0; j < num ; ++j)
      {
         int x;cin>>x;a[x-1] |= (1<<i);
      }
    }
    int ans = 0;
    for(int i = 0; i < k; ++i)
    {
      int x;cin>>x;
      if(x)ans |= (1<<i);
    }
    da = 0;
    dfs(0,0,ans);
    cout<<da<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define INF 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
int ans[510][510];
int main(){
  int n,m,q;
  cin >> n >> m >> q;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    ans[a][b]++;
  }
  rep(i,502){
    rep(j,502)ans[i][j + 1] += ans[i][j];
  }
  rep(i,q){
    int a,b;
    cin >> a >> b;
    int sum = 0;
    REP(j,a,b + 1)sum += ans[j][b] - ans[j][a - 1];
    cout << sum << endl; 
  }
  return 0;
}


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    char c;
    cin>>c;
    if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o' ) cout<<"vowel"<<endl;
    else cout<<"consonant"<<endl;
    return 0;
}

Measured memory_bytes: 764
import sys

def main():
  input = sys.stdin.readline().rstrip

  S = int(input())
  h,m,s=0,0,0
  h = int(S / 60 / 60)
  m = int(S / 60%60)
  s=S%60
  print(str(h)+':'+str(m)+':'+str(s))


if __name__ == '__main__':
  main()



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

#define  int  long long
#define  endl  '\n'
const int mod = 1e9 + 7;

map<int, int> cnt;

void primeFactors(int x)
{

   for(int i = 2; i * i <= x; i++)
   {
      int tot = 0;
      while(x % i == 0)
      {
         tot++;
         x /= i;
      }
      if(tot)
        cnt[i] += tot;
   }

   if(x > 1)
      cnt[x]++;
}

int power(int b, int p)
{
   if(p == 0)
     return 1;
   int x = power(b, p / 2);
   x = (x * x) % mod;
   if(p & 1)
     x = (x * b) % mod;

   return x;
}

int32_t main()
{ 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);  
  int n;
  cin >> n;


  for(int i = 1; i <= n; i++)
    primeFactors(i);

  int ans = 1;

  for(auto it : cnt)
  {
     int x = it.second;
     ans *= (x + 1);
     ans %= mod;
  }

  cout << ans;
  
  return 0;
}

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

const int mod = 1e9 + 7;

int exp(int x, int n) {
    int ret = 1;
    while(n) {
        if(n & 1) ret = 1LL * ret * x % mod;
        x = 1LL * x * x % mod;
        n >>= 1;
    }
    return ret;
}
int inv(int x) {
    return exp(x, mod - 2);
}
int fact[4010], invf[4010];
int comb(int n, int k) {
    return 1LL * fact[n] * invf[k] % mod * invf[n - k] % mod;
}

int A, B;
int po[4010];

int cc2[2010][2010];
int dp2(int a, int b) {
    int &ret = cc2[a][b];
    if(ret != -1) return ret;
    if(b == 0) return ret = 1;

    ret = 0;
    if(a) {
        ret += dp2(a - 1, b - 1);
        ret %= mod;
    }
    if(b) {
        ret += dp2(a, b - 1);
        ret %= mod;
    }
    return ret;
}

int cc1[2010][2010];
int dp1(int n, int b) {
    int &ret = cc1[n][b];
    if(ret != -1) return ret;
    if(n == 0) return ret = 1;

    ret = 0;
    if(n > b) {
        ret += dp1(n - 1, b);
        ret %= mod;
    }
    if(b) {
        ret += dp2(n - b, b - 1);
        ret %= mod;
    }
    return ret;
}

int main() {
    po[0] = 1;
    for(int i = 1; i < 4010; i++) {
        po[i] = po[i - 1] * 2 % mod;
    }
    fact[0] = 1;
    for(int i = 1; i < 4010; i++) {
        fact[i] = 1LL * fact[i - 1] * i % mod;
    }
    for(int i = 0; i < 4010; i++) {
        invf[i] = inv(fact[i]);
    }

    cin >> A >> B;

    memset(cc1, -1, sizeof(cc1));
    memset(cc2, -1, sizeof(cc2));

    int ans = 0;
    for(int t = 0; t <= A; t++) {
        for(int b = 0; b <= min(B - 1, t); b++) {
            /// comb(B - 1, b)

            ans += 1LL * dp1(t, b) * comb(B - 1, b) % mod;
            ans %= mod;
        }
    }
    cout << ans;
}


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

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

  vector<long long> lucas(87);
  lucas[0] = 2; lucas[1] = 1;
  for (int i = 2; i < 87; i++) {
    lucas[i] = lucas[i-1] + lucas[i-2];
  }
  int n;
  cin >> n;
  cout << lucas[n] << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int		main(void)
{
	int h, w, k;
	cin >> h >> w >> k;

	vector<bool> H(h);
	vector<bool> W(w);
	vv(char) table(6, vector<char>(6));

	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cin >> table[i][j];
		}
	}
	int ans = 0;
	for (int a = 0; a < (1 << h); ++a)
	{
		bitset<6> A(a);
		for (int b = 0; b < (1 << w); ++b)
		{
			bitset<6> B(b);
			int sum = 0;
			for (int i = 0; i < h; ++i)
			{
				for (int j = 0; j < w; ++j)
				{
					if (!A[i] && !B[j] && table[i][j] == '#')
						++sum;
				}
			}
			if (sum == k)
				++ans;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3636
import itertools
n,m,q=map(int,input().split())
lis=[]
ans=0

for _ in range(q):
    a,b,c,d = map(int, input().split())
    lis.append([a-1,b-1,c,d])

for i in itertools.combinations_with_replacement(range(1,m+1),n):
    tmp=0
    for j in range(q):
        if i[lis[j][1]] - i[lis[j][0]] == lis[j][2]:
            tmp+=lis[j][3]
    ans=max(ans,tmp)
print(ans)

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

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
	int n,k;
	scanf("%d %d",&n,&k);
	int i, tmp;
	long c=0;
	for (i=k+1;i<=n;i++) {
		c+=((long)i-k)*(n/i);
		tmp = n%i;
		if (tmp >= k) {
			c+=(k==0)?tmp-k:tmp-k+1;
		}
	}
	printf("%ld\n",c);
	return 0;
}


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

int main() {
	int a, b, c, d, e, k, diff;
	cin >> a >> b >> c >> d >> e >> k;
	
	diff = e - a;
	
	if(diff <= k) cout << "Yay!";
	else cout << ":(";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
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; }
typedef long long ll;

int gcd(int a, int b) {
    if (b > a) gcd(b, a);
    int r;
    while(r = a % b) {
        a = b;
        b = r;
    }
    return b;
}


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

    int res;
    rep(i, 0, N) {
        int a;
        cin >> a;
        if (i == 0) res = abs(X - a);
        else res = gcd(res, abs(X - a));
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline())
P = list(map(int, sys.stdin.readline().split()))

ans = 0
for i, p_i in enumerate(P):
    if p_i == i + 1:
        if i + 1 == N:
            P[i], P[i-1] = P[i-1], P[i]
        else:
            P[i+1], P[i] = P[i], P[i+1]
        ans += 1

print(ans)

Measured memory_bytes: 20792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main(){
	oneforall
	char a[10000],b[10000];
	cin>>a+1>>b+1;
	ll asize = 0;
	ll bsize = 0;
	while (a[asize+1]) { asize++; }
	while (b[bsize+1]) { bsize++; }
	ll dp[3001][3001];
	FOR(i, 0, 3001)FOR(j, 0, 3001) { dp[i][j] = 0; }
	FOR(i,1,asize+1){
		FOR(j,1,bsize+1){
			if(a[i] == b[j])dp[i][j] = dp[i-1][j-1]+1;
			else{dp[i][j] = max(dp[i-1][j],dp[i][j-1]);}
		}
	}
	string x;
	while(asize and bsize){
		if(a[asize] == b[bsize]){
			x += a[asize];
			asize--;
			bsize--;
		}
		else if(dp[asize-1][bsize]>dp[asize][bsize-1])asize--;
		else bsize--;
	}
	reverse(x.begin(),x.end());
	cout<<x;
	return 0;
}

Measured memory_bytes: 70656
# coding: utf-8
# Your code here!
import re
S=0
while True:
    try:
        x=input()
        R=re.compile("\d+")
        m=R.findall(x)
        M=[int(s) for s in m]
        S+=sum(M)
    except EOFError:
        break
print(S)


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

int main() {
  int N,K;
  int64_t Z=0;
  cin>>N>>K;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
    p[i]--;
  }
  vector<int> q(N+1);
  map<int,int> m;
  m[0]=1;
  for(int i=0;i<N;i++){
    int j=i+1-K;
    if(j>=0){
      m[q[j]]--;
    }
    q[i+1]=(q[i]+p[i])%K;
    if(m.count(q[i+1])){
      m[q[i+1]]++;
    }
    else{
      m[q[i+1]]=1;
    }
    Z+=m[q[i+1]]-1;
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 13956
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
    if(cin >> f){in(r...);return true;}
    else return false;
}
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
const int INF = 1e18, MOD = 1e9 + 7;
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

main(){
    INCANT;
    int r, d, x, res = 0;
    string s;
    in(r, d, x);
    res = x;
    rep(i, 10){
        res = r * res - d;
        print(res);
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean xbANDa = false;
        boolean bANDxa = false;
        int acount = 0;
        int bcount = 0;
        int abcount = 0;
        
        for (int i = 0; i < n; i++) {
            String str = sc.next();
            if (str.charAt(0) != 'B' && str.charAt(str.length() - 1) == 'A') {
                acount++;
                xbANDa = true;
            }
            if (str.charAt(0) == 'B' && str.charAt(str.length() - 1) != 'A') {
                bcount++;
                bANDxa = true;
            }
            if (str.charAt(0) == 'B' && str.charAt(str.length() - 1) == 'A') {
                acount++;
                bcount++;
            }
            for (int j = 0; j < str.length() - 1; j++) {
                if (str.charAt(j) == 'A' && str.charAt(j + 1) == 'B') {
                    abcount++;
                }
            }
        }
        
        int count = 0;
        if (xbANDa || bANDxa) {
            count = Math.min(acount, bcount);
        } else {
            count = Math.max(0, acount - 1);
        }
        
        System.out.println(count + abcount);
    }
}


Measured memory_bytes: 30716
using System;
using System.Linq;
using static System.Console;

class class_A
{
    static int calc(int n0, int A, int B)
    {
        var n = n0;
        var cnt = 0;
        while (n != 0)
        {
            cnt += n % 10;
            n /= 10;
        }
        if (A <= cnt && cnt <= B)
        {
            return n0;
        }
        return 0;
    }

    static void Main()
    {
        var tmp = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = tmp[0];
        var A = tmp[1];
        var B = tmp[2];

        var cnt = 0;

        for (var n = 0; n <= N; n++)
        {
            cnt += calc(n, A, B);
        }
        WriteLine(cnt);
    }
}


Measured memory_bytes: 13396
<?php
fscanf(STDIN,"%d",$n);
fscanf(STDIN,"%s",$s);
$lefts = array();
$rights = array();
for($i=0;$i<$n;$i++) $rights[$s[$i]]++;

//print_r($rights);

$lefts['W'] = 0;
$lefts['E'] = 0;
$min = 10**7;

for($i=0;$i<=$n;$i++){
  $count = $lefts['W']+$rights['E'];
  //echo $count."\n";
  $lefts[$s[$i]]++;
  $rights[$s[$i]]--;
  $min = min($count,$min);
  $count = 0;
}

echo $min;


Measured memory_bytes: 4728
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#define N 103
#include<map>
#include<bitset>
#include<deque>
#include<cstdlib>
#include<set>
#include<ctime>
#define ll long long
#define mp make_pair
using namespace std;
ll read()
{
	ll x=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return f*x;
}
int n,a[N],len,as[N]; 
int main()
{
	len=n=read();
	for(int i=1;i<=n;++i) a[i]=read();
	for(int i=1;i<=n;++i)
	{
		int j=0;
		for(j=len;j>=1;--j) if(a[j]==j) break;
		if(!j)
		{
			cout<<-1;
			return 0;
		}
		as[n-i+1]=j;
		for(int k=j;k<len;++k) swap(a[k],a[k+1]);
		len--;
	 }
	 for(int i=1;i<=n;++i) cout<<as[i]<<'\n';
	return 0;
 }


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

#define MEM(a, b) memset(a, (b), sizeof(a))
#define PI 3.1415926535897932384626433832795
#define endl '\n'
#define exists(s, e) (s.find(e)!=s.end())
#define WHILE(n)
#define pb push_back
#define f first
#define s second
#define UNI(vec) vec.erase(std::unique(vec.begin(), vec.end()),vec.end());
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
typedef long long ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<int, pii> piii;

const int INF = 0x3f3f3f3f;
#define MAXN 1001
using namespace std;
int n,m,ans;
int dp[MAXN][MAXN];
int mod = 1e9+7;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n>>m;
    char c;

    for (int i =0; i < n; i++){
        for(int j = 0 ; j < m; j++){
            cin>>c;
            if(c=='#')
                dp[i][j] = -1;
        }
    }
    for(int i = 0; i < MAXN; i++){
        if(dp[i][0] == -1)
            break;
        dp[i][0] = 1;
    }
    for(int i = 0; i < MAXN; i++){
        if(dp[0][i] == -1)
            break;
        dp[0][i] = 1;
    }
    for(int i = 1; i <n; i++){
        for(int j = 1; j <m; j++){
            if(dp[i][j] == -1) continue;
            if(dp[i-1][j] != -1 && dp[i][j-1] != -1)
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
            else if(dp[i][j-1] != -1)
                dp[i][j] = dp[i][j-1];
            else if(dp[i-1][j] != -1)
                dp[i][j] = dp[i-1][j];
            dp[i][j]%=mod;
            //cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<dp[n-1][m-1];
}


Measured memory_bytes: 4224
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

 class Main{

	public static void main(String[] args) throws IOException {
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));		

		int n = Integer.parseInt(br.readLine());
		int[] in = new int[n];
		int max = Integer.MIN_VALUE;
		int mini = 0;
		int maxj=0;
		boolean con=false;
		
		for (int i = 0; i < n; i++)
			in[i] = Integer.parseInt(br.readLine());
		
		for (int i = 0; i < n - 1; i++) {
			if (in[i] > in[mini])
				continue;
			mini=i;
			for (int j = i + 1; j < n; j++){
				if(i!=0&&con&&i<maxj){
					mini=i;
					max=in[maxj]-in[i];
					break;}
				else if(max+in[i]<in[j]){
					max=in[j]-in[i];
					mini=i;
					maxj=j;
					con=false;
				}
			}con=true;
		}
		System.out.println(max);
	
	}}

Measured memory_bytes: 37688
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef double D;
const ll inf=(1ll<<62);
const ll mod=1e9+7;
const int MX=3e5+9;
int n,a[2][MX],dp[2][MX];
int main(){
    cin>>n;
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            scanf("%d",&a[i][j]);
        }
    }
    dp[1][n-1]=a[1][n-1];
    dp[0][n-1]=a[0][n-1]+a[1][n-1];
    for(int i=n-2;i>=0;i--){
        dp[1][i]=a[1][i]+dp[1][i+1];
        dp[0][i]=a[0][i]+max(dp[0][i+1],dp[1][i]);
    }
    cout<<dp[0][0]<<endl;
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using MII = std::unordered_multimap<int, int>;

long long int MX = 1000000007LL;

long long int  calc_pattern(MII const & edge, int parents_node, int node, long long int k, long long int p){
	auto range = edge.equal_range(node);
	long long int q = k - 2;
	for (auto it = range.first; it != range.second; ++it) {
		if(it->second != parents_node){
			p *= calc_pattern(edge, node, it->second, k, q) % MX;
			p %= MX;
			q -= 1;
		}
	}
	return p;
}

int main()
{
	long long int N, K;
	cin>> N >> K;
	MII edge;
	for (long long int i = 0; i < N - 1; i++){
		int a,b;
		cin >> a >> b; 
		edge.emplace(a - 1,b - 1);
		edge.emplace(b - 1,a - 1);
	}
	long long int p = K;
	long long int q = K - 1;
	auto range = edge.equal_range(0);
	for (auto it = range.first; it != range.second; ++it) {
		p *= calc_pattern(edge, 0, it->second, K, q) % MX;
		p %= MX;
		q -= 1;
	}
	cout << p;
	return 0;
}

Measured memory_bytes: 15560
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int main()
{
    string s;

    cin >> s;

    int ans = 0;
    rep(i, 4) {
        if( s[i] == '+' ) ++ans;
        else --ans;
    }

    cout << ans << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(100010);
	rep(i,n){
		int b;
		cin >> b;
		a.at(b)++;
	}
	int ans=0;
	rep(i,100000){
		ans=max(ans,a.at(i)+a.at(i+1)+a.at(i+2));
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
vector<int>g[5100];
int sz[5100];
int h[5100];
long long C[5100][5100];
long long fact[5100];
long long ret=1;
int N;
long long dp[5100][5100];
long long calc(vector<int>v,int K){
	int n=v.size();
	for(int i=0;i<=n;i++){
		for(int j=0;j<=K;j++){
			dp[i][j]=0;
		}
	}
	int tot=0;
	for(int i=0;i<v.size();i++)tot+=v[i];
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=K;j++){
			if(!dp[i][j])continue;
			for(int k=0;k<=v[i]&&j+k<=K;k++){
				dp[i+1][j+k]=(dp[i+1][j+k]+dp[i][j]*C[v[i]][k]%mod*C[v[i]][k]%mod*fact[k])%mod;
			}
		}
	}
	long long ret=0;
	for(int i=0;i<=K;i++){
//		printf("%d: %lld\n",i,dp[n][i]*C[tot-i][K-i]%mod*C[tot-i][K-i]%mod*fact[K-i]%mod);
		if(i%2==0){
			ret=(ret+dp[n][i]*C[tot-i][K-i]%mod*C[tot-i][K-i]%mod*fact[K-i])%mod;
		}else{
			ret=(ret+mod-dp[n][i]*C[tot-i][K-i]%mod*C[tot-i][K-i]%mod*fact[K-i]%mod%mod)%mod;
		}
	}
//	for(int i=0;i<n;i++)printf("%d ",v[i]);
//		printf("(%d) -> %lld\n",K,ret);
	return ret;
}
void dfs(int a,int b){
	sz[a]=1;
	int tot=0;
	vector<int>v;
	for(int i=0;i<g[a].size();i++){
		if(g[a][i]==b)continue;
		dfs(g[a][i],a);
		sz[a]+=sz[g[a][i]];
		v.push_back(h[g[a][i]]);
		tot+=h[g[a][i]];
	}
	tot++;
	int cap=min(sz[a],N-sz[a]);
	h[a]=cap;
//	printf("%d %d %d\n",a,cap,tot);
	if(cap>=tot)return;
	long long tmp=0;
	tmp=(tmp+calc(v,tot-cap-1))%mod;
	v.push_back(1);
	tmp=(tmp+calc(v,tot-cap))%mod;
	ret=ret*tmp%mod;
}
int main(){
	fact[0]=1;
	for(int i=1;i<5100;i++)fact[i]=fact[i-1]*i%mod;
	C[0][0]=1;
	for(int i=0;i<5050;i++){
		for(int j=0;j<=i;j++){
			C[i+1][j]=(C[i+1][j]+C[i][j])%mod;
			C[i+1][j+1]=(C[i+1][j+1]+C[i][j])%mod;
		}
	}
	int a;scanf("%d",&a);
	N=a;
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(q);
		g[q].push_back(p);
	}
	dfs(0,-1);
	printf("%lld\n",ret);
}

Measured memory_bytes: 404096
#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 main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b,k;
  cin >> a >> b >> k;
  if(k<=a){
    cout << a-k << " " << b << endl;
  }else{
    cout << 0 << " " << max(0LL, b-(k-a)) << endl;
  }

  return 0;
}



Measured memory_bytes: 3608
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long total = in.nextLong();
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) a[i] = in.nextInt();
            long sum = 0;
            for (int x : a) sum += x;
            if (sum == total) {
                out.println(n);
            } else if (sum < total) {
                out.println(n - 1);
            } else {
                Arrays.sort(a);
                long got = 0;
                int res = 0;
                for (int x : a) {
                    got += x;
                    if (got <= total) {
                        ++res;
                    }
                }
                out.println(res);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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 long long INF = 1LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int main(int argc, char const *argv[]) {
    ll n, d, a;
    cin >> n >> d >> a;
    vector<P> v(n);
    for(int i=0;i<n;i++){
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(),v.end());
    ll tot=0LL;
    ll cnt=0LL;
    queue<P> q;
    for(int i=0;i<n;i++){
        ll x=v[i].first;
        ll h=v[i].second;
        while(q.size() && q.front().first < x){
            tot-=q.front().second;
            q.pop();
        }
        h-=a*tot;
        if(h<=0) continue;
        ll dmg = (h+a-1)/a;
        tot+=dmg;
        cnt+=dmg;
        q.push(P(x+d*2, dmg));
    }
    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

   private static final String INPUT_FILE_PATH = "";

   void solve() {
      String s = in.nextToken();
      int sum = 0;
      for (char c : s.toCharArray()) {
         sum += c - '0';
         sum %= 9;
      }
      out.println(sum == 0 ? "Yes" : "No");
   }

   private final InputReader in;
   private final PrintWriter out;

   private Main(InputReader in, PrintWriter out) {
      this.in = in;
      this.out = out;
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

      public String nextToken() {
         while (st == null || !st.hasMoreTokens()) {
            try {
               st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
               throw new RuntimeException(e);
            }
         }
         return st.nextToken();
      }

      public int nextInt() {
         return Integer.parseInt(nextToken());
      }

      public long nextLong() {
         return Long.parseLong(nextToken());
      }

      public double nextDouble() {
         return Double.parseDouble(nextToken());
      }
   }

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      new Main(inputReader, printWriter).solve();

      printWriter.close();
   }

}


Measured memory_bytes: 36796
//PLUS ULTRA

#include<bits/stdc++.h>
using namespace std;
     
     
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define mp make_pair
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define nfor(i,st,n) for(int i = st; i >= n ; i--)

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

const int N = 1e5 + 10 , mod =  1000000007;



int main(){
    SPEED;

    string s; cin >> s;

    if(s[2] ==s[3]  && s[4] == s[5])cout << "Yes" << endl;
    else cout << "No" << endl;

    
    return 0;
}
      
       


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

int main() {
  int n,k;
  cin>>n>>k;
  vector<int> ls(n);
  for(int i=0;i<n;i++){cin>>ls.at(i);}
  sort(ls.begin(),ls.end());
  reverse(ls.begin(),ls.end());
  int sum=0;
  for(int i=0;i<k;i++){sum+=ls.at(i);}
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#これの元のprojectionは通ったが、これはおかしくなる。
#数字自体は誤差の範囲内に収まった正解なので、-e16みたいな表示になるせいだと思う
#たぶんベクトルのノルムで割る操作が悪い
#連立方程式を解くべきか
L1=input().split( )
[xp1,yp1,xp2,yp2]=[int(L1[0]),int(L1[1]),int(L1[2]),int(L1[3])]
direction=[xp2-xp1,yp2-yp1]
norm_direc=[(xp2-xp1)/((xp2-xp1)**2+(yp2-yp1)**2)**(1/2),(yp2-yp1)/((xp2-xp1)**2+(yp2-yp1)**2)**(1/2)]
q=int(input())
L=[]
for i in range(q):
    L2=input().split( )
    L.append([int(L2[0]),int(L2[1])])

Point=[]
for i in range(q):
    Point.append([(L[i][0]-xp1),(L[i][1]-yp1)])

Vec=[]
for i in range(q):
    Vec.append([L[i][0]-xp1,L[i][1]-yp1])
Proj=[]
for i in range(q):
    inter=Vec[i][0]*norm_direc[0]+Vec[i][1]*norm_direc[1]
    Proj.append([norm_direc[0]*inter,norm_direc[1]*inter])
#以下射影用
#L2=[]

#for i in range(q):
#    L2.append([xp1+Proj[i][0],yp1+Proj[i][1]])
#for i in range(q):
#    print(*L2[i])

vert=[]
for i in range(q):
    vert.append([Vec[i][0]-Proj[i][0],Vec[i][1]-Proj[i][1]])
L3=[]
for i in range(q):
    a=L[i][0]-2*vert[i][0]
    b=L[i][1]-2*vert[i][1]
    if -0.00000001<a<0.00000001:
        a=0
    if -0.00000001<b<0.00000001:
        b=0
    L3.append([a,b])

for i in range(q):
    print(*L3[i])



Measured memory_bytes: 6588
def ExchangeChar(c): 
  charNum = ord(c)
  if(ord("a") <= charNum and charNum <= ord("z")):
    return chr(charNum - 32) 
  elif(ord("A") <= charNum and charNum <= ord("Z")):
    return chr(charNum + 32)
  else:
    return c

words = list(input())
ans = []
for i in range(len(words)):
  ans.append(ExchangeChar(words[i]))

if(len(ans) == 1):
  print(ans[0])
else:
  for i in range(len(ans)-1):
    print(ans[i],end='')
  print(ans[i+1])



Measured memory_bytes: 5716
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
string s;
int32_t main(){
CODE_START;
cin>>s;
if(s[0]==s[1]){
    cout<<"Bad";
    return 0;
}
if(s[1]==s[2]){
    rc("Bad");
}
if(s[2]==s[3])
rc("Bad");
rc("Good");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define fill(i,n) memset(i,n,sizeof(i))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N;
int a[100010];

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
   cin>>N;
   bool ok=true;
   rep(i,0,N){
       cin>>a[i];
       if(a[i]%2)ok=false;
   }
   if(ok){
       cout<<"second"<<endl;
   }
   else cout<<"first"<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>

#define mod 1000000000+7;
typedef long long ll;
using namespace std;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n; cin >> n;
	double sum;
	for(int i{}; i<n; i++){
		double z; cin >> z;
		sum+=1/z;
	}

	cout << 1/sum << "\n";
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007





int lcm(int a,int b){
	return a/__gcd(a,b) * b;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


map< int, int > prime_factor(int n) {
  map< int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};



signed main()
{
  int N,K;
  cin>>N>>K;
  long long a[N];
  long long x[N];
  long long b[N];
  REP(i,0,N){
    cin>>a[i];
    x[i]=0;
    b[i]=0;
  }
  x[0]=a[0];
  if(a[0]>0){
    b[0]=a[0];
  }
  REP(i,1,N+1){
    x[i]=x[i-1]+a[i];
    if(a[i]>0){
    b[i]=b[i-1]+a[i];
    }else{
      b[i]=b[i-1];
    }

  }
  if(N==K){
    if(x[N-1]>0){
      cout<<x[N-1]<<endl;
    }else{
      cout<<0<<endl;
    }
    return 0;
  }
  long long ans=0;
  REP(i,0,N-K+1){
    long long tmp=0;

    if(i==0){
      tmp=x[K-1]+b[N-1]-b[K-1];
    }else if(i==N-K){
      tmp=x[N-1]-x[N-K-1]+b[N-K-1];
    }else{
      
      tmp=x[K+i-1]-x[i-1]+b[i-1]+b[N-1]-b[K+i-1];
    }
   
    ans=max(ans,tmp);
    if(i==0){
      tmp=b[N-1]-b[K-1];
    }else if(i==N-K){
      tmp=b[N-K-1];
    }else{
      tmp=b[i-1]+b[N-1]-b[K+i-1];
      
    }
  
    ans=max(ans,tmp);

  }
  cout<<ans<<endl;

}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
   cin>>n;
  
     int arr[n];
   for(int i=0;i<n;i++)
       cin>>arr[i];

      int count=0,value;
  for(int i=0;i<n;i++)
  { 
      if(i==0)
      {
        count++;
        value=arr[i];
      }
     else
     {
        value = min(value,arr[i]);
         if(value >= arr[i])
            count++;
     }
   }
     cout<<count;
}


Measured memory_bytes: 1024
H, W = map(int, input().split())
B = [[0 for i in range(W)] for j in range(H)]
for i in range(H):
  a = list(input())
  for j in range(W):
    if a[j] == '#':
      B[i][j] = '#'
      if i-1>=0 and j-1>=0 and B[i-1][j-1]!='#':
        B[i-1][j-1] += 1
      if i-1>=0 and B[i-1][j]!='#':
        B[i-1][j] += 1
      if i-1>=0 and j+1<W and B[i-1][j+1]!='#':
        B[i-1][j+1] += 1
      if j-1>=0 and B[i][j-1]!='#':
        B[i][j-1] += 1
      if j+1<W and B[i][j+1]!='#':
        B[i][j+1] += 1
      if i+1<H and j-1>=0 and B[i+1][j-1]!='#':
        B[i+1][j-1] += 1
      if i+1<H and B[i+1][j]!='#':
        B[i+1][j] += 1
      if i+1<H and j+1<W and B[i+1][j+1]!='#':
        B[i+1][j+1] += 1
for i in range(H):
  ans = ''.join([str(n) for n in B[i]])
  print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

const int MAX_N=100005;
vector<int> to[MAX_N];

ll dp_w[MAX_N],dp_b[MAX_N];

void dfs(int v,int p=-1){
    dp_w[v]=1;
    dp_b[v]=1;
    for(int u:to[v]){
        if(p==u) continue;
        dfs(u,v);
        dp_w[v]=(dp_w[v]*(dp_w[u]+dp_b[u]))%mod;
        dp_b[v]=(dp_b[v]*(dp_w[u]))%mod;
    }
}

int main(){
    int n;
    cin>>n;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        --a;--b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dfs(0);
    cout<<(dp_b[0]+dp_w[0])%mod<<endl;
}

Measured memory_bytes: 10240