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

using namespace std;

#define pii pair<int,int>
#define pb push_back
#define ll long long
#define MOD 1000000007

ll fact[1000] = {0};
ll factorial(int n){
    if (n >= 0) {
        fact[0] = 1;
        for (int i=1;i<=n;++i) fact[i] = i * fact[i - 1];
        return fact[n];
    } else return -1;
}

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

int toint(const string &s) { 
    stringstream ss(s);
    int x; 
    ss >> x; 
    return x; 
}
int main() {
  ll h,n;
  cin>>h>>n;
  
  ll sum = 0;
  
  for(int i=0;i<n;i++) {
    ll temp;
    cin>>temp;
    sum+=temp;
    
    if(sum >= h) {
      cout<<"Yes";
      break;
    }
  }
  
  if(sum < h) cout<<"No";
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define R return
#define MEM(dp,i) memset(dp,i,sizeof(dp))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll inf=(1ll<<60);
const int MX = 300009;

int main(){
    int A,B;
    scanf("%d%d",&A,&B);
    if(A==B){
        puts("Draw");
        R 0;
    }
    if(A==1){
        puts("Alice");
        R 0;
    }
    if(B==1){
        puts("Bob");
        R 0;
    }
    if(A>B)puts("Alice");
    else puts("Bob");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef vector<int,vector<int>> vvec;
typedef long double ld;

//----***Like a Pythonista***----
#define REP(i,j,n) for (ll i=j;i<(n);i++)
#define RREP(i,n,j) for (ll i = n; j<i;i--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(all(__VA_ARGS__),0LL)
#define dsum(...) accumulate(all(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(all(a)); }
template<class T> inline auto min(const T& a){ return *min_element(all(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
const int MOD=1000000007;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***----
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define HERE  cout<<"Here"<<endl;

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

map<ll,ll> prime_factor(ll n){
    map<ll,ll> res;
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            ++res[i];
            n/=i;
        }
    }
    if(n!=1) res[n]=1;
    return res;
}

signed main(){
  int A,B;cin>>A>>B;
  map<ll,ll> A_P=prime_factor(A),B_P=prime_factor(B),ans_P;
  int ans=0;
  each(m,A_P){
    if(B_P[m.first]){ans++;};
  }
  print((ans+1))

}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            long N = cin.ReadLong;
            long[] A = cin.ReadLongArray(N);
            long[] B = new long[N];
            for (long i = 0; i < N; i++)
            {
                long j = A[i];
                B[j - 1] = i + 1;
            }
            for (long i = 0; i < N; i++)
            {
                Console.Write(B[i] + " ");
            }


        }
            

                
    }  
            


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}


Measured memory_bytes: 29912
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

const string YES = "Yes";
const string NO = "No";

void solve(std::vector<std::vector<long long>> A, long long N, std::vector<long long> b){
    set<ll> rec;
    REP(i, N) rec.insert(b[i]);
    vector<vb> r(3, vb(3, false));
    REP(i, 3) REP(j, 3) if(rec.count(A[i][j])) r[i][j] = true;
    if(r[0][0] && r[0][1] && r[0][2]) {cout<<YES<<endl;return;}
    if(r[1][0] && r[1][1] && r[1][2]) {cout<<YES<<endl;return;}
    if(r[2][0] && r[2][1] && r[2][2]) {cout<<YES<<endl;return;}
    if(r[0][0] && r[1][0] && r[2][0]) {cout<<YES<<endl;return;}
    if(r[0][1] && r[1][1] && r[2][1]) {cout<<YES<<endl;return;}
    if(r[0][2] && r[1][2] && r[2][2]) {cout<<YES<<endl;return;}
    if(r[0][0] && r[1][1] && r[2][2]) {cout<<YES<<endl;return;}
    if(r[0][2] && r[1][1] && r[2][0]) {cout<<YES<<endl;return;}
    cout<<NO<<endl;
}

int main(){
    std::vector<std::vector<long long>> A(3, std::vector<long long>(3));
    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    long long N;
    scanf("%lld",&N);
    std::vector<long long> b(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&b[i]);
    }
    solve(std::move(A), N, std::move(b));
    return 0;
}


Measured memory_bytes: 256
function ary2(y,x){x=x||y;return Array(y).fill(0).map(a=>Array(x).fill(0));}
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  one: function(f){return this.a(f);},
  single: function(f){return this.a(f);},
  l: function(f){
    var s = this._s, y = this._y;
    s[y] = typeof s[y] === "string" ? s[y].split(" ") : s[y].reverse();
    this._y++;
    return f?s[y]:s[y].map(a=>+a);
  },
  line: function(f){return this.l(f);},
  row: function(f){return this.l(f);},
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
  matrix: function(n,f){return this.m(n,f);},
  ary: function(n,m){
    var s = this._s, y = this._y, r = ary2(n+1);
    for(var i = 0; i < m; i++){
      var t = s[y+i].split(" ");
      r[t[0]][t[1]]++;
    }
    this._y += m;
    return r;
  },
};
var a=[],b=[];
function root(a,x){return a[x]===x?x:a[x]=root(a,a[x]);}
function same(a,x,y){return root(a,x)===root(a,y);}
function unite(a,x,y){x=root(a,x);y=root(a,y);if(x===y)return;a[x]=y;}
var o = new gets(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a(), k = o.a(), l = o.a();
  for(var i = 0; i <= n; i++)a[i] = b[i] = i;
  for(i = 0; i < k; i++){
    var t = o.l();
    unite(a,t[0],t[1]);
  }
  for(i = 0; i < l; i++){
    t = o.l();
    unite(b,t[0],t[1]);
  }
  var u = [], v = {}, ans = [];
  for(i = 0; i < n; i++){
    u[i] = root(a,i+1)+","+root(b,i+1);
    if(v[u[i]])v[u[i]]++; else v[u[i]] = 1;
  }
  for(i = 0; i < n; i++){
    ans[i] = v[u[i]];
  }
  return ans.join(" ");
}

Measured memory_bytes: 147064
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

    int n; cin>>n;
    string s; cin>>s;

    int c1 = 0, c2 = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R')c1++;
        else c2++;
    }
    int c3 = 0;
    for(int i = 0; i < n - c2; i++){
        if(s[i] == 'W')c3++;
    }

    cout<<min({c1, c2, c3})<<"\n";




}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1) res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 3704
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    K = int(input())
    print("ACL" * K)


if __name__ == '__main__':
    main()

Measured memory_bytes: 72740
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  cout << a + b/2 << endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static long MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        long[] min = new long[n+1];
        min[0] = 0;
        for (int i = 1; i < n+1; i++) {
            min[i] += min[i-1] + i;
        }
        // System.out.println(Arrays.toString(min));
        
        long[] max = new long[n+1];
        max[0] = n;
        for (int i = 1; i < n+1; i++) {
            max[i] += max[i-1] + n-i;
        }
        // System.out.println(Arrays.toString(max));
        
        long ans = 0;
        for (int i = k-1; i < n+1; i++) {
            ans += max[i] - min[i] + 1;
            ans %= MOD;
            // System.out.println(ans);
        }
        System.out.println(ans);
        
        
    }
}


Measured memory_bytes: 38832
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int  n;
int res[505][505];
void dfs(int start,int to,int index){
	if(to-start+1<=1) return;
	for(int i=start;i<to;i++)
	       for(int j=i+1;j<=to;j++) {res[i][j]=index;
		  		}
	int mid=(start+to)>>1;
	dfs(start,mid,index+1),dfs(mid+1,to,index+1);
	}
	int main(){
	cin>>n;
	dfs(1,n,1);
	for(int i=1;i<n;i++)
	for(int j=i+1;j<=n;j++)
	cout<<res[i][j]<<" ";
}


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

int main(){
  int e[20][2] = {}, a, b = 0;

  for(int i = 0; i < 12; i++){
    cin>>a;
    
    for(int j = 0; j < 12; j++){
      if(e[j][0] == 0){
	e[j][0] = a;
	e[j][1]++;
	break;
      } else if (e[j][0] == a){
	  e[j][1]++;
	  break;
	}
    }
  }

  for(int j = 0; j < 12; j++){
    if(e[j][1]%4 == 0){
      b += e[j][1]/4;
    }
  }

  if(b == 3) cout<<"yes"<<endl;
  else cout<<"no"<<endl;
  return 0;
}



Measured memory_bytes: 3080
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(long long i = 0; i < (n); i++)
using namespace std;
int main()
{
    const long long INF = 100000000;
    long long N, M, R, ans = INF;
    cin>>N>>M>>R;
    vector<long long>r(R);
    rep(i,R){
        cin>>r[i];
        --r[i];
    }
    vector<vector<long long>>adj(N,vector<long long>(N, INF));
    rep(i,N) adj[i][i] = 0;
    
    rep(i,M){
        long long A, B, C;
        cin>>A>>B>>C;
        --A;
        --B;
        adj[A][B] = adj[B][A] = C;
    }

    rep(k,N){
        rep(i,N){
            rep(j,N){
                if(adj[i][k] != INF && adj[k][j] != INF){
                    adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);
                }
            }
        }
    }

    sort(r.begin(), r.end());
    do{
        long long a = 0;
        rep(i,R-1){
            if(adj[r[i]][r[i+1]] != INF) a += adj[r[i]][r[i+1]];
        }
        ans = min(ans,a);
    }while(next_permutation(r.begin(), r.end()));

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    int n,x,y;
    cin >> n >> x >> y;
    x--; y--;
    vector<int> ans(n,0);
    rep(i,n) {
        vector<int> dis(n,inf);
        vector<bool> seen(n,false);
        priority_queue<P,vector<P>,greater<P>> q;
        q.emplace(0,i);
        while(!q.empty()) {
            int nf = q.top().first;
            int ns = q.top().second;
            q.pop();
            if(seen[ns]) continue;
            seen[ns] = true;
            dis[ns] = nf;
            vector<int> can;
            if(ns > 0) can.pb(ns-1);
            if(ns < n-1) can.pb(ns+1);
            if(ns == x) can.pb(y);
            if(ns == y) can.pb(x);
            for(int j : can) {
                if(seen[j]) continue;
                if(dis[j] > nf+1) q.emplace(nf+1,j);
            }
        }
        rep2(j,i+1,n) if(dis[j] < n) ans[dis[j]]++;
    }
    rep2(i,1,n) cout << ans[i] << endl;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))

lst=0
  
for i in range(N):
  if A[i]%2==0:
    if A[i]%3!=0 and A[i]%5!=0:
      lst+=1
      break

    
if lst==1:
  print('DENIED')
else:
  print('APPROVED') 

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

int bubbleSort(int A[],int N){
	int sw=0;
	bool flag=1;
	for(int i=0;flag;i++){
		flag=0;
		for(int j=N-1;j>=i+1;j--){
			if(A[j]<A[j-1]){
				swap(A[j],A[j-1]);
				flag=1;
				sw++;
			}
		}
	}
	return sw;
}
int main(){
	int A[100],N,sw;
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	sw=bubbleSort(A,N);
	for(int i=0;i<N;i++){
		if(i)cout<<" ";
		cout<<A[i];
	}
	cout<<endl;
	cout<<sw<<endl;
	
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    ll a[n], b[n];
    rep(i, 0, n){
        cin >> a[i] >> b[i];
    }

    ll count = 0;
    rrep(i, n - 1, 0){
        a[i] += count;
        if(a[i] % b[i] != 0){
            count += b[i] - a[i] % b[i];
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 1792
s = input()
q = int(input())
for _ in range(q):
    L = input().split()
    a, b = int(L[1]), int(L[2])
    if L[0] == 'print':
        print(s[a:b+1])
    elif L[0] == 'reverse':
        s = s[:a] + s[a:b+1][::-1] + s[b+1:]
    elif L[0] == 'replace':
        s = s[:a] + L[3] + s[b+1:]

Measured memory_bytes: 7652
package main
 
import (
    "fmt"
)
 
func main() {
		var s, ans string
		var n,l int
		fmt.Scan(&n)
		fmt.Scan(&s)
		
		l = n/2
		if n%2 == 0{
			if s[:l] == s[l:]{
				ans = "Yes"
			}else{
				ans = "No"
			}
		}else{
			ans = "No"
		}
		fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long l;
int main()
{
    l x1,x2,x3,x4,x5;
    cin>>x1>>x2>>x3>>x4>>x5;
    if(x1==0) cout<<1;
    else if(x2==0) cout<<2;
    else if(x3==0) cout<<3;
    else if(x4==0) cout<<4;
    else cout<<5; 
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
using namespace std;
int main(){
	int n;	cin>>n;
	int data[101][101];
	memset(data,0,sizeof(data));
	int id,num,rout;
	for(int i=0;i<n;i++){
		cin>>id>>num;
		id--;
		for(int j=0;j<num;j++){
			cin>>rout;
			data[id][rout-1]=1;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(j)	cout<<" ";
			cout<<data[i][j];
		}
		cout<<endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    string s = "No";

    for(int i=1; i<=9; i++) {
        for(int j=1; j<=9; j++) {
            if(i*j == n) {
                s = "Yes";
                break;
            }
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t; cin >> s >> t;
  int n = s.length(), m = t.length();
  vector<string> v;
  for(int i = 0; i <= n - m; i++){
    bool flg = false;
    string u = s;
    string ans = "";
    int cnt = 0;
    for(int j = 0; j < m; j++){
      if(s[i+j] == t[j] || s[i+j] == '?') cnt++;
    }
    if(cnt == m){
      for(int j = 0; j < m; j++)
        u[i+j] = t[j];
      flg = true;
    }
    if(flg){
      for(int i = 0; i < n; i++){
        if(u[i] == '?') ans += "a";
        else ans += u[i];
      }
      v.push_back(ans);
    }
  }
  if(v.empty()){
    cout << "UNRESTORABLE" << endl;
  }
  else{
    string ans = v[0];
    for(int i = 1; i < v.size(); i++){
      if(ans > v[i]) ans = v[i];
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
Als = []
Bls = []
ans = 'No'
if Bls == Als:
    ans = 'Yes'
for i in range(N):
    Als.append(input())
for i in range(M):
    Bls.append(input())
for i in range(N-M):
    for j in range(0,N-M):
        for k in range(M):
            if Bls[k] == Als[i+k][j:M+j]:
                ans = 'Yes'
            else:
                ans = 'No'
                break
        if ans == 'Yes':
            break
    if ans == 'Yes':
        break
print(ans)

Measured memory_bytes: 9188
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    V< V<int> > c(10, V<int>(10)), a(h, V<int>(w));
    for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) cin >> c[i][j];
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> a[i][j];
    for (int k = 0; k < 10; k++) for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) chmin(c[i][j], c[i][k] + c[k][j]);
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] >= 0) ans += c[a[i][j]][1];
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 384
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template< typename T > istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,c;
    cin>>n>>c;
    int d[c][c];
    rep(i,c){
        rep(j,c){
            cin>>d[i][j];
        }
    }
    int cc[n][n];
    vec a0(c);
    vec a1(c);
    vec a2(c);
    rep(i,n){
        rep(j,n){
            cin>>cc[i][j];
            cc[i][j]--;
            if((i+j)%3==0) a0[cc[i][j]]++;
            if((i+j)%3==1) a1[cc[i][j]]++;
            if((i+j)%3==2) a2[cc[i][j]]++;
        }
    }
    ll ans=INF;
    rep(i,c){
        rep(j,c){
            if(i==j) continue;
            rep(k,c){
                if(j==k||i==k) continue;
                int memo=0;
                rep(l,c){ // lは色
                    memo+=d[l][i]*a0[l];
                    memo+=d[l][j]*a1[l];
                    memo+=d[l][k]*a2[l];
                }
                chmin(ans,memo);
            }
        }
    }
    cout<<ans<<endl;
    
}

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

int main()
{
 int n,m;
    cin>>n;
     int t[n];
     int s[n];
        for(int a=0;a<n;a++)
        {
            cin>>t[a];

            s[a]=t[a];
        }
        cin>>m;
        int p[m]={0};
        int x[m]={0};
        int sum[m]={0};
        for(int a=0;a<m;a++)
        {
           cin>>p[a]>>x[a];
        }
        for (int z=0;z<m;z++)
        {
            for(int j=0;j<n;j++)
            {
                if(p[z]==(j+1))
                {
                    t[j]=x[z];
                }
                    sum[z]+=t[j];
                    t[j]=s[j];
            }
        }
        for(int z=0;z<m;z++)
        {
            printf("%d \n",sum[z]);
        }
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    stdin.byLine().map!(to!int)
        .map!(d=>iota(600/d).map!(i=>i*i*d*d*d).reduce!"a+b"())
        .map!(to!string).join("\n").writeln();
}

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

const int mod = 1e9 + 7;

ll n, m, ans;

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

  if (abs(n - m) > 1) {
    cout << 0 << endl;
    return 0;
  }
  if (n == m)
    ans = 2;
  else
    ans = 1;
  for (int i = 1; i <= n; ++i) ans = ans * i % mod;
  for (int j = 1; j <= m; ++j) ans = ans * j % mod;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#define ll long long 
#define pb push_back
#include<string>
#include<cctype>
using namespace std;
	
int main()
{
	 ios_base::sync_with_stdio(false);
	cin.tie(0);
	 ll a;
    long double b;
    cin >> a >> b;
    b *= 100;
    ll bb = (b + 0.1);
    ll c = a * bb;
    c /= 100;
cout<<c<<endl;
    return 0;   
 

}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;

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

	ll ans=0;
	if(m>n*2){
		ans+=n+(m-n*2)/4;
	}else{
		ans+=m/2;
	}

	cout<<ans<<endl;

}


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

using namespace std;
using ll = long long;

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

  int n, m;
  cin >> n >> m;
  priority_queue<ll> a;
  for (int i = 0; i < n; i++) {
    ll x;
    cin >> x;
    a.push(x);
  }

  while (m-- > 0) {
    auto x = a.top();
    a.pop();
    a.push(x / 2);
  }

  ll ans = 0;
  while (!a.empty()) {
    ans += a.top();
    a.pop();
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4204
#include <bits/stdc++.h>
#define MAXN 200100
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e9 + 7;
int roads[MAXN], rails[MAXN];
map <pii, int> freq;

int find_road(int i){
    return roads[i] = (i == roads[i]? i : find_road(roads[i]));
}
int find_rail(int i){
    return rails[i] = (i == rails[i]? i : find_rail(rails[i]));
}
void merge_road(int a, int b){
    int fa = find_road(a);
    int fb = find_road(b);

    if (fa != fb){
        roads[fb] = fa;
    }
}

void merge_rail(int a, int b){
    int fa = find_rail(a);
    int fb = find_rail(b);

    if (fa != fb){
        rails[fb] = fa;
    }
}

int main (){
    ios_base::sync_with_stdio(false);
    int n, k, l, a, b;

    cin >> n >> k >> l;

    for (int i=1; i<=n; i++){
        rails[i] = i;
        roads[i] = i;
    }

    for (int i=0; i<k; i++){
        cin >> a >> b;
        merge_road(a ,b);
    }

    for (int i=0; i<l; i++){
        cin >> a >> b;
        merge_rail(a, b);
    }

    for (int i=1; i<=n; i++){
        freq[{find_road(i),find_rail(i)}]++;
    }

    for (int i=1; i<=n ; i++){
        cout << freq[{find_road(i),find_rail(i)}] << " ";
    }
    cout << endl;
    return 0;
}

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

int main()
{
    char x;
    cin >> x;

    if (isupper(x))
        cout << 'A' << endl;
    else
        cout << 'a' << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;

int main(void){
  int i,N,K;
  cin >> N >> K;
  vector<ll> v(N);
  REP(i,N) cin >> v[i];
  ll mini=1e9,calc;
  int k=K-1;
  REP(i,N-k){
    if(v[i]*v[i+k] < 0) calc=2*min(abs(v[i]),abs(v[i+k]))+max(abs(v[i]),abs(v[i+k]));
    else calc=max(abs(v[i]),abs(v[i+k]));
    if(mini>calc)mini=calc;
  }
  cout << mini << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main( void ){
	int a,b,k,turn=0;
	scanf("%d%d%d",&a,&b,&k);

	while( k>0 ){
		if( turn==0 ){
			if( a%2==1 ) a--;
			b += a/2;
			a = a/2;
			turn=1;
		}else{
			if( b%2==1 ) b--;
			a += b/2;
			b = b/2;
			turn=0;
		}
		k--;
	}
	printf("%d %d\n",a,b);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#define inf (int)(1e9)

signed compair(const void *a, const void *b){
	return *(int *)a - *(int *)b;
}

int min(int a, int b){
	return a <= b ? a : b;
}

int main(){
	int H, W, N, i, j, now, next, thenj, ans = inf;
	scanf("%d%d%d", &H, &W, &N);
	int *L = (int *)malloc(sizeof(int) * (W + 1));
	for(i = 0; i < W; i++){
		L[i] = 1;
	}
	int *X = (int *)malloc(sizeof(int) * N);
	int *Y = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d%d", &X[i], &Y[i]);
		X[i]--;
		Y[i]--;
		L[Y[i]]++;
	}
	int **yoko = (int **)malloc(sizeof(int *) * (W + 1));
	for(i = 0; i < W; i++){
		yoko[i] = (int *)malloc(sizeof(int) * L[i]);
		yoko[i][0] = H;
		L[i] = 1;
	}
	yoko[W] = (int *)malloc(sizeof(int) * (H + 1));
	for(i = 0; i <= H; i++){
		yoko[W][i] = i;
	}
	L[W] = H + 1;
	for(i = 0; i < N; i++){
		yoko[Y[i]][L[Y[i]]] = X[i];
		L[Y[i]]++;
	}
	for(i = 0; i <= W; i++){
		qsort(yoko[i], L[i], sizeof(int), compair);
	}
/*	printf("yoko:\n");
	for(i = 0; i <= W; i++){
		for(j = 0; j < L[i]; j++){
			printf("%d ", yoko[i][j]);
		}
		printf("\n");
	}
	printf("\n");
*/	for(i = 0, now = 0; i < W; i++){
//		printf("i = %d\n", i);
//		printf("now = %d\n", now);
		next = inf;
		for(j = 0; j < L[i]; j++){
			if(yoko[i][j] > now){
				next = min(next, yoko[i][j]);
			}
		}
//		printf("next = %d\n", next);
		ans = min(ans, next);
		thenj = inf;
		for(j = 0; j < L[i + 1]; j++){
			if(yoko[i + 1][j] > now){
				thenj = min(thenj, j);
			}
		}
//		printf("thenj = %d\n", thenj);
		if(yoko[i + 1][thenj] > now + 1){
			now++;
		}
		else{
			for(j = thenj + 1; j < L[i + 1]; j++){
				if(yoko[i + 1][j] > yoko[i + 1][j - 1] + 1){
					break;
				}
			}
//			printf("j = %d\n", j);
			if(yoko[i + 1][j - 1] < next - 1){
				now = yoko[i + 1][j - 1] + 1;
			}
			else{
				printf("%d\n", ans);
				return 0;
			}
		}
	}
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int RHYTHM[6] = {5, 7, 5, 7, 7};

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

    while(true){
        int N;
        std::cin >> N;
        if(!N){break;}

        vector<int> ls;
        for(int i=0;i<N;++i){
            string w;
            std::cin >> w;

            ls.emplace_back(w.size());
        }

        int res = -1;
        for(int i=0;i<N;++i){
            int pos = 0, len = 0;
            for(int j=i;j<N;++j){
                if(len + ls[j] > RHYTHM[pos]){
                    break;
                }else if(len + ls[j] == RHYTHM[pos]){
                    len = 0;
                    ++pos;
                }else{
                    len += ls[j];
                }

                if(pos == 5){
                    break;
                }
            }

            if(pos == 5){
                res = i + 1;
                break;
            }
        }

        std::cout << res << std::endl;
    }
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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 dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

ll ans = 0;


void merge(int A[],int left,int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1+1],R[n2+1];
    for(int i = 0; i < n1; i++) L[i] = A[left + i];
    for(int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] =  INT_MAX;
 
    int i = 0, j = 0;
    for(int k = left;k < right; k++){
        if(L[i] < R[j]){
            A[k] = L[i++];
        }else{
            A[k] = R[j++];
            ans += n1 - i;
        }
    }
}

void mergeSort(int A[],int left,int right){
    if(left+1 < right){
        int mid = (left+right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int A[n];
    REP(i,n) cin>>A[i];
    mergeSort(A,0,n);
    cout<<ans<<endl;
}


Measured memory_bytes: 4736
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#include <iostream>
#include <map>
#define re register
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define MAXN 4000007
#define mo 19930726
#define ll long long
using namespace std;
typedef unsigned long long ull;
#define ms(arr) memset(arr, 0, sizeof(arr))
const int inf = 0x3f3f3f3f;
ll n,k,c1,c2;
int main()
{
	cin>>n>>k;
	for(re int i=1;i<=n;i++){
		if(i%k==0) c1++;
	}
	if(k%2==0)
		for(re int i=1;i<=n;i++){
			if(i%k==k/2) c2++;
		}
	cout<<c1*c1*c1+c2*c2*c2;
}

Measured memory_bytes: 256
import heapq
n = int(input())
A = []
for _ in range(n):
    a, b = map(int, input().split())
    heapq.heappush(A, [b, a])
a_sum = 0
f = 1
for _ in range(n):
    b, a = heapq.heappop(A)
    a_sum += a
    if a_sum > b:
        f = 0
        break
print(["No", "Yes"][f])

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

#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

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

    int N; cin >>N;
    vector<int> a(N); cin >> a;
    int ans = 0;
    rep1(i, N) {
        if (a[i] == a[i-1]) {
            a[i] = -1;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a[100001]={0},b[100001]={0},n,tmp,amax=0,bmax=0,staya=0,staya2=0,A=0,stayb=0,B=0,stayb2=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>tmp;
        if(i%2==1){
            a[tmp]++;
            if(amax<tmp)amax=tmp;
        }
        else {
            b[tmp]++;
            if(bmax<tmp)bmax=tmp;
        }
    }
    for(int i=1;i<=amax;i++){
        if(a[i]>staya){
            staya2=staya;
            staya=a[i];
            A=i;
        }
        else if(a[i]>staya2){
            staya2=a[i];
        }
    }
    for(int i=1;i<=bmax;i++){
        if(b[i]>stayb){
            stayb2=stayb;
            stayb=b[i];
            B=i;
        }
        else if(b[i]>stayb2){
            stayb2=b[i];
        }
    }
    if(A!=B){
        cout<<n-(staya+stayb)<<endl;
        return 0;
    }
    else{
        if(staya+stayb2>stayb+staya2){
            cout<<n-(staya+stayb2)<<endl;
            return 0;
        }
        else{
            cout<<n-(staya2+stayb)<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1024
// https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_c

#include<bits/stdc++.h>
using namespace std;

int main() {
	long long n, k;
	cin >> n >> k;
	vector<long long> a(n+1);
	a[0] = 1;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (i <= k);
		else {
			if (a[i] > a[i-k]) cout << "Yes\n";
			else cout << "No\n";
		}
	}
	
	return 0;
}


Measured memory_bytes: 4840
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;

int main(){
    int A[3];
    for(int i=0;i<3;i++){
        cin >> A[i];
    }
        sort(A,A+3);
        int ans;
        
        ans = abs(A[1]-A[0])+abs(A[2]-A[1]);
        
        cout << ans << endl;
    
    return 0;
}



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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N; cin >> N;
  string S; cin >> S;
  // Left to right
  {
    int count = 0;
    rep(i, N) {
      if (S[i] == '(') count++;
      if (S[i] == ')') count--;
      if (count < 0) count = 0;
    }
    rep(i, count) {
      S += ')';
    }
  }

  N = S.size();
  {
    int count = 0;
    for(int i = N - 1; i >= 0; i--) {
      if (S[i] == ')') count++;
      if (S[i] == '(') count--;
      assert(count >= 0);
    }
    rep(i, count) {
      S = "(" + S;
    }
  }
  cout << S << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cout << H << " ";
	debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
	for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = sz(s)+1;

	vector<int> a(n),b(n);
	rep(i,n){
		if(s[i]=='<')
			a[i+1] = a[i]+1;
	}
	rrep(i,n){
		if(s[i]=='>')
			b[i] = b[i+1]+1;
	}
	ll ans = 0;
	rep(i,n){
		ans += max(a[i],b[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
 
using namespace std;
 
int C, D, W, X;
int E[16][31], F[16][31];
int memo[31][51][6];
const int dx[] = {-1, 1};
 
int solve(int d, int w, int x)
{
    if (d == D) return 0;
 
    int &res = memo[d][w][x];
    if (res != -1) return res;
   
    res = solve(d+1, w, x);
 
    for (int i = 0; i < C; i++) {
        if (w + F[i][d] <= W && E[i][d] != 0) {
            res = max(res, solve(d+1, w + F[i][d], x) + E[i][d]);      
        }    
    }
 
    if (x+1 <= X) {
        for (int i = 0; i < C; i++) {
            for (int j = 0; j < 2; j++) {
                int nx = i, cost = 0, f = 0;
                while (1) {
                    if (nx < 0 || nx >= C || E[nx][d] == 0) break;
                    f += F[nx][d];
                    cost += E[nx][d];
                    if (w + f <= W) {
                        res = max(res, solve(d+1, w + f, x+1) + cost);
                    }
                    nx += dx[j];
                }
            }   
        }
    }
    return res;
}
 
int main()
{
    while (cin >> C >> D >> W >> X, C) {
        for (int i = 0; i < C; i++) {
            for (int j = 0; j < D; j++) {
                cin >> E[i][j];
            }
        }
 
        for (int i = 0; i < C; i++) {
            for (int j = 0; j < D; j++) {
                cin >> F[i][j];
            }
        }
 
        memset(memo, -1, sizeof(memo));
     
        int res = solve(0, 0, 0);
        cout << res << endl;
    }
    return 0;
}

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

int main()
{
	int n;
	cin>>n;
	map<int,int> hm;
	vector<int> ans;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		hm[a]++;
		if(hm[a]==2)
		{
			ans.push_back(a);
			hm[a] = 0;
		}
	}
	sort(ans.begin(),ans.end());
	if(ans.size()<2) cout<<0;
	else
		cout<<1LL*ans[ans.size()-1]*ans[ans.size()-2];
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

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

	int H, W;
	cin >> H >> W;
	
	vector<vector<int> > vA(H);
	rep(i, H) vA[i].resize(W);
	rep(i, H) rep(j, W) {
		char a;
		cin >> a;
		vA[i][j] = (a == '#') ? 0 : 1; // black:0 white:1
	}

	set<pair<int, int> > sW;
	set<pair<int, int> > sB;

	rep(i, H) rep(j, W) {
		if (vA[i][j] == 0) {
			sB.insert(make_pair(i, j));
		}
		else {
			sW.insert(make_pair(i, j));
		}
 	}

	if (sW.empty()) {
		cout << "0" << endl;
		return 0;
	}

	int cnt = 0;
	set<pair<int, int> > sBcheck = sB;

	while (1) {
		if (sBcheck.empty()) {
			break;
		}

		set<pair<int, int> > sBtmp;
		for (set<pair<int, int> >::iterator it = sBcheck.begin(); it != sBcheck.end(); ++it) {
			int a = it->first;
			int b = it->second;
			if (a != 0) {
				if (vA[a - 1][b] != 0) {
					vA[a - 1][b] = 0; sBtmp.insert(make_pair(a - 1, b));
				}
			}
			if (a != H - 1) {
				if (vA[a + 1][b] != 0) {
					vA[a + 1][b] = 0; sBtmp.insert(make_pair(a + 1, b));
				}
			}
			if (b != 0) {
				if (vA[a][b - 1] != 0) {
					vA[a][b - 1] = 0; sBtmp.insert(make_pair(a, b - 1));
				}
			}
			if (b != W - 1) {
				if (vA[a][b + 1] != 0) {
					vA[a][b + 1] = 0; sBtmp.insert(make_pair(a, b + 1));
				}
			}
		}

		sBcheck = sBtmp;
		if (!sBtmp.empty()) {
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 96896
#include<cstdio>
#include<algorithm>

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

using namespace std;

typedef pair<bool,int> pbi;

pbi dp[41][4];
int n,p[41],t[41];

pbi solve(int i,int k){
	if(~dp[i][k].second) return dp[i][k];

	if(i==n-1) return dp[i][k]=make_pair(true,-p[i]);

	pbi res(false,i);
	if(k<3 && abs(p[i+1]-p[i])*(k+1)<=t[i+1]-t[i]){
		pbi tmp=solve(i+1,k+1);
		if(tmp.first) tmp.second-=abs(p[i+1]-p[i]);
		res=max(res,tmp);
	}
	if(p[i]*(k+1)+p[i+1]<=t[i+1]-t[i]){
		pbi tmp=solve(i+1,1);
		if(tmp.first) tmp.second-=p[i]+p[i+1];
		res=max(res,tmp);
	}
	return dp[i][k]=res;
}

int main(){
	for(;scanf("%d",&n),n;){
		p[0]=t[0]=0;
		rep(i,n) scanf("%d%d",p+i+1,t+i+1);
		n++;

		rep(i,n) rep(k,4) dp[i][k].second=-1;

		pbi res=solve(0,0);
		if(res.first) printf("OK %d\n",-res.second);
		else          printf("NG %d\n",res.second+1);
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);

    	
    	while(true){
    	
    	int a = scan.nextInt();
    	String op = scan.next();
    	int b = scan.nextInt();
  	

    	
    	if(op.equals("+")){
    	System.out.printf("%d\n",a+b);
    		}
    	if(op.equals("-")){
        	System.out.printf("%d\n",a-b);
        	}
    	if(op.equals("*")){
        	System.out.printf("%d\n",a*b);
        	}
    	if(op.equals("/")){
        	System.out.printf("%d\n",a/b);
        	}
    	if(op.equals("?")){
    		return;
    	}
    	}
    }	
}

Measured memory_bytes: 18132
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 1234567890123456
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;

//initialization here
//
int x[200005];
int y[200005];
//
//initialization finish


// your function is here
//

//
// your function finished

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	//

	int n;cin >> n;
	rep(i,n) 
	{
		cin >> x[i];
		y[i] = x[i];
	}

	sort(y,y+n);

	int mean1 = y[n/2 - 1];
	int mean2 = y[n/2];

	rep(i,n)
	{
		if (x[i] <= mean1) Print(mean2);
		else Print(mean1);
	}


	//
	// your code finished


	return 0;
}

Measured memory_bytes: 3712