akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define el endl
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define sz size()
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define nn " " 
#define bg begin()
#define en end()
#define mod 1000000007
using namespace std;

int main()
{
    ll n,m;
    cin>>n>>m;
    string s[n];
    ll a[n][m]={0},i,j;
    for(i=0;i<n;i++)
        cin>>s[i];
    a[0][0]=1;
    for(i=1;i<n;i++)
    {
        if(s[i][0]=='.')
            a[i][0]=a[i-1][0];
        else
            a[i][0]=0;
    }
    for(j=1;j<m;j++)
    {
        if(s[0][j]=='.')
            a[0][j]=a[0][j-1];
        else
            a[0][j]=0;
    }
    for(i=1;i<n;i++)
    {
        for(j=1;j<m;j++)
        {
            if(s[i][j]=='.')
                a[i][j]=(a[i-1][j]+a[i][j-1])%mod;
            else
                a[i][j]=0;
        }
    }
    
    cout<<a[n-1][m-1];
}

Measured memory_bytes: 9088
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int func(int x, int p){
    return x * (100 + p) / 100;
}

int main(){

    for(int x, y, s; cin >> x >> y >> s, x;){
        int ans = 0;
        for(int a = 1; a <= 1000; a++){
            for(int b = 1; b <= 1000; b++){
                if(func(a, x) + func(b, x) == s){
                    ans = max(ans, func(a, y) + func(b, y));
                }
            }
        }
        cout << ans << endl;
    }


    return 0;
}


Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int modpow(int x, int y) {
    int res = 1;
    while (y) {
        if (y % 2) res = 1LL * res * x % inf;
        y >>= 1;
        x = 1LL * x * x % inf;
    }
    return res;
}

int main(){cout<<fixed<<setprecision(20);
		   //lcm
           //素因数分解
           ll n;
           cin>>n;
           vll a(n);
           rep(i,0,n)cin>>a[i];
           map<ll,ll> prime;
           vector<map<ll,ll>> cnt(n);
           rep(i,0,n){
             ll k=a[i];
             for(ll j=2;j*j<=k;j++){
               while(k%j==0){
                cnt[i][j]++;
                 k/=j;
               }
             }
             if(k!=1)cnt[i][k]++;
             for(auto v:cnt[i]){
              chmax(prime[v.first],v.second);
             }
           }
           ll lcm=1;
           for(auto v:prime){
              ll f=v.first;
              ll s=v.second;
              lcm*=pow(f,s);
              lcm%=inf;
           }
           ll ans=0;
           rep(i,0,n){
             ll b=1;
             b=lcm*modpow(a[i],(inf-2));
             b%=inf;
             ans+=b;
             ans%=inf;
           }
           if(ans<0)ans+=inf;
           cout<<ans<<endl;
           //for(auto v:prime)cout<<v.first<<" "<<v.second<<endl;
}

Measured memory_bytes: 6744
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>
#include <cstdint>
#include <cstring>

using namespace std;


//2019-08-18 D
//#define DEBUG



int main()
{
	//string * s;
	//s = new string[3];

	//string * t;
	//t = new string[3];


	string s, t;

	//for (long long int i = 0; i < 3; i++){
		cin >> s;
	//}
	//for (long long int i = 0; i < 3; i++){
		cin >> t;
	//}

	#ifdef DEBUG
		cout << s << "," << t << endl;
	#endif

	//for (long long int i = 0; i < N; i++){
	//	//cout << s[i] << "   ";
	//	sort(s[i].begin(), s[i].end());
	//	//cout << s[i] << endl;
	//}

	long long int count = 0;

	for (long long int j = 0; j < 3; j++){
			if (s[j] == t[j]){
				++count;
			}
	}

	cout << count << endl;

	#ifdef DEBUG
		system("pause");
	#endif

	return 0;
}

Measured memory_bytes: 256
function main(input) {
  var h = Number(input);
  var cnt = 0;
  while (h > 0) {
    h = Math.floor(h / 2);
    cnt++;
  }
  console.log(Math.pow(2, cnt) - 1);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin >> a >> b >> c;
    if(a%3==0||b%3==0||(a+b)%3==0){
        print("Possible");
    }else{
        print("Impossible");
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
using namespace std;
typedef long long int ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a, pro = 0;
	bool cnt[8] = {};
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a >= 3200)pro++;
		else cnt[a / 400] = 1;
	}
	ll mi = 0;
	for (int i = 0; i < 8; i++)if (cnt[i])mi++;
	if (!mi)mi++, pro--;
	cout << mi << ' ' << mi + pro << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
x,y,h = [],[],[]
for i in range(N):
    X,Y,H = map(int,input().split())
    x += [X]
    y += [Y]
    h += [H]
a = 0
while h[a] == 0:
    a += 1 
    if a == N:
        for i in range(101):
            if i not in x:  X = i
        for i in range(101):
            if i not in y:  Y = i
        print(X,Y,1)
        exit()

for cx in range(101):
    for cy in range(101):
        H = h[a] + abs(x[a]-cx) + abs(y[a]-cy)
        ans = True
        R = list(range(N))[0:a] + list(range(N))[a+1:N]
        for i in R:
            if h[i] != max(H - abs(x[i]-cx) - abs(y[i]-cy),0):
                ans = False
                break
        if ans:
            print(cx,cy,H)
            break
    else:
        continue
    break

Measured memory_bytes: 3064
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    drink = [[int(a) for a in input().split()] for _ in range(N)]
    drink.sort()
    price = 0
    for i in range(N):
        a, b = drink[i]
        if b <= M:
            price += a * b
            M -= b
        else:
            price += a * M
            break
    print(price)

    return  0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 21528
x, y = map(int, input().split())
tmp = 2*y - x
if tmp%3 != 0:
    print(0)
    exit()
up = tmp // 3
total = y - up*2 + up

n = total
k = up
mod = 10**9 + 7

#print(n)
#print(k)

if k == 0:
    print(1)
    exit()
try:
    modinv_table = [-1] * (k+1)
    modinv_table[1] = 1
    for i in range(2, k+1):
        modinv_table[i] = (-modinv_table[mod % i] * (mod // i)) % mod
except:
    k = total - up
    modinv_table = [-1] * (k + 1)
    modinv_table[1] = 1
    for i in range(2, k + 1):
        modinv_table[i] = (-modinv_table[mod % i] * (mod // i)) % mod

def binomial_coefficients(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
        ans *= modinv_table[i + 1]
        ans %= mod
    return ans

print(binomial_coefficients(n, k))

Measured memory_bytes: 25428
import java.math.BigInteger;

public class Main {

  private static void solve() {
    int n = ni();
    long[] a = nal(n);
    for (long v : a) {
      if (v == 0) {
        System.out.println(0);
        return;
      }
    }
    BigInteger ret = BigInteger.ONE;
    for (long v : a) {
      ret = ret.multiply(BigInteger.valueOf(v));
      if (ret.compareTo(BigInteger.valueOf(1000000000000000000L)) > 0) {
        System.out.println(-1);
        return;
      }
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 56128
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <climits>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int, in){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}

int main() {
	int V{in()}, inf{INT_MAX};
	vector<vector<int>> v(V, vector<int>(V, inf));
	auto loop = [&](auto f) {
		for (int i{0}; i < V; i++)
			f(i);};
	loop([&](int i) {
		 v[i][i] = 0;});
	for (int E{in()}; E; E--) {
		int s = in(), t = in(), d = in();
		v[s][t] = d;
	}
	loop([&](int k) {
		 loop([&](int i) {
			  if (v[i][k] < inf)
				loop([&](int j) {
					 if (v[k][j] < inf)
						v[i][j] = min(v[i][j], v[i][k] + v[k][j]);});});});
	if ([&]{
		for (int i{0}; i < V; i++)
			if (v[i][i] < 0)
				return false;
		return true;}())
		for (auto &y: v) {
			for (int &x: y) {
				out(&x == &y[0] ? "": " ");
				if (x < inf)
					out(x);
				else
					out("INF");
			}
			outl();
		}
	else
		outl("NEGATIVE CYCLE");
}


Measured memory_bytes: 2700
#include<iostream>
#include<deque>
using namespace std;
int main(){
    string s; cin>>s;
    int n; cin>>n;
    bool rev = 0;
    deque<char> dq;
    for(char c: s) dq.push_back(c);
    for(int i = 0; i < n; i++){
        int x; cin>>x;
        if(x == 1) rev = !rev;
        else{
            int a; char b; cin>>a>>b;
            if(rev == (a-1)) dq.push_front(b);
            else dq.push_back(b);
        }
        /*for(int j = 0; j < dq.size(); j++){
            cout<<dq[j];
        }
        cout<<endl;*/
    }
    if(!rev){
        for(int i = 0; i < dq.size(); i++){
            cout<<dq[i];
        }
    }
    else{
        for(int i = dq.size()-1; i >= 0; i--){
            cout<<dq[i];
        }
    }
    cout<<endl;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}


/* O(log n) */
struct UnionFind {
  vector<int> parent;  // parent[root] is the negative of the size.
  UnionFind(int n) : parent(n, -1){};
  bool unite(int u, int v) {
    u = root(u);
    v = root(v);
    if (u == v)
      return false;
    if (parent[u] > parent[v])
      swap(u, v);
    parent[u] += parent[v];
    parent[v] = u;
    return true;
  }
  bool issame(int u, int v) {
    return root(u) == root(v);
  }
  int root(int u) {
    return parent[u] < 0 ? u : parent[u] = root(parent[u]);
  }
  int size(int u) {
    return -parent[root(u)];
  }
};

signed main() {
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  rep(i, N) {
    cin >> P[i];
  }

  UnionFind UF(N - K + 1);
  vector<int> sum(N);
  rep(i, N - 1) {
    sum[i + 1] = (P[i + 1] > P[i]);
    sum[i + 1] += sum[i];
  }


  vector<int> asc_head;
  rep(i, N - K + 1) {
    if (sum[i + K - 1] - sum[i] == K - 1)
      asc_head.pb(i);
  }


  rep(i, len(asc_head) - 1) {
    UF.unite(asc_head[i], asc_head[i + 1]);
  }


  set<int> s;
  rep(i, K + 1) {
    s.insert(P[i]);
  }

  rep(i, N - K) {
    int l = P[i], r = P[i + K];
    int mn = *(s.begin()), mx = *(s.rbegin());

    if (l == mn && r == mx) {
      UF.unite(i, i + 1);
    }

    if (i == N - K - 1)
      break;
    s.erase(l);
    s.insert(P[i + K + 1]);
  }


  set<int> r;
  rep(i, N - K + 1) {
    r.insert(UF.root(i));
  }
  cout << len(r) << "\n";
}

Measured memory_bytes: 12032
n=int(input())
la=list(map(int,input().split()))
lb=list(map(int,input().split()))
lc=list(map(int,input().split()))
s=lb[la[0]-1]
for i in range(1,n):
  s+=lb[la[i]-1]
  if la[i]-la[i-1]==1:
    s+=lc[la[i-1]-1]
print(s)

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


long long _min(long long a, long long b, long long c) {
    long long t = a < b ? a : b;
    return t < c ? t : c;
}
long long sec(long long a, long long b, long long c) {
    if (a < b)
        return a < c ? (b < c ? b : c) : a;
    else
        return b < c ? (a < c ? a : c) : b;
}
long long _max(long long a, long long b, long long c) {
    long long t = a < b ? b : a;
    return t < c ? c : t;
}


long long gcd(long long s, long long g) {
    if (g % s == 0)
        return s;
    else
        return gcd(g % s, s);
}

long long get_gcd(long long a, long long b, long long c) {
    long long one = _min(a,b,c), two = sec(a,b,c), three = _max(a,b,c);
    return gcd(gcd(one, two), three);
}



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

    long long sum = 0;
    /*
    long long ***table = (long long ***)calloc(210, sizeof(long long **));
    for (int i = 0; i < 210; i++) {
        table[i] = (long long **)calloc(210, sizeof(long long *));
        for (int j = 0; j < 210; j++) {
            table[i][j] = (long long *)calloc(210, sizeof(long long));
        }
    }
    */


    for (long long i = 1; i <= K; i++) {
        for (long long j = 1; j <= K; j++) {
            for (long long k = 1; k <= K; k++) {
                sum += get_gcd(i, j, k);
            }
        }
    }

    cout << sum << endl;

}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int X,A;
  cin >> X >> A;
  if(X<A)
  {
    cout << 0 << endl;
    return 0;
  }
  cout << 10 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

char grid[6][6];
int h, w, k;

bool is_ok(vector<int>&vec1, vector<int>&vec2){
	int coun = 0;
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (vec1[i] != 0 && vec2[j] != 0){
				if (grid[i][j] == '#') coun++;
			}
		}
	}
	if (coun == k) return true;
	return false;
}

int main(){
	cin >> h >> w >> k;
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			cin >> grid[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < (1<<h); i++){
		vector<int> vec1;
		for (int j = 0; j < h; j++){
			if (i & (1<<j)){
				vec1.push_back(1);
			}else{
				vec1.push_back(0);
			}
		}
		for (int j = 0; j < (1<<w); j++){
			vector<int> vec2;
			for (int k = 0; k < w; k++){
				if (j & (1<<k)){
					vec2.push_back(1);
				}else{
					vec2.push_back(0);
				}
			}
			if (is_ok(vec1, vec2)) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3556
# D - Ki

N, Q = map(int, input().split())

children = [[] for _ in range(N)]
points = [0] * N

for _ in range(N - 1):
    a, b = map(int, input().split())
    children[a - 1].append(b - 1)
    children[b - 1].append(a - 1)

for _ in range(Q):
    p, x = map(int, input().split())
    points[p - 1] += x

stack = []
stack.append(0)
visited = [False] * N
while stack:
    key = stack.pop()
    visited[key] = True
    for child in children[key]:
        if visited[child] == False:
            points[child] += points[key]
            stack.append(child)

print(*points)


Measured memory_bytes: 55856
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ll q,h,s,d;
  cin>>q>>h>>s>>d;
  ll n;
  cin>>n;
  q=q*4;
  h=h*2;
  vector<ll> v;
  v.push_back(q);
  v.push_back(h);
  v.push_back(s);
  sort(v.begin(),v.end());
  ll ans=0;
  if((v[0]*2)>d)
  {
    	ans=ans+(n/2)*d;
    	n=n%2;
    	if(n)
          ans=ans+v[0];
  }
  else
    ans=ans+n*v[0];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
S = input()
lenS = len(S)
ans = "No"

def checkPalindrome(string):
    l = len(string)
    string2 = string[::-1]
    if string[:l//2] == string2[:l//2]:
        return True
    else:
        return False

if checkPalindrome(S):
    if checkPalindrome(S[:(lenS-1)//2]):
        if checkPalindrome(S[(lenS+3)//2-1:]):
            ans = "Yes"

print(ans)

Measured memory_bytes: 9132
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b && b <= c)
       cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
       cout << a << " " << c << " " << b << endl;
       else if(b <= c && c <= a)
       cout << b << " " << c << " " << a << endl;
       else if(b <= a && a <= c)
       cout << b << " " << a << " " << c << endl;
       else if(c <= a && a <= b)
       cout << c << " " << a << " " << b << endl;
       else if(c <= b && b <= a)
       cout << c << " " << b << " " << a << endl;
}


Measured memory_bytes: 3116
//invincible M15
//IIT-(ISM)Dhanbad
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define pi  3.141592653589793238462643383279
#define ff first
#define ss second
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=(int)x; i<y; i++)
#define high_functioning_sociopath  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const unsigned int M = 1000000007;
/*------------------------------------- THE GAME IS ON ---------------------------------------------*/
ll dp[100005];
ll mincost(int n,int arr[])
{
       if(n==2)return dp[n]=(abs(arr[1]-arr[0]));
       if(n==1)return 0;
       if(dp[n]!=-1)return dp[n];
       else return dp[n]=min((abs(arr[n-1]-arr[n-2]))+mincost(n-1,arr),(abs(arr[n-1]-arr[n-3]))+mincost(n-2,arr));
}
void solve()
{
       int n;
       cin>>n;
       int arr[n];
       for(int i=0;i<n;i++)cin>>arr[i];
       memset(dp,-1,sizeof(dp));
       cout<<mincost(n,arr)<<endl;
}
int32_t main()
{
   high_functioning_sociopath
   ll t=1;
   //cin>>t;
   while(t--)
   {
      solve();
   }
}

Measured memory_bytes: 8648
def numba_compile(numba_config):
    import os, sys
    if sys.argv[-1] == "ONLINE_JUDGE":
        from numba import njit
        from numba.pycc import CC
        cc = CC("my_module")
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature)(func)
            cc.export(func.__name__, signature)(func)
        cc.compile()
        exit()
    elif os.name == "posix":
        exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
        for func, _ in numba_config:
            globals()[func.__name__] = vars()[func.__name__]
    else:
        from numba import njit
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature, cache=True)(func)
        print("compiled!", file=sys.stderr)

import sys
import numpy as np

def solve(H, W, AB):
    A = W+1
    identity = -(1<<62)
    sqrtA = 500
    n_buckets = A // sqrtA + 1
    Data = np.zeros(n_buckets * sqrtA, dtype=np.int64)
    Data[0] = 1<<30
    Bucket_min = np.zeros(n_buckets, dtype=np.int64)
    Lazy = np.full(n_buckets, identity, dtype=np.int64)

    def eval_data(k):
        if Lazy[k] != identity:
            l, r = k*sqrtA, (k+1) * sqrtA
            for i in range(l, r):
                Data[i] = i-Lazy[k]
            Lazy[k] = identity

    def update(s, t, x):
        for k in range(s//sqrtA, (t-1)//sqrtA+1):
            l, r = k*sqrtA, (k+1)*sqrtA
            if s <= l and r <= t:
                Bucket_min[k] = l-x
                Lazy[k] = x
            else:
                eval_data(k)
                for i in range(max(l,s), min(r,t)):
                    Data[i] = i-x
                Bucket_min[k] = Data[l:r].min()

    def get_min(s, t):
        res = 1 << 62
        bl, br = s//sqrtA+1, t//sqrtA
        if bl > br:
            eval_data(br)
            return Data[s:t].min()
        if bl < br:
            res = Bucket_min[bl:br].min()
        ll, rr = bl*sqrtA, br*sqrtA
        if s < ll:
            eval_data(bl-1)
            mi = Data[s:ll].min()
            if res > mi:
                res = mi
        if rr < t:
            eval_data(br)
            mi = Data[rr:t].min()
            if res > mi:
                res = mi
        return res

    Ans = np.zeros(H, dtype=np.int64)
    for i in range(H):
        a, b = AB[i]
        update(a, b+1, a-1-get_min(a-1, a))
        ans = get_min(1, W+1)
        Ans[i] = ans+i+1 if ans < 1<<25 else -1

    return Ans

numba_compile([
    [solve, "i8[:](i8,i8,i8[:,:])"]
])

def main():
    H, W = map(int, sys.stdin.buffer.readline().split())
    AB = np.array(sys.stdin.buffer.read().split(), dtype=np.int64).reshape(H, 2)
    Ans = solve(H, W, AB)
    print("\n".join(map(str, Ans.tolist())))

main()


Measured memory_bytes: 53596
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;



int main(){
     
    long n,k,ans;
    
    cin>>n>>k;
    ans=k;
    for(int i=0;i<n-1;i++)ans*=k-1;
    cout<<ans<<endl;
     
    return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  ll t;
  cin >> n >> t;
  vector<ll> a(n);
  ll ans = 0;
  ll lim = a[0] + t;
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++){
    if(i == 0) {
      ans = t;
      continue;
    }
    if(lim > a[i]){
      ll ext = (a[i]+t-lim);
      if(ext < 0) continue;
      lim = a[i]+t;
      ans +=  ext;
    }else{
      lim = a[i] + t;
      ans += t;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4752
#include <stdio.h>
#include <vector>
#include <utility>
#include <functional>

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

template <class T> inline bool chmax(T& a, T b){
    if(a < b){a = b; return true;}
    return false;
}

// 抽象セグメント木 : 一点更新, 区間クエリ
template <class Element, class opeEle> // (要素型, 作用素型)
class SegmentTree{
private:
    int n; // 配列の大きさ
    int N; // 2の冪乗
    const Element id; // 単位元 : クエリ関数の単位元
    const std::function<Element(Element, Element)> queryF; // 区間クエリ関数
    const std::function<void(Element&, opeEle)> updateF; // 点更新関数 
    std::vector<Element> data; // データを格納する配列
public:
    SegmentTree(int n , Element id, 
                        std::function<Element(Element, Element)> queryF,
                        std::function<void(Element&, opeEle)> updateF)
                            : n(n), id(id), queryF(queryF), updateF(updateF){
        N = 1; while(N < n) N <<= 1;
        data.assign(2 * N, id);
    }
    SegmentTree(std::vector<Element>& A, Element id, 
                        std::function<Element(Element, Element)> queryF,
                        std::function<void(Element&, opeEle)> updateF)
                            : n(A.size()), id(id), queryF(queryF), updateF(updateF){
        N = 1; while(N < n) N <<= 1;
        data.assign(2 * N, id);
        for(int i = 0; i < n; ++i) data[i + N] = A[i];
        for(int i = N-1; i > 0; --i) data[i] = queryF(data[2*i], data[2*i+1]);
    }
    void resize(int nn){
        n = nn; N = 1; while(N < n) N <<= 1;
        data.assign(2 * N, id);
    }
     // 作用素 opで, A[idx]の値を更新
    bool update(int idx, opeEle op){
        idx += N; 
        updateF(data[idx], op);
        //data[idx] = updateF(data[idx], op);
        idx /= 2;
        while(idx > 0){
            data[idx] = queryF(data[2 * idx], data[2 * idx + 1]);
            idx /= 2;
        }
        return true;
    }
    // 区間 [l, r) での値を取得
    Element query(int l, int r)const{
        Element valL = id, valR = id;
        l += N; r += N;
        while(l < r){
            if(l & 1) valL = queryF(valL, data[l++]);
            if(r & 1) valR = queryF(data[--r], valR);
            l >>= 1; r >>= 1;
        }
        return queryF(valL, valR);
    }
    Element at(int idx){
        return data[idx + N];
    }
};



int main(void){
    constexpr auto gcd = [](int a, int b){
        while(b != 0){a %= b; std::swap(a, b);}
        return a;
    }; constexpr int id_gcd = 0;
    constexpr auto upd8 = [](int &a, int b){a = b;};
    int n; scanf("%d", &n);
    SegmentTree<int, int> Seg(n, id_gcd, gcd, upd8);
    REP(i, n){ int v; scanf("%d", &v); Seg.update(i, v); }
    int res = 1;
    for(int i = 0; i < n; ++i) chmax(res, gcd(Seg.query(0, i), Seg.query(i+1, n)));
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 1280
sa = list(input())
sb = list(input())
sc = list(input())


turn = "a"

while(1):
  if turn == "a":
    if not sa: break
    turn = sa[0]
    del sa[0]
  if turn == "b":
    if not sb: break
    turn = sb[0]
    del sb[0]
  if turn == "c":
    if not sc: break
    turn = sc[0]
    del sc[0]
    
print(turn.upper())

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

int main()
{
  int n, x;
  vector<int> seqs;
  cin >> n;
  while (n--)
  {
    cin >> x;
    int low = 0, high = int(seqs.size()) - 1, id = -1;
    while (low <= high)
    {
      int mid = (low + high) / 2;
      if (seqs[mid] >= x) low = mid + 1;
      else
      {
        id = mid;
        high = mid - 1;
      }
    }
    if (id >= 0) seqs[id] = x;
    else seqs.push_back(x);
  }
  cout << seqs.size() << endl;
}


Measured memory_bytes: 892
import itertools
N,M = map(int,input().split())
src = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]

es = [set() for i in range(N)]
for a,b in src:
    es[a].add(b)
    es[b].add(a)

ans = 0
for ptn in itertools.permutations(range(1,N)):
    v = 0
    for to in ptn:
        if to not in es[v]:
            break
        else:
            v = to
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;
 
class RollingHash{
    const int mod = 1e9+7;
    const int base = 1007;
    vector<int> hash, power;
public:
    RollingHash(const string &s){
        int n = SZ(s);
        hash.assign(n+1, 0);
        power.assign(n+1, 1);
        REP(i,n){
            hash[i+1] = (hash[i] * base + s[i]) % mod;
            power[i+1] = (power[i] * base) % mod;
        }
    }
    inline int get(int l, int r) const {
        int res = hash[r] - hash[l] * power[r-l] % mod;
        if(res < 0) res += mod;
        return res;
    }
    inline int s_hash(){return get(0,SZ(hash));}

    inline int getLCP (int a, int b) const {
        int len = min(SZ(hash)-a, SZ(hash)-b);
        int ok = 0, ng = len;
        while(abs(ok-ng) > 1){
            int mid = (ok+ng) / 2;
            if(get(a, a+mid) != get(b, b+mid)) ng = mid;
            else ok = mid;
        }
        return ok;
    }
};
 
signed main(){
    int n; string s; cin >> n >> s;
    RollingHash rh(s);
    int ans = 0;
    auto judge = [&](int d){
        map<int,int> mp;
        REP(i,n-d+1){
            int v = rh.get(i, i+d);
            if(mp.count(v)){
                if(i - mp[v] >= d) return true;
            }
            else mp[v] = i;
        }
        return false;
    };
    int ok = 0, ng = n/2 + 1;
    while(abs(ok-ng) > 1){
        int mid = (ok+ng) / 2;
        if(judge(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << '\n';
}

Measured memory_bytes: 4020
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,l=0;
  cin>>n;
  vector<int> a(n+2);
  for(i=1;i<=n;i++) cin>>a.at(i);
  for(i=0;i<n+1;i++) l+=abs(a.at(i+1)-a.at(i));
  for(i=1;i<n+1;i++){
    if((a.at(i+1)-a.at(i))*(a.at(i)-a.at(i-1))>=0) cout<<l<<endl;
    else cout<<l-2*min(abs(a.at(i+1)-a.at(i)),abs(a.at(i)-a.at(i-1)))<<endl;
  }
}

Measured memory_bytes: 3772
#include<stdio.h>
int main(){
  int H,W,i,j;
  do{
    scanf("%d %d",&H,&W);
    if(H == 0 && W == 0)
      break;
    for(i=1;i <= H;i++){
      for(j=1;j <= W;j++){
    
	if((i+j) % 2 == 0){
	  printf("#");
      }
      if((i+j) % 2 != 0){
	printf(".");
	  }
      if(j == W){
	printf("\n");
      }
    }
  }
    printf("\n");
  }while(H <= 300 && W <= 300);
  return 0;
}

Measured memory_bytes: 572
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 
int get_val(int a,int b){
    int tmp;
    
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
 
    /* ユークリッドの互除法 */
    int r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}


int main(){

    int N;
    cin >> N;

    int A[N];
    for( int ni = 0 ; ni < N ; ni++ ){
        cin >> A[ni];
    }

    sort(A,A+N);

    int value_bef[N];
    int value_aft[N];

    value_bef[0]=A[0];
    for( int ni = 1 ; ni < N ; ni++ ){
        if(value_bef[ni-1]==1){
            value_bef[ni] = 1;
        }else{
            value_bef[ni] = get_val(value_bef[ni - 1],A[ni]) ;
        }
    }

    int ni_max = N-1 ;
    value_aft[ni_max]=A[ni_max];
    for( int ni = ni_max-1 ; ni >=0 ; ni-- ){
        if(value_aft[ni+1]==1){
            value_aft[ni] = 1;
        }else{
            value_aft[ni] = get_val(value_aft[ni + 1],A[ni]) ;
        }
    }

    int max = value_aft[1];
    if(max<value_bef[ni_max-1]) max = value_bef[ni_max-1];

    int tmp;
    for( int ni = 1 ; ni < ni_max ; ni++ ){
        tmp = get_val(value_bef[ni-1],value_aft[ni+1]);
        if(max < tmp) max = tmp;
    }

    cout << max;    

}

Measured memory_bytes: 1408
import math

a,b,x=list(map(int,input().strip().split()))

if a**2*b/2<x:
    ans=90-math.degrees(math.atan2(1,2/a*(b-x/a**2)))
else:
    ans=90-math.degrees(math.atan(2*x/a/b**2))
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct node{
  int key;
  node *left,*right,*p;
  node(){}
  node(int key):key(key){left=right=p=NULL;};
};
node *root;
void insert(node z){
  node *y=NULL;
  node *x=root;
  while(x!=NULL){
    y=x;
    if(z.key<x->key) x=x->left;
    else x=x->right;
  }
  z.p=y;
  if(y==NULL) root=new node(z);
  else if(z.key<y->key) y->left=new node(z);
  else y->right=new node(z);
}
bool find(int z){
  node *x=root;
  while(x!=NULL){
    if(z==x->key) return true;
    if(z<x->key) x=x->left;
    else x=x->right;
  }
  return false;
}
node *nxt(node *x){
  if(x->left!=NULL) return nxt(x->left);
  return x;
}
void del(node *x){
  //cout<<x->key<<endl;
  node *y=x->p;
  if(x->left==NULL&&x->right==NULL){
    if(y!=NULL&&y->left==x) y->left=NULL;
    if(y!=NULL&&y->right==x) y->right=NULL;
    delete(x);
    return;
  }
  if(x->left==NULL&&x->right!=NULL){
    if(y!=NULL&&y->left==x) y->left=x->right;
    if(y!=NULL&&y->right==x) y->right=x->right;
    x->right->p=y;
    delete(x);
    return;
  }
  if(x->left!=NULL&&x->right==NULL){
    if(y!=NULL&&y->left==x) y->left=x->left;
    if(y!=NULL&&y->right==x) y->right=x->left;
    x->left->p=y;
    delete(x);
    return;
  }
  node *z=nxt(x->right);
  x->key=z->key;
  del(z);
}
void del(int k){
  node *x=root;
  while(x!=NULL){
    if(k==x->key) break;
    if(k<x->key) x=x->left;
    else x=x->right;
  }
  //cout<<k<<" "<<x->key<<endl;
  del(x);
}
void inorderTreeWalk(node *v){
  if(v==NULL) return;
  inorderTreeWalk(v->left);
  cout<<" "<<v->key;
  inorderTreeWalk(v->right);
}
void preorderTreeWalk(node *v){
  if(v==NULL) return;
  cout<<" "<<v->key;
  preorderTreeWalk(v->left);
  preorderTreeWalk(v->right);
}
signed main(){
  int n;
  cin>>n;
  root=NULL;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    //cout<<(root==NULL?-1:root->key)<<endl;
    if(s=="print"){
      inorderTreeWalk(root);
      cout<<endl;
      preorderTreeWalk(root);
      cout<<endl;
      continue;
    }
    int x;
    cin>>x;
    if(s=="insert"){
      insert(node(x));
    }
    if(s=="find"){
      cout<<(find(x)?"yes":"no")<<endl;
    }
    if(s=="delete"){
      del(x);
    }
  }
  return 0;
}



Measured memory_bytes: 21772
#include<bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
vector<string>v;
void dfs(string str,string t="",int cnt=0){
    if(cnt==2){
        v.push_back(t);
        return;
    }else{
        for(int i=0;i<str.size();i++){
            dfs(str,t+str[i],cnt+1);
        }
    }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b,c;
    while(cin>>a>>b>>c){
        cout<<max(a,max(b,c))*10+(a+b+c)-max(a,max(b,c))<<endl;
    }
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S, T;
  cin >> S >> T;
  ll index = 0;
  ll ans = INF;
  for (ll i = 0; i < S.size(); ++i) {
    ll temp = 0;
    for (ll j = 0; j < T.size(); ++j) {
      if (i + j >= S.size()) {
        temp = INF;
        break;
      }
      if (S.at(i + j) != T.at(j)) {
        temp += 1;
      }
    }
    ans = min(temp, ans);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
char s[105];
int main()
{
    int flag1=0;
    int flag2=0;
    int n;
    scanf("%d",&n);
    if(n/100>12||n/100==0) flag1=1;
    if(n%100>12||n%100==0) flag2=1;
    if(flag1==1&&flag2==1)
    {
        cout<<"NA"<<endl;
    }
    else if(flag1==1)
    {
        cout<<"YYMM"<<endl;
    }
    else if(flag2==1)
    {
        cout<<"MMYY"<<endl;
    }
    else
    {
        cout<<"AMBIGUOUS"<<endl;
    }
}


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

int main() {
  long long n,c=0;
  cin >> n;
  for(int i=1; i < n; i++){
    for(int j = 1;  j < n; j++){
      if(i * j < n) c++;
      if(i * j >= n) break;
    }
  }
  cout << c;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int fib1, fib2, fib3;

	fib1 = 1;
	fib2 = 1;

	scanf("%d", &n);

	for (i = 0; i < n - 1; i++){
		fib3 = fib1 + fib2;
		fib1 = fib2;
		fib2 = fib3;
	}

	if (n == 0){
		printf("%d\n", fib1);
	}
	else if (n == 1){
		printf("%d\n", fib2);
	}
	else {
		printf("%d\n", fib3);
	}
	return (0);

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)

vector<vector<ll>> vec(1, vector<ll>(3));
vector<vector<ll>> dp(1, vector<ll>(3));

int main() {
    ll n;
    cin >> n;

    vec.resize(n+1, vector<ll>(3));
    dp.resize(n+1, vector<ll>(3));

    rep(i,n){
        rep(j,3){
            cin >> vec.at(i).at(j);
        }
    }

    //dp配列だけ[1]は1日目。他は[0]が1日目
    for(ll i = 0; i < n; i ++){
        for(ll j = 0; j < 3; j++){
            for(ll k = 0; k < 3; k++){
                if(j == k) continue;
                chmax(dp.at(i + 1).at(k), dp.at(i).at(j) + vec.at(i).at(k));
            }
        }
    }

    ll res = 0;
    rep(i,3){
        chmax(res, dp.at(n).at(i));
    }
    cout << res << endl;

}


Measured memory_bytes: 11136
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int main() {
	string S;
	cin >> S;
	if (S.length() % 2 == 1) {
		cout << "No\n";
		return 0;
	}

	for (int i = 0; i < S.length() / 2; i++) {
		if (S[2 * i] != 'h' || S[2 * i + 1] != 'i') {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;

}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Possible" << endl; exit(0); }
void no() { cout << "Impossible" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

const int INF = 1001001001;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  sort(all(a));
  if (a.back() >= n) no();
  if (a.back() % 2 == 0) {
    if (a[0] != a.back() / 2) no();
  } else {
    if (a[0] != (a.back() + 1) / 2) no();
  }
  map<int, int> cnt;
  rep(i, n) cnt[a[i]]++;
  if (a.back() % 2 == 0) {
    if (cnt[a[0]] != 1) no();
  } else {
    if (cnt[a[0]] != 2) no();
  }
  repic(i, a[0] + 1, a.back()) {
    if (cnt[i] < 2) no();
  }
  yes();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000
bool f = false;
map<pair<string,string>,int> get(string S){
	int N = S.size();
	map<pair<string,string>,int> mp;
	for(int i=0;i<(1<<N);i++){
		string s="",t="";
		for(int j=0;j<N;j++){
			if((i>>j)&1)s+=S[j];
			else t+=S[j];
		}
		reverse(t.begin(),t.end());
		if(f)swap(s,t);
		mp[make_pair(s,t)]++;
	}
	f=true;
	return mp;
}

int main(){
	
	int N;
	cin>>N;
	
	string S;
	cin>>S;
	
	map<pair<string,string>,int> mp0 = get(S.substr(0,N)),mp1 = get(S.substr(N));
	
	long long ans = 0;

	for(auto a:mp0){
		ans += (long long)a.second * mp1[a.first];
	}
	cout<<ans<<endl;
	
	return 0;
}

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

using namespace std;

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

  return 0;
}



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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){} //@shibh308's template
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

//----------------------library------------------------//

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

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    CIN(N);
    int ans=(N+1)*100/108;
    if(N==ans*108/100) printf("%d\n",ans);
    else printf(":(\n");

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 2005

struct Info{

	bool operator<(const struct Info &arg) const{

		return value > arg.value;
	}
	ll value,loc;
};

ll N;
ll dp[SIZE][SIZE];
Info info[SIZE];


int main(){

	scanf("%lld",&N);

	for(int i = 0; i < N; i++){

		scanf("%lld",&info[i].value);
		info[i].loc = i;
	}
	sort(info,info+N);

	//dp[処理済みの個数][左に移動する個数]
	for(int i = 0; i <= N; i++){
		for(int k = 0; k <= N; k++){
			dp[i][k] = 0;
		}
	}

	for(ll i = 0; i < N; i++){
		//printf("\ninfo[%lld].value:%lld loc:%lld\n",i,info[i].value,info[i].loc);
		for(ll k = 0; k <= i; k++){
			ll num_R = i-k;

			//printf("k;%lld dp[i][k]:%lld\n",k,dp[i][k]);
			//左
			dp[i+1][k+1] = max(dp[i+1][k+1],dp[i][k]+abs(k-info[i].loc)*info[i].value);
			//printf("左:%lld\n",dp[i+1][k+1]);

			//右
			dp[i+1][k] = max(dp[i+1][k],dp[i][k]+abs((N-1-num_R)-info[i].loc)*info[i].value);
			//printf("to:%lld 位置差分:%lld 右:%lld\n",N-1-num_R,abs((N-k-1)-info[i].loc),dp[i+1][k]);
		}
	}

	ll ans = 0;
	for(ll i = 0; i <= N; i++){

		ans = max(ans,dp[N][i]);
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 35168