akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(vr) vr.begin(),vr.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
const int N=10;
int a[N][N],h,w,k;
int main()
{
    //freopen("ss.inp","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>h>>w>>k;
    for (int i=1;i<=h;i++)
        for (int j=1;j<=w;j++) {
            char ch;
            cin>>ch;
            a[i][j]=(ch=='#');
        }
    int res=0;
    for (int mask1=0;mask1<(1<<h);mask1++)
        for (int mask2=0;mask2<(1<<w);mask2++) {
            int d=0;
            for (int i=1;i<=h;i++)
                for (int j=1;j<=w;j++)
                    if (a[i][j] && ((mask1>>(i-1))&1)==0 && ((mask2>>(j-1))&1)==0) d++;
            if (d==k) res++;
        }
    cout<<res;
    return 0;
}


Measured memory_bytes: 3484
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=20;
static const int D=365;
static const int ntype=26;
static int ans[D+1];
static int max_score=0;
static int t=100500;

class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int Score(int type){
    int sum=0;
    contest[type].last=0;
    for(int day=1;day<=D;++day){
        if(ans[day]==type){
            sum+=contest[type].s[day];
            int n=day-contest[type].last;
            sum-=contest[type].c*(n*(n-1)/2);
            contest[type].last=day;
        }
    }
    if(ans[D]!=type){
        int n=D-contest[type].last;
        sum-=contest[type].c*(n*(n+1)/2);
    }
    return sum;   
}

void Output(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    for(int d=1;d<=D;++d) cout<<ans[d]<<'\n';
}

void Init(){
    for(int d=1;d<=D;++d) ans[d]=rand()%ntype+1;
}

void Greedy(){
    vector<int> l(ntype+1,0);
    int score=0;
    for(int d=1;d<=D;++d){
        for(int i=1;i<=ntype;++i) score-=contest[i].c*(d-l[i]);
        int temp=score;
        int t=-1;
        for(int i=1;i<=ntype;++i){
            int k=contest[i].s[d]+contest[i].c*(d-l[i])+score;
            if(k>temp){
                temp=k;
                t=i;
            }
        }
        ans[d]=t;
        l[t]=d;
    }
}

void change(){
    int p=rand()%D+1;
    int temp=ans[p];
    int temp_score=Score(temp);
    ans[p]=rand()%ntype+1;
    //cout<<"p: "<<p<<" from: "<<temp<<" to: "<<ans[p]<<endl;
    int delta=Score(ans[p])-temp_score;
    if(delta>0) max_score+=delta;
    else ans[p]=temp;
}

void swap(){
    int p1=rand()%D+1;
    int p2=rand()%D+1;
    while(p1==p2) p2=rand()%D+1;
    int temp_score=Score(ans[p1])+Score(ans[p2]);
    int temp=ans[p1];
    ans[p1]=ans[p2];
    ans[p2]=temp;
    int delta=Score(ans[p2])+Score(ans[p1])-temp_score;
    if(delta>0) max_score+=delta;
    else{
        ans[p2]=ans[p1];
        ans[p1]=temp;
    }
}

void Solve(int times){
    Greedy();
    for(int i=1;i<=ntype;++i) max_score+=Score(i);
    for(int i=0;i<times;++i){
        swap();
        change();
    }
}

int main(){
    srand(seed);
    Input();
    Solve(t);
    Output();
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    string O,E; cin >> O >> E;
    for(int i=0;i<O.size()+E.size();i++){
        if(i%2==0) cout << O[i/2];
        else cout << E[(i-1)/2];
    }
}



Measured memory_bytes: 256
/*
     _              ,_,
    / \   _ __, ___,| |__   __ _,_ __
   / ^ \ | '_ \/ _ \| '_ \ / _` | /_/
  /-/-\-\|-| |--| |-|-|_)-|-(_|-|-|
 /_/   \_\_| |__| |_|_.__/ \__,_|_|
 
*/
#include <bits/stdc++.h>
using namespace std;
 
#define int long long int
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(a)       (a).begin(),(a).end()
#define rep(i,a,n)   for(int i=a ; i<n ; i++)
 
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<ll,ll> mii;
typedef map<char,ll> mci;
 
ll gcd(ll a, ll b){
	if(b==0)return a;
	else return gcd(b, a%b);
}

signed main(){
    ios_base :: sync_with_stdio (false);
	cin.tie(NULL);
	// cout << fixed << setprecision(15);
 
	ll TESTS=1; 
	// cin>>TESTS;
	while(TESTS--){
		ll x; cin>>x;
		if(x>=30)cout<<"Yes";
		else cout<<"No";
		cout<<endl;


	}
    return(0);
}

Measured memory_bytes: 3600
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Map;
import java.util.TreeMap;

public class Main
{
  private static final long mod = 1000000007;
  // public static long gcd(long a, long b)
  // {
  //   if(b == 0) return a;
  //   return gcd(b, a % b);
  // }
  // public static Pair extended_gcd(long a, long b)
  // {
  //   if (a == 0) {
  //       return new Pair(0L, 1L);
  //   }
  //   Pair p = extended_gcd(b % a, a);
  //   long x = p.second - (b / a) * p.first;
  //   long y = p.first;
  //   return new Pair(x, y);
  // }
  public static long power(long b, long p)
  {
    if(p == 0) return 1L;
    long ret = power(b, p / 2);
    ret = (ret * ret) % mod;
    if(p % 2 == 1) ret = (ret * b) % mod;
    return ret;
  }
  public static long modInverse(long a, long mod)
  {
    return power(a, mod - 2);
  }
  public static void main(String[] args) throws FileNotFoundException
  {
      Scanner scanner = new Scanner(System.in);//new File("input.txt"));
      int n = scanner.nextInt();
      long[] a = new long[n];
      for(int i = 0 ; i < n ; i++)
        a[i] = scanner.nextInt();
      TreeMap<Integer, Integer> map = new TreeMap<>();
      for(int i = 0 ; i < n ; i++)
      {
        int temp = (int)a[i];
        for(int j = 2 ; j * j <= temp ; j++)
        {
          int cnt = 0;
          while(temp % j == 0)
          {
            temp /= j;
            ++cnt;
          }
          if(map.containsKey(j))
            map.put(j, Math.max(cnt, map.get(j)));
          else
            map.put(j, cnt);
        }
        if(temp != 1)
        {
          if(map.containsKey(temp))
            map.put(temp, Math.max(1, map.get(temp)));
          else
            map.put(temp, 1);
        }
      }
      long lcm = 1;
      for(Map.Entry<Integer, Integer> e : map.entrySet())
      {
        // System.out.println(e.getKey() + " " + e.getValue());
        lcm = (lcm * power(e.getKey(), e.getValue())) % mod;
      }
      long sum = 0;
      for(int i = 0 ; i < n ; i++)
      {
          sum = (sum + (lcm * modInverse(a[i], mod)) % mod) % mod;
      }
      System.out.println(sum);
  }
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll h, w; cin >> h >> w;
    map<string, ll> m;
    priority_queue<ll> que;
    rep(i, h) {
        string s; cin >> s;
        rep(j, w) {
            string tmp = s.substr(j, 1);
            if(m.count(tmp)) m[tmp]++;
            else m[tmp] = 1;
        }
    }
    for(auto p: m) {
        auto value = p.second;
        que.push(value);
    }
    rep(i, (h/2)*(w/2)) {
        ll num = que.top();
        que.pop();
        if(num < 4) {
            cout << "No" << endl;
            return 0;
        }
        else {
            num -= 4;
            if(num > 0) que.push(num);
        }
    }

    if((h%2) == 0 && (w%2) == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    else if((h%2) == 0 && (w%2) == 1) {
        rep(i, h/2) {
            ll num = que.top();
            que.pop();
            if(num < 2) {
                cout << "No" << endl;
                return 0;
            }
            else {
                num -= 2;
                if(num > 0) que.push(num);
            }
        }
    }
    else if((h%2) == 1 && (w%2) == 0) {
        rep(i, w/2) {
            ll num = que.top();
            que.pop();
            if(num < 2) {
                cout << "No" << endl;
                return 0;
            }
            else {
                num -= 2;
                if(num > 0) que.push(num);
            }
        }
    }
    else {
        rep(i, (h/2)+(w/2)) {
            ll num = que.top();
            que.pop();
            if(num < 2) {
                cout << "No" << endl;
                return 0;
            }
            else {
                num -= 2;
                if(num > 0) que.push(num);
            }
        }
    }
    
    cout << "Yes" << endl;    

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-13;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
char in[310];
int dp[310][310][310];

int solve(int a,int b,int c){
	if(~dp[a][b][c])return dp[a][b][c];
	if(a>b)return 0;
	if(a==b)return 1;

	int ret=0;
	if(in[a]==in[b]){
		ret=max(ret,solve(a+1,b-1,c)+2);
	}
	ret=max(ret,solve(a+1,b,c));
	ret=max(ret,solve(a,b-1,c));
	if(c){
		ret=max(ret,solve(a+1,b-1,c-1)+2);
	}
	return dp[a][b][c]=ret;
}
int main(){
	scanf("%s",in);
	int a;scanf("%d",&a);
	int n=strlen(in);
	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;
	printf("%d\n",solve(0,n-1,a));
}

Measured memory_bytes: 116608
#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

int main(int argc, char *argv[]) {
  int n, b, loop = 1;
  while (cin >> b, b) {
    cin >> n;
    vector<int> wv(n, 0), vv(n, 0);
    for (int i = 0; i < n; i++) {
      int w, v;
      char c;
      cin >> v >> c >> w;
      wv[i] = w;
      vv[i] = v;
    }

    vector<int> res(b + 1, -1), log(b + 1, -1);
    res[0] = 0;
    for (int i = 0; i < n; i++) {
      for (int j = b - wv[i]; j >= 0; j--) {
        if (res[j] >= 0 && res[j] + vv[i] > res[j + wv[i]]) {
          res[j + wv[i]] = res[j] + vv[i];
          log[j + wv[i]] = i;
        }
      }
    }

    auto itr = max_element(res.begin(), res.end());

    cout << "Case " << loop << ':' << endl;
    cout << *itr << endl;
    cout << itr - res.begin() << endl;
    loop++;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int>a(n+1);
  for(int i=0;i<n;i++)
  {
    int p;
    cin>>p;
    a[p]=i+1;
  }
   for(int i=1;i<=n;i++)
  {
    cout<<a[i]<<' ';
  }
  return 0;
}
    

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef int64_t LL;
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MOD=1e9+7;
int main()
{
  int N,pos=0;
  LL A=0,one=0,two=1;
  cin>>N;
  vector<LL> x(N,0);
  rep(i,N){cin>>x.at(i);if(x.at(pos)<x.at(i))pos=i;}
  while(x.at(pos)>0)
  {
    one=0;
    rep(i,N)one+=x.at(i)%2==1,x.at(i)/=2;
    A=(A+((N-one)*one%MOD)*two%MOD)%MOD;two=2*two%MOD;
  }
  return cout<<A<<endl,0;
}

Measured memory_bytes: 2560
input_line = input()
statements = input_line.split(' ')
five=0
seven=0
no=0
for statement in statements:
    if int(statement) == 5:
        five += 1
    elif int(statement) ==7:
        seven += 1
    else:
        no += 1

if five == 2 and seven == 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
# abc175_a.py
# https://atcoder.jp/contests/abc175

global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    S = lines[0]
    # X = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[0].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    if S == 'SSS':
        result = 0
    elif S == 'RRR':
        result = 3
    else:
        if 'RR' in S:
            result = 2
        else:
            result = 1

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['RRS']
        lines_export = [2]
    if pattern == 2:
        lines_input = ['SSS']
        lines_export = [0]
    if pattern == 3:
        lines_input = ['RSR']
        lines_export = [1]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9140
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n][2];
    for(int i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1];
    }
    int flag=0;
    for(int i=2;i<n;i++){
        if(a[i][0]==a[i][1]&&
            a[i-1][0]==a[i-1][1]&&
            a[i-2][0]==a[i-2][1]){
                cout<<"Yes";
                flag=1;
                break;
            }
    }
    if(flag==0) cout<<"No";
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
long long n;
int main(){
	cin>>n;
	for(long long i=0;i<64;i++){
		if((1LL<<i)>n){
			cout<<((1LL<<i)-1);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = []
ct = {}
for i in range(N):
    name = input()
    S.append(name)
    if name in ct:
        ct[name] += 1
    else:
        ct[name] = 1

m = 0

for name in S:
    if ct[name] > m:
        m = ct[name]

ls = []

for name in ct:
    if ct[name] == m:
        ls.append(name)

for name in sorted(ls):
    print(name)

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

int n;
long long s[200010],ans,a[100010],b[100010],c[200010];
int main()
{
 scanf("%d",&n);
 long long ji1=0,ji2=0;
 for(int i=1;i<=n;++i)
 {
  scanf("%lld%lld",&a[i],&b[i]);
  c[i]=a[i];
  c[i+n]=b[i];
  ji1+=a[i];
  ji2+=b[i];
 }
 ans=min(ji1,ji2);
 sort(c+1,c+2*n+1);
 for(int i=1;i<=n;++i)
 s[i]=s[i-1]+c[i];
 for(int i=1;i<=n;++i)
 {
  long long x=a[i],y=b[i];
  if(x>y)
  swap(x,y);
  if(lower_bound(c+1,c+2*n+1,x)-c<=n-2)
  {
   if(lower_bound(c+1,c+2*n+1,y)-c<=n-1)
   ans=min(ans,s[n]);
   else
   ans=min(ans,y+s[n-1]);
  }
  else
  ans=min(ans,x+y+s[n-2]);
 }
 printf("%lld\n",ans);
 return 0;
}

Measured memory_bytes: 4352
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

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

int h,w;
char B[50][51];

vector< pair<int,int> > get_path(int x0,int y0,int x1,int y1){
	bool vis[50][50]={};
	vis[y0][x0]=true;
	static pair<int,int> pre[50][50];

	int head=0,tail=0;
	static pair<int,int> Q[50*50];
	Q[tail++]=make_pair(y0,x0);
	while(head<tail){
		int y=Q[head].first,x=Q[head].second; head++;
		rep(k,4){
			int yy=y+dy[k],xx=x+dx[k];
			if(0<=yy && yy<h && 0<=xx && xx<w && B[yy][xx]=='.' && !vis[yy][xx]){
				vis[yy][xx]=true;
				Q[tail++]=make_pair(yy,xx);
				pre[yy][xx]=make_pair(y,x);
			}
		}
	}

	int y=y1,x=x1;
	vector< pair<int,int> > P(1,make_pair(y1,x1));
	while(y!=y0 || x!=x0){
		pair<int,int> tmp=pre[y][x];
		P.push_back(tmp);
		y=tmp.first;
		x=tmp.second;
	}
	reverse(P.begin(),P.end());
	P.pop_back();
	return P;
}

int main(){
	int n; scanf("%d%d%d",&h,&w,&n);
	rep(i,h) scanf("%s",B[i]);
	int left[50][50],on[50][50],off[50][50];
	rep(i,h) rep(j,w) scanf("%d",left[i]+j);
	rep(i,h) rep(j,w) scanf("%d",on[i]+j);
	rep(i,h) rep(j,w) scanf("%d",off[i]+j);

	vector<int> reach[50][50]; // reach[i][j] := ( マス (i,j) を通る時刻の列 )
	int t=0;
	int y0,x0; scanf("%d%d",&y0,&x0);
	rep(i,n-1){
		int y1,x1; scanf("%d%d",&y1,&x1);
		vector< pair<int,int> > P=get_path(x0,y0,x1,y1);
		rep(j,P.size()){
			reach[P[j].first][P[j].second].push_back(t++);
		}
		x0=x1; y0=y1;
	}
	reach[y0][x0].push_back(t++);

	int ans=0;
	rep(i,h) rep(j,w) {
		int m=reach[i][j].size();
		if(m>0){
			ans+=on[i][j];
			rep(k,m-1){
				int d=reach[i][j][k+1]-reach[i][j][k];
				ans+=min(off[i][j]+on[i][j],d*left[i][j]);
			}
			ans+=off[i][j];
		}
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 6336
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
string s,t;
int m,n;
vector<vector<int>> dp(3000,vector<int>(3000));
int calc(int i,int j){
    if(i==m||j==n){
        return 0;
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    int ans;
    if(s[i]==t[j]){
        ans=1+calc(i+1,j+1);    
    }
    else{
        ans=max(calc(i+1,j),calc(i,j+1));
    }
    return dp[i][j]=ans;
}
void solve(){
    cin>>s>>t;
    m=s.length(),n=t.length();
    dp.assign(m,vector<int>(n,-1));
    int lcs=calc(0,0);
    string res="";
    int sl=0,st=0;
    while(sl<m && st<n){
        if(s[sl]==t[st]){
            res+=s[sl];
            sl++,st++;
        }
        else if(calc(sl+1,st)>calc(sl,st+1)){
            sl++;    
        }
        else{
            st++;
        }
    }
    cout<<res<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 35840
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1LL << 60);
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n, k;
  cin >> n >> k;
  vector<ll> x(n);
  for(ll i = 0; i < n; i++) cin >> x[i];

  ll ans = INF;
  for(ll i = 0; i < n-k+1; i++){
    ll l = x[i], r = x[i+k-1];
    //cout << l << ' ' << r << endl;

    if(r <= 0) ans = min(ans, abs(l));
    else if(l < 0 && r > 0) ans = min(ans, abs(min(abs(r), abs(l))+r-l));
    else if(l >= 0) ans = min(ans, r);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
def main():
    s = input()
    As = []
    Zs = []
    for i in range(len(s)):
        if s[i] == "A":
            As.append(i)
        elif s[i] == "Z":
            Zs.append(i)
    return Zs[-1] - As[0] + 1

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 11196
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long 
#define int long long 
#define vll vector<long long>
#define pii pair<long long ,long long > 
#define vvi vector< vector<long long > > 
#define vpii vector<pair<int,int>> 
#define pll  pair<long long ,long long > 
#define pb  push_back
#define ff  first 
#define sec second  
#define SORT(a) sort(a.begin(),a.end())
#define SORTR(a) sort(a.rbegin(),a.rend()) 
#define m_p make_pair
#define all(x) (x.begin(),x.end()) 
#define sz(v) ((int)(v.size()))
#define endl '\n'
typedef vector< long long > vi ;
const int MOD=1e9 +7 ;
int size=10000000; 
 
int32_t main(){
  fast; 
 /* #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif 
  
*/  int T=1; //cin>>T; 
  while(T--){

    int n; cin>>n;
    vector< vi > dp(n,vi(3,0)); 

    for(int i=0;i<n;i++){
      int a,b,c; cin>>a>>b>>c;

      if(i==0){
        dp[0][0]=a; 
        dp[0][1]=b; 
        dp[0][2]=c; 
      } 
      else{

        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a; 
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b; 
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c; 

      }
    }


    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl; 

  


  }
    


  return 0; 
} 


Measured memory_bytes: 5760
import sys
s = input()
k = int(input())
data = []
start = s[0]
seq = 1
if len(set(list(s))) == 1:
    print(len(s)*k//2)
    sys.exit()
for i in s[1:]:
    if start == i:
        seq += 1
    else:
        data.append(seq)
        start = i
        seq = 1
else:
    data.append(seq)
#print(data)
if s[0] != s[-1]:
    ans = 0
    for i in data:
        ans += i//2
    else:
        print(ans*k)
else:
    pati = data[0] + data[-1]
    ans = pati//2*(k-1)
    for i in range(1,len(data)-1):
        ans += data[i]//2*k
    else:
        print(ans+data[0]//2+data[-1]//2)

Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<map>
using namespace std;
int main() {
	int A;
	int B;
	int C;
	cin >> A >> B >> C;
	if (B + C <= A)
		cout << 0 << endl;
	else
	cout << B + C - A << endl;
	return 0;
}

Measured memory_bytes: 256
MOD = 998244353
n, k = map(int, input().split())
seg = [list(map(int, input().split())) for _ in range(k)]
dp = [0 for _ in range(n+1)]
dp[1] = 1
cum = [0 for _ in range(n+1)]
cum[1] = 1
for i in range(2, n+1):
	for l, r in seg:
		r, l = max(i-l, 0), max(i-r-1, 0)
		dp[i] += cum[r] - cum[l]
		dp[i] %= MOD
	cum[i] = cum[i-1] + dp[i]
	cum[i] %= MOD
print(dp[n])

Measured memory_bytes: 100108
#define _USE_MATH_DEFINES
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <list>
#include <algorithm>
#include <sstream>
#include <set>
#include <math.h>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <numeric>
 
using namespace std;

string s; int P,G,W,L;
 
int main(){
 
cin>>s; 

P=s.size(); 

for(int i=0; i<s.size(); i++) if(s[i]=='g') W++;

for(int i=0; i<s.size(); i++){

  if(P>G){
    if(s[i]=='g') W--; 
    else L++;
    G++; P--;
  }
  
}

cout<<W-L<<endl;

return 0;
 
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int r = Integer.parseInt(in.readLine());
    if(r<1200)
      System.out.println("ABC");
    else if(r<2800)
      System.out.println("ARC");
    else
      System.out.println("AGC");
  }
}


Measured memory_bytes: 21332
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int X = GetInt();
		int A = GetInt();
		Console.WriteLine((X < A) ? 0 : 10);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

//---------------------------

int main(){
    ll n, tmp=0;
    cin >> n;
    VL sum(n);
    rep(i,n){
        ll a;
        cin >> a;
        tmp += a;
        sum[i] = tmp;
    }

    ll ans = (ll)1 << 60; // INF

    // even is pos, odd is neg
    ll accum = 0, cnt = 0;
    if(sum[0] <= 0){
        accum = 1 - sum[0];
        cnt = abs(accum);
    }
    rep2(i,1,n){
        ll x = sum[i] + accum;
        if(i%2==0 && x <= 0){
            accum += abs(x) + 1;
            cnt += abs(x) + 1;
        }else if(i%2==1 && x >= 0){
            accum -= abs(x) + 1;
            cnt += abs(x) + 1;
        }
    }
    chmin(ans, cnt);

    // even is neg, odd is pos
    accum = 0, cnt = 0;
    if(sum[0] >= 0){
        accum = - 1 - sum[0];
        cnt = abs(accum);
    }
    rep2(i,1,n){
        ll x = sum[i] + accum;
        if(i%2==0 && x >= 0){
            accum -= abs(x) + 1;
            cnt += abs(x) + 1;
        }else if(i%2==1 && x <= 0){
            accum += abs(x) + 1;
            cnt += abs(x) + 1;
        }
    }
    chmin(ans, cnt);

    cout << ans << endl;

    return 0;
}

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

int main()
{
  int n,x,t;
  cin>>n>>x>>t;
  int a=0;
  if(n%x==0)
  {
    a=n/x;
  }
  else
  {
    a=n/x;
    a++;
  }
  cout<<a*t;
  return(0);
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
const int N = 202020;
#define ll long long
ll k, n;

ll tieudiet(ll k)
{
    if (k == 1)
        return 1;
    return 2 * tieudiet(k / 2) + 1;
}

int main()
{
    ios::sync_with_stdio(0);
    cin >> k;
    cout << tieudiet(k);
    return 0;
}

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

int *get_list(int);
void sort(int);
void display(int *,int);

int main(){
  int n=0,i=0,j=0,key=0;
  int *list;
  scanf("%d",&n);

  sort(n);
  
  free(list);
  
  return 0;
}
  
int *get_list(int n){
  int *list;
  int i=0;
  
  list = (int *)malloc(sizeof(int)*n);

  if(0 <= n && n <= 100){
    
    for(i=0;i<n;i++){
      
      scanf("%d",list + i);
      
      if(0>list[i] || list[i]>1000){
	printf("error\n");
	exit(8);
      }
      //printf("%d ",*(list+i));
    }
    //printf("\n");
  }
  else{
    printf("error\n");
    exit(8);
  }
  return list;
  }

void sort(int n){
  int i=0,j=0,key=0;
  int *list; 
  list = get_list(n);
  
  display(list,n);
  
  for(i=1; i<n; i++){
    key = list[i];
    j = i-1;
    while(j>=0 && list[j]>key){
      list[j+1] = list[j];
      j--;
    }
    list[j+1]=key;
    display(list,n);
  }
}

void display(int *list,int n){
  int i=0;
  
  for(i=0; i<n; i++){
    if(i)printf(" ");
    printf("%d",list[i]);
  }
  printf("\n");
}



Measured memory_bytes: 2128
#include<bits/stdc++.h>
const int two[6]={0,2,4,8,16,32};
int n,m,ans;
using namespace std;

int main()
{
  scanf("%d%d",&n,&m);
  ans=two[m]*((n-m)*100+m*1900);
  printf("%d",ans);
return 0;
}

Measured memory_bytes: 256
def calc(w, h, v, t, x, y, p, q)
  c = 0
  d = v * t
  (-d / w - 2 .. d / w + 2).each do |i|
    tx = i * w + (i.odd? ? w - p : p)
    next if (tx - x).abs > d
    dy = Math::sqrt(d ** 2 - (tx - x) ** 2);
    next if (q - y).abs > dy
    r = [ (dy + y) / h, -(dy - y) / h - 1 ].map(&:to_i)
    r[1] -= 1 if y > dy
    if r[0] == r[1]
      c += 1 if (tx - x) ** 2 + (q - y) ** 2 <= d * d
    else
      c += r[0] - r[1] - 1;
      r.each do |k|
        ty = k * h + (k.odd? ? h - q : q);
        c += 1 if (tx - x) ** 2 + (ty - y) ** 2 <= d * d
      end
    end
  end
  c
end
1.times do
  w, h, v, t, x, y, p, q = gets.split.map(&:to_i)
  puts calc(w, h, v, t, x, y, p, q)
end

Measured memory_bytes: 8816
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double[] P = new double[N];
        for(int i=0;i<N;i++){
            P[i] = sc.nextDouble();
        }
        double[][] dp = new double[N + 1][N + 1];
        dp[0][0] = 1.0;
        for(int j=1;j<N+1;j++){
            dp[0][j] = 0;
        }
        for(int i=1;i<N+1;i++){
            for(int j=0;j<=i;j++){
                if(j==0){
                    dp[i][j] = dp[i - 1][j] * (1 - P[i - 1]);
                }else{
                    dp[i][j] = dp[i - 1][j - 1] * P[i - 1] + dp[i - 1][j] * (1 - P[i - 1]);
                }
            }
        }
        double sum = 0;
        for(int i=(N/2)+1;i<N+1;i++){
            sum += dp[N][i];
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 123452
import java.util.*;

class Main{
    public static boolean check(ArrayList<Integer> a, int N, int K) {
        int M = a.size();
        int offset = 0;

        for (int i = 0; i < M; ++i) {
            int l = a.get(i);
            for (int j = 0; j < l; j++){
                if (offset + j + K > N) break;
                if (offset + l - K >= 0) return true;
            }
            offset += l;
        }
        return false;
    }

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

        int N = s.length();
        ArrayList<Integer> a = new ArrayList<>();
        for(int i = 0; i < N;) {
            int j;
            for (j = i; j < N && s.charAt(i) == s.charAt(j); ++j) ;
            a.add(j - i);
            i = j;
        }

        int l = 1, u = N+1;
        while (u - l > 1) {
            int c = (l + u) / 2;
            boolean res = check(a, N, c);
            Collections.reverse(a);
            res = res || check(a, N, c);

            if (res) {
                l = c;
            } else {
                u = c;
            }
        }
        System.out.println(l);
    }
}

Measured memory_bytes: 27244
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int len=s.size();
	bool v=0;
	for(int i=0;i<len;i++)
	{
		if(!v) {if(s[i]=='C') v=1;}
		else {if(s[i]=='F') {printf("Yes");return 0;}}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a=n%10;
    if(a==3)
        cout<<"bon"<<endl;
    else if(a==0||a==1||a==6||a==8)
        cout<<"pon"<<endl;
    else
        cout<<"hon"<<endl;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Main
{
    class Program
    {
        static void Main(string[] arg)
        {

            //string[] nm = Console.ReadLine().Split(' ');
            //int n = int.Parse(nm[0]);
            //int m = int.Parse(nm[1]);
            int[] line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Console.WriteLine(line[0] * line[1] * 0.5);
            //Console.ReadLine();

        }
    }
}


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

string s;
int n, b[80001], dp[11];

void solve(string s){
	memset(dp, 0, sizeof(dp));
	n = s.size();
	for(int i=0; i<n; ++i)
		b[i+1] = s[i] - '0';
	for(int i=1; i<=n; ++i){
		if(i & 1) b[i] *= -1;
		b[i] += b[i-1];
		b[i] %= 11;
		if(b[i] < 0) b[i] += 11;
	}
//	for(int i=0; i<=n; ++i)
//		cout << i << " " << b[i] << "\n";
	int ans = 0;
	++dp[0];
	for(int i=1; i<=n; ++i){
//		cout << i << " " << ans << "\n";
		ans += dp[b[i]];
		if(b[i] == b[i-1]) --ans;
		else ++dp[b[i]];
	}
	cout << ans << "\n";
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1){
		cin >> s;
		if(s == "0") return 0;
		solve(s);
	}
}


Measured memory_bytes: 3540
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

N = int(input())
H = MAP()

dp = [0] * (N)

for i in range(N):
	if i+1 == len(H):continue
	if H[i+1] <= H[i]:
		dp[i+1] = dp[i]+1

print(max(dp))

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	string s; cin >> s;
	vi num(4);
	rep(i, 4) num[i] = int(s[i] - '0');

	const int n = 3;
	rep(bit, (1<<n)){
		vector<char> op;
		int res = num[0];
		rep(i, n){
			if(bit & (1<<i)){
				res += num[i+1];
				op.push_back('+');
			}
			else{
				res -= num[i+1];
				op.push_back('-');
			}
		}

		if(res == 7){
			rep(i, 4){
				cout << num[i];
				if(i != 3) cout << op[i];
			}
			cout << "=7\n";
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(str, input().split()))
dic = {}
for num in a:
    if num in dic:
        dic[num] += 1
    else:
        dic[num] = 1
ans = 0
for num in dic:
    if int(num) > dic[num]:
        ans += dic[num]
    else:
        ans += min(dic[num], abs(int(num)-dic[num]))
print(ans)


Measured memory_bytes: 20984
using System;
using System.Linq;
using System.Collections.Generic;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            long MOD = 1000000000+7;

            long Power = 1;

            while(n>0)
            {
                Power = (Power*n % MOD);
                n--;
            }

            Console.WriteLine(Power);
        }
    }
}


Measured memory_bytes: 13140
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] x = new long[n];
    long[] y = new long[n];
    long[] h = new long[n];
    long X = 0;
    long Y = 0;
    long H = 0;
    for(int i = 0; i < n; i++) {
      x[i] = sc.nextLong();
      y[i] = sc.nextLong();
      h[i] = sc.nextLong();
      if(h[i] > 0) {
        X = x[i];
        Y = y[i];
        H = h[i];
      }
    }
    long ansx = 0;
    long ansy = 0;
    long ansh = 0;
    for(long cx = 0; cx <= 100; cx++) {
      for(long cy = 0; cy <= 100; cy++) {
        long th = H + Math.abs(X - cx) + Math.abs(Y - cy);
        int p = 0;
        for(int i = 0; i < n; i++) {
          long t = Math.max(th - Math.abs(x[i] - cx) - Math.abs(y[i] - cy), 0);
          if(t != h[i]) p++;
        }
        if(p == 0) {
          ansx = cx;
          ansy = cy;
          ansh = th;
        }
      }
    }
    System.out.println(ansx + " " + ansy + " " + ansh);
  }
}


Measured memory_bytes: 23636
#include <cstdio>
#include <vector>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int N, L, a[100009], dp[100009]; vector<int> x[50009];
int main() {
	scanf("%d%d", &N, &L);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		x[a[i]].push_back(i + 1);
	}
	for (int i = L - 1; i >= 1; i--) {
		for (int j : x[i]) {
			dp[j] = max(dp[j - 1], dp[j + 1]) + (L - a[j - 1]);
		}
	}
	printf("%d\n", *max_element(dp, dp + N + 1));
	return 0;
}

Measured memory_bytes: 5908
N,Y=map(int, input().split())

x=y=z=-1

for i in range(N+1):
    if i*10000>Y:
        continue
    for j in range(N+1):
        if i*10000+j*5000>Y:
            continue
        elif (N-i-j)*1000+j*5000+i*10000==Y:
            x=i
            y=j
            z=N-j-i
            break

print(x,y,z)


Measured memory_bytes: 3064
import networkx as nx

H, W = map(int, input().split())
maze = [input() for _ in range(H)]

G = nx.grid_2d_graph(H, W)
for h in range(H):
    for w in range(W):
        # 壁に入る辺を削除
        if maze[h][w] == '#':
            for dh, dw in ((1, 0), (0, 1), (-1, 0), (0, -1)):
                if ((h - dh, w - dw), (h, w)) in G.edges():
                    G.remove_edge((h - dh, w - dw), (h, w))


def bfs(sy, sx):
    d = dict()
    d[(sy, sx)] = 0
    for coordinate_from, coordinate_to in nx.bfs_edges(G, (sy, sx)):
        d[coordinate_to] = d[coordinate_from] + 1
    return max(d.values())


ans = 0
for y in range(H):
    for x in range(W):
        if maze[y][x] == '.':
            ans = max(ans, bfs(y, x))
print(ans)


Measured memory_bytes: 53624
#include <iostream>
#include <vector>

using namespace std;

int main( void )
{
	long double a;
	while ( cin >> a )
	{
		vector <long double> s(20);
		s[1] = a;
		for ( int i = 2; i <= 10; i++ )
		{
			if ( i % 2 == 0 )
			{
				s[i] = s[i-1] * 2.0;
			}
			else
			{
				s[i] = s[i-1] / 3.0;
			}
		}

		double kotae = 0.0;
		for ( int i = 1; i <= 10; i++ )
		{
			kotae += s[i];
		}

		cout.setf( ios::fixed );
		cout.precision( 8 );
		cout << kotae << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
int n;
cin >> n;
int ans = 180*(n-2);
cout << ans << endl;
}


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

public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();
		int num = Integer.parseInt(str);

		int h;
		int m;
		int s;

		s = num%60;
		m = num/60%60;
		h = num/60/60;

		System.out.println(h + ":" + m + ":" + s);
	}

}

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

#define watch(x) cout << (#x) << " = " << (x) << endl
#define PI double(2 * acos(0.0))
#define LL long long
#define MOD 1000000007
#define PB push_back 
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define PPIII pair < pair <int, int> , int>
#define PIPII pair < int, pair <int, int> >
long long dp[405][405];
long long ans = 0;
long long prefix[405];
long long find(long long array[], int n, int x, int y)  {
    if(y < x)   {
        return 0;
    }
    if(dp[x][y] != -10) {
        return dp[x][y];
    }
    if(x == y)  {
        dp[x][y] = array[x];
        return dp[x][y];
    }
    dp[x][y] = LONG_MAX;
    int min_index = 0;
    for(int i = x; i < y; i++)  {
        dp[x][y] =  min(dp[x][y], prefix[y] - prefix[x-1] + find(array, n, x, i) + find(array, n, i+1, y));
    } 
    return dp[x][y];
}
int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    long long array[n+1];
    for(int i = 1; i <= n; i++)  {
        cin >> array[i];
    }
    prefix[1] = array[1];
    for(int i = 2; i <= n; i++) {
        prefix[i] = prefix[i - 1] + array[i];
    }
    for(int i = 1; i < 405; i++)    {
        for(int j = 1; j < 405; j++)    {
            dp[i][j] = -10;
        }
    }

    find(array, n, 1, n);
    cout << dp[1][n] - prefix[n];
    return 0;
}


Measured memory_bytes: 1536
import sys
array = [0,0,0,0,0,0]
for I in range(len(array)):
    array[I] = int(input())
    if not ( 0 <= array[I] <= 123 ):
        sys.exit()
print('Yay!') if (array[4] - array[0]) <= array[-1] else print(':(')

Measured memory_bytes: 9120
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int n, m;
    std::cin>>n>>m;

    std::cout<<(n - 1) * (m - 1)<<std::endl;
    return 0;
}

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

class UnionFind {
public:
    explicit UnionFind(int n)
        : roots(n)
        , sizes(n, 1)
    {
        iota(begin(roots), end(roots), 0);
    }

    // 頂点xの属する木の根である頂点を探す
    int find_root(int x) const
    {
        if (x == roots[x]) {
            return x;
        }
        roots[x] = find_root(roots[x]);
        return roots[x];
    }

    // 頂点x、頂点yが属する木を連結する
    void unite(int x, int y)
    {
        // 頂点x、頂点yのそれぞれの木の根rx、ryを得る
        auto rx = find_root(x);
        auto ry = find_root(y);

        // すでに同じ木かどうかチェック
        if (rx == ry) {
            return;
        }

        // 大きい方の木の下に小さい方の木を連結するようにする
        // (rxのほうが小さい時はrxとryを入れ替える)
        if (sizes[rx] < sizes[ry]) {
            swap(rx, ry);
        }

        // ryをrxに属するようにする
        roots[ry] = rx;
        sizes[rx] += sizes[ry];
        sizes[ry] = 0;
    }

    // 頂点xと頂点yが同じ木に属するならtrue、そうでなければfalseを返す
    bool same(int x, int y) const
    {
        return find_root(x) == find_root(y);
    }

    // 頂点xが属する木の大きさを返す
    int size(int x) const
    {
        return sizes[find_root(x)];
    }
private:
    mutable vector<int> roots; // 頂点iの属する木の根を持つ(roots[i]が頂点iの属する木の根)
    vector<int> sizes; // 木の根iに属する頂点の数(木のサイズ)
};

void solve(long long N, long long M, std::vector<long long> X, std::vector<long long> Y, std::vector<long long> Z)
{
    UnionFind uf(N + 1);

    for (ll i = 0; i < M; i++) {
        uf.unite(X[i], Y[i]);
    }

    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        if (uf.find_root(i) == i) {
            ans++;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
#pragma GCC diagnostic ignored "-Wunused-result"
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> X(M);
    std::vector<long long> Y(M);
    std::vector<long long> Z(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
        scanf("%lld",&Z[i]);
    }
    solve(N, M, std::move(X), std::move(Y), std::move(Z));
    return 0;
}


Measured memory_bytes: 3456
K = int(input())-1
lst = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(lst[K])

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

int main()
{
	int a,b,c,d,sum=0;
	string s;

	cin>>a>>b>>c>>d;
    if((a+b)==(c+d))
        cout<<"Balanced";
    else if((a+b)>(c+d))
        cout<<"Left";
    else
    {
        cout<<"Right";
    }
    
	
	return 0;
}
	

Measured memory_bytes: 256