akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define Maxn 1007
using namespace std;
int n;
int a[Maxn][Maxn];
void print()
{
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=n;j++)
            if (a[i][j]==0) printf("."); else printf("%c",a[i][j]+'a'-1);
        printf("\n");
    }
}
void dfs(int n)
{
    if (n==4)
    {
        a[1][1]=1,a[1][2]=1;
        a[2][1]=2,a[2][2]=2;
        a[1][3]=3,a[2][3]=3;
        a[1][4]=4,a[2][4]=4;
        a[3][1]=5,a[4][1]=5;
        a[3][2]=6,a[4][2]=6;
        a[3][3]=7,a[3][4]=7;
        a[4][3]=8,a[4][4]=8;
        return;
    }
    if (n==5)
    {
        a[1][1]=1,a[1][2]=1;
        a[1][3]=2,a[1][4]=2;
        a[1][5]=3,a[2][5]=3;
        a[3][5]=4,a[4][5]=4;
        a[5][5]=5,a[5][4]=5;
        a[5][3]=6,a[5][2]=6;
        a[5][1]=7,a[4][1]=7;
        a[3][1]=8,a[2][1]=8;
        a[2][3]=9,a[2][4]=9;
        a[3][2]=10,a[4][2]=10;
        return;
    }
    if (n==8||n==12)
    {
        a[n][n]=1,a[n][n-1]=1;
        a[n-1][n]=2,a[n-1][n-1]=2;
        a[n][n-2]=3,a[n-1][n-2]=3;
        a[n][n-3]=4,a[n-1][n-3]=4;
        a[n-2][n]=5,a[n-3][n]=5;
        a[n-2][n-1]=6,a[n-3][n-1]=6;
        a[n-2][n-2]=7,a[n-2][n-3]=7;
        a[n-3][n-2]=8,a[n-3][n-3]=8;
        dfs(n-4);
        return;
    }
    if (n==13)
    {
        a[n][n]=1,a[n][n-1]=1;
        a[n][n-2]=2,a[n][n-3]=2;
        a[n][n-4]=3,a[n-1][n-4]=3;
        a[n-2][n-4]=4,a[n-3][n-4]=4;
        a[n-4][n-4]=5,a[n-4][n-3]=5;
        a[n-4][n-2]=6,a[n-4][n-1]=6;
        a[n-4][n]=7,a[n-3][n]=7;
        a[n-2][n]=8,a[n-1][n]=8;
        a[n-1][n-2]=9,a[n-1][n-3]=9;
        a[n-2][n-1]=10,a[n-3][n-1]=10;
        dfs(n-5);
        return;
    }
    a[n][n-1]=1,a[n][n-2]=1;
    a[n-1][n]=2,a[n-2][n]=2;
    a[n][n-3]=3,a[n][n-4]=3;
    a[n][n-5]=4,a[n-1][n-5]=4;
    a[n-2][n-4]=5,a[n-2][n-5]=5;
    a[n-1][n-3]=6,a[n-2][n-3]=6;
    a[n-3][n]=7,a[n-3][n-1]=7;
    a[n-3][n-2]=8,a[n-4][n-2]=8;
    a[n-5][n-1]=9,a[n-5][n-2]=9;
    a[n-4][n]=10,a[n-5][n]=10;
    a[n-3][n-4]=11,a[n-3][n-5]=11;
    a[n-4][n-3]=12,a[n-5][n-3]=12;
    dfs(n-6);
    return;
}
int main()
{
    scanf("%d",&n);
    if (n==2)
    {
        printf("%d\n",-1);
        return 0;
    }
    if (n%3==0)
    {
        for (int i=1;i<=n;i+=3)
        {
            a[i][i+1]=1,a[i][i+2]=1;
            a[i+1][i]=2,a[i+2][i]=2;
        }
        print();
        return 0;
    }
    if (n==7)
    {
        a[1][5]=1,a[2][5]=1;
        a[3][5]=2,a[4][5]=2;
        a[1][6]=3,a[2][6]=3;
        a[3][6]=4,a[4][6]=4;
        a[1][7]=5,a[2][7]=5;
        a[3][7]=6,a[4][7]=6;
        a[5][1]=7,a[5][2]=7;
        a[5][3]=8,a[5][4]=8;
        a[6][1]=9,a[6][2]=9;
        a[6][3]=10,a[6][4]=10;
        a[7][1]=11,a[7][2]=11;
        a[7][3]=12,a[7][4]=12;
        a[5][6]=13,a[5][7]=13;
        a[6][5]=14,a[7][5]=14;
        print();
        return 0;
    }
    dfs(n);
    print();
    return 0;
}

Measured memory_bytes: 5120
N,T = map(int,input().split())
tlist=[0]*N
vlist=[0]*N
tvlist=[[0,0]]*N
dp=[[0]*T for i in range(N+1)]

for i in range(N):
    tvlist[i] = list(map(int,input().split()))
tvlist.sort(key=lambda x: x[0])
for i in range(N):
    tlist[i] = tvlist[i][0]
    vlist[i] = tvlist[i][1]

for i in range(N):
    for t in range(T):
        if t>=tlist[i]:
            dp[i+1][t] = max(dp[i][t],dp[i][t-tlist[i]]+vlist[i])
        else:
            dp[i+1][t] = dp[i][t]

ans=0
for i in range(N):
    ans = max(ans,dp[i][T-1]+vlist[i])

print(ans)

Measured memory_bytes: 116572
#include <iostream>

using namespace std;

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


Measured memory_bytes: 3076
using System;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        new Solver().Solve();
#if DEBUG
        Console.ReadLine();
#endif
    }
}

class Solver
{
    string A;
    string B;
    string S;

    public void Solve()
    {
        // 正規表現パターン文字列を作成
        StringBuilder sb = new StringBuilder();
        sb.Append(@"\A\d{");
        sb.Append(A);
        sb.Append(@"}-\d{");
        sb.Append(B);
        sb.Append(@"}\z");
        string pattern = sb.ToString();

        bool is_match = System.Text.RegularExpressions.Regex.IsMatch(S, pattern);

        if (is_match)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }

    public Solver()
    {
        string[] AB = ReadStringArray();
        A = AB[0];
        B = AB[1];
        S = ReadString();
    }

    static String ReadString() { return Console.ReadLine(); }
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static long ReadLong() { return long.Parse(Console.ReadLine()); }
    static double ReadDouble() { return double.Parse(Console.ReadLine()); }
    static String[] ReadStringArray() { return Console.ReadLine().Split(' '); }
    static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray(); }
    static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(e => long.Parse(e)).ToArray(); }
    static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(e => double.Parse(e)).ToArray(); }
}


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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int main( ) {
        IO;
        #ifdef LOCAL
            freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        int x , k;
        cin >> x >> k;
        int l = k - x + 1 , r = k + x - 1;
        for( int i = l; i <= r; i++ ) cout << i << " ";
        return 0;
}










Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 110;
const int MAXK = 510;

int k, a[6];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    FOR(i,1,5) cin >> a[i];
    sort(a+1, a+6);
    cin >> k;
    if (a[5] - a[1] > k) cout << ":(";
    else cout << "Yay!";
    return 0;
}

Measured memory_bytes: 256
# solution 3
import heapq
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
Q = []
s = []
heapq.heappush(Q, (-A[0]-B[0]-C[0], 0, 0, 0))
for n in range(K):
    q, i, j, k = heapq.heappop(Q)
    print(-q)
    if i < X-1 and (i+1, j, k) not in s:
            heapq.heappush(Q, (- A[i+1] - B[j] - C[k], i+1, j, k))
            s.append((i + 1, j, k))
    if j < Y-1 and (i, j+1, k) not in s:
            heapq.heappush(Q, (- A[i] - B[j+1] - C[k], i, j+1, k))
            s.append((i, j + 1, k))
    if k < Z-1 and (i, j, k+1) not in s:
            heapq.heappush(Q, (- A[i] - B[j] - C[k+1], i, j, k+1))
            s.append((i, j, k + 1))

Measured memory_bytes: 4596
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <malloc.h>
using namespace std;

int main()
{
	int A,B;
	cin>>A>>B;
	int result;
	if(B%A==0)
	{
		result = A+B;
	}
	else
	{
		result = B-A;
	}
	cout<<result<<endl;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    long long K;
    cin >> S >> K;
    int l = sizeof(S);
    int ans = 1;
    for (long long i = 0; i < K; i++)
    {
        if (S[i] == '1')
        {
            continue;
        }else
        {
            ans = S[i] - '0';
            break;
        }
        
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, A, B = gets.split.map(&:to_i)
H = N.times.map { gets.to_i }

def bsearch(ng:, ok:, &is_ok)
  while (ok - ng).abs > 1
    mid = (ok + ng) / 2
    if is_ok.call(mid)
      ok = mid
    else
      ng = mid
    end
  end
  ok
end

def ok?(count)
  b_damage = B * count
  diff = A - B
  rest_count = count
  H.each do |h|
    rest_h = h - b_damage
    next if rest_h <= 0
    c = (rest_h + diff - 1) / diff
    if c > rest_count
      return false
    end
    rest_count -= c
  end
  true
end

ng = 0
ok = H.max
res = bsearch(ng: ng, ok: ok) { |n| ok?(n) }
puts res

Measured memory_bytes: 5172
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    String blank = sc.nextLine();
    char[][] s = new char[h][w];
    int dx[] = {1, 1, 1, 0, 0, -1, -1, -1};
    int dy[] = {0, 1, -1, 1, -1, 0, 1, -1};

    for(int i = 0; i < h; i++){
      String ss = sc.nextLine();
      s[i] = ss.toCharArray();
    }

    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        if(s[i][j] == '.'){
          int cnt = 0;
          for(int k = 0; k < 8; k++){
            int tmpX = i + dx[k];
            int tmpY = j + dy[k];
            if(tmpX>=0 && tmpX<h && tmpY>=0 && tmpY<w&& s[tmpX][tmpY] == '#'){
              cnt++;
            }
          }
          char d[] = String.valueOf(cnt).toCharArray();
          s[i][j] = d[0];
        }
      }
    }

    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        System.out.print(s[i][j]);
      }
      System.out.println("");
    }


  }
}


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

int main(){
    int a;
    int b;
    int x;
    int y;
    int r;
    
    cin >> a >> b >> x >> y >> r;
    
    if (x - r < 0 || x + r > a){
        cout << "No" << endl;
    }else if (y - r < 0 || y + r > b){
        cout << "No" << endl;
    }else {
        cout << "Yes" << endl;
    }
    return 0;
}


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

int main() {
  string S; cin >> S;
  string pred;
  if (S == "Sunny") pred = "Cloudy";
  else if (S == "Cloudy") pred = "Rainy";
  else if (S == "Rainy") pred = "Sunny";
  cout << pred << endl;
}

Measured memory_bytes: 256
import itertools
n=input()
op=list(itertools.product(['+','-'],repeat=3))
l=list(n)
for i in op:
	tmp=n[0]+i[0]+n[1]+i[1]+n[2]+i[2]+n[3]
	if eval(tmp)==7:
		print(tmp+'=7')
		break


Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <cstring>
#include <vector>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt;
int main(){
	string a;
	cin>>a;
	if(a[0]<97) cout<<"A";
	else cout<<"a";
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <bitset>
#include <cmath>
#define ff first
#define ss second
#define MAXN 100005
#define INF 1000000001000000001LL
//#define int long long

using namespace std;

const int mod = 998244353; //1000000007;
int n, k, m, i, j, mn = 1000;
string s, t, u, ans;

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base :: sync_with_stdio(false);
    cin.tie();

    cin >> n >> k;
    cin >> s;

    u = s;
    reverse(u.begin(), u.end());
    t = s + u;

    for(i = 0; i < n; i++){
        if(s[i] < mn)
            mn = s[i];

        ans += 'z';
    }

    for(i = 0; i <= n; i++){
        string s1 = "", res = "";

        for(j = i; j < i + n; j++)
            s1 += t[j];

        if(k == 1){
            ans = min(ans, s1);
            continue;
        }

        if(s1[n - 1] != mn)
            continue;

        //cout << s1 << endl;

        int r = 0, cr, cl = 0;
        while(n - 1 - r >= 0 && s1[n - 1 - r] == mn)
            r++;

        cr = n - r; cl = 0;
        for(j = 0; r != 2 * n && j < k - 2; j++)
            cl += r, r = min(r * 2, 2 * n);

        //cout << cl << " " << cr << " " << r << " " << res << endl;

        for(j = cl; j < cr; j++)
            res += s1[j];

        while(res.size() != n + (n - max(0, cr - cl)))
            res += char(mn);

        reverse(res.begin(), res.end());
        res.resize(n);

        ans = min(ans, res);
    }

    cout << ans;

    return 0;
}







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

int main(){
  int n;cin>>n;
  int s[n];
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>s[i];
    ans+=s[i];
  }

  sort(s,s+n);

  int i=0;

  if(ans%10==0){
    for(i=0;i<n;i++){
      if(s[i]%10!=0){
	ans-=s[i];break;
      }
    }
    if(i==n) ans=0;
  }

  cout<<ans<<endl;
    
  
  return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    readline = sys.stdin.readline

    n = int(readline())

    dp = [[0] * 3 for _ in range(n + 1)]

    for i in range(1, n + 1):  # i日目の最大幸福度,1-indexed
        a, b, c = map(int, input().split())
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a
        dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + b
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c

    print(max(dp[n]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 59628
x = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
x = x.split()
N = int(input())
S = input()

ans = []
for i in S:
    for j in range(len(x)):
        if i==x[j]:
            ans.append(x[(j+N)%26])
print("".join(ans))


Measured memory_bytes: 3060
//stringray

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

/*#ifndef __LOCAL__ 
#pragma comment(linker,"/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif*/ 

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ost;

typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<set<int>> vsi;

#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define pb emplace_back
#define F first
#define S second
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0)


const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T>
istream& operator >> (istream& is,vector<T>& vec){
  for(T &x:vec)is>>x;
  //for(int i=0;i<vec.size();++i)is>>x[i];
  return is;
}

template<typename T>
ostream& operator << (ostream& os,vector<T>& vec){
  for(int i=0;i<vec.size();++i){
    os<<vec[i]<<(i+1==vec.size()?"":" ");
  }
  return os;
}

ll mpow(ll a, ll b){
  ll ret=1;
  while(b>0){
    if(b&1)ret=(ret*a)%mod;
    (a=a*a)%=mod;
    b>>=1LL;
  }
  return ret;
}

//#define int int64_t
int a[N+2];
int x[N+2];
void solve(){
  int n;cin>>n;
  vi v(n+2);
  fori(i,n)cin>>a[i];
  v[2]=a[1];
  for(int i=3;i<=n;++i){
   v[i]=a[i-1]-v[i-1]; 
  }
  //time to get x[1]
  //also n is odd so xn+x1=an , xn=v[n]+x1, 2*x1+v[n]=a[n]
  x[1]=(a[n]-v[n])/2;
  //now find x[2],x[3],..so on 
  for(int i=2;i<=n;++i){
    if(i&1)x[i]=x[1]+v[i];
    else x[i]=v[i]-x[1];
  }
  fori(i,n)x[i]*=2;
  fori(i,n)cout<<x[i]<<" ";
  cout<<endl;
}
int32_t  main(){
  IOS;
  solve();
  return 0;
}



Measured memory_bytes: 2560
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n,m;
    while(cin >> n >> m){
        int cost[1005],  vote[1005] = {0}, ma = 0, ans;
        rep(i,n){
            cin >> cost[i];
        }
        int inp;
        rep(i,m){
            cin >> inp;
            rep(j,n){
                if(cost[j] <= inp){
                    vote[j]++;
                    if(ma < vote[j]){
                        ma = vote[j];
                        ans = j + 1;
                    }
                    break;
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1168
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	lint N, K;
	cin >> N >> K;

	vector<lint> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	// 2進法で表したときの各桁について注目する。（0の数が過半数ならmaxXのその桁は1となる。）
	// Kと比較してKのi桁目が1ならmaxXも1にできる。
	// (flag)上の桁から見ていってKが1なのにmaxXは0となる場合その先maxXはKによらず1,0を決めれる。
	lint one, maxX = 0;
	bool flag = false;
	for (int i = 39; i >= 0; i--) {

		// N個の入力のi桁目の1の数を数える
		one = 0;
		for (int j = 0; j < N; j++) if ((1LL << i) & A[j]) one++;

		// flagがtrueまたはKのi桁目が1 でかつ0が過半数ならmaxXのi桁目を1にする。
		if ((flag || (K & (1LL << i))) && one - N / 2 <= 0) maxX += (1LL << i);

		// Kが1でmaxXが0となるならそれ以降は必ずK>maxXが成立するのでflag=trueにしてmaxXの1,0は自由に決めれる。
		if (!flag && (K & (1LL << i)) && one - N / 2 > 0) flag = true;

	}

	lint ans = 0;
	for (int i = 0; i < N; i++) ans += A[i] ^ maxX;

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
//入力された文字列を逆順に出力
using namespace std;

int main(){
  string a;
  cin >>a;
  for(int i =a.size()-1;i >=0;i--){
    putchar(a[i]);
  }
 cout << endl;
  return 0;
} 

Measured memory_bytes: 1164
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,a,b,c,d,e,f,g,h,i,j,k,w,ok,ng,l,q,ans;
ll x[500005],y[500005],z[500005];
ll dp[10005][105][3];
char s[500005],t[500005];
bool flag,dame;

void solve(ll i,ll sum,bool flag){
	//now looking i bit
	if(i == n){
		if(sum == 0){
			p("hoi");
			ans += 1;
		}
		return;
	}else if(!flag){
		for(int j=0;j<=9;j++){
			solve(i+1,(sum+j)%d,0);
		}
	}else{
		a = s[i] - '0';
		for(int j=0;j<a;j++){
			solve(i+1,(sum+j)%d,0);
		}
		solve(i+1,(sum+a)%d,1);
	}
}

int main(){
    cin >> s >> d;
	n = strlen(s);
	dp[0][0][1] = 1;
	for(i=0;i<n;i++){
		for(j=0;j<d;j++){
			for(k=0;k<=9;k++){
				dp[i+1][(j+k)%d][0] += dp[i][j][0];
				dp[i+1][(j+k)%d][0] %= mod;
			}
			a = s[i] - '0';
			for(k=0;k<a;k++){
				dp[i+1][(j+k)%d][0] += dp[i][j][1];
				dp[i+1][(j+k)%d][0] %= mod;
			}
			dp[i+1][(j+a)%d][1] += dp[i][j][1];
			dp[i+1][(j+a)%d][1] %= mod;
		}
	}
	for(i=0;i<=n;i++){
		for(j=0;j<d;j++){
			//pe(dp[i][j][0]);
		}
	//	el;
	}
	p((dp[n][0][0] + dp[n][0][1] + mod - 1) % mod);
	return 0;
}

Measured memory_bytes: 49792
import numpy as np

n, m, q = map(int, input().split())

mat = np.zeros((n, n), dtype=int)

for i in range(m):
    l, r = map(int, input().split())
    mat[l-1, r-1] += 1
mat = np.flipud(mat)
matmul = np.cumsum(mat, axis=0)
matmul = np.flipud(matmul)
matmul2 = np.cumsum(matmul, axis=1)

for i in range(q):
    p, q = map(int, input().split())
    ans = matmul2[p-1, q-1]
    print(ans)

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

public class Main {

    private static Scanner sc;
    private static int[][] neg8 = new int[][]{{-1,-1}, {0,-1}, {1,-1}, {-1,0}, {1,0}, {-1,1}, {0,1}, {1,1}};

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int H, W;
            H = sc.nextInt();
            W = sc.nextInt();
            char[][] arr = new char[H][W];
            for (int i = 0; i < H; i++) {
                String next = sc.next();
                for (int j = 0; j < W; j++) {
                    arr[i][j] = next.charAt(j);
                }
            }

            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    char c = arr[i][j];
                    if (c == '#') continue;

                    int count = 0;
                    for (int[] ints : neg8) {
                        try {
                            char c1 = arr[i + ints[0]][j + ints[1]];
                            if (c1 == '#') count++;
                        } catch (ArrayIndexOutOfBoundsException e) {
                        }
                    }
                    arr[i][j] = Character.forDigit(count, 10);
                }
            }

            for (char[] chars : arr) {
                for (char aChar : chars) {
                    System.out.print(aChar);
                }
                System.out.println();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}



Measured memory_bytes: 21972
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;

long long gcd(long long x, long long y){
			if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }
int main(){
int A,B,C;
cin >> A >> B >> C;
int M = max(max(A,B),C);
if(3*M%2!=(A+B+C)%2)M=M+1;
cout << (3*M-(A+B+C))/2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a, b, c;
    int x, y;
    scanf("%d %d %d", &a, &b, &c);
    
    if( a > b ){
    x = a;
    y = b;
    a = y;
    b = x;
    } 
    if( b > c ){
    x = b;
    y = c;
    b = y;
    c = x;
    }
    if( a > b ){
    x = a;
    y = b;
    a = y;
    b = x;
    }
    
    printf("%d %d %d\n", a, b, c);
    return 0;
}
    


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

using namespace std;

const long long INF = 1ll << 60;
const long long INIT = 1e15;

void dijkstra(int src, vector<vector<pair<int, int>>>& city, vector<long long>& dist){
  priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;
  
  for(int i = 0; i < dist.size(); i++){
    if(i == src){
      dist[i] = 0;
    }else{
      dist[i] = INF;
    }
  }
  
  pq.push(make_pair(0, src));
  
  while(!pq.empty()){
    pair<long long, int> node = pq.top();
    pq.pop();
    
    for(pair<int, int> next : city[node.second]){
      if(node.first + next.first < dist[next.second]){
        dist[next.second] = node.first + next.first;
        pq.push(make_pair(dist[next.second], next.second));
      }
    }
  }
}

int main(){
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--; t--;
  
  vector<vector<pair<int, int>>> city_yen(n), city_snuuk(n);
  for(int i = 0; i < m; i++){
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    
    city_yen[u].push_back(make_pair(a, v));
    city_yen[v].push_back(make_pair(a, u));
    city_snuuk[u].push_back(make_pair(b, v));
    city_snuuk[v].push_back(make_pair(b, u));
  }
  
  vector<long long> yen(n), snuuk(n);
  dijkstra(s, city_yen, yen);
  dijkstra(t, city_snuuk, snuuk);
  
  vector<long long> max_snuuk(n);
  max_snuuk[n - 1] = INIT - snuuk[n - 1] - yen[n - 1];
  for(int i = n - 2; i >= 0; i--){
    max_snuuk[i] = max(INIT - snuuk[i] - yen[i], max_snuuk[i + 1]);
  }
  
  for(int i = 0; i < n; i++){
    cout << max_snuuk[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 16068
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define riterator reverse_iterator
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 1e5;
const int S = 26;
const int P = 1e9+7;
char a[N+3];
int cnt[S+3];
int n;

int main()
{
	scanf("%d%s",&n,a+1);
	for(int i=1; i<=n; i++) cnt[a[i]-96]++;
	llong ans = 1ll;
	for(int i=1; i<=S; i++) ans = ans*(cnt[i]+1ll)%P;
	ans = (ans-1+P)%P;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Text;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var length = s.Length;
            var sb = new StringBuilder();

            for (var i = 0; i < length; i++)
            {
                if (i % 2 != 0)
                {
                    continue;
                }

                sb.Append(s[i]);
            }

            Console.WriteLine(sb.ToString());
        }
    }
}

Measured memory_bytes: 26256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# A,Bそれぞれの累積和を作る
# 初期値は0冊目まで読んだときの値（ここでは0）を入れておく
a = [0]
b = [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

# 読める最大の冊数
ans = 0

# Bは全て（=M冊目まで）読めることを初期値とする
# Aの山で読む本を増やすにつれて、jは（広義）単調減少する
j = M

# Aの山について、何冊目まで読むか
for i in range(N + 1):

    # Aの山だけでK分オーバーの場合
    # これ以上iを増やしても無意味なので打ち切る
    if a[i] > K:
        break

    # a[i]+b[j] > K　ならjをデクリメント
    # Bの山を全て読めると仮定した後、下の方から一冊ずつ諦める
    # jはiの増加に対して広義単調減少（しゃくとり法）、Mから0まで一回走査するだけで良い
    while b[j] > K - a[i]:
        j -= 1

    # 冊数はi+j、全てのiに対してi+jを比較、最大のものが答え
    ans = max(ans, i + j)

print(ans)


Measured memory_bytes: 47480
/*
Character Drawing Adapted from FAKEUPDATE.NET
		   _    _____         _
		   \`,""   ,'7"r-..__/ \
		  ,'\ `, ,',','    _/   \
		 /   \, 7 / /     (   \ |
		J     \/ j  L______\  / |
		L   __JF"""/""\"\_,    /
		L,-"| O|  f O |  L_  _/
		F   \_ /  \__/   `-  j|
			.-'    `"""    ,' |          _..====.._
			\__/         r"_  A        ,' _..---.._`,
			 `-.______,,-L// / \  ___,' ,'_..:::.. `,`,
					  j   / / / 7"    `-<""=:'  '':. \ \
					 /   <,' /  F  . i , \   `,    :T W I
					 |    \,'  /    >X<  |     \   :| | L
					 |     `._/    ' ! ` |      I  :| |  G
					  \           \     /       |  :H T  |
					 __>-.__   __,-\   |        |  S P   |
					/     /|   | \  \  \_       | 'A R   |
				   /   __/ |   |  L  L   \      K./ /    L
				  /   |    |   4  I  I    |    E./ /   ,'
				 J    \    I    L F  I    |    // / _,'
		_________|     |   F    |J   F    |   //_/-'
		\   __   |    /   J     |/  J     |  /="
		\\  \_\  \__,' \  F     |   F     |
		\\\_____________\/      F__/      F
		 \\| 计算机编程 |_____/  (______/
		  \/从入门到入土/
*/
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
#include <functional>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	int iNum;
	cin >> iNum;
	cout << ceil(pow(2, int(log2(iNum)))) << endl;
endapp:
	system("pause > nul");
	return 0;
}

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

const int INF = 1000000;
int edge[100][100];

void WF(int n){
	for(int k = 0;k < n;++k){
		for(int i = 0;i < n;++i){
			for(int j = 0;j < n;++j){
				if(i == j) continue;
				edge[i][j] = min(edge[i][j], edge[i][k] + edge[k][j]);
			}
		}
	}
}

int main(){
	int n, p, r, k, t, a;
	for(int i = 0;i < 100;++i){
		for(int j = 0;j < 100;++j){
			edge[i][j] = INF;
		}
	}
	cin >> n;
	for(int i = 0;i < n;++i){
		cin >> r >> k;
		--r;
		for(int j = 0;j < k;++j){
			cin >> a;
			--a;
			edge[r][a] = 1;
		}
	}
	WF(n);
	cin >> p;
	for(int i = 0;i < p;++i){
		int s, d, v;
		cin >> s >> d >> v;
		--s;
		--d;
		if(edge[s][d] + 1 <= v) cout << edge[s][d] + 1 << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int a,b,c;
int main(){
	a=read(),b=read(),c=read();
	if((a==b&&a^c)||(a==c&&a^b)||(b==c&&a^b)){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

int main()
{
	ll a, b, c; cin >> a >> b >> c;

	if ((a + b + 2 * pow(a * b, 0.5L)) < c)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 384
n,d = gets.strip.split.map(&:to_i)
array = []
while num = gets
  array << num.chomp.split
end
sum = 0
for i in 0..n-2
  for k in i+1..n-1
    kai = 0
    j = 0
    while j < d do
      kai += (array[i][j].to_i-array[k][j].to_i)**2
      j += 1
    end
    if Math.sqrt(kai).floor == Math.sqrt(kai)
      sum += 1
    end
  end
end
puts sum

Measured memory_bytes: 14124
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

ll dp[100][2]; // i桁, small or girigiri?

int main() {
  constexpr int max_digit = 50;

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  memset(dp, -1, sizeof(dp));
  rep(i, n) cin >> a[i];
  
  dp[0][0] = 0;
  for (int d = 0; d < max_digit; ++d) {
    ll mask = 1LL << (max_digit - d - 1);
    
    int num = 0;
    rep(i, n) if (a[i] & mask) ++num;

    ll cost0 = mask * num;
    ll cost1 = mask * (n - num);
    
    if (dp[d][1] != -1) {
      dp[d + 1][1] = max(dp[d + 1][1], dp[d][1] + max(cost0, cost1));
    }

    if (dp[d][0] != -1) {
      if (k & mask) {
        dp[d + 1][1] = max(dp[d + 1][1], dp[d][0] + cost0);
      }
    }

    if (dp[d][0] != -1) {
      if (k & mask) {
        dp[d + 1][0] = max(dp[d + 1][0], dp[d][0] + cost1);
      } else {
        dp[d + 1][0] = max(dp[d + 1][0], dp[d][0] + cost0);
      }
    }

    // cout << dp[d][0] << " " << dp[d][1] << endl;
  }

  cout << max(dp[max_digit][0], dp[max_digit][1]) << endl;
}


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

int main()
{

	int n, x = 0, y = 0;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	int b[n];
	for(int i = 0; i < n; i++)
		cin >> b[i];

	for(int i = 0; i < n; i++)
		if(a[i] > b[i])
			x = x + a[i], y = y + b[i];
		
	cout << x - y << endl;
	return 0;
}

Measured memory_bytes: 256
def f():
 global d
 p=[d[0]]
 for i in range(len(d)-1):
  a,b=d[i],d[i+1]
  r=(b-a)/3
  p+=[a+r,a+r+r*(1+3**.5*1j)/2,b-r,b]
 d=p
d=[0j,100+0j]
for _ in[0]*int(input()):f()
for e in d:print(e.real,e.imag)


Measured memory_bytes: 5888
n, m = map(int, input().strip().split())
L = [list(map(int, input().split())) for _ in range(m)]

# if m>n:
#     print(-1)
#     exit()
ans=[None]*n
for l in L:
    if ans[l[0]-1] is None:
        ans[l[0]-1]=l[1]
    elif ans[l[0]-1]!=l[1]:
        print(-1)
        exit()
if n==1:
    if ans[0] is None:
        print(0)
    else:
        print(ans[0])
    exit()
elif ans[0]==0:
    print(-1)
    exit()
for i,v in enumerate(ans):
    if v is None:
        ans[i]=0
if ans[0]==0:
    ans[0]=1
print("".join(list(map(str,ans))))

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

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    out.println(n * (n + 1) / 2);
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public 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();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 21076
#include<iostream>

using namespace std;
using ll = long long int;

int main(void) {
    ll n, z = 0; cin >> n;
    for (ll i = 10; i <= n; i *= 5) z += n / i;
    n % 2 == 0 ? cout << z << endl : cout << 0 << endl;
}

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

while True:
    a, op, b = map(str, input().split())
    if op == '?':
        break
    if op == '+':
        print(int(a) + int(b))
    elif op == '-':
        print(int(a) - int(b))
    elif op == '*':
        print(int(a) * int(b))
    elif op == '/':
        print(int(int(a) / int(b)))




Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
typedef pair<int, int> P; typedef pair<ll, ll> PLL;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
void princ(auto x){cout<<x<<" ";}; void print(auto x){cout<<x<<"\n";};
///////////////////////////////////////////////////////////////////////////////////

ll h,w;
bool mp[2001][2001];
ll sum[2001][2001];

void init(){
    ll l=-1,r=-1;
    ll tmp = 0;
    rep(i,2001)rep(j,2001)sum[i][j]=0;
    rep(i,h){
        rep(j,w){
            //print("nya");
            if(!mp[j+1][i+1]){
                if(l==-1)l=j+1;
                r = j+1;
                if(j==w-1){
                    tmp = r-l+1;
                    if(r!=-1)for(int ll = l;ll<=r;ll++){
                        sum[ll][i+1]+=tmp;
                    }

                //cout<<i+1<<" "<<l<<" "<<r<<" "<<tmp<<endl;
                    r=-1;l=-1;
                }
            }else{
                tmp = r-l+1;
                //cout<<i+1<<" "<<l<<" "<<r<<" "<<tmp<<endl;
                if(r!=-1)for(int ll = l;ll<=r;ll++){
                    sum[ll][i+1]+=tmp;
                }
                r= -1;
                l = -1;
            }
        }
    }
    rep(i,w){
        rep(j,h){
            if(!mp[i+1][j+1]){
                if(l==-1)l=j+1;
                r = j+1;
                if(j==h-1){
                    tmp = r-l+1;
                    if(r!=-1)for(int ll = l;ll<=r;ll++){
                        sum[i+1][ll]+=tmp;
                    }
                    r=-1;l=-1;
                }
            }else{
                tmp = r-l+1;
                if(r!=-1)for(int ll = l;ll<=r;ll++){
                    sum[i+1][ll]+=tmp;
                }
                r= -1;
                l = -1;
            }
        }
    }
}

ll calc(ll x,ll y){
    return sum[x][y];
}


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>h>>w;
    string s;
    rep(i,2001)rep(j,2001)mp[i][j]=false;
    rep(i,h){
        cin>>s;
        rep(j,s.size()){
            if(s[j]=='#'){
                mp[j+1][i+1] = true;
            }
        }
    }
    ll ans = 0;
    init();
    rep(i,w)rep(j,h){
        if(!mp[i+1][j+1]){
            if(chmax(ans,calc(i+1,j+1))){
                //cout<<i+1<<" "<<j+1<<" "<<ans<<endl;
            }
        }
    }
    print(ans-1);
    return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
//#pragma GCC target("avx,avx2,sse4.2")
#define rep(q, a, b) for (int q = a, q##_end_ = b; q <= q##_end_; ++q)
#define dep(q, a, b) for (int q = a, q##_end_ = b; q >= q##_end_; --q)
#define mem(a, b) memset(a, b, sizeof a)
#define debug(a) cerr << #a << ' ' << a << "___" << endl
using namespace std;
// char buf[10000000], *p1 = buf, *p2 = buf;
#define Getchar() getchar()  // p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 10000000, stdin), p1 == p2) ? EOF : *p1++
void in(int &r) {
    static char c;
    r = 0;
    while (c = Getchar(), c < 48);
        ;
    do
        r = (r << 1) + (r << 3) + (c ^ 48);
    while (c = Getchar(), c > 47);
}
int main(){
	int n,m;
	in(n),in(m);
	int v=n/(2*m+1);
	if(n%(2*m+1))++v;
	cout<<v<<endl;
	return 0;
}

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

int main() {
  int N,X,T;

  cin >> N >> X >> T;

  if(N % X == 0){
    cout << T* (N/X) << endl;
  }else{
    cout << T * (N / X + 1) << endl;
  }
  return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int k, x;
	cin >> k >> x;
	for(int i = x - k + 1; i < x + k; ++i)
	{
		cout << i << " ";
	}
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3580
S = input()
Q = int(input())
flag = 1
left = ""
right = ""

for i in range(Q):
    q = input().split()
    if q==["1"]:
        flag *= -1
    else:
        if flag==1 and q[1]=="1":
            left = q[2]+left
        elif flag==1 and q[1]=="2":
            right += q[2]
        elif flag==-1 and q[1]=="1":
            right += q[2]
        else:
            left = q[2]+left
# print(S)

if flag==1:
    print(left+S+right)
else:
    print(right[::-1]+S[::-1]+left[::-1])


Measured memory_bytes: 4504
#include<bits/stdc++.h>
using namespace std;
long long n,a[25];
long long dfs(int x,int y,int z,int k) {
	if(y-x<=1)
		return 0;
	long long ans=1e18;
	for(int i=x+1;i<=y-1;i++)
		ans=min(ans,dfs(x,i,z,z+k)+dfs(i,y,z+k,k)+a[i]*(z+k));
	return ans;
}
int main() {
	cin>>n;
	for(int i=1; i<=n; i++)
		cin>>a[i];
	cout<<a[1]+a[n]+dfs(1,n,1,1)<<endl;
	return 0;
}

Measured memory_bytes: 256