akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<int,int> P;


int main(){
  ll N;
  ll a[100100];
  ll nowprice = 1;
  ll ans=0;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a[i];
    a[i]--;
  }
  for(int i=0;i<N;i++){
    if(a[i]+1 == nowprice){
      nowprice++;
    }
    ans += a[i]/nowprice;
    if(i==0) nowprice = 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;
        do {
            String result = sc.next();
            switch(result) {
                case "AC":
                    ac++;
                    break;
                case "WA":
                    wa++;
                    break;
                case "TLE":
                    tle++;
                    break;
                case "RE":
                    re++;
                    break;
            }
        }while(sc.hasNext());

        System.out.println("AC x " + ac);
        System.out.println("WA x " + wa);
        System.out.println("TLE x " + tle);
        System.out.println("RE x " + re);
    }

}

Measured memory_bytes: 58924
// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

const int N = 2e5+50;
int cnt[N];
int n;
int a[N];

int main(int argc, char const *argv[]) {
    // code
    scanf("%d", &n);
    for (int i=0; i<n; ++i) {
        scanf("%d", &a[i]);
        ++cnt[a[i]];
    }

    LL ans = 0;
    for (int i=1; i<=n; ++i) {
        ans += 1LL * cnt[i] * (cnt[i]-1) / 2;
    }

    for (int i=0; i<n; ++i) {
        printf("%lld\n", ans - cnt[a[i]] + 1);
    }
    return 0;
}


Measured memory_bytes: 3712
import numpy as np
import sys
import collections

N = int(input())
A = list(map(int, input().split()))
res = 1
if 0 in A:
    print(0)
    sys.exit()
for i in range(N):
    res *= A[i]
    if res > 1e18:
        print(-1)
        sys.exit()
print(res)


Measured memory_bytes: 40004
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll S, W;
  cin >> S >> W;
  if (W >= S)
    cout << "unsafe" << endl;
  else
    cout << "safe" << endl;

  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b)
    {
        swap(a, b);
    }
    if (b > c)
    {
        swap(b, c);
    }
    if (a > b)
    {
        swap(a, b);
    }
    cout << c*10 + b + a << endl;
    return 0;
}

Measured memory_bytes: 256
#from math import sqrt
#from heapq import heappush, heappop
#from collections import deque

a, b, c = [int(v) for v in input().split()]

if a == b and b != c:
    print("Yes")
    exit()

if b == c and c != a:
    print("Yes")
    exit()

if c == a and a != b:
    print("Yes")
    exit()

print("No")


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

using namespace std;


int main(void) {
    long long N,A,B,ans=0,tmp;
    bool isBuleTurn=true;

    cin>>N>>A>>B;

    if(A==0){
        cout<<0<<endl;
        return 0;
    }


    tmp=N/(A+B);
    ans=tmp*A;

    tmp=N%(A+B);

    if(tmp>= A){
        ans=ans+A;
    }else{
        ans=ans+tmp;
    }

    cout<<ans<<endl;




	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



int main()
{
	int n, k, x, y;
	cin >> n >> k >> x >> y;

	if (n <= k)
		cout << n * x << endl;
	else
		cout << k * x + (n - k) * y << endl;

}


Measured memory_bytes: 256
// 累積和の学習
// cf. https://qiita.com/drken/items/56a6b68edef8fc605821

#include <bits/stdc++.h>

#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main() {

    int N;
    cin >> N;

    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }

    // 累積和と連想配列
    vector<long> s(N + 1, 0);

    map<long, long> nums;
    for (int i = 0; i < N; ++i) s[i + 1] = s[i] + a[i];
    for (int i = 0; i < N + 1; ++i) nums[s[i]]++;


    // 集計処理
    long res = 0;
    for (auto it : nums) {
        //printf(it);
        //printf(it.second);
        //MEMO: キー・値それぞれを itr->first, itr->second
        long num = it.second; // it.first が it.second 個ある
        res += num * (num - 1) / 2; //NC2
    }
    cout << res << endl;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<(int)c;++i)
int main(){
  int a,b,c;
  cin >> a>> b >> c;
  swap(a,b);
  swap(a,c);
  cout << a<<" "<< b<<" "<< c << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e9

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;


int main(){
    string s, t;
    cin >> s >> t;
    if(t.substr(0, t.size()-1) == s){p("Yes");}
    else{p("No");}

    return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N; cin >> N;
    map<string, map<int, int> > T;
    rep(i,N){
        string S; int P; cin >> S >> P;
        T[S][-P] = i+1;
    }
    for(auto p1: T){
        for(auto p2: p1.second){
            cout << p2.second << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ll long long 

int main () {
	int i,j,k,l,n,m;
	string s;
	cin>>s;
	n = s.size();
	for(i=0;i<n/2;i++)
		if(s[i]!=s[n-i-1]) {
			cout<<"No\n";
			return 0;
		}
	m = n/2;
	for(i=0;i<m/2;i++)
		if(s[i]!=s[m-1-i]) {
			cout<<"No\n";
			return 0;
		}
	for(i=0;i<m/2;i++)
		if(s[i+m+1]!=s[m+1+m-1-i]) {
			cout<<"No\n";
			return 0;
		}
	cout<<"Yes\n";
	return 0;
}



Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Ratio
import Text.Printf
import System.IO

main :: IO ()
main = do
  e <- isEOF 
  when (not e) $ do
    [a,b,c,d,e,f] <- map read . words <$> getLine
    let det = a * e - b * d
    let x0 = (e * c - b * f) % det
    let y0 = (a * f - d * c) % det
    let x = fromRational x0 :: Double
    let y = fromRational y0 :: Double
    printf "%.3f %.3f\n" x y
    main



Measured memory_bytes: 4360
#include <iostream> 
#include <cstdio> 
#include <cstdlib>  
#include <algorithm> 
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>
#include<functional>
using namespace std;
typedef long long ll;


long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}


int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++) cin >> s[i];
    vector<bool> row(h, false);
    vector<bool> gyo(w, false);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                row[i] = true;
                gyo[j] = true;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        if (row[i]) {
            for (int j = 0; j < w; j++) {
                if (gyo[j]) {
                    cout << s[i][j];
                }
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

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


int main() {
	int x,a,b;
	cin >> x >> a >> b;
	string S = (abs(x - a) < abs(x - b)) ? "A" : "B";
	cout << S << endl;
	
	return 0;
}

Measured memory_bytes: 256
// finish date: 2018/03/10

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int A, B;
    cin >> A >> B;
    int c = 0;
    FOR(i, A, B+1) {
        string s1 = to_string(i);
        string s2 = s1;
        reverse(s2.begin(), s2.end());
        if (s1 == s2) {
            c++;
        }
    }
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()

N = len(S)
M = len(T)

if N < M:
    print('UNRESTORABLE')
    
else:

    ans = 'UNRESTORABLE'
    for i in range(N-M+1):
        make = True
        for j in range(M):
            if S[i+j] != '?' and S[i+j] != T[j]:
                make = 0
        if make:
            ans = S[:i] + T + S[i+M:]
    if ans == 'UNRESTORABLE':
        print(ans)
    else:
        ans = list(ans)
        for i in range(N):
            if ans[i] == '?':
                ans[i] = 'a'
        print(''.join(ans))


Measured memory_bytes: 3064
#define _USE_MA_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vector<string> s(n);
    rep(i,n)cin>>s[i];
    int ans=0;
    rep(i,n){
        rep(j,s[i].length()){
            if(s[i][j]=='A'&&s[i][j+1]=='B')ans++;
        }
    }
    int ab=0,a=0,b=0;
    rep(i,n){
        if(s[i][0]=='B'&&s[i][s[i].length()-1]=='A')ab++;
        else if(s[i][s[i].length()-1]=='A')a++;
        else if(s[i][0]=='B')b++;
    }
    if(ab==0&&a+b==0)cout<<ans<<endl;
    else if(ab==0)cout<<ans+min(a,b)<<endl;
    else if(a+b==0)cout<<ans+ab-1<<endl;
    else cout<<ans+ab+min(a,b)<<endl;
}
    

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

int main() {
 int n ;
 cin >>n;
 vector<int> vec(n),three(3);
 int ans = 0;
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  for(int i=0; i<n-2;i++){
    three.at(0) =vec.at(i)   ;
    three.at(1) =vec.at(i+1) ;
    three.at(2) =vec.at(i+2) ;
    sort(three.begin(),three.end());
    if(three.at(1) == vec.at(i+1)){
      ans++;
    }
  }
  
  cout << ans ;
}


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

void Swap(string &s){
  for(int i=0;i<s.size()/2;i++){
    swap(s[i],s[(s.size()+1)/2+i]);
  }
}

void Inc(string &s){
  for(int i=0;i<s.size();i++){
    if('0'<=s[i] && s[i]<='8')s[i]++;
    else if(s[i] == '9')s[i] = '0';
  }
}

void Dec(string &s){
  for(int i=0;i<s.size();i++){
    if('1'<=s[i] && s[i]<='9')s[i]--;
    else if(s[i] == '0')s[i] = '9';
  }
}

int main(){
  int n;
  string r,m;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> r >> m;
    for(int i=r.size()-1;i>=0;i--){
      if(r[i]=='A')reverse(m.begin(),m.end());
      if(r[i]=='C')m = m.substr(1,m.size()-1) + m[0];
      if(r[i]=='E')Swap(m);
      if(r[i]=='M')Inc(m);
      if(r[i]=='J')m = m[m.size()-1] + m.substr(0,m.size()-1);
      if(r[i]=='P')Dec(m);
    }
    cout << m << endl;
  }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 3 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
vector<int> G[N];
ll f(ll x){return x * ( x + 1) / 2;}
int main(){/*
    freopen("in","r",stdin);
    freopen("out","w",stdout);*/

    ll x;
    cin >> x;
    ll a = -1, b = 1e9, mid;
    while(b - a > 1){
        mid = (a + b) >> 1;
        if(f(mid) <= x)
            a = mid;
        else
            b = mid;
    }
    if(f(a) < x)
        a++;
    cout << a << endl;
    return 0;
}   

Measured memory_bytes: 7296
#include<iostream>//动态规划剪枝是么从dp0开始
#include<cmath>
#include<algorithm>
#include<string>//stl和数据结构应该一起训练
#include<memory.h>
using namespace std;
int dp[10001];
int v,w;
int n,W;
int main()
{	
	cin>>n>>W;
	memset(dp,-1,sizeof(dp+W+1));
	dp[0]=0;//两种模型,只能选择一次和多次选择
	for(int i=0;i<n;i++)//尽量和循环变量别扯上关系
	{
		cin>>v>>w;
		for(int j=w;j<=W;j++)
			if(dp[j-w]!=-1)
				dp[j]=max(dp[j],dp[j-w]+v);
	}
	int maxn=0;
	for(int i=0;i<=10001;i++)
		maxn=max(dp[i],maxn);
	cout<<maxn<<endl;
	return 0;
}


Measured memory_bytes: 3148
x, n = map(int, input().split())
 
if n != 0:
    s = set(map(int, input().split()))
    origin_set = set(range(-1, 102))
    result_set = origin_set - s
    result_list = list(result_set)
    result_num = 1000
 
    for i in result_list:
      if abs(x-i) < result_num:
        min_num = i
        result_num = abs(x-i)
      elif abs(x-i) == result_num:
        if i < min_num:
          min_num = i
    print(min_num)
else:
  print(x)

Measured memory_bytes: 9144
#include<iostream>
#include <string>
using namespace std;
 
int main() {
	string n;
	int a,h;


	while(1){
		cin >> n;
		if( n=="-" ) break;

		cin >> a;
		for(int i=0;i<a;i++){
        cin >> h;
        n=n.substr(h)+n.substr(0,h);
        }
        cout << n << "\n";
    }

    return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>

int main(void) {
  int i, n, a;
  scanf("%d", &n);
  double ans = 0.0;
  for(i = 0; i < n; ++i) scanf("%d", &a), ans += 1.0 / a;
  printf("%lf", 1 / ans);
  return 0;
}

Measured memory_bytes: 128
//Volume0-0071
import java.util.Scanner;

class Cell{
	public boolean bomb;
	public boolean xpl;
}

public class Main {

	private static final int      L     = 8;
	private static       int      i,j,x,y;
    private static       Cell[][] board = new Cell[L][L];

	public static void main(String[] args) {

		//declare
		String   s;
		int      n,No;

		//initialize
		init();

        //input
        Scanner sc = new Scanner(System.in);
        No = n = Integer.parseInt(sc.nextLine());
        while(n-- > 0){
        	sc.nextLine();
        	for(i=0;i<L;i++){
        		s = sc.nextLine();
        		for(j=0;j<L;j++){
        			if(s.charAt(j) == '1'){
        				board[i][j].bomb = true;
        			} else {
        				board[i][j].bomb = false;
        			}
        			board[i][j].xpl = false;
        		}
        	}

        	x = Integer.parseInt(sc.nextLine()) - 1;
        	y = Integer.parseInt(sc.nextLine()) - 1;

        	//calculate
        	do {
        		xpl();
        		check();
        	} while (x != -1);

        	//output
        	System.out.println("Data "+(No-n)+":");
        	for(i=0;i<L;i++){
        		for(j=0;j<L;j++){
        			if(board[i][j].bomb){
        				System.out.print(1);
        			} else {
        				System.out.print(0);
        			}
        		}
        		System.out.println();
        	}
        }
	}

	private static void init(){
		for(i=0;i<L;i++){
			for(j=0;j<L;j++){
				board[i][j] = new Cell();
			}
		}
	}

	private static void xpl(){

		board[y][x].bomb = false;

		for(i=x-3;i<=x+3;i++){
			if(0 <= i && i < L && i != x){
				board[y][i].xpl = true;
			}
		}
		for(i=y-3;i<=y+3;i++){
			if(0 <= i && i < L && i != y){
				board[i][x].xpl = true;
			}
		}
	}

	private static void check(){
		x = -1;
		out:for(i=0;i<L;i++){
			for(j=0;j<L;j++){
				if(board[i][j].bomb && board[i][j].xpl){
					x = j; y = i;
					break out;
				}
			}
		}
	}
}

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

typedef complex<double> Point;
typedef Point Vector;
typedef pair<Point, Point> Segment;
typedef Segment Line;
typedef pair<Point, double> Circle;
typedef vector<Point> Polygon;
double dot(Vector a, Vector b){
	return real(a) * real(b) + imag(a) * imag(b);
}
double cross(Vector a, Vector b){
	return real(a) * imag(b) - imag(a) * real(b);
}
Point project(Line l, Point p){
	Vector base = l.second - l.first;
	base /= abs(base);
	double r = dot(p - l.first, base);
	return l.first + r * base;
}
Point reflect(Line l, Point p){
	Vector ortho = p - project(l, p);
	return p - 2.0 * ortho;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Point p1, p2;
	double x, y;
	cin >> x >> y;
	p1 = Point(x, y);
	cin >> x >> y;
	p2 = Point(x, y);
	Line l(p1, p2);
	int q;
	cin >> q;
	while(q--){
		cin >> x >> y;
		Point z = reflect(l, Point(x, y));
		cout << fixed << setprecision(15) << real(z) << " " << imag(z) << "\n";
	}
}


Measured memory_bytes: 3384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long x = Long.parseLong(sc.next());
        long ans = (x / 11) * 2;
        if(x % 11 == 0) {}
        else if(x % 11 <= 6) ans++;
        else ans += 2;
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

int n, m;

struct CumulativeSum{
    vector<int> data;
    CumulativeSum(int sz) : data(sz, 0) {};
    void add(int k, int x){
        data[k] += x;
    }
    void build(){
        for(int i = 1; i < data.size(); i++){
            (data[i] += data[i - 1]) %= m;
        }
    }
    //区間[0,k]の和
    int query(int k){
        if(k < 0) return 0;
        return (data[min(k, (int)data.size() - 1)]);
    }
    //区間[l.r)の和
    int query(int l, int r){
        return query(r - 1) - query(l - 1);
    }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int ans = 0;    
    cin >> n >> m;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
        a[i] %= m;
        // if(a[i] == 0) ans++;
    }
    CumulativeSum cs(n);
    rep(i, 0, n) cs.add(i, a[i]);
    cs.build();
    map<int, int> mp;
    mp[0]++;
    rep(i, 0, n){
        mp[cs.data[i]]++;
    }
    for(auto it = mp.begin(); it != mp.end(); it++){
        int tmp = it -> second;
        tmp = tmp * (tmp - 1) / 2;
        ans += tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>
 
//define
#define trav(i,v)   for(auto i: v)
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()
#define itn int 

//typedef
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long inf = 100000000000000;

using namespace std;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

void solve()
{
    int n;
    cin>>n;
    vi v(n+1);
    int setwise=0;
    repu(i,1,n)
    {
        cin>>v[i];
        setwise=__gcd(setwise,v[i]);
    }
    if(setwise!=1)
    {
        cout<<"not coprime\n";
        return;
    }
    int m=1000000;
    vi vis(m+1,0), div(m+1,0);
    div[1]=1;
    for(ll i=2;i<=m;i++)
    {
        if(div[i])
            continue;
        div[i]=i;
        for(ll j=i*i;j<=m;j+=i)
        {
            if(div[j])
                continue;
            div[j]=i;
        }
    }
    vi cnt(m+1,0);
    repu(i,1,n)
    {
        vi vv;
        while(v[i]!=1)
        {
            if(cnt[div[v[i]]])
            {
                v[i]/=div[v[i]];
                continue;
            }
            cnt[div[v[i]]]=1;
            vis[div[v[i]]]++;
            vv.pb(div[v[i]]);
            v[i]/=div[v[i]];
        }
        trav(x,vv)
            cnt[x]=0;
    }
    repu(i,1,m)
    {
        if(vis[i]>1)
        {
            cout<<"setwise coprime\n";
            return;
        }
    }
    cout<<"pairwise coprime\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
        tt++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 18772
#include <iostream>
#include <cstdio>

using namespace std;

int main(void) {

    int n;
    cin >> n;

    int *arr = new int[n];
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }

    int m = 1;
    for (int f = 4; m < 100; ++m, f<<=1) {
        if (n / f == 0)
            break;
    }

    int *G = new int[m];
    G[m-1] = 1;
    for (int i = m - 2, f = 4; i >= 0; --i, f<<=1) {
        G[i] = f;
    }

    int count = 0;
    for (int i = 0; i < m; ++i) {
        int g = G[i];
        for (int j = g; j < n; ++j) {
            int k, key = arr[j];
            for (k = j - g; k >= 0 && arr[k] > key; k-=g, ++count) {
                arr[k + g] = arr[k];
            }
            arr[k+g] = key;
        }
    }

    printf("%d\n", m);
    for (int i = 0; i < m - 1; ++i) {
        printf("%d ", G[i]);
    }
    printf("%d\n", G[m - 1]);
    printf("%d\n", count);
    for (int i = 0; i < n; ++i) {
        printf("%d\n", arr[i]);
    }

    delete[] arr;
    delete[] G;

    return 0;
}

Measured memory_bytes: 4896
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    for(int z=1;z<=100000;z++){
        cin>>a>>b;
        if(a==0&&b==0){
            break;
        }
        if(a>b){
            swap(a,b);
        }
        cout<<a<<" "<<b<<endl;
    } 
}



Measured memory_bytes: 3092
n = 4

A = ['' for _ in range(2**n)]
for bit in range(2**n):
    i = bit
    mask = 1 << 0
    if bit & mask:
        A[i] += 'AKIH'
    else:
        A[i] += 'KIH'

    mask = 1 << 1
    if bit & mask:
        A[i] += 'AB'
    else:
        A[i] += 'B'

    mask = 1 << 2
    if bit & mask:
        A[i] += 'AR'
    else:
        A[i] += 'R'

    mask = 1 << 3
    if bit & mask:
        A[i] += 'A'
    else:
        A[i] += ''
        
#print(A)

print('YES') if input() in A else print('NO')

Measured memory_bytes: 38384
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, X, T = LI()

    ans = ((N - 1) // X + 1) * T
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10100
/* Author rumoisen */
/* created 2018/11/10 */

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

using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}

using namespace std;

int main() {
  int a,b;
  cin>>a>>b;
  int ans=0;
  for(int i=a;i<=b;i++){
    int c=i/10000%10,d=i/1000%10,e=i/100%10,f=i/10%10,g=i%10;
    if(c==g&&d==f) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

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

    int N;
    int line = 3;
    vector<vector<int>> data(line, vector<int>(line));

    rep(i,line){
        rep(j,line){
            cin >> data.at(i).at(j);
        }
    }

    cin >> N;
    vector<int> numbers(N);

    rep(i,N){
        cin >> numbers.at(i);
    }

    vector<vector<bool>> maru(line, vector<bool>(line));

    rep(cnt,N){
        rep(i,line){
            rep(j,line){
                if(data.at(i).at(j) == numbers.at(cnt)){
                    maru.at(i).at(j) = true;
                };
            }
        }
    }
   
    int judge = 0;

    // ビンゴの8通りを記述する
    rep(i,line) if(maru.at(i).at(0) && maru.at(i).at(1) && maru.at(i).at(2)) judge = 1;
    rep(i,line) if(maru.at(0).at(i) && maru.at(1).at(i) && maru.at(2).at(i)) judge = 1;
    if(maru.at(0).at(0) && maru.at(1).at(1) && maru.at(2).at(2)) judge = 1;
    if(maru.at(0).at(2) && maru.at(1).at(1) && maru.at(2).at(0)) judge = 1;

    if(judge == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
//#define mp make_pair

ll a, b, c, x, y, ans = inf;


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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

cin >> a >> b >> c >> x >> y;

ans = min(ans, a*x+b*y);
if(x>y){
    ans = min(ans, c*2*y + (x-(y))*a);
    ans = min(ans, c*2*x);
}

else {
    ans = min(ans, c*2*x + (y-(x))*b);
    ans = min(ans, 2*c*y);
}

cout << ans << endl;


return 0;}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n,a,b,tx,tr;
    scanf("%d %d %d",&n,&a,&b);
    tr = n * a;
    if(b >= tr){
        printf("%d\n",tr);
        return 0;
    }else{
        printf("%d\n",b);
        return 0;
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<numeric>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(N);
    V<LL> vec;
    REP(a,N){
        LCIN(b);
        vec.pb(b);
    }
    sort(ALL(vec));
    LL ruiseki[1000000];
    ruiseki[0]=0;
    REP(a,N){
        ruiseki[a+1]=ruiseki[a]+vec.at(a);
    }
    int a;
    int ins=0;
    for(a = N-1;a >= 0;a--){
    //    cout<<vec.at(a)<<" "<<ruiseki[a]*2<<endl;
        if(!(vec.at(a) <= ruiseki[a]*2)){
            ins = N-a;
            break;
        }
    }
    COUT(ins);
    return 0;
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
char s[15];
int n;
bool f=false;
int main(){
	scanf("%s",s+1),n=strlen(s+1);
	if(s[1]!='A'){puts("WA");return 0;}
	if(s[2]>='A'&&s[2]<='Z'){puts("WA");return 0;}
	for(int i=3;i<=n;++i){
		if(i==n&&!f)break;
		if(f&&s[i]>='A'&&s[i]<='Z'){f=false;break;}
		if(s[i]=='C'){f=true;continue;}
		if(s[i]>='A'&&s[i]<='Z')break;
	}
	if(f)puts("AC");
	else puts("WA");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, deque<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

int N, Q;
deque<long long> iq, q;

vector<long long> solve() {
    if (Q == 0) return vector<long long>(N, 1);
    
    // stack
    int iter = 0;
    for (int i = 0; i < Q; ++i) {
        while (iter && q[iter-1] >= iq[i]) --iter;
        q[iter++] = iq[i];
    }
    q.resize(iter);
    int NN = N;
    if (N >= q[0]) NN = q[0];
    else q.push_front(N);

    //COUT(NN); COUT(q);

    // dp
    map<long long, long long> dp;
    dp[q.back()] = 1;
    for (int i = q.size()-1; i > 0; --i) {
        long long cur = q[i], nex = q[i-1];
        dp[nex] += dp[q[i]] * (cur / nex);
        cur %= nex;
        while (cur > NN) {
            int id = upper_bound(q.begin(), q.end(), cur) - q.begin() - 1;
            nex = q[id];
            dp[nex] += dp[q[i]] * (cur / nex);
            cur %= nex;
        }
        if (cur) dp[cur] += dp[q[i]];
    }

    //COUT(dp);
    
    vector<long long> res(N, 0);
    res[NN-1] = dp[NN];
    for (int i = NN; i > 1; --i) res[i-2] = res[i-1] + dp[i-1];
    return res;
}

int main() {
    cin >> N >> Q;
    iq.resize(Q); q.resize(Q);
    for (int i = 0; i < Q; ++i) cin >> iq[i];
    const auto &res = solve();
    for (int i = 0; i < N; ++i) cout << res[i] << endl;
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
string s;
long long mod=1000000007;
int d;
int dp[2][100009][109];

int main(){
  cin >> s >> d;
  //はじめは未確定で、mで割った余りが0
  dp[0][0][0]=1;
  int n=s.size();
  //上からみていく
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<d;k++){
        //確定しているものの遷移
        dp[1][i+1][(k+j)%d]=(dp[1][i+1][(k+j)%d]+dp[1][i][k])%mod;
        //未確定なものの遷移
        if(j>s[i]-'0')continue;
        //s[i]より小さければ確定に遷移
        else if(j<s[i]-'0')dp[1][i+1][(k+j)%d]=(dp[1][i+1][(k+j)%d]+dp[0][i][k])%mod;
        //s[i]と等しければ未確定に遷移
        else dp[0][i+1][(k+j)%d]=(dp[0][i+1][(k+j)%d]+dp[0][i][k])%mod;
      }
    }
  }
  long long k=(dp[0][n][0]+dp[1][n][0])%mod;
  if(k==0){k+=mod;}
  cout << k-1 << endl;
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

const int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
//const int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy[] = { 0, -1, 1, -1, 1, 0, -1, 1 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }

int h, w;

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	cin >> h >> w;
	vs v(h); cin >> v;
	bool f = true;
	REP(i, h)REP(j, w)
	{
		if (v[i][j] == '#')
		{
			bool ff = false;
			REP(k, 4)
			{
				int x = i + dx[k], y = j + dy[k];
				if (!valid(x, y, h, w)) continue;
				if (v[x][y] == '#') ff = true;
			}
			if (!ff) f = false;
		}
	}
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}

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

int main(){
  long long int N,A,B;
  long long int ans = 0;
  scanf("%lld %lld %lld",&N,&A,&B);
  
  ans = N / (A+B) * A;
  N %= (A+B);
  
  if(N >= A){
    ans += A;
  }else{
    ans += N;
  }
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 128
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;
const int maxn = 2000100;



int main(){
        _
        ll r,c; cin >> r >> c;
        ll res = ((r*c)/2ll)+((r*c)%2ll);
        if(r==1ll or c==1ll){
            cout<<1<<endl;
        }
        else cout<<res<<endl;

return 0;
}




Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

typedef long long ll;

const static long long INF = 1000000000;

vector<ll> g[100010];
vector<ll> color(100010);


bool dfs(ll v, ll c) {
  color[v] = c;
  for(int i=0;i<g[v].size();i++) {
    if(color[g[v][i]] == c) return false;
    if(color[g[v][i]] == 0 && !dfs(g[v][i], -c)) return false;
  }
  return true;
}
int main() {
  ll n, m;
  cin >> n >> m;
  for(int i=0;i<m;i++) {
    ll ai, bi;
    cin >> ai >> bi;
    ai--;bi--;
    g[ai].push_back(bi);
    g[bi].push_back(ai);
  }
  bool a = dfs(0, 1);
  ll ans;
  if(a) {
    ll b=0, w=0;
    for(int i=0;i<n;i++) {
      if(color[i] == 1) b++;
    }
    w = n - b;
    ans = b*w - m;
  }
  else
    ans = n*(n-1)/2 - m;
  cout << ans << endl;

}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
double a,b,x;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>b>>x;
	double c=x/(a*a);
	double ans=90-atan(c<b/2 ? c*a*2/b/b : (a/2)/(b-c))*180/M_PI;
	cout<<fixed<<setprecision(15)<<ans<<endl;
	return 0;
}


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

int rev(char[],int);
int main(){
  char s[100],t[100]; scanf("%s",s);
  int len=strlen(s),f=0;
  if(rev(s,len)==0){ 
    if(rev(s,len/2)==0) printf("Yes\n");
    else printf("No\n");
  }else printf("No\n");
  return 0;
}

int rev(char s[], int l){
  int f=0;
  for(int i=0; i<l/2; i++){
    if(s[i]==s[l-1-i]) continue;
    else{ f=1; break;}
  }
  return f;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){ 
  int n;
  cin >> n;
  cout << (n + 2 - 1) / 2 << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int kMaxN = 100000;

int parent(int i) {
    return i / 2;
}

int left(int i) {
    return 2 * i;
}

int right(int i) {
    return 2 * i + 1;
}

int main() {
    int n;
    int A[kMaxN];

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

    for (int i = 1; i <= n; i++) {
        cout << "node " << i << ": key = " << A[i] << ", ";
        if (parent(i) >= 1) {
           cout << "parent key = " << A[parent(i)] << ", ";
        }
        if (left(i) <= n) {
            cout << "left key = " << A[left(i)] << ", ";
        }
        if (right(i) <= n) {
            cout << "right key = " << A[right(i)] << ", ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 3084
#include "bits/stdc++.h"

using namespace std;

int main() {
  int n;
  cin >> n;
  map<string, int> cnt;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    sort(begin(s), end(s));
    cnt[s]++;
  }

  long long ans = 0;
  for (auto p : cnt) {
    ans += 1ll * p.second * (p.second - 1) / 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	cin>>a>>b;
	a%=b;
	cout<<min(b-a,a)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define INF 100000000
using namespace std;
int main() {
	while (true) {
		bool flag = false;
		int n, k;
		cin >> n >> k;
		if (n == 0 && k == 0) return 0;
		vector<int>a;
		for (int i = 0; i < k; i++) {
			int num;
			cin >> num;
			a.push_back(num);
			if (num == 0) flag = true;
		}
		sort(a.begin(), a.end());
		vector<int>camv;
		vector<int>sv;
		vector<int>ev;
		int ns = 0, ne = 0;
		for (int i = 0; i + 1 < k; i++) {
			if (a[i] + 1 != a[i + 1]) {
				ne = i;
				camv.push_back(ne - ns + 1);
				sv.push_back(a[ns]);
				ev.push_back(a[ne]);
				ns = i + 1;
			}
			if (i == k - 2 && a[i] + 1 == a[i + 1]) {
				ne = i + 1;
				camv.push_back(ne - ns + 1);
				sv.push_back(a[ns]);
				ev.push_back(a[ne]);
				ns = i + 1;
			}
		}
		/*for (int i = 0; i < camv.size(); i++) {
			cout << camv[i] << " " << sv[i] << " " << ev[i] << endl;
		}*/
		int res = 0;
		if (flag) {
			for (int i = 0; i < camv.size(); i++) {
				res = max(res, camv[i]);
			}
			for (int i = 0; i + 1 < camv.size(); i++) {
				if (ev[i] + 2 == sv[i + 1]) {
					res = max(res, camv[i] + camv[i + 1] + 1);
				}
			}
		}
		else {
			for (int i = 0; i < camv.size(); i++) {
				res = max(res, camv[i]);
			}
		}
		cout << res << endl;
	}
	return 0;
}


Measured memory_bytes: 3488