akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
    map<string, int> A;
    map<string, int> B;
    int N, M;
    string s;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> s;
        A[s]++;
    }
    cin >> M;
    for (int i = 0; i < M; i++) {
        cin >> s;
        B[s]++;
    }
    int max = 0;
    auto begin = A.begin(), end = A.end();
    for (auto iter = begin; iter != end; iter++) {
        string key = iter->first;
        int a = 0;
        if (B.count(key)){
            a = iter->second - B[key];
        } else {
            a = iter->second;
        }
        if (a > max){
            max = a;
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

template<typename T>
void print_old(vector<T>vec){
    for(int i=0; i< vec.size(); i++)
      cout<< vec[i]<<" ";
}
//  prints any type which supports iterators...
template <class T>
void print(T& c){
   for( typename T::iterator i = c.begin(); i != c.end(); i++ ){
      std::cout << *i << "\n";
   }
   cout<< "\n";
}
// void f(const vector< int >& v) {
// int r = 0;
// tr(v, it) {
// r += (it)(*it);
// }
// return r;
// }
typedef vector< int > vi;
typedef pair< int,int > pii;
typedef vector<string> vs;
typedef vector<vi> vv;
#define sz(a) int((a).size())
#define pb push_back
#define forn(n) for(int i =0 ; i< n; i++)
#define all(c) c.begin(), c.end()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define ll long long
const int inf = 1e9 +1000;


int main(){
    fastio;
   //  int t;
   //  cin>> t;
// here previous approach of D_knapsack won't work because W is huge...we cannot have an array that is this long...
// alternative approach could be to use array of values...and and weight...
    int t = 1;
    while(t--){
        int n;
        ll W;
        cin>>n>>W;
        vector<int> weight(n), value(n);
      for(int i = 0; i < n; i++){
          cin >> weight[i] >> value[i];
      }
    //   for(int j = 0; j< n; j++){
    //       cout << weight[j] << " " << value[j] << "\n";
    //   }
     int total_sum = 0;
     for(auto x: value){
         total_sum += x;
     }

     vector<ll> dp(total_sum +1 , inf);
     dp[0] = 0;
    //  dp[i] --here is minimum total weight of items with total value exactly i
    for(int i= 0; i < n; ++i){
        for(int value_taken = total_sum - value[i]; value_taken >= 0; --value_taken){
            dp[value_taken +value[i]] = min(dp[value_taken + value[i]], dp[value_taken]+weight[i]);
        }
    }

    ll ans{0};
    for(int i = 0; i<= total_sum; ++i){
        if(dp[i] <= W){
            ans = max(ans, (ll)i);
        }
    }
    cout << ans << "\n";

      }
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

#define N 100000
#define M 50000

int n,s[N],t[M];

int binarySearch(int);

int main(){

  int q,i,count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&s[i]);

  }
  scanf("%d",&q);

    for(i=0;i<q;i++){

      scanf("%d",&t[i]);

      if(binarySearch(t[i])==1) {count++;}

    }

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

  return 0;
}

int binarySearch(int key){

  int left=0,right=n,mid;

  while (left<right){

    mid=(left+right)/2;

  if(s[mid]==key) return 1;

  else if(key<s[mid])
    right=mid;

  else left=mid+1;

  }

  return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 1000000
using namespace std;
int n,a[N+5];char s[N+5];
int main()
{
	RI i;for(scanf("%d%s",&n,s+1),--n,i=1;i<=n;++i) a[i]=abs(s[i]-s[i+1]);
	RI f=1;for(i=1;i<=n;++i) if(a[i]==1) {f=0;break;}
	for(i=1;i<=n;++i) a[i]==2&&(a[i]=f);
	RI ans=0;for(i=1;i<=n;++i) (((n-1)^(i-1))==n-i)&&(ans^=a[i]);
	return printf("%d",ans*(f+1)),0;
}

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

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
    int N;
    map<string, int> S;
    cin >> N;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        S[s] += 1;
    }

    int max_val = 0;
    for (auto itr = S.begin(); itr != S.end(); itr++) {
        if (itr->second > max_val) {
            max_val = itr->second;
        }
    }

    for (auto itr = S.begin(); itr != S.end(); itr++) {
        if (itr->second == max_val) {
            cout << itr->first << endl;
        }
    }
    return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 25216
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuilder reversed = new StringBuilder();
        for (int i = s.length() - 1; i >= 0; i--) {
            char c = s.charAt(i);
            reversed.append(c);
        }
        String part1 = s.substring(0, (s.length() - 1) / 2);
        StringBuilder part1Reversed = new StringBuilder();
        for (int i = part1.length() - 1; i >= 0; i--) {
            char c = part1.charAt(i);
            part1Reversed.append(c);
        }
        String part2 = s.substring((s.length() + 3) / 2 - 1);
        StringBuilder part2Reversed = new StringBuilder();
        for (int i = part2.length() - 1; i >= 0; i--) {
            char c = part2.charAt(i);
            part2Reversed.append(c);
        }
        if (s.equals(reversed.toString()) && part1.equals(part1Reversed.toString())
                && part2.equals(part2Reversed.toString())) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");

    }

}


Measured memory_bytes: 23124
#!/usr/bin/env python
 
import sys
import re
 
_,a,b,c,d = [ int(x)-1 for x in sys.stdin.readline().split() ]
m = sys.stdin.readline().strip()
#
if c>d:
    if m[b-1:d+2].find("...")<0:
        print( "No" )
        exit()
else:
    # b -> d
    if m[b+1:d].find("##")>=0:
        print( "No" )
        exit()
    #
    # a -> c
    if m[a+1:c].find("##")>=0:
        print( "No" )
        exit()

print( "Yes" )


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vl a(n);
	FOR(i,0,n) cin >> a[i];

	vl dp(n+1);
	dp[0] = 1;

	ll m = 2e5 + 10;
	vl sum(m);

	FOR(i,0,n) {
		if (i == 0 || a[i-1] != a[i]) sum[a[i]] = (sum[a[i]] + dp[i]) % MOD;
		dp[i+1] = sum[a[i]];
	}
	cout << dp[n] << endl;
	//FOR(i,0,n+1) cerr << dp[i] << " ";
	//cerr << endl;
}



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

class Main {
    static final String YES = "Yes";
    static final String NO = "No";

    // Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        String S;
        S = sc.next();
        solve(S);
    }

    static void solve(String S){
        boolean isEven = true;
        for (char c: S.toCharArray()) {
            if (isEven && c == 'L') {
                System.out.println("No");
                return;
            }
            if (!isEven && c == 'R') {
                System.out.println("No");
                return;
            }
            isEven = !isEven;
        }

        System.out.println("Yes");

    }
}


Measured memory_bytes: 25172
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(ll i=0;i<n;++i)
#define END(x) (*(x.end()-1))
#define INF (INT_MAX)

using namespace std;
typedef long long ll;


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; }
template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

template<typename T>
T lcm(T a,T b){
    return a/gcd(a,b)*b;
}

int main(void){
    int h,w;
    cin>>h>>w;
    vector<vector<char>>M(h,vector<char>(w));
    rep(i,h){
        rep(j,w){
            char a;
            cin>>a;
            M[i][j]=a;
        }
    }
    vector<vector<int>>dp(h,vector<int>(w,0));
    M[0][0]='#';
    dp[0][0]=1;
    rep(i,h){
        rep(j,w){
            if(M[i][j]=='#')continue;
            if(i==0){
                dp[i][j]=dp[i][j-1];
                continue;
            }
            if(j==0){
                dp[i][j]=dp[i-1][j];
                continue;
            }
            dp[i][j]=(dp[i][j-1]+dp[i-1][j]) % int(1e9+7);
        }
    }
    cout<<dp[h-1][w-1];
}
/*
*/

Measured memory_bytes: 8500
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

typedef long long ll;

int main() {
    ll n;
    cin >> n;
    vector<ll> a;
    a.resize(n);
    for (ll i = 0; i < n; i++)
        cin >> a[i];
    ll j = 0;
    ll res = 0;
    ll x = 0;
    for (ll i = 0; i < n; i++) {
        while (j < n && (x & a[j]) == 0) {
            x = x xor a[j];
            res += (j - i + 1);
            j++;
        }
        x = x xor a[i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LLI long long int
#define LI long int 
const LI MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//            When something is important enough, you do it even if the odds are not in your favor.
LLI fac[(LI)1e7+4];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      fac[1]=1;
      LLI i;
      fo(i,2,1e7+4){
        if(fac[i]==0){
          LLI j=1;
          while(i*j<1e7+4){
            fac[j*i]=i;
            j++;
          }
        }
      }
      LLI n;cin>>n;
      LLI ans=1;
      fo(i,2,n+1){
        std::map<LLI, LLI> m;
        LLI j=i;
        while(j>=2){
          m[fac[j]]++;
          j/=fac[j];
        }
        LLI pd=1;
        for(auto x:m){
          pd*=x.ss+1;
        }
        ans+=i*pd;
      }
      cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 81708
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
i64 divceil(i64 a, i64 b) { return a / b + (a > 0 && a % b ? 1 : 0); }
int main() {
    i64 T[2], A[2], B[2];
    cin >> T[0] >> T[1] >> A[0] >> A[1] >> B[0] >> B[1];
    if(A[0] < B[0]) {
        swap(A[0], B[0]);
        swap(A[1], B[1]);
    }
    A[0] *= T[0], B[0] *= T[0];
    A[1] *= T[1], B[1] *= T[1];
    i64 a = A[0] + A[1], b = B[0] + B[1];
    if(a == b) {
        cout << "infinity" << endl;
    } else if(a > b) {
        cout << 0 << endl;
    } else {
        i64 dif1 = b - a, dif0 = A[0] - B[0];
        i64 ans = 2 * divceil(dif0, dif1) - 1;
        if(dif0 % dif1 == 0) ans++;
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n;
	cin >> n;
	int ma = 0;
	for (int i = 0; i < n; ++i)
	{
		int in;
		cin >> in;
		ma += in % 2;
	}
	cout << (ma?"first":"second") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000000;
long long f[MAX_N + 1];
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, W;
    memset(f, 0x3f, sizeof(f));
    cin>> N >> W;
    f[0] = 0;
    for (int i = 0, w, v; i < N; ++i)
    {
        cin >> w >> v;
        for (int j = MAX_N; j >= v; j--) 
        {
            f[j] = std::min(f[j], f[j - v] + w);
        }
    }
  
  for (int i = MAX_N; i >= 0; --i) 
  {
    if (f[i] <= W) 
    {
      std::cout << i;
      break;
    }
  }
}


Measured memory_bytes: 8064
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static class Node{
		private ArrayList<Node>next_list;

		boolean is_visited;
		int id;

		public static ArrayList<Integer>pass_list = new ArrayList<>();

		public Node(int id){
			this.id = id;
			next_list = new ArrayList<>();
			is_visited = false;
		}

		public void addNext(Node next){
			next_list.add(next);
		}

		public void searchPassBack(){
			is_visited = true;

			for(Node next : next_list){
				if(next.is_visited)continue;
				pass_list.add(next.id);
				next.searchPassBack();
				break;
			}
		}

		public void searchPassFront(){
			is_visited = true;

			for(Node next : next_list){
				if(next.is_visited)continue;
				pass_list.add(0,next.id);
				next.searchPassFront();
				break;
			}
		}
	}

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

		int node_count = sc.nextInt();
		int pass_count = sc.nextInt();

		Node[] node_list = new Node[node_count];

		for(int i = 0;i < node_list.length;i++){
			node_list[i] = new Node(i + 1);
		}

		for(int i = 0;i < pass_count;i++){
			int j = sc.nextInt() - 1;
			int k = sc.nextInt() - 1;
			node_list[j].addNext(node_list[k]);
			node_list[k].addNext(node_list[j]);
		}

		Node.pass_list.add(1);
		node_list[0].searchPassBack();
		node_list[0].searchPassFront();
		ArrayList<Integer>pass = Node.pass_list;

		System.out.println(pass.size());
		for(int i = 0;i < pass.size();i++){
			System.out.print(pass.get(i));
			if(i != pass.size() - 1)System.out.print(" ");
		}
		System.out.println();
		sc.close();
	}
}


Measured memory_bytes: 118472
from bisect import bisect_left,bisect_right
a,b,q=map(int,input().split())
s=[-(10**21)]+[int(input())for _ in range(a)]+[10**21]
t=[-(10**21)]+[int(input())for _ in range(b)]+[10**21]
for _ in range(q):
  x=int(input())
  s1,s2=s[bisect_right(s,x)-1],s[bisect_right(s,x)]
  t1,t2=t[bisect_right(t,x)-1],t[bisect_right(t,x)]
  ans=10**11
  for i in [s1,s2]:
    for j in [t1,t2]:
      ans=min(ans,abs(i-j)+min(abs(x-i),abs(x-j)))
  print(ans)

Measured memory_bytes: 12804
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 998244353;
const int N = 3000 + 3;

int n, s;
int a[N];
int dp[N][N];

int solve(int pos, int s) {
    if (s == 0)
        return n - (pos - 1) + 1;

    if (pos > n) 
        return 0;

    if (dp[pos][s] != -1) 
        return dp[pos][s];

    int ans = solve(pos + 1, s);
    if (a[pos] <= s)
        ans += solve(pos + 1, s - a[pos]);

    return dp[pos][s] = ans % MOD;
}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    cin >> n >> s;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

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

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += solve(i, s);
        ans %= MOD;
    }

    cout << ans;
}

Measured memory_bytes: 70784
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
inline int read()
{
	int x = 0 , f = 1; char ch = getchar();
	while(ch < '0' || ch > '9')	{if(ch == '-')	f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 405 , mod = 998244353;
int n , sa , sb;
int a[N] , b[N];
ll p[N][N] , fac[N] , inv[N] , f[N][N][N];
inline ll ksm(ll a,int b)
{
	ll res = 1;
	while(b)
	{
		if(b & 1) res = res * a % mod;
		a = a * a % mod; b >>= 1;
	}
	return res;
}
inline void init(int m)
{
	fac[0] = inv[0] = 1;
	for(int i = 1;i <= m;i ++) fac[i] = fac[i - 1] * i % mod;
	inv[m] = ksm(fac[m],mod - 2);
	for(int i = m - 1;i >= 1;i --) inv[i] = inv[i + 1] * (i + 1) % mod;
}
int main()
{
	n = read(); ll ans = 0;
	for(int i = 1;i <= n;i ++) sa += a[i] = read() , sb += b[i] = read();
	init(max(sa,sb));
	for(int i = 1;i <= n;i ++) for(int j = 0;j <= sb;j ++) p[i][j] = j ? p[i][j - 1] * a[i] % mod : 1;
	f[0][0][0] = -1;
	for(int i = 1;i <= n;i ++) for(int j = 0;j <= sa;j ++) for(int k = 0;k <= sb;k ++) 
	{
		f[i][j][k] = f[i - 1][j][k];
		for(int l = 0;l < b[i];l ++) if(j >= a[i] && k >= l) f[i][j][k] = (f[i][j][k] - f[i - 1][j - a[i]][k - l] * p[i][l] % mod * inv[l] % mod + mod) % mod;
	}
	for(int j = 0;j <= sa;j ++) for(int k = 0;k <= sb;k ++) ans = (ans + f[n][j][k] * sa % mod * fac[k] % mod * ksm(ksm(j,k + 1),mod - 2) % mod) % mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 515200
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
total = 0
for i in range(N):
    total += min(A[i]+A[i+1], B[i])
    if A[i]+A[i+1] < B[i]:
        A[i+1] = 0
    elif A[i] < B[i]:
        A[i+1] -= (B[i]-A[i])
 
print(total)

Measured memory_bytes: 18624
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

const MOD: i64 = 1e9 as i64 + 7;

fn main() {
    let n: usize = read();
    let n64 = n as i64;

    let mut dp: Vec<i64> = vec![0; n+10];
    let mut sum = n64;
    dp[1] = n64;
    for i in 2..n+1 {
        let i64 = i as i64;
        let less = max(0, i64 - 3);
        let more = n64 - 1 - less;

        dp[i] = (sum + MOD - dp[i-2] + more * n64 % MOD + less * (n64 - 1) % MOD) % MOD;
        sum += dp[i];
        sum %= MOD;
    }

    println!("{}", dp[n]);

}

Measured memory_bytes: 12540
r,c = map(int,input().split())
sheet = [list(map(int,input().split())) for i in range(r)]
for i in range(r):
    sheet[i].append(sum(sheet[i]))
         
column_sum = [0]*(c+1)
for j in range(c+1):
    for i in range(r):
        column_sum[j] += sheet[i][j]

for i in range(r):
    print(*sheet[i])
print(*column_sum)



Measured memory_bytes: 6232
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<pair<int,int>> v;
  for(int i=1;i<=n;i++){
  	int q;
  	cin>>q;
  	v.push_back(make_pair(q,i));
  }
  sort(v.begin(),v.end());
  for(auto i :v){
  	cout<<i.second<<" ";
  }
  return 0;
}
  

Measured memory_bytes: 4292
import Data.List
import Control.Monad

main = do
    [n,m] <- map read . words <$> getLine :: IO [Int]
    abs <-  replicateM n (map read . words <$> getLine) :: IO [[Int]]
    print $ solve (sort abs) 0 m

solve :: [[Int]] -> Int -> Int -> Int 
solve _ cPrc 0 =  cPrc
solve (ab:abs) cPrc tNum = if tNum >= b then solve abs (cPrc + a*b) (tNum - b) else cPrc + a*tNum
    where
        a = ab !! 0
        b = ab !! 1

Measured memory_bytes: 145788
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,c;
    cin>>n>>m>>c;
    int cnt = 0;
    vector<int> b(m);
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0;i<m;i++){
        cin>>b.at(i);
    }
    for(int i=0;i<n;i++){
        int sum = 0;
        for(int j=0;j<m;j++){
            cin>>a.at(i).at(j);
            sum += a.at(i).at(j) * b.at(j);
        }
        
        if(sum+c>0) cnt++;
    }
    
    
    cout<< cnt <<endl;
}


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

using namespace std;

int main()
{
	int N;
	int A;
	int B;
	cin >> N >> A >> B;
	int n_max = 0;
	int n_min = 0;
	n_max = min(A, B);
	if (N < A + B) {
		n_min = A + B - N;
	}
	cout << n_max << " " << n_min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    int A, B;
    cin  >> A >> B;
    int cnt;
    string str;

    for (int i = A; i <= B; i++)
    {
        str = to_string(i);
        if (str[0] == str[4] && str[1] == str[3]) cnt++;
    }
    
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return float(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	d,t,s=MI()
	ans="No"

	if d<=t*s:
		ans="Yes"
	print(ans)














if __name__ == "__main__":
	main()


Measured memory_bytes: 9248
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll n;
    string s;
    cin>>n>>s;
    ll ans=0,x=0;
    rep(i,n){
        if(s[i]=='I') x++,chmax(ans,x);
        else x--;
    }
    cout<<ans<<endl;


}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    solve();


    return 0;
}

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

int cntcf(int N){
    vector<int> x(N+1);
    int ans = 1;
    int num = N;
    for (int i = 2; i <= N; i++)
    {
        while (num % i == 0)
        {
            x.at(i)++;
            num /= i;
        }
    }
    for (int i = 2; i <= N; i++){
        ans *= x.at(i) + 1;
    }
    return ans;
}

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

    int cnt = 0;
    for (int i = 1; i <= N; i+=2)
    {
        if(cntcf(i) == 8) cnt++;
    }
    
    cout << cnt << endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    ll n;cin>>n;
    vl p(n);
    rep(i,n)cin>>p[i];
    ll ttl = accumulate(all(p),0LL);
    ll res = L_INF;
    ll tmp = 0;
    rep(i,n-1){
        tmp+=p[i];
        res = min(res,abs(ttl-2*tmp));
    }
    out(res);
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
  int height[300], weight[300];
  int i = 0, j = 0, count = 0, l = 0;

  for(i=1;i<=300;i++){
    scanf("%d %d", &height[i], &weight[i]);
    if(height[i]==0&&weight[i]==0) break;
    count++;
  }

  for(l=1;l<=count;l++){
    for(i=1;i<=height[l];i++){
      for(j=1;j<=weight[l];j++){
        if(i%2==0){
          if(j%2==0){
            printf("#");
          }else{
            printf(".");
          }
        }else{
          if(j%2==0){
            printf(".");
          }else{
            printf("#");
          }
        }
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 1004
//package Div2_655;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        char c[]=br.readLine().toCharArray();
        int rem=0;
        for(int i=0;i<c.length;i++){
            int x=c[i]-48;
            rem+=x;
            if(rem>=9){
                rem-=9;
            }
        }
        if(rem==0){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 36176
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
#define enld endl
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N,D; cin >> N >> D;
    int ans = 0;
    for(int i=0;i<N;i++){
        ll X,Y; cin >> X >> Y;
        if(X*X + Y*Y <= D*D) ans++;
    }
    cout << ans << enld;
    return 0;
}

Measured memory_bytes: 3556
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		//入力表示

		int ab = sc.nextInt();
		int bc = sc.nextInt();
		int ca = sc.nextInt();

		int area = ab * bc / 2;
		System.out.println(area);
	}
}

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

int main(){
 while(true){
  int h,w;
  cin >> h >> w;
  
  if(h==0 && w==0) break;

  int d = h*h+w*w;

  int H = 150;
  int W = 150;
  int D = 150*150+150*150;

  //対角線が長い時
  for(int y=1; y<=150; y++){
   for(int x=y+1; x<=150; x++){
    int z = y*y+x*x;

    if(z<=d){
     continue;
    }else{
     if(z<D){
      H = y; 
      W = x;
      D = z;
     }
     break;
    }
   }
  }
  
  //対角線が同じ長さの時
  for(int y=h+1; y<150; y++){
   bool flag = false;
   
   for(int x=y+1; x<=150; x++){
    int z = y*y+x*x;
 
    if(z==d){
     H = y; 
     W = x;
     D = z;
     flag = true;
    }
    if(z>=d) break;
   }   
   if(flag) break;
  }

  cout << H << ' ' << W << endl;
 }
 return 0;
}
 


Measured memory_bytes: 3096
taro,hanako = 0,0
w=[]
n = int(raw_input())
for i in xrange(n):
    w.append(map(str, raw_input().split()))
for j in xrange(n):
    if w[j][0]>w[j][1]:
        taro+=3
    elif w[j][0]<w[j][1]:
        hanako+=3
    else:
        taro+=1
        hanako+=1
#print n
#print w
print taro,hanako

Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
#define MOD 998244353 //1000000007

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

    // solution comes here
    ll N;
    cin >> N;
    vl L(N);
    rep(i, N) cin >> L[i];

    sortup(L);

    ll ans=0;
    rep(i, N-2) {
        for(ll j=i+1; j<N-1; j++) {
            ll key = L[i] + L[j];
            ll r = lower_bound(L.begin(),L.end(), key) - L.begin();
            ans += r-j-1;
        }
    }

    cout << ans << nl;
}

Measured memory_bytes: 256
<?php
$x = trim(fgets(STDIN));

$pn = new PrimeNumber();
$prime_number = $pn->createPrimeNumber($x*2);

for($i=0;$i<count($prime_number);$i++){
  if($prime_number[$i] >= $x){
    echo $prime_number[$i];
    exit;
  }
}

  class PrimeNumber {

    public $prime = [];

    function createPrimeNumber($n){
      $sqrt = floor(sqrt($n));
      $lists = array_fill(2, $n-1, true);
      for ($i=2; $i<=$sqrt; $i++) {
        if (isset($lists[$i])) {
          for ($j=$i*2; $j<=$n; $j+=$i) {
            unset($lists[$j]);
          }
        }
      }
      $this->prime = array_keys($lists);
      return $this->prime;
    }

    function primeFactorization($value){
      if(count($this->prime) === 0){
        $this->createPrimeNumber($value);
      }
      $prime_count = count($this->prime);
      $ret=[];
      $sqrt=floor(sqrt($value));
      for($i=0;$i<$prime_count;$i++){
        // 平方根を超えた場合は残った値が素数
        if($sqrt < $this->prime[$i]){
          $ret[$value]=1;
          return $ret;
        }
        // 割り切れる間続ける
        while($value%$this->prime[$i]==0){
          if(!isset($ret[$this->prime[$i]])){
            $ret[$this->prime[$i]]=0;
          }
          $ret[$this->prime[$i]]++;
          $value=intdiv($value, $this->prime[$i]);
          if($value==1){
            return $ret;
          }
        }
      }
    }
  }


Measured memory_bytes: 12792
#include<bits/stdc++.h>
#define mk make_pair
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
string s[500];
int h,w,sum=0;
vector<int>x,y;
void del(int t1,int t2){
  vector<pair<char,pair<int,int> > >p;
  for(int i=t1;i<h;i++)if(s[i][t2]!='.'){
    p.push_back(mk(s[i][t2],mk(i,t2)));
    break;
  }
  for(int i=t1;i>=0;i--)if(s[i][t2]!='.'){
    p.push_back(mk(s[i][t2],mk(i,t2)));
    break;
  }
  for(int i=t2;i<w;i++)if(s[t1][i]!='.'){
    p.push_back(mk(s[t1][i],mk(t1,i)));
    break;
  }
  for(int i=t2;i>=0;i--)if(s[t1][i]!='.'){
    p.push_back(mk(s[t1][i],mk(t1,i)));
    break;
  }
  sort(p.begin(),p.end());
  if(p.size()>=2){
    r(i,p.size()-1){
      if(p[i].first==p[i+1].first){
        sum++;
        s[p[i].second.first][p[i].second.second]='.';
        s[p[i+1].second.first][p[i+1].second.second]='.';
      }
    }
  }
}
int main(){
  cin>>h>>w;
  r(i,h)cin>>s[i];
  r(i,h)r(j,w)if(s[i][j]!='.'){
      y.push_back(i),x.push_back(j);
      if(i+1<h)y.push_back(i+1);
      if(j+1<w)x.push_back(j+1);
    }
  r(k,5)r(i,y.size())r(j,x.size())
    if(s[y[i]][x[j]]=='.')del(y[i],x[j]);
  cout<<sum*2<<endl;
}

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

int main(){
	string s;
	while(true){
		cin >> s;
		if(s == "0")break;
		int sum = 0;
		for(int i = 0; i < s.size(); i++){
			sum += s[i] - '0';
		}
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3160
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc086.contest.atcoder.jp/tasks/arc086_a>
問題文============================================================
 高橋君は，N 個のボールを持っています． 最初，i 番目のボールには，整数 Ai が書かれています．
 
 高橋君は，いくつかのボールに書かれている整数を書き換えて，
 N 個のボールに書かれている整数が K 種類以下になるようにしたいです．
 
 高橋君は，少なくとも何個のボールの整数を書き換える必要があるでしょうか？

=================================================================

解説=============================================================

 ある数字が何個存在するのかを確認し、K種類より大きければ、K種類以下になるように、
 数が少ないものから順に書き換えていけば良い
 
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N,K; cin >> N >> K;
    vector<ll> A(N);
    for(auto &in:A) cin >> in;
    map<ll,ll> mp;
    for(auto v:A) mp[v]++;
    vector<ll> ps;
    for(auto c:mp) ps.push_back(c.second);
    sort(ps.begin(),ps.end());
    ll ans = 0;
    for(int i = 0; i < (int)ps.size()-K;i++){
        ans += ps[i];
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 16500
// 
// 本番
//   2部マッチングやフローをしようとしたがLTE
// 本番後
//   LHiCの解答を理解 (https://beta.atcoder.jp/contests/agc029/submissions/3793091)
//   大きい数から順番に見ていく。大きい数とペアになれる数は常に一意。
//   例えばもっとも大きい数が 0b110101 とすると、これとペアになれるのは0b1010 + 1のみ。
//   数はmultisetで管理すると便利。ペアになったものから除去していく。

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
	int N;
	cin >> N;
	multiset<ll> ms;
	REP(n, N) {
        ll a;
        cin >> a;
        ms.insert(a);
	}

    int ans = 0;
    while (!ms.empty()) {
        auto a = *ms.rbegin();
        ms.erase(ms.find(a));

        // ペアになる数は now - aで表せる
        ll now = 1;
        while(now <= a) now *= 2;
		auto it2 = ms.find(now - a);

		// ペアになる数が存在しない
		if (it2 == ms.end()) continue;

		// ペアになる数が存在する
		ms.erase(it2);
		++ans;
    }
	cout << ans << endl;
	return 0;
}


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

int main(){
    int n;
    while (1){
	cin >> n;
	if (n == 0) break;
	vector<int> s;
	int b;
	for (int i = 0; i < n; i++){
	    cin >> b;
	    s.push_back(b);
	}
	int c = 0;
	while (1){
	    vector<int> freq(1000, 0);
	    for (int i = 0; i < n; i++)
		freq[s[i]]++;

	    vector<int> ss = s;
	    for (int i = 0; i < n; i++)
		ss[i] = freq[ss[i]];

	    if (ss == s){
		cout << c << endl;
		for (int i = 0; i < s.size(); i++)
		    printf("%d%c", s[i], (i == s.size()-1)? '\n':' ');
		break;
	    }

	    s = ss;
	    c++;
	}
    }
}

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

int main() {
	int w, h, x, y;
	cin >> w >> h >> x >> y;
	printf("%.10f ", (double)w*h / 2);
	if ((w % 2 == 0 && x == w / 2) && (h % 2 == 0 && y == h / 2))
		cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int i = kb.nextInt();
		int j = kb.nextInt();
		int k = kb.nextInt();
		if (i + j + k >= 22)
			System.out.println("bust");
		else
			System.out.println("win");
		kb.close();
	}

}


Measured memory_bytes: 21588
//ALL GLORY TO JESUS CHRIST 
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;

#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n-1); i>=0; --i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    double a, b, x; cin >> a >> b >> x;
    const double pi = acos(-1); 
    double res = 0.0;
    if(0.5*a*a*b <= x) {
        double a_ = 2*x;
        a_ /= a;
        a_ /= a;
        a_ -= b;
        res = atan((b-a_)/a);
    } else {
        double a_ = 2*x;
        a_ /= a;
        a_ /= b;
        res = atan(b/a_);
    }
    res = 180.0*res/pi;
    cout << setprecision(10) << res << "\n"; 
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

int main()
{
  int ave[20];
  int jsup=0;
  for(int j=0;j<20;j++)
    {
      int n;
      cin >> n;
      if(n==0)
	{
	jsup = j;
	break;
	}
      int s[100];
      int max=-1, min=1001;
      int max_i = -1, min_i=-1;
      for(int i=0;i<n;i++)
	{
	  cin >> s[i];
	  if(s[i] > max)
	    {
	      max = s[i];
	      max_i = i;
	    }
	  if(s[i] < min)
	    {
	      min = s[i];
	      min_i = i;
	    }
	  if(i == n-1 && max == min)
	    min_i = max_i+1;
	}
      int sum=0;
      for(int i=0;i<n;i++)
	{
	  if(i==max_i || i==min_i)
	    continue;
	  else
	    sum += s[i];
	}
      ave[j] = sum/(n-2);
    }
  for(int j=0;j<jsup;j++)
    {
      cout << ave[j] << endl;
    }
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
// vector<vector<int>> data(i, vector<int>(j))
// vector<vector<vector<char>>> data(N, vector<vector<char>>(3, vector<char>(3)))


int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
    if(a.at(i) % 2 == 0 && a.at(i)%3!=0 && a.at(i)%5 != 0){
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

string s;
int K;

void init()
{
	cin >> s >> K;
}

void update(int pos)
{
	if (s[pos] == 'a') return;
	int t = 'z' - s[pos] + 1;
	if (t <= K) {
		K-= t;
		s[pos] = 'a';
	}
}

void solve()
{
	rep(i, s.length()) update(i);
	K %= 26;
	while (K--) {
		s.back()++;
		if (s.back() > 'z') s.back() = 'a';
	}
	cout << s << endl;
}





Measured memory_bytes: 512
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  ll a, b, v, w, t;
  cin >> a >> v >> b >> w >> t;
  if(v <= w) {
    cout << "NO" << endl;
  } else {
    if(abs(b - a) <= (v - w) * t) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<double> VD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);
	
	int a, b;
	cin >> a >> b;
	if (a >= 13)
		cout << b;
	else
		if (a >= 6)
			cout << b / 2;
		else
			cout << 0;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a,b,sum1,sum2;
		sum1 = sum2 = 0;
		
		a = sc.nextInt();
		b = sc.nextInt();
		
		
		for(int i = 0;i < 999;i++){
			sum1 += i;
			sum2 += i + 1;
			
			if(sum1 >= a && sum2 >= b){
				if(sum1 - a == sum2 - b){
					System.out.println(sum1 - a);
				}
			}
		}
	}
}

Measured memory_bytes: 21844
import java.util.*;

public class Main {

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        int d = sc.nextInt();

        int ans = 0;

        for (int i = n; i < m + 1; i++) {
           if (i % d == 0) ans++;
        }

        System.out.println(ans);

        sc.close();

    }

}

Measured memory_bytes: 35648
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    string s="";double out=0;
    rep(i,n){
      string tmp;double a,b;
      cin>>tmp>>a>>b;
      a/=100;
      if(s==""){
	s=tmp;
	out=abs(b/a/a-22.0);
      }else if(out>abs(b/a/a-22.0)){
	out=abs(b/a/a-22.0);
	s=tmp;
      }
      //cout<<tmp<<" "<<b/a/a<<" "<<abs(b/a/a-22.0)<<endl;
    }
    cout<<s<<endl;
  }
}

Measured memory_bytes: 1232
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using pii = pair<int,int>;
using ll = long long;
#define LIM 256

vector<int> G[LIM], R[LIM];
int N, M;
int d[LIM];
bool used[LIM];
bool vi[LIM];

void f(int v)
{
    used[v] = true;
    for (const int nxt : R[v]) {
        if (!used[nxt]) f(nxt);
    }
}

bool ok(int v)
{
    bool rec = used[v];
    vi[v] = true;
    for (const int nxt : G[v]) {
        if (!vi[nxt]) rec &= ok(nxt);
    }
    return rec;
}

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

    while (cin >> M, M) {
        cin >> N;
        for (int i=0; i<=N+1; ++i)  G[i].clear(), R[i].clear();
        memset(d, 0, sizeof(d));
        memset(used, 0, sizeof(used));
        memset(vi, 0, sizeof(vi));

        for (int i=1; i<=N; ++i) cin >> d[i];

        for (int s=0; s<=N; ++s) {
            for (int j=1; j<=M;++j) {
                int t = s+j + d[s+j];
                t = min(max(t, 0), N+1);
                G[s].push_back(t);
                R[t].push_back(s);
            }
        }
        f(N+1);
        outl(ok(0)? "OK" : "NG");
    }
}




Measured memory_bytes: 3204