akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 998244353 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll power(int k, int n, int M){
  if(n == 0) return 1;
  if(n == 1) return (ll)k;

  ll res = power(k, n/2, M);

  res = res * res % M;
  return n%2 == 1 ? res * k % M : res;
}

/* Starry Sky Tree */
//0-index

struct StarrySkyTree{
  typedef ll Type;
  int segn2;
  vector<Type> data, s_data;
  function<Type(Type, Type)> merge;

  StarrySkyTree(function<Type(Type, Type)> merge, int n): merge(merge)
  {
    for(segn2=1; segn2<n; segn2*=2);
    data.assign(segn2*2, 0);
    s_data.assign(segn2*2, 0);
  }

  StarrySkyTree(int n): //Original Ver.
    StarrySkyTree([](Type a, Type b){ return (a + b) % mod; }, n) {}

  //get value of [a,b)
  Type query(int a, int b, int l = 0, int r = -1, int k = 0){
    if(r == -1) r = segn2;
    if(r <= a || b <= l) return 0; //大きさに注意
    if(a <= l && r <= b) return (data[k] + s_data[k] * (r - l) % mod) % mod;
    return
      (merge(query(a, b, l, (l+r)/2, k*2+1), query(a, b, (l+r)/2 , r, k*2+2)) +
      s_data[k] * max(0, min(b, r) - max(a, l)) % mod) % mod;
  }

  //add x to [a,b)
  Type add(int a, int b, Type x, int l = 0, int r = -1, int k = 0){
    if(r == -1) r = segn2;
    if(a <= l && r <= b) {
      s_data[k] += x;
      s_data[k] %= mod;
    } else if(a < r && l < b) {
      data[k] = merge(add(a, b, x, l, (l+r)/2, k*2+1), add(a, b, x, (l+r)/2, r, k*2+2));
    }

    return (data[k] + s_data[k] * (r - l)) % mod;
  }

};


int main(){
  int N, K, A;
  ll ans = 0;

  cin >> N >> K >> A;

  ll initEnvN = power(N, mod - 2, mod) % mod;
  ll invN = A * power(N * 100, mod - 2, mod) % mod;

  StarrySkyTree seg(K+1);

  int r = min(1+N, K);
  seg.add(1, r, initEnvN);
  ans += max(0, N+1 - r) * initEnvN;

  for(int i=1; i<K; i++) {
    ll p = seg.query(i, i+1);

    int r = min(i+N+1, K);
    seg.add(i+1, r, invN * p % mod);
    ans += max(0, i+N+1 - r) * invN % mod * p % mod;
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 7088
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };

int N = 1e3 + 7;


int main() {
	fastIO;
	bool valid = true;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (x % 2 == 0 && (x % 3 && x % 5)) {
			valid = false;
		}
	}
	if (valid)
		cout << "APPROVED";
	else
		cout << "DENIED";

}


Measured memory_bytes: 256
a,b,k = list(map(int, input().split()))
if(b-a <= 200):
  for i in range(a, b+1):
    if(i < a + k or b - k < i):
      print(i)
else:
  for i in range(a, a+k):
    print(i)
  for i in range(b-k+1, b+1):
    print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

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

int main() {
  
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i,H) cin >> S[i];

  vector score(H, vector<int>(W, INF));
  score[0][0] = 1;

  queue<P> que;
  que.emplace(0, 0);
  while (!que.empty()) {
    P p = que.front(); que.pop();
    rep(i,4) {
      P q;
      q.first = p.first + dy[i];
      q.second = p.second + dx[i];
      if (q.first < 0 || q.first >= H || q.second < 0 || q.second >= W) continue;
      if (S[q.first][q.second] == '#' || score[q.first][q.second] < INF) continue;
      score[q.first][q.second] = score[p.first][p.second] + 1;
      que.push(q);
    }
  }

  if (score[H - 1][W - 1] == INF) cout << -1 << endl;
  else {
    int ans = H * W;
    ans -= score[H - 1][W - 1];
    rep(i,H) rep(j,W) if (S[i][j] == '#') ans--;
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3600
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class SumOfLargeNumbers {
        public static int MOD = (int) (Math.pow(10, 9) + 7);

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            long result = 0;
            for (long i = k; i <= n + 1; i++) {
                long min = i * (i - 1) / 2;
                long max = (2 * n - i + 1) * i / 2;
                long add = max - min + 1;
                result = (result + add) % MOD;
            }
            out.append(String.valueOf(result));
        }

    }
}



Measured memory_bytes: 35852
S = input()
N = len(S)
K = int(input())

dp = [[[0, 0] for i in range(4)] for j in range(N+1)]
dp[0][0][0] = 1

for i in range(N):
    for j in range(4):
        for k in range(2):
            nd = int(S[i])
            for d in range(10):
                nj = j
                nk = k
                if d != 0: nj += 1
                if nj > K: continue
                if k == 0:
                    if d > nd: continue
                    if d < nd: nk = 1
                dp[i+1][nj][nk] += dp[i][j][k]

print(sum(dp[N][K]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
map<pair<ll,ll>,int> mp;
int n,zero;
int quick_pow(int x,int y)
{
    int ans=1;
    while(y)
	{
        if(y & 1) ans=(ll)ans*x % mod;
        y>>=1;
        x=(ll)x*x%mod;
    }
    return ans;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
	{
		ll a,b;
		scanf("%lld%lld", &a,&b);
        ll d=__gcd(a, b);
        if(d==0) {zero++;continue;}
		a/=d,b/=d;
        if(a<0) a=-a,b=-b;
        mp[{a, b}]++;
    }
    ll ans=1;
    for(auto it : mp)
	{
        if(it.second==0) continue;
        ll a=it.first.first,b=it.first.second;
        ll d=quick_pow(2, mp[{a, b}]);
        b=-b;
        if(b<0) a=-a,b=-b;
        if(mp.count({b, a}))
		{
            d=(d+quick_pow(2,mp[{b, a}])-1)%mod;
            mp[{b,a}] = 0;
        }
        ans=ans*d%mod;
    }
    ans=(ans-1+zero+mod)%mod;
    printf("%lld\n",ans);
    return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


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

    vector<int>a(n+2,0),l(n+2,0),r(n+2,0);
    rep2(i,1,n+1)cin>>a[i];

    l[1]=a[1];
    rep2(i,2,n+1){
        l[i]=__gcd(l[i-1],a[i]);
    }

    r[n]=a[n];
    for(int i=n-1;i>0;i--){
        r[i]=__gcd(r[i+1],a[i]);
    }

    int ans=0;
    rep2(i,1,n+1){
        ans=max(ans,__gcd(l[i-1],r[i+1]));
    }

    cout<<ans<<endl;
}


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

int main (){
	int A, B;cin>>A>>B;
	int ans = A-B;
	if(ans<A+B)ans=A+B;
	if(ans<A*B)ans=A*B;
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello
{
    private const int INF = 1000000007;
    public static void Main()
    {
        string S = NextString();
        ///'x'は無限に追加できるから'x'を除いたものが回文なら可能
        List<char> list = new List<char>();
        List<char> A = new List<char>();
        for (int i = 0; i < S.Length; i++)
            if (S[i] != 'x') list.Add(S[i]);
        int M = (int)Math.Ceiling(list.Count() / 2.0);
        for (int i = 0; i < M; i++)
            if (list[i] != list[list.Count() - 1 - i]) { Console.WriteLine(-1); return; }
            else A.Add(list[i]);
        ///それぞれの文字間隔に'x'が何個含まれているか
        int a = 0;
        int b = S.Length - 1;
        int ans = 0;
        foreach (var c in A)
        {
            int a_c = 0;
            for (; a < S.Length; a++)
                if (S[a] != c) { a_c++; }
                else break;
            int b_c = 0;
            for (; b >= 0; b--)
                if (S[b] != c) { b_c++; }
                else break;
            a += 1;b -= 1;
            ans += Math.Abs(a_c - b_c);
        }
        Console.WriteLine(ans);
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13396
#include<stdio.h>

int main(void){

  int n, l, i;
  int sum = 0;
  int ans = 0;

  scanf("%d %d", &n, &l);

  for(i = 0; i < n; i++){
    sum += l + i;
  }

  if(- n + 1 <= l && l <= 0){
    ans = sum;
  }
  else if(l < - n + 1){
    ans = sum - l - n + 1;
  }
  else{
    ans = sum - l;
  }

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

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

#define N 10000
#define NIL -1

struct Node{int p,l,r;};
struct Node T[N];
int n;

void preParse(int u){
  if(u==NIL) return;

  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);

}

void inParse(int u){
  if(u==NIL) return;

  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL) return;

  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,j,v,l,r,root;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].p=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL) T[l].p=v;
    if(r!=NIL) T[r].p=v;
  }

  for(i=0;i<n;i++){
    if(T[i].p==NIL) root=i;
  }
  
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2084
//submitted by Himj
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=1<<21;
int arr[21][21];
ll dp[21][mxn],n,r;
ll solve(int i,int mask)
{
 // cout<<i<<" "<<mask<<"\n";
  if(i==n)
    return 1;
  int j;
  if(dp[i][mask]!=-1)
    return dp[i][mask];
  ll ans=0;
  fr(j,0,n)
  {
    
    int val=1<<j;
    int temp=mask&val;
    //cout<<temp<<" ";
    if(arr[i][j]==1 and (temp==0))
    {
      ans=(ans+solve(i+1,mask|val))%mod;
    }
  }
  return dp[i][mask]=ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

  int t=1;
  //cin>>t;
    while(t--){
      cin>>n;
      int i,j;
      fr(i,0,n)
      fr(j,0,n)
      cin>>arr[i][j];
      r=1<<n;
      r--;
      ms(dp,-1);
      ll ans=solve(0,0);
      cout<<ans;
      
       
    }
  return 0;
  }



Measured memory_bytes: 344448
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
int main(void){
	int h,n,cnt=0;
	cin>>h>>n;
	REP(i,n){
		int a;
		cin>>a;
		cnt+=a;
	}
	if(cnt>=h)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
s=input()

s_a=s.count("a")
s_b=s.count("b")
s_c=s.count("c")

if s_a==0 or s_b==0 or s_c==0:
    if max(s_a, s_b, s_c)>=2:
        print("NO")
    else:
        print("YES")
else:
    if max(s_a, s_b, s_c)-min(s_a, s_b, s_c)>=2:
        print("NO")
    else:
        print("YES")


Measured memory_bytes: 9064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int num(string s) {
	int a = 0;
	for (char c : s) {
		if (c - 'a' > a) {
			a = c - 'a';
		}
	}
	return a;
}

void create(string s, int upper, int n) {
	if (s.size() >= n) {
		cout << s << endl;
		return;
	}
	for(int i = 0; i < upper + 1; i++) {
		create(s + (char) ('a' + i), num(s + (char) ('a' + i)) + 1, n);
	}
}

int main() {
	int n;
	cin >> n;
	create("", 0, n);
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<cmath>

using namespace std;
typedef long long LL;
char s[2333];

int main(){
	
	int i,j,k;
	scanf("%s",s+1),i=strlen(s+1);
	printf("%c%d%c",s[1],i-2,s[i]);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <iomanip>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll

using namespace std;
using Graph = vector<vector<int> >;


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

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


int N;
vector<int> Sushi;

double DP[310][310][310];


double rec(int i, int j, int k){
  if (DP[i][j][k] != -1) return DP[i][j][k];
  if (i == 0 && j == 0 && k == 0) return 0.0;

  double cnt = 0;

  if (i - 1 >= 0) cnt += rec(i - 1, j , k) * i;
  if (j - 1 >= 0) cnt += rec(i + 1, j - 1, k) * j;
  if (k - 1 >= 0) cnt += rec(i, j + 1, k - 1) * k;

  cnt += (double)N;

  cnt *= 1.0 / (i + j + k);
  
  return DP[i][j][k] = cnt;
}

signed main() {
  cin >> N;

  int one = 0;
  int two = 0;
  int three = 0;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    if (a == 1) one++;
    if (a == 2) two++;
    if (a == 3) three++;
    Sushi.push_back(a);
  }

  for (int i = 0; i < 310; i++) {
    for (int j = 0; j < 310; j++) {
      for (int k = 0; k < 310; k++){
        DP[i][j][k] = -1;
      }
    }
  }
  
  cout << setprecision(20) << rec(one, two, three) << endl;
}


Measured memory_bytes: 233088
// Why am I so dumb? :c
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

int n, a, b, l, r;

void solve() {
    scanf("%d %d %d %d %d", &n, &a, &b, &l, &r);
    b -= a;
    --n;

    for (int i = 0; i <= n; ++i) {
        ll cl1 = l * 1ll * i;
        ll cr1 = r * 1ll * i;

        ll cl2 = l * 1ll * (n - i);
        ll cr2 = r * 1ll * (n - i);

        if (cl1 - cr2 <= b && b <= cr1 - cl2) {
            printf("YES\n");
            return;
        }
    }

    printf("NO\n");
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

struct Edge {
  int src, dest; int64_t weight;
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
void add_edge(Graph &g, int src, int dest, int64_t weight) {
  g[src].push_back((Edge){src, dest, weight});
  g[dest].push_back((Edge){dest, src, weight});
}

struct UnionFind {
  vector<int> parent;
  UnionFind (int n) : parent(n, -1) {}
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  int size(int x) { return -parent[root(x)]; }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (parent[y] < parent[x]) swap(x, y);
    parent[x] += parent[y];
    parent[y] = x;
    return true;
  }
};

vector<int> dfs(const Graph &g, int now, int prev, vector<bool>& visited) {
  visited[now] = true;
  vector<int> res;
  for (const auto& e : g[now]) {
    if (e.dest == prev) continue;
    if (visited[e.dest]) res.push_back(e.weight);
    else {
      res = dfs(g, e.dest, now, visited);
      res.push_back(e.weight);
    }
  }
  return res;
}

int main() {
  while (true) {
    int64_t n,k,s;
    cin>>n>>k>>s;
    if(!n) break;
    using C = tuple<int64_t,int64_t,int64_t>;
    vector<C> vc;
    REP(i,n) {
      int64_t x,y,z;
      cin>>x>>y>>z;
      vc.emplace_back(x,y,z);
    }
    if (k == 1) {
      cout << (6 * s * s) << endl;
      continue;
    }
    Graph g(n);
    UnionFind uf(n);
    vector<bool> is_circle(n, false);
    REP(i,n) REP(j,i) {
      int64_t x1,y1,z1,x2,y2,z2;
      tie(x1,y1,z1) = vc[i];
      tie(x2,y2,z2) = vc[j];
      int64_t lx, ly, lz;
      lx = s - abs(x1-x2);
      ly = s - abs(y1-y2);
      lz = s - abs(z1-z2);
      if (lx <= 0 || ly <= 0 || lz <= 0) continue;
      int64_t ov = 2 * (lx * ly + ly * lz + lz * lx);
      add_edge(g, i, j, ov);
      bool c = uf.merge(i, j);
      if (!c) is_circle[uf.root(i)] = true;
    }
    vector<bool> visited(n, false);
    int64_t res = -1;
    bool ok = false;
    REP(i,n) {
      if (g[i].size() == 1 && !visited[i]) {
        auto v = dfs(g, i, -1, visited);
        int m = v.size();
        REP(j,m-k+2) {
          int64_t sum = 0;
          REP(l,k-1) {
            sum += v[j+l];
          }
          res = max(res, sum);
          ok = true;
        }
      }
      if (is_circle[uf.root(i)] && !visited[i]) {
        auto v = dfs(g, i, g[i][0].dest, visited);
        int m = v.size();
        if (m == k) {
          int64_t sum = 0;
          REP(j,m) sum += v[j];
          res = max(res, sum);
          ok = true;
        } else {
          REP(j,m) {
            int64_t sum = 0;
            REP(l,k-1) {
              sum += v[(j+l)%m];
            }
            res = max(res, sum);
            ok = true;
          }
        }
      }
    }
    if (ok) {
      cout << (6 * s * s * k - res) << endl;
    } else {
      cout << -1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3232
#include<iostream>
 
using namespace std;
 
int main()
{
    int n;
    cin>>n;
    while(n)
    {
        int r=n%10;
        if(r==7)
        {
            cout<<"Yes";
            return 0;
        }
        n=n/10;
    }
    cout<<"No";
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;


int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.precision(20);
  int n;
  cin >> n;
  vector<ll> a(n), b(n), c(n-1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  for (int i = 0; i < n; i++)
    cin >> b[i];
  for (int i = 0; i < n-1; i++)
    cin >> c[i];
  ll saf = 0;
  for (int i = 0; i < n; i++) {
    saf += b[a[i]];
    if (i > 0 and a[i-1] +1 == a[i]) saf += c[a[i-1]];
  }
  cout << saf << endl;

  
}



Measured memory_bytes: 256
n = int(input())
x = [None] * n
y = [None] * n
for i in range(n):
    a = int(input())
    x[i] = [0] * a
    y[i] = [0] * a
    for j in range(a):
        x[i][j], y[i][j] = map(int, input().split())
ans = 0
for i in range(2 ** n):
    a = [-1] * n
    cnt = 0
    for j in range(n):
        tmp = (i >> j) & 1
        cnt += tmp
        if tmp == 1:
            for p, q in zip(x[j], y[j]):
                if ((i >> (p - 1)) & 1) != q:
                    break
                a[p - 1] = q
            else:
                continue
            break
    else:
        for j in range(n):
            tmp = (i >> j) & 1
            if a[j] != -1 and a[j] != tmp:
                break
        else:
            ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 
signed main()
{
    SPEED;
    int i;
    string t,s;
    cin>>s;
    cin>>t;
    if((int)s.length()+1==(int)t.length())
    {
        for(i=0;i<s.length();++i)
        {
            if(s[i]!=t[i])
            {
                cout<<"No";
                return 0;
            }
        }
        cout<<"Yes";
    }
    else
        cout<<"No";
}

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

typedef unsigned long long int ULLI;

int main()
{
	int n;
	int *data;
	int dif;
	ULLI count = 0;

	scanf("%d", &n);

	data = (int*)malloc(n * sizeof(int));

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

		if (i != 0) {
			dif = data[i] - data[i - 1];
			if (dif < 0) {
				dif *= -1;
				count += dif;
				data[i] += dif ;
			}
		}
	}


/*	for (int i = 0; i < n; i++)
		printf("%d ", data[i]);
	printf("\n");*/

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

	free(data);

	return 0;
}

Measured memory_bytes: 2248
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



def solve(n, k):
    if n % k == 0:
        return n // k
    diff = (n // k) + 1
    target = n - n % k
    r = n % k
    if r % diff == 0:
        return solve(n - r, k)
    n -= (r // diff + 1) * diff
    return solve(n, k)


n = I()
ret = 0
for i in range(n):
    a, k = LI()
    ret ^= solve(a, k)

print("Takahashi" if ret else "Aoki")


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

vector<int> list_753_num = {3, 5, 7};

unsigned GetDigit(unsigned num)
{
  return std::to_string(num).length();
}

bool is753(long num)
{
  string string_num = to_string(num);
  bool done_used_7 = false;
  bool done_used_5 = false;
  bool done_used_3 = false;
  rep(i, string_num.size())
  {
    if (string_num[i] == '7')
      done_used_7 = true;
    else if (string_num[i] == '5')
      done_used_5 = true;
    else if (string_num[i] == '3')
      done_used_3 = true;
  }

  return done_used_7 && done_used_5 && done_used_3;
}

void push_753()
{
  int vec_size = list_753_num.size();
  int digit = GetDigit(list_753_num[vec_size - 1]);
  rep(i, vec_size)
  {
    if (GetDigit(list_753_num[i]) == digit)
    {
      int num = list_753_num[i] * 10;
      list_753_num.emplace_back(num + 3);
      list_753_num.emplace_back(num + 5);
      list_753_num.emplace_back(num + 7);
    }
  }
}

int main()
{
  int N;
  cin >> N;
  int digit = GetDigit(N);
  rep(i, digit - 1)
  {
    push_753();
  }
  sort(list_753_num.begin(), list_753_num.end());

  while (true)
  {
    if (list_753_num[list_753_num.size() - 1] > N)
    {
      list_753_num.pop_back();
      continue;
    }
    break;
  }

  long ans = 0;
  rep(i, list_753_num.size())
  {
    if (is753(list_753_num[i]))
      ans++;
  }

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)

ll const inf = 1e18;

struct MCMF{
	int sr, sn;
	vector<ll> d;
	vector<int> dr, ce;
	vector<vector<int> > g;
	
	struct ED{
		int v, cp;
		ll cs, cc;
		ED(){}
		ED(int a, int b, ll c):v(a), cp(b), cs(c), cc(c) {}
	};
	
	vector<ED> ed;
	
	pair<int, ll> kl(int v, int cp = 1e9){
		if (v == sn)return make_pair(cp, 0);
		int fl = 0;
		ll cs = 0;
		for (;~ce[v]; --ce[v]){
			int t = g[v][ce[v]];
			if (!ed[t].cp)continue;
			int u = ed[t].v;
			if (dr[v] + 1 != dr[u] || ed[t].cc)continue;
			pair<int, ll> an = kl(u, min(ed[t].cp, cp - fl));
			fl += an.first;
			cs += ed[t].cs * an.first + an.second;
			ed[t].cp -= an.first;
			ed[t ^ 1].cp += an.first;
			if (fl == cp)break;
		}
		if (fl < cp)dr[v] = 0;
		return make_pair(fl, cs);
	}
	
	void upd(){
		f(i, 0, g.size()){
			for (int t: g[i])ed[t].cc += d[i] - d[ed[t].v];
			ce[i] = g[i].size() - 1;
		}
	}
	
	void di(){
		f(i, 0, d.size())d[i] = inf;
		d[sr] = 0;
		f(i, 0, dr.size())dr[i] = 0;
		priority_queue<pair<ll, int> > q;
		q.push(make_pair(0, sr));
		while (!q.empty()){
			ll c = -q.top().first;
			int v = q.top().second;
			q.pop();
			if (c > d[v])continue;
			for (int t: g[v])if (ed[t].cp){
				int u = ed[t].v;
				ll nc = c + ed[t].cc;
				if (nc < d[u])dr[u] = dr[v] + 1, q.push(make_pair(-(d[u] = nc), u));
			}
		}
		upd();
	}
	
	pair<int, ll> mcmf(int s, int t){
		sr = s, sn = t;
		d = vector<ll>(g.size(), inf);
		dr = vector<int>(g.size(), 1e9);
		ce = vector<int>(g.size());
		d[sr] = dr[sr] = 0;
		f(it, 1, g.size())f(i, 0, g.size())if (d[i] != inf)for (int t: g[i])if (ed[t].cp){
			int u = ed[t].v;
			ll nc = d[i] + ed[t].cs;
			if (nc < d[u])d[u] = nc, dr[u] = dr[i] + 1;
		}
		upd();
		int fl = 0;
		ll cs = 0;
		while (d[sn] != inf){
			pair<int, ll> t = kl(sr);
			fl += t.first;
			cs += t.second;
			di();
		}
		return make_pair(fl, cs);
	}
	
	void aded(int a, int b, int w1 = 1, int cst = 0, int w2 = 0){
		g.resize(max((int)g.size(), max(a, b) + 1));
		g[a].push_back(ed.size());
		ed.emplace_back(b, w1, cst);
		g[b].push_back(ed.size());
		ed.emplace_back(a, w2, -cst);
	}
};

int const NN = 2000;
pair<int, int> p[NN];
int dp[NN], n, tp[4];
 
int main(){
	scanf("%d", &n);
	f(i, 0, n)scanf("%d%d%d", &p[i].first, &p[i].second, dp + i);
	f(i, 0, n)scanf("%d%d%d", &p[i + n].first, &p[i + n].second, dp + i + n);
	n <<= 1;
	int sr = n, sn = n | 1;
	f(i, 0, 4)tp[i] = n + 2 + i;
	n >>= 1;
	MCMF mf;
	f(i, 0, n)mf.aded(sr, i, dp[i]);
	f(i, n, n << 1)mf.aded(i, sn, dp[i]);
	f(i, 0, n)f(j, 0, 4)mf.aded(i, tp[j], 1e9, ((j & 1) ? p[i].first : -p[i].first) + ((j & 2) ? p[i].second : -p[i].second));
	f(i, n, n << 1)f(j, 0, 4)mf.aded(tp[j], i, 1e9, ((j & 1) ? -p[i].first : p[i].first) + ((j & 2) ? -p[i].second : p[i].second));
	printf("%lld\n", -mf.mcmf(sr, sn).second);
}

Measured memory_bytes: 1340
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <tuple>
#include <functional>
#include <limits>
#include <utility>
#include <string>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cstring>

// use printf, scanf instead of cout, cin.

using namespace std;

template <typename T>
struct Node
{
	Node(const T& value) : mValue(value), mNext(nullptr), mPrev(nullptr) {}

	T mValue;

	Node<T>* mNext;
	Node<T>* mPrev;
};

template <typename T>
class List
{
private:

	Node<T>* mFront;
	Node<T>* mBack;

public:

	List() : mFront(nullptr), mBack(nullptr) {}
	~List() { while (mFront) popFront(); }

	void pushFront(const T& val)
	{
		auto node(new Node<T>(val));

		if (mFront)
		{
			node->mNext = mFront;
			mFront->mPrev = node;

			mFront = node;
		}
		else
		{
			mFront = node;
			mBack = node;
		}
	}

	void pushBack(const T& val)
	{
		auto node(new Node<T>(val));

		if (mBack)
		{
			node->mPrev = mBack;
			mBack->mNext = node;

			mBack = node;
		}
		else
		{
			mFront = node;
			mBack = node;
		}
	}

	void popFront()
	{
		if (mFront)
		{
			auto next(mFront->mNext);
			delete mFront;

			if (next)
			{
				next->mPrev = nullptr;
				mFront = next;
			}
			else
			{
				mFront = mBack = nullptr;
			}
		}
	}

	void popBack()
	{
		if (mBack)
		{
			auto prev(mBack->mPrev);
			delete mBack;

			if (prev)
			{
				prev->mNext = nullptr;
				mBack = prev;
			}
			else
			{
				mFront = mBack = nullptr;
			}
		}
	}

	void erase(const T& val)
	{
		auto node(mFront);

		while (node)
		{
			if (node->mValue == val)
			{
				if (node->mPrev) node->mPrev->mNext = node->mNext;
				else mFront = node->mNext;

				if (node->mNext) node->mNext->mPrev = node->mPrev;
				else mBack = node->mPrev;

				delete node;

				break;
			}

			node = node->mNext;
		}
	}

	void print()
	{
		auto node(mFront);

		size_t i(0);
		while (node)
		{
			printf(i++ ? " %d" : "%d", node->mValue);

			node = node->mNext;
		}

		printf("\n");
	}
};

int main()
{
	List<int> list;

	int n;
	scanf("%d", &n);

	for (size_t i(0); i < n; ++i)
	{
		char command[16];
		scanf("%s", command);

		if (!strcmp(command, "insert"))
		{
			int x;
			scanf("%d", &x);

			list.pushFront(x);
		}
		else if (!strcmp(command, "delete"))
		{
			int x;
			scanf("%d", &x);

			list.erase(x);
		}
		else if (!strcmp(command, "deleteFirst"))
		{
			list.popFront();
		}
		else if (!strcmp(command, "deleteLast"))
		{
			list.popBack();
		}
	}

	list.print();

	return 0;
}

Measured memory_bytes: 34312
#include<stdio.h>
 
#define rep(i,n) for(int i=0; i< (int)(n); i++)
#define max(x,y) x>y?x:y
 
int main() {
  int n;
  // int n = 5;
 
  scanf("%d\n", &n);
  int a[n];
  // long long int a[] = {2, 1, 5, 4, 3};
  rep(i,n){
    scanf("%d\n", &a[i]);
  }
  long long int res = 0, mx = -1;
  rep(i,n){
    res += max(mx-a[i],0);
    mx = max(mx,a[i]);
  }
  printf("%lld\n", res);
  return 0;
}

Measured memory_bytes: 2472
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    long W = sc.nextLong();
    int N = sc.nextInt();
    HashMap<Long, Integer> map = new HashMap<Long, Integer>();
    for(int i = 0; i < N; i++) {
      long a = sc.nextLong() - 1;
      long b = sc.nextLong() - 1;
      long n = a * W + b;
      for(int k = 0; k < 3; k++) {
        for(int l = 0; l < 3; l++) {
          long s = n - k * W - l;
          if(a - k >= 0 && b - l >= 0 && a - k < H - 2 && b - l < W - 2 && s >= 0) {
            if(map.containsKey(s)) {
              map.put(s, map.get(s) + 1);
            } else {
              map.put(s, 1);
            }
          }
        }
      }
    }
    long[] num = new long[10];
    for(long s : map.keySet()) {
      num[map.get(s)]++;
    }
    long sum = 0;
    for(int i = 1; i < 10; i++) {
      sum += num[i];
    }
    num[0] = (H - 2) * (W - 2) - sum;
    for(int i = 0; i < 10; i++) {
      System.out.println(num[i]);
    } 
  }
}


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

int main(){
    int n,l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
    for(int i=0;i<n;i++){
        cout << s[i];
    }
    cout << endl;
}

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

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

    if(n >= 1000){
        cout << "ABD" << endl;
    }else{
        cout << "ABC" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var x,y int
	fmt.Scan(&x,&y)

	g := map[int]int {1:1,2:3,3:1,4:2,5:1,6:2,7:1,8:1,9:2,10:1,11:2,12:1}

	if g[x] == g[y] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define Pause system("pause")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int a[250];
int main()
{
	IOS;
    int n;
    cin>>n;
    for (int i = 1; i <= 2*n; i++)
    {
        cin >> a[i];
    }
    sort(a + 1, a + 2 * n + 1);
    int ans = 0;
    for (int i = 1; i <= 2 * n; i += 2)
    {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(void){
  string s,t;
  cin>>s>>t;
  
  if(s[0]==t[2]&&s[1]==t[1]&&s[2]==t[0])
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}

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

int main()
{
  long long n;
  long long  max1, max2,maxp1,maxp2,max12, max22,maxp12,maxp22;
  maxp1 = -1;
  maxp2 = -1;
  max1 = 0;
  max2 = 0;
  maxp12 = -1;
  maxp22 = -1;
  max12 = 0;
  max22 = 0;
  cin >> n;
  long long A[n];
  map<long,long> M1,M2;
  for (long long i = 0; i <= 100000; i++){
    M1[i] = 0;
    M2[i] = 0;
  }
  for (long long i = 0; i < n; i++)
    cin >> A[i];

  for (long long i = 0; i < n; i+= 2)
    M1[A[i]] += 1;

  for (long long i = 1; i < n; i+= 2)
    M2[A[i]] += 1;


  for (long long i = 0; i <= 100000; i++) {
    if (M1[i] > max1){
      max1 = M1[i];
      maxp1 = i;
    }
    if (M2[i] > max2){
      max2 = M2[i];
      maxp2 = i;
    }
  }

  M1.erase(maxp1);
  M2.erase(maxp2);

  for (long long i = 0; i <= 100000; i++) {
    if (M1[i] >= max12){
      max12 = M1[i];
      maxp12 = i;
    }
    if (M2[i] >= max22){
      max22 = M2[i];
      maxp22 = i;
    }
  }

  if (maxp1 != maxp2)
    cout << (n-max1-max2);
  else
    cout << min({(n-max1-max22),(n-max12-max2)});
}

Measured memory_bytes: 13568
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#define rep(x,to) for(x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;


int main(void){

int n,i,s,kin=100000;
double wkin;
	cin >> n;
	rep(i,n){
		wkin = kin * 1.05;
		s=0;
		if((wkin /1000) > (int)(wkin /1000)) s = 1;
		kin = ((int)(wkin /1000) + s) * 1000;
	}
	cout << kin << endl;
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<int>;
using P = pair<int,int>;

int main()
{
    string s;cin >>s;
    if(s=="ABC")puts("ARC");
    else puts("ABC");
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,(e))
#define irp(i,s,e) for(int i=(s);i>(e);--i)
#define irpz(i,s) irp(i,(s),-1)
template<class T> T in(){T x;cin>>x;return x;}
// long long a = in<long long>();
template<class T> void inarr(int s,int e,T &v){rp(i,s,e)cin>>v[i];}
// inarr<vi>(0,N,V);

int N;

ll solve(){
	ll ans=0;
	map<pair<int,int>,ll> C;//[{i,j}]<ll>=count

	rp(k,1,N+1){
		string s = to_string(k);
		int i = s[0]-'0';
		int j = s[s.size()-1]-'0';
		C[{i,j}]++;
	}

	// for(auto m:C){cout<<"["<<m.first.first<<","<<m.first.second<<"] "<<m.second<<"\n";}///

	for(auto m:C){
		int i = m.first.first, j = m.first.second;
		ll cij = m.second;
		ll cji = C[{j,i}];
		// cout<<"["<<i<<","<<j<<"] "<<cij<<" ";
		// cout<<"["<<j<<","<<i<<"] "<<cji<<" ";
		// cout<<"cij*cji = "<<cij*cji<<"\n";
		ans += cij*cji;
	}

	return ans;
}

int main(){
	cin>>N;
	ote(solve());
}


Measured memory_bytes: 256
import sys
from operator import itemgetter
sys.setrecursionlimit(1000000) # 再帰上限を増やす

def main():
    input = sys.stdin.readline  # 文字列に対してinputした場合は、rstripするのを忘れずに！
    N, M = map(int, input().rstrip().split())

    require_list = []
    for _ in range(M):
        s, e = map(int, input().rstrip().split())
        require_list.append([s, e])
    require_list.sort(key=itemgetter(1))

    count = 1
    now_require = require_list[0]
    for next_require in require_list[1:]:
        # 前回の終点よりも、今回の始点の方が右にある場合
        if now_require[1] <= next_require[0]:
            count += 1
        else:
            next_require[1] = now_require[1]
        now_require = next_require

    print(count)

if __name__ == '__main__':
    main()

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

int main() {
		long x;
		cin>>x;
		for(long i =x; ; i++){
			int flag=0;
			if(i==2){
				cout<<"2";
				break;
			}
			if(i==3){
				cout<<"3";
				break;
			}
			if(i%2==0||i%3==0){
			flag=1;
			continue;
			}
			for(long j=5;j*j<=i;j=j+6){
				if(i%j==0||i%(j+2)==0)
				{
					flag=1;
					break;
				}
			}
			if(flag==0){
				cout<<i;
				return 0;
			}
		}
		return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
//#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
string s;

int main() {
	getline(cin, s);
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == ' ') {
			cout << " ";
			continue;
		}
		if (s[i] == '.') {
			cout << ".";
			continue;
		}
		char b = s[i] -32;
		cout << b;
	}
	cout << endl;
}

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

int main(){
    int n,a;
    cin >>n;
    int ans[n]={0};
    for(int i=0;i<n-1;i++){
        cin >>a;
        ans[a-1]++;
    }
    for(int i=0;i<n;i++){cout <<ans[i]<<endl;}
    
    return 0;
}

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

int main(void){
  int n = 0;
  cin >> n;
  double sum = 0.0;
  for(int i = 0; i < n; i++){
    string s1, s2;
    cin >> s1 >> s2;
    if(s2 == "JPY"){
      sum += stoi(s1);
    }else{
      sum += stod(s1)*380000;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int a, b;
  cin >> a >> b;
  string ans = a * b % 2 == 0 ? "No" : "Yes";
  print(ans);
  return 0;
}

Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 05/17/20 20:37:02
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int k; cin>>k;
  string s; cin>>s;
  if (s.size() <= k) {
    cout << s << endl;
  } else {
    cout << s.substr(0,k) << "..." << endl;
  }

  return 0;
}


Measured memory_bytes: 3652
N, M, K = gets.split.map(&:to_i)
MOD = 998244353

def mpow(x, n)
  ret = 1
  while n > 0
    if n.even?
      x = x * x % MOD
      n >>= 1
    else
      ret = ret * x % MOD
      n -= 1
    end
  end
  ret
end

@fac, @inv, @fiv = [1, 1], [1, 1], [1, 1]
(2 ... N).each do |i|
  @fac[i] = @fac[i - 1] * i % MOD
  @inv[i] = MOD - @inv[MOD % i] * (MOD / i) % MOD
  @fiv[i] = @fiv[i - 1] * @inv[i] % MOD
end
c = ->(n, m){@fac[n] * @fiv[n - m] * @fiv[m] % MOD}
f = ->(n, m, i){m * c[n - 1, i] * mpow(M - 1, N - 1 - i) % MOD}
puts (0 .. K).inject(0){|s, i| (s + f[N, M, i]) % MOD}

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

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef vector<int> vi;
typedef vector<vi> vii;

int N, D;

double getDistance(vi &a, vi &b) {
    int tmp;
    REP(i, D) {
        tmp += pow(a[i]-b[i], 2);
    }
    return sqrt(tmp);
}

bool isInt(double n) {
    return floor(n) == ceil(n);
}

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

    vii X(N);
    REP(i, N) {
        vi tmp(D);
        REP (j, D) {
            cin >> tmp[j];
        }
        X[i] = tmp;
    }

    int result = 0;

    REP(i, N) {
        for (int j = i+1; j<N; ++j) {
            double d = getDistance(X[i], X[j]);
            if (isInt(d)) {
                ++result;
            }
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
          string[] input_line = Console.ReadLine().Split(' ');
          long a = long.Parse(input_line[0]);
          long b = long.Parse(input_line[1]);
          long c = long.Parse(input_line[2]);
          
          long ballNum = ((a/(b+c))*b) + Math.Min(a % (b + c),b);
          
          Console.WriteLine(ballNum);
        }
    }
}


Measured memory_bytes: 13140
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse = True)
it = 0
for i in range(M):
    A[it]=A[it]//2
    if it<N-1:
        if A[it]<A[it+1] and A[0]<A[it+1]:
            it+=1
        else:
            A.sort(reverse = True)
            it = 0
    if it == N-1:
        A.sort(reverse = True)
        it = 0
print(sum(A))

Measured memory_bytes: 14252
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;

constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

int keta(LL a) {
	LL num = a;
	int ret = 0;
	while (num >= 10) {
		ret++;
		num /= 10;
	}
	ret++;
	return ret;
}

int main() {
	LL n;
	cin >> n;
	vector<int> v;
	for (LL i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)v.emplace_back(i);
	}
	UNIQ(v);
	int ans = HINF;
	for (int i = 0; i < v.size(); i++) {
		LL a = n / v[i];
		//cout <<a<<" " <<ans << endl;
		ans = min(ans, max(keta(v[i]), keta(a)));
	}
	cout << ans << endl;
	//system("pause");
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;


long long int a, b, c, d, gc;
long long int x[10];

int gcd(int a, int b) {
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main() {
	cin >> a >> b >> c >> d;
	gc = c * d / gcd(c, d);
	x[0] = b / c;
	x[1] = b / d;
	x[2] = b / gc;
	x[3] = (a - 1) / c;
	x[4] = (a - 1) / d;
	x[5] = (a - 1) / gc;
	x[6] = x[0] + x[1] - x[2] - (x[3] + x[4] - x[5]);	// A以上でB以下で割り切れるもの
		cout << b - a + 1 - x[6] << endl;

	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using tpl = tuple<char, int>;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N, M;
int A[11];
int B[11] = {0,2,5,5,4,5,6,3,7,6};
int dp[10010];
int nxt[10010];

int rec(int ma){
    if(dp[ma] >= -1) return dp[ma];
    int res = -1;
    if(ma == 0){
        res = 0;
    }
    else{
        for(int i = 0; i < M; i++){
            if(ma -  B[A[i]] >= 0 && rec(ma - B[A[i]]) != -1){
                if(res <= rec(ma - B[A[i]]) + 1){
                    res = max(res, rec(ma - B[A[i]]) + 1);
                    nxt[ma] = i;
                }
            }
        }
    }
    return dp[ma] = res;
}

int main(){

    cin >> N >> M;
    for(int i = 0; i < M; i++) cin >> A[i];
    sort(A, A + M);
    for(int i = 0; i < 10010; i++) dp[i] = -2;
    rec(N);
    int c = N;
    string s;
    while(c != 0){
        int seli = nxt[c];
        s += (A[seli] + '0');
        c = c - B[A[seli]];
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

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

int n;
int a4,a2;

int main(){
	cin>>n;
	REP(i,n){
		int t;
		cin>>t;
		if(t%4==0){
			a4++;
		}else if(t%2==0){
			a2++;
		}
	}
	int s=a2?1:0;
	if((n-a2+s)/2<=a4){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}
		



Measured memory_bytes: 256