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

typedef complex<double> P;
typedef pair<P,P> L;

const double EPS = 1e-8;

double dot(P a, P b){ return real(conj(a)*b); }

double cross(P a, P b){ return imag(conj(a)*b); }

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b,c) > EPS) return 1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < -EPS) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

P normal(P p){ return p / abs(p); }

P rotate(P p, double rad){
  double x = real(p) * cos(rad) - imag(p) * sin(rad);
  double y = real(p) * sin(rad) + imag(p) * cos(rad);
  return P(x,y);
}


int n[2];
vector<P> v[2];

bool solve(){
  for(int i=0;i<n[0];i++){
    for(int j=0;j<n[1];j++){
      for(int k=-1;k<=1;k+=2){
        P nor = normal(v[1][j] - v[0][j]) * EPS;
        L line = L(v[0][i] + rotate(nor, M_PI/2.0*k), v[1][j] + rotate(nor, M_PI/2.0*(-k)));
        int c[2] = {ccw(line.first, line.second, v[0][i]), ccw(line.first, line.second, v[1][j])};
        bool res = true;
        for(int l=0;l<2;l++){
          for(int l2=0;l2<n[l];l2++){
            if(ccw(line.first, line.second, v[l][l2]) != c[l]){
              res = false;
              break;
            }
          }
          if(!res) break;
        }
        if(res) return true;
      }
    }
  }
  return false;
}

int main(){
  double x, y;
  while(cin >> n[0] >> n[1] && (n[0]|n[1])){
    for(int i=0;i<2;i++){
      v[i].clear();
      for(int j=0;j<n[i];j++){
        cin >> x >> y;
        v[i].push_back(P(x, y));
      }
    }
    cout << (solve() ? "YES" : "NO") << endl;
  }
}

Measured memory_bytes: 1252
#include <stdio.h>

int main(){
    int k,n,set_1=0,dice[100][7];
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++)
        for(int j=1;j<7;j++)
            scanf("%d", &dice[i][j]);
    
    for(int x=0;x<n-1;x++){
        for(int y=x+1;y<n;y++){
            for(int i=0;i<6;i++){
                if(dice[x][1]==dice[y][1])
                    for(int j=0;j<4;j++){
                        
                        //一致判定
                        for(k=1;k<7;k++)
                            if(dice[x][k]!=dice[y][k]) break;
                        
                        if(k==7)
                            set_1 = 1;
                        
                        //スピン
                        dice[y][0] = dice[y][2];
                        dice[y][2] = dice[y][3];
                        dice[y][3] = dice[y][5];
                        dice[y][5] = dice[y][4];
                        dice[y][4] = dice[y][0];
                        
                        
                    }
                
                //回転
                
                dice[y][0] = dice[y][1];
                
                switch(i){
                        
                    case 2:
                        dice[y][1] = dice[y][3];
                        dice[y][3] = dice[y][6];
                        dice[y][6] = dice[y][4];
                        dice[y][4] = dice[y][0];
                        break;
                        
                    default:
                        dice[y][1] = dice[y][2];
                        dice[y][2] = dice[y][6];
                        dice[y][6] = dice[y][5];
                        dice[y][5] = dice[y][0]; 
                        break;
                        
                }
            }
        }
    }
    
    printf(set_1==1 ? "No\n" : "Yes\n");
    return 0;
}

Measured memory_bytes: 1012
S = input()
s = len(S)
L = []
A = ""
for i in S[:int((s-1)/2)]:
    L.append(i)
    A += i
    
A = A[::-1]
#print(A)

B = ""
for i in S[int((s+1)/2):]:
    B += i
    
B = B[::-1]
#print(B)

if S == S[::-1] and A == S[:int((s-1)/2)] and B == S[int((s+1)/2):]:
    print("Yes")
else:
    print("No")

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

using namespace std;

int main(void)
{
    int N;
    vector<int> A, B, C;

    cin >> N;

    for (int i = 0; i < N; i++)
    {
        int n;
        cin >> n;
        A.push_back(n);
    }

    for (int i = 0; i < N; i++)
    {
        int n;
        cin >> n;
        B.push_back(n);
    }

    for (int i = 0; i < N - 1; i++)
    {
        int n;
        cin >> n;
        C.push_back(n);
    }

    int sum = 0;
    int prev = -1;
    for (int i = 0; i < N; i++)
    {
        sum += B[A[i] - 1];
        if (prev + 1 == A[i])
        {
            sum += C[prev - 1];
        }
        prev = A[i];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
import math

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

if a**2*b/2 >= x:
    si = 90 - math.degrees(math.atan(2*x/a/b**2))
    # si = 90 - math.degrees(math.atan((a**2*b-2*x)/a/b**2))
    print(si)
elif a**2*b > x:
    si = 90 - math.degrees(math.atan(a**3/2/(a**2*b-x)))
    print(si)
else:
    print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()


int main(){
    int n, d, x;
    cin >> n >> d >> x;
    int ans = x;
    rep(i,n){
        int a;
        cin >> a;
        ans =ans + d/a + 1;
        if(d % a == 0) ans--;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3576
N=int(input().strip())
S=input().strip()
inf=10**8
ecr=0
for i in range(N):
    if S[i]=='E':
        ecr+=1
ans=inf
wcl=0
for i in range(len(S)):
    if i==0:
        if S[i]=='E':
            ecr-=1
        spre=S[i]
        ans=min(ans,ecr+wcl)
    else:
        if S[i]=='E':
            ecr-=1
        if spre=='W':
            wcl+=1
        spre=S[i]
        ans=min(ans,ecr+wcl)
print(ans)

Measured memory_bytes: 3828
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            for (var i = 0; i < 3; ++i)
                Write(ReadLine()[i]);
            WriteLine();
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 25744
#include <iostream>
#include <cstdio>
#include <map>
#include <cmath>
using namespace std;

int p_count = 0;
int H, W;
char A[8][8];
string ans = "Impossible";

void solution(int h, int w, int count) {
    if (h >= H || w >= W) {
        return;
    }
    if (A[h][w] == '.') {
        return;
    }
    if (h == H-1 && w == W-1 && count == p_count) {
        ans = "Possible";
        return;
    }
    solution(h+1, w, count+1);
    solution(h, w+1, count+1);
}

int main() {
    cin >> H >> W;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
            if (A[i][j] == '#') {
                p_count++;
            }
        }
    }
    solution(0, 0, 1);
    cout << ans << endl;
}


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

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(buf.readLine());
		StringBuilder sb = new StringBuilder();
		int num = 0;
		for (int j = 3; j <= n; j++) {
			if (j % 3 == 0) {
				sb.append(" " + j);
			} else {
				num = j;
				while (num != 0) {
					if (num % 10 == 3) {
						sb.append(" " + j);
						break;
					} else {
						num = num / 10;
					}
				}
			}

		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 26260
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <functional>
#include <utility>

using namespace std;
typedef long long lli;
typedef pair<lli,int> pli;

const lli inf=1e15;

struct edge{
	int t,w[2];
	edge() {}
	edge(int t,int a,int b):t(t){
		w[0]=a; w[1]=b;
	}
};

vector<edge> adj[100001];
int n,m,s,t;
lli dist[100001][2],mx[100001];
int vis[100001];

void dijk(int s,int t,int j) {
	priority_queue<pli,vector<pli>,greater<pli>> que;
	que.push(pli(0,s));
	fill(vis,vis+n+1,0);
	for(int i=1;i<=n;i++) dist[i][j] = inf;
	dist[s][j] = 0;

	while(!que.empty()) {
		lli cost=que.top().first;
		int cur=que.top().second;
		que.pop();

		if(vis[cur]) continue;
		vis[cur]=1;

		for(auto &it:adj[cur]) {
			if(!vis[it.t] && dist[it.t][j] > cost + it.w[j]) {
				dist[it.t][j] = cost+it.w[j];
				que.push(pli(dist[it.t][j],it.t));
			}
		}
	}
}


int main() {
	scanf("%d%d%d%d",&n,&m,&s,&t);
	for(int i=0,u,v,a,b;i<m;i++) {
		scanf("%d%d%d%d",&u,&v,&a,&b);
		adj[u].push_back(edge(v,a,b));
		adj[v].push_back(edge(u,a,b));
	}

	dijk(s,t,0);
	dijk(t,s,1);

	for(int i=n-1;i>=0;i--) {
		mx[i] = dist[i+1][0] + dist[i+1][1];
		if(i!=n-1) mx[i] = min(mx[i],mx[i+1]);
	}
	for(int i=0;i<n;i++) printf("%lld\n",inf-mx[i]);
	
	return 0;
}


Measured memory_bytes: 11132
using System;

public class Hello
{
    public static int flag = 0;
    public static void Main()
    {
        var s = Console.ReadLine();
        var t = Console.ReadLine();
        char[] cs = s.ToCharArray();
        char[] ct = t.ToCharArray();

        Array.Sort(cs);
        Array.Sort(ct);

        Array.Reverse(ct);
        bool output = checker(cs, ct);
        if (output)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");


    }

    public static bool checker(char[] cs, char[] ct)
    {
        bool output = false;
       int shorter = Math.Min(cs.Length, ct.Length);
        int lasti = 0;
        for (int i = 0; i < shorter; i++)
        {

            if (cs[i] < ct[i])
            {
                output = true;
                break;
            }
            if (cs[i] > ct[i])
            {
                break;
            }
            lasti=i;
        }
        if (lasti == shorter - 1)
        {
            if (cs.Length < ct.Length) output = true;
        }
        return output;
        
    }

    
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(n) cout<<a[i]<<endl printf("%s\n"," " );
#define sc(a) scanf("%d",&a);
#define scl(a) scanf("%lld",&a);
#define scf(a) ascanf("%f",&a);
#define ff first
#define ss second
#define pu push_back
#define inf 1000000001
#define MOD 1000000007 
#define INF 100000000000001
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    int a[100010];
    int cg[100010];
    int cg1[100010];
    cin>>n;
    int tmp;
    rep(n) 
    {
	    cin>>a[i];
    }
    tmp= a[0];
    rep(n)
    {
    	tmp = __gcd(tmp,a[i]);
    	cg[i] = tmp;
    }
    tmp = a[n-1];
    for(int i = n-1;i>=0;i--)
    {
    	tmp = __gcd(tmp,a[i]);
    	cg1[i] = tmp;
    }
    int ans = -1;
    for(int i = 1;i<n-1;i++)
    {
    	ans = max({ans,__gcd(cg[i-1],cg1[i+1])});
    }
    ans = max({ans,cg1[1]});
    ans = max({ans,cg[n-2]});
    cout<<ans<<endl;
    return 0;

}
    

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int gcd(int x,int y){
    if(x%y==0){
        return y;
    }else{
        return(gcd(y,x%y));
    }
}
vector<int> divisor(int x){
    vector<int> p;
    for(int i=1;i*i<=x;i++){
        if(x%i==0){
            p.push_back(i);
            
            if(i != x/i) p.push_back(x/i);
        }
    }
    sort(p.begin(),p.end(),greater<int>());
    return p;
}

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    int cnt = 0;
    vector<int> v = divisor(gcd(a,b));
    /*
    for(auto x:v){
        cout << x << endl;
    }
    */
    cout << v[k-1] << endl;
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//213
	int n;
	cin>>n;
	vi arr(n);
	ll sum = 0;
	for(int &i:arr)cin>>i,sum+=i;
	sum=round(sum/(double)n);
	ll ans = 0;
	for(int i:arr)ans+=pow(i-sum,2);
	cout<<ans;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int dp[105][4][3];

int main(void){
    string s; cin >> s;
    int KK; cin >> KK;

    int n = s.size();

    dp[0][0][0] = 1;
    for(int i=0; i<n; i++){
        for(int j=0; j<=KK; j++){
            for(int k=0; k<2; k++){
                int now_d = s[i] - '0';
                for(int d=0; d<10; d++){
                    // 次の状態に移る前に添字の準備
                    int next_i = i+1;
                    int next_j = j;
                    int next_k = k;
                    // d の値に応じて添字を修正
                    if(d!=0) next_j++;
                    if(next_j > KK) continue;
                    if(k == 0){
                        if(now_d < d) continue;
                        if(d < now_d) next_k = 1;
                    }
                    dp[next_i][next_j][next_k] += dp[i][j][k];
                }
            }
        }
    }
    cout << dp[n][KK][0] + dp[n][KK][1] << endl;
    return 0;
}

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

int main() {
  string s;
  cin>>s;
  int n=s.size(), x=1,m=2019,tot=0;
  reverse(s.begin(),s.end());
  vector<int> a(n);
  for(int i=0;i<n;i++){
    tot+=(s[i]-'0')*x;
    a[i]=tot%m;
    x=x*10%m;
  }
  vector<int> b(2019);
  for(int i=0;i<2019;i++) cin>>b[i];
   for(int i=0;i<n;i++){
     b[a[i]]++;
   }
  int ans=b[0]*(b[0]+1)/2;
  for(int i=1;i<2019;i++){
    if(b[i]>1) ans+=b[i]*(b[i]-1)/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4444
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
  ll N; cin >> N;
  ll m = LLONG_MAX;
  for(ll i = 1; i <= 1000000; i++){
    if(N % i == 0){
      m = min(m, i + N / i);
    }
  }
  cout << m - 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N, C;
    cin >> N >> C;
    vector<pair<PL,ll>> r(N);
    rep(i, 0, N){
        ll s, t, c;
        cin >> s >> t >> c;
        r[i].first = {s, t};
        r[i].second = c;
    }
    sort(ALL(r));
    VP rec;
    ll ans = 0;
    rep(i, 0, N){
        bool f = false;
        rep(j, 0, rec.size()){
            if(rec[j].second == r[i].second){
                rec[j] = {r[i].first.second, r[i].second};
                f = true;
                break;
            }else if(rec[j].first < r[i].first.first){
                rec[j] = {r[i].first.second, r[i].second};
                f = true;
                break;
            }
        }
        if(!f){
            rec.push_back({r[i].first.second, r[i].second});
        }
    }
    cout << rec.size() << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
  string a, b;
  cin >> a >> b;
  string str = a + b;
  int t = stoi(str);
  bool flag = false;
  for(int i = 1; i <= 1000; i++)
  {
      int tmp = pow(i, 2);
      if(tmp == t)
      {
          flag = true;
      }
  }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}



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

using namespace std;

static inline int in(){ int x; scanf("%d", &x); return x; }

int main()
{
  string s;
  while (cin >> s){
    bool ok = true;
    for (int i = 0; i < s.size(); i++){
      if (i % 2 == 0){
        if (s[i] < '1' || '6' < s[i]){
          ok = false;
          break;
        }
      }
      else {
        if (s[i] < '1' || '5' < s[i]){
          ok = false;
          break;
        }
      }
    }
    if (s.size() % 2 == 1 || !ok){
      puts("NA");
      continue;
    }
    char *table[6] = {
      "abcde",
      "fghij",
      "klmno",
      "pqrst",
      "uvwxy",
      "z.?! "
    };
    for (int i = 0; i < s.size(); i += 2){
      printf("%c", table[s[i] - '1'][s[i + 1] - '1']);
    }
    puts("");
  }

  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b;
  cin>>a>>b;
  if(a>=13)
    cout<<b;
  if(a>=6&&a<=12)
    cout<<b/2;
  if(a<=5)
    cout<<0;
  return 0;
}

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

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

    for(int i = 0; i < n - 1; i++) {
        if(h[i] - h[i + 1] >= 2) {
            cout << "No" << endl;
            return 0;
        } else if(h[i] - h[i + 1] == 1) {
            h[i + 1]++;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 640
#include <cstdio>

using namespace std;

int main() {
  char abcd[4];
  int a, b, c, d;
  scanf("%c%c%c%c", &abcd[0], &abcd[1], &abcd[2], &abcd[3]);
  a = int(abcd[0])-48;
  b = int(abcd[1])-48;
  c = int(abcd[2])-48;
  d = int(abcd[3])-48;
  //printf("%d %d %d %d", a, b, c, d);
  if (a+b+c+d == 7) {
    printf("%d+%d+%d+%d=7", a, b, c, d);
  } else if (a+b+c-d == 7) {
    printf("%d+%d+%d-%d=7", a, b, c, d);
  } else if (a+b-c+d == 7) {
    printf("%d+%d-%d+%d=7", a, b, c, d);
  } else if (a+b-c-d == 7) {
    printf("%d+%d-%d-%d=7", a, b, c, d);
  } else if (a-b+c+d == 7) {
    printf("%d-%d+%d+%d=7", a, b, c, d);
  } else if (a-b+c-d == 7) {
    printf("%d-%d+%d-%d=7", a, b, c, d);
  } else if (a-b-c+d == 7) {
    printf("%d-%d-%d+%d=7", a, b, c, d);
  } else if (a-b-c-d == 7) {
    printf("%d-%d-%d-%d=7", a, b, c, d);
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int n, A[50];

int solve(int i, int m) {
  if ( m == 0 ) return 1;
  if ( i >= n ) return 0;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main() {
  int q, M, i;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &M);
    if ( solve(0, M) ) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}


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

#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;
ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}

const int N = 1e6+9;
pair<int, int> a[N];
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);    
    int n, t; cin >> n >> t;

    for(int i = 1; i <= n; i++) {
    	cin >> a[i].ft >> a[i].sd;
    }
    sort(a+1, a+n+1);
    const int inf = 1e8;
    vector<vector<int>> f(n+1, vector<int> (3003));
    for(int i = 1; i <= n; i++) {
    	for(int j = 1; j <= t; j++) {
    		f[i][j] = max(f[i-1][j], (j < a[i].ft ? -inf : f[i-1][j-a[i].ft]) + a[i].sd);
    	}
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
    	ans = max(ans, f[i][t-1] + a[i+1].sd);

    }
    cout << ans << "\n";
    



    return 0;
    
}


Measured memory_bytes: 35584
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/numeric/ublas/vector.hpp>
// ↓これいる？
#include <boost/graph/strong_components.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;
using namespace boost::numeric;
using ll = long long;
namespace bst = boost;
template<class T> void fill(T& v) { for (auto&& i : v) cin >> i; }

//#include "atcoder.hpp"

int main() {
    int A, B;
    
    cin >> A >> B;
    
  if (A > 9 || B > 9)
    cout << -1 << endl;
  else
    cout << A * B << endl;
    
    return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;


int main (){
    cout << fixed << setprecision(8);
    ll n;
    cin >> n;
    double a[n],b=0;
    

    rep(i,n)  {
        cin >> a[i];
        b+=1.0/a[i];
    }

    cout << 1.0/b << endl;


}

Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 3e4 + 5, mod = (int) 0;
int a[N], b[N];
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) a[i] = (i + 1) * N, b[i] = (n - i) * N;
    for (int i = 0; i < n; ++i) {
        int p;
        cin >> p;
        p--;
        a[p] += i;
    }
    for (int i = 0; i < n; ++i) {
        cout << a[i] << ' ';
    }
    cout << endl;
    for (int i = 0; i < n; ++i) {
        cout << b[i] << ' ';
    }
    cout << endl;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  string s, t;
  cin >> s >> t;
  cout << t + s << endl;
  return 0;
}

Measured memory_bytes: 256
name=['A','B','C','D','E']
shop = []
while True:
 a,b = map(int,input().split())
 if a == 0 and b == 0:
   break
 shop.append(a+b)
 if len(shop) == 5:
   m = max(shop)
   print(name[shop.index(m)],m)
   shop = []


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define ll long long
#define pb push_back
#define mp make_pair

vec<vec<int>> edge;
vec<int> dp;
vec<int> score;

int dfs(int start)
{
	int ret = 1;
	dp[start] = 1;
	rep(i, edge[start].size()) {
		if (dp[edge[start][i]]) continue;
		ret += dfs(edge[start][i]);
	}
	return ret;
}

int odd(int start)
{
	int flag = 0;
	rep(i, edge[start].size()) {
		if (score[edge[start][i]]) {
			if ((score[start] - score[edge[start][i]]) % 2) continue;
			flag = 1;
			break;
		}
		score[edge[start][i]] = score[start] + 1;
		if (odd(edge[start][i])) {
			flag = 1;
			break;
		}
	}
	return flag;
}


int main(void)
{
	int n, m;
	cin >> n >> m;
	edge.resize(n);
	dp.resize(n);
	score.resize(n);
	rep(i, n) dp[i] = 0;
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		l--;
		r--;
		edge[l].pb(r);
		edge[r].pb(l);
	}

	ll ans = 0;
	ll left = 0;
	// vec<pair<ll, int>> keep; // first: size, second: odd
	ll count_odd = 0;
	ll count_even = 0;
	int next_dp = 0;
	while(next_dp < n) {
		int next = - 1;
		for (int i = next_dp; i < n; i++) {
			if (!dp[i]) {
				next = i;
				next_dp = i + 1;
				break;
			}
		}
		if (next < 0) break;

		int N = dfs(next);
		if (N == 1) {
			left++;
			continue;
		}
		rep(i, n) score[i] = 0;
		score[next] = 1;
		int flag = odd(next);
		if (flag) ans++;
		else ans += 2;
		if (flag) count_odd++;
		else count_even++;
	}
	ans += count_even * (count_even - 1) * 2 + count_even * count_odd * 2 + count_odd * (count_odd - 1);
	ans += left * left + left * (n - left) * 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9472
s=input()[::-1]
mod=[0]*2019
mod[0]=1
x=1
num=0
ans=0

for t in s:
    num += int(t) * x
    num %= 2019
    x *= 10
    x %= 2019
    mod[num] +=1

for u in mod:
    ans += u*(u-1)//2

print(ans)

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

int main()
{
  	int n,pt = 0,ph = 0;
  	string st,sh;
  
 	cin >> n;
   	
  	for(int i = 0;i < n;i++){
      cin >> st >> sh;
      
      if(st == sh){
       	pt++;
        ph++;
      }else{
        if(st > sh)
          pt += 3;
        else
          ph += 3;
      }
    }
  	cout << pt << " " << ph << endl;
  
}


Measured memory_bytes: 3176
x, y, a, b, c = map(int, input().split())
p = list(map(int , input().split()))
q = list(map(int , input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

r = r + p[:x] + q[:y]
r.sort(reverse=True)
#print(r[:x+y])
print(sum(r[:x+y]))



Measured memory_bytes: 111852
n = int(input())
s = input()
n = len(s)
l = 0
r = 0
tmp = 0
for i in range(n):
  if(s[n-1-i] == ')'):
    tmp += 1
  else:
    tmp -= 1
    if(tmp < 0):
      tmp = 0
      r += 1
tmp = 0
for i in range(n):
  if(s[i] == '('):
    tmp += 1
  else:
    tmp -= 1
    if(tmp < 0):
      tmp = 0
      l += 1


for i in range(l):
  print('(',end = '')
print(s,end='')
for i in range(r):
  print(')',end = '')
 

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra(){
  priority_queue<pair<int, int> > PQ;
  int color[MAX];
  int d[MAX];
  for(int i = 0; i < n; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  PQ.push(make_pair(0, 0));
  color[0] = GRAY;

  while(!PQ.empty()){
    pair<int, int> f = PQ.top();
    PQ.pop();
    int u = f.second;

    color[u] = BLACK;

    if(d[u] < f.first * (-1)) continue;

    for(int j = 0; j < adj[u].size(); j++){
      int v = adj[u][j].first;
      if(color[v] == BLACK) continue;
      if(d[v] > d[u] + adj[u][j].second){
	d[v] = d[u] + adj[u][j].second;
	PQ.push(make_pair(d[v] * (-1), v));
	color[v] = GRAY;
      }
    }
  }

  for(int i = 0; i < n; i++) cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << 
endl;
}

int main(){
  int k, u, v, c;

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> u >> k;
    for(int j = 0; j < k; j++){
      cin >> v >> c;
      adj[u].push_back(make_pair(v, c));
    }
  }

  dijkstra();

  return 0;
}

Measured memory_bytes: 7996
#include<bits/stdc++.h>
using namespace std;
int main(){ 
    int N;
    cin >> N;
    int a[N];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(a,a+N, greater<int>());
    int alice = 0, bob = 0;
    for(int i = 0; i < N; i++){
        if(i%2==0) alice += a[i];
        else bob += a[i];
    }
    cout << alice-bob << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int data[10];
    while (n--) {
        for (int i = 0; i < 10; ++i) {
            cin >> data[i];
        }
        bool ans = true;
        int l, r;
        l = r = 0;
        for (int j = 0; j < 10; ++j) {
            if (data[j] > l)
                l = data[j];
            else if (data[j] > r)
                r = data[j];
            else {
                ans = false;
                break;
            }
        }
        if (ans)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3080
#include <stdio.h>

#define swap(typ, x, y) \
    do { \
        typ tmp; \
        tmp = x; \
        x = y; \
        y = tmp; \
    } while (0)

void max_heapify(int *arr, int i, int size) {
    int l, r, largest;

    l = (i+1) * 2 - 1;
    r = (i+1) * 2;

    if (l <= (size - 1) && arr[l] > arr[i]) {
        largest = l;
    } else {
        largest = i;
    }
    if (r <= (size - 1) && arr[r] > arr[largest]) {
        largest = r;
    }

    if (largest != i) {
        swap(int, arr[i], arr[largest]);
        max_heapify(arr, largest, size);
    }
}

void build_max_heap(int *arr, int size) {
    for (int i = (size / 2); i >= 0; i--) {
        max_heapify(arr, i, size);
    }
}

int main(void) {
    int h;
    int arr[500000];

    scanf("%d", &h);

    for (int i = 0; i < h; i++) {
        int x;
        scanf("%d", &x);
        arr[i] = x;
    }

    build_max_heap(arr, h);

    for (int i = 0; i < h; i++) {
        printf(" %d", arr[i]);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int cal(int x,int y){
  return x * y;
}


int main() {
 int a,b,c,d;
 int s1,s2;
 cin >> a >> b >> c >> d;

 s1 = cal(a,b);
 s2 = cal(c,d);

 if(s1 > s2){
   cout << s1 << endl;
 }else{
   cout << s2 << endl;
 }
}


Measured memory_bytes: 256
#include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>
#include <cstring>
#include <cstdlib>

typedef long long ll;

using namespace std;

int N;
int ball[10];

bool dfs(int a, int b, int num){
	if(num == 10) return true;
	if(ball[num] > a && dfs(ball[num], b, num+1)) return true;
	if(ball[num] > b && dfs(a, ball[num], num+1)) return true;
	return false;	
}

int main(void){
	cin >> N;

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

		for(int j=0; j<10; j++){
			cin >> ball[j];
		}
		if(dfs(0, 0, 0)) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
long long a;
long long d[500005];
int main()
{
    scanf("%lld",&a);
    long long ans=0;
    long long mi;
    int f=0;
    for(int i=0;i<a;i++)
        scanf("%lld",&d[i]);
    sort(d,d+a);
    long long q=0,r=a-1;
    long long t;
    for(int i=0;i<a;i++)
    {
        //cout<<d[q]<<" "<<d[r]<<endl;
        if(i%2==0)
        {
            if(d[r]>=d[q])
                t=d[r]-d[q++];
            else
                t=d[q++]-d[r];
            if(t<mi||f==0)
            {
                mi=t;
                f=1;
            }
            ans+=t;
        }
        else
        {
            if(d[r]>=d[q])
                t=d[r--]-d[q];
            else
                t=d[q]-d[r--];
            if(t<mi||f==0)
            {
                mi=t;
                f=1;
            }
            ans+=t;
        }
        if(q==r)
        {
            r=0;
        }
    }
    long long ans1=ans-mi;
    ans=0;
    f=0;
    sort(d,d+a,greater<long long>());
    q=0,r=a-1;
    for(int i=0;i<a;i++)
    {
        //cout<<d[q]<<" "<<d[r]<<endl;
        if(i%2==0)
        {
            if(d[r]>=d[q])
                t=d[r]-d[q++];
            else
                t=d[q++]-d[r];
            if(t<mi||f==0)
            {
                mi=t;
                f=1;
            }
            ans+=t;
        }
        else
        {
            if(d[r]>=d[q])
                t=d[r--]-d[q];
            else
                t=d[q]-d[r--];
            if(t<mi||f==0)
            {
                mi=t;
                f=1;
            }
            ans+=t;
        }
        if(q==r)
        {
            q=0;
        }
    }
    long long ans2=ans-mi;
    if(ans2<ans1)
        ans=ans1;
    else
        ans=ans2;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4540
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

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

    int N = sc.nextInt();

    LinkedList<Double> v = new LinkedList<>();
    for (int i = 0; i < N; i++) {
      v.add(sc.nextDouble());
    }

    Collections.sort(v);

    while (v.size() > 1) {
      double a = v.poll();
      double b = v.poll();
      v.addFirst((a + b) / 2.0);
    }

    System.out.println(v.get(0));
  }
}

Measured memory_bytes: 24532
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int n, k;
  readf("%s %s\n", &n, &k);
  auto a = readln.chomp.split.to!(int[]);
  n -= k;
  auto res = 1 + n / (k - 1) + !!(n % (k - 1));
  res.writeln;
}


Measured memory_bytes: 4284
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
const int MOD = 1e9 + 7;
inline int qpow(int a, int b)
{
	register int res = 1;
	for(; b; b >>= 1)
	{
		if(b & 1)
			res = (long long)res * a % MOD;
		a = (long long)a * a % MOD;
	}
	return res;
}
int f[MAXN][MAXN];
int fac[MAXN * MAXN], fav[MAXN * MAXN];
int n, k;
inline int C(int n, int m)
{
	return (long long)fac[n] * fav[m] % MOD * fav[n - m] % MOD;
}
int main()
{
	cin >> n >> k;
	if(k == 1)
	{
		puts("1");
		return 0;
	}
	fac[0] = 1;
	for(register int i = 1; i <= n * k; ++i)
		fac[i] = (long long)fac[i - 1] * i % MOD;
	fav[n * k] = qpow(fac[n * k], MOD - 2);
	for(register int i = n * k - 1; i >= 0; --i)
		fav[i] = (long long)fav[i + 1] * (i + 1) % MOD;
	f[0][0] = 1;
	for(register int i = 1; i <= n; ++i)
	{
		for(register int j = 0; j <= i; ++j)
		{
			f[i][j] = f[i - 1][j];
			if(j)
				f[i][j] = (f[i][j] + (long long)f[i][j - 1] * (n - j + 1) % MOD * C(n * k - i - (j - 1) * (k - 1) - 1, k - 2) % MOD) % MOD;
//			cerr << f[i][j - 1] << " ";
		}
//		cerr << endl;
	}
	cout << f[n][n] << endl;
} 

Measured memory_bytes: 47360
N = int(input())
A = [int(i)-1 for i in input().split(" ")]
count = 0
for i in range(N):
    # 相手が自分を好いているか確認
    if i==A[A[i]]:
        count+=1
# 各ペア1回ずつ多く数えているので半分に
pair = count//2
print(pair)

Measured memory_bytes: 13880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int a,b,c; cin  >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;

//const ll MOD=(ll)1e9+7;
//const ll inf=(ll)1e14;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int n,m,h,w;
string s;
ll a[100011],b[100011];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  cin>>n;
  ll pre=0;
  a[0]=0;
  ll sum=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    sum+=abs(pre-a[i]);
    pre=a[i];
  }
  sum+=abs(pre-0);
  a[n+1]=0;
  for(int i=0;i<n+1;i++){
    b[i]=abs(a[i+1]-a[i]);
  }
  for(int i=0;i<n;i++){
    cout<<sum-b[i]-b[i+1]+abs(a[i+2]-a[i])<<endl;
  }
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}





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

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

int main() {
#ifdef cute
	freopen("in", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	ll n;
	cin >> n;
	ll a[n];
	const ll Mod = 1e9+7;

	for(ll i = 0; i < n; i++) cin >> a[i];
	
	ll sum = 0;
	for(ll bit = 0; bit < 61; bit++) {
		ll ct = 0;

		for(ll i = 0; i < n; i++)
			ct += (a[i] >> bit) & 1;

		ll A = ct*(n-ct) % Mod;
		ll B = (1ll << bit) % Mod;
		sum += A*B % Mod;
		sum %= Mod;
	}

	cout << sum;
	
#ifdef cute
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif
}

// g++ o .cpp -O2 -std=c++11 -D cute -Wall -Wno-unused-result



Measured memory_bytes: 2560
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for ( int i = 1; i < n; ++i ) {
        string x = s.substr(0, i);
        string y = s.substr(i, n-i);
//        cout << i << " " << x << " " << y << endl;
        vector<int> cnt_x(26, 0);
        vector<int> cnt_y(26, 0);
        rep(j, (int)x.size()) ++cnt_x[x[j]-'a'];
        rep(j, (int)y.size()) ++cnt_y[y[j]-'a'];
//        for ( auto p : cnt_x ) cout << p << " ";
//        cout << endl; 
//        for ( auto p : cnt_y ) cout << p << " " ;
//        cout << endl;
        int tmp_ans = 0;
        rep(j, 26) {
            if ( cnt_x[j] > 0 && cnt_y[j] > 0 ) ++tmp_ans;
        }
//        cout << tmp_ans << endl;
        ans = max(tmp_ans, ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
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)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int index[200020];

int main(){
  int n;
  cin >> n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  vector<string> v;
  int m=-1;
  for(auto i=mp.begin();i!=mp.end();i++){
    int p=i->second;
    m=max(m,p);
  }
  for(auto i=mp.begin();i!=mp.end();i++){
    if(i->second==m)v.push_back(i->first);
  }
  sort(v.begin(),v.end());
  rep(i,v.size()){
    cout << v[i] << endl;
  }
return 0;}

Measured memory_bytes: 26868
using System;

namespace Rectangle
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			string input = Console.ReadLine();
		
			char[] CharSeparators = new char[] {' '};
			string[] array = input.Split(CharSeparators);

			string array1 = array[0];
			string array2 = array[1];

			int a = int.Parse (array1);
			int b = int.Parse (array2);

			var area = a*b;
			var periphery =(a+b)*2;
			Console.WriteLine (area+" "+periphery);

		}
	}
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===


// スライド最小値
// 長さNの数列 a[0], ..., a[N - 1]について区間[i, i + K), i = 0, ..., N - Kにおける
// 最小値を格納した配列 y[i] を返す
// 時間計算量 : O(N)
Vi slide_min(const Vi& vec, int k)
{
	int vecl = (int)vec.size();
	Vi res(vecl - k + 1);
	deque<int> deq;
	for (int i = 0; i < k; ++i) {
		while (!deq.empty() && vec[deq.back()] >= vec[i]) deq.pop_back();
		deq.push_back(i);
	}
	res[0] = vec[deq.front()];
	for (int i = k; i < vecl; ++i) {
		while (!deq.empty() && vec[deq.back()] >= vec[i]) deq.pop_back();
		deq.push_back(i);
		if (deq.front() == i - k) deq.pop_front();
		res[i - k + 1] = vec[deq.front()];
	}
	return res;
}


// スライド最大値
// 長さNの数列 a[0], ..., a[N - 1]について区間[i, i + K), i = 0, ..., N - Kにおける
// 最大値を格納した配列 y[i] を返す
// 時間計算量 : O(N)
std::vector<int> slide_max(const std::vector<int>& vec, int k)
{
	int vecl = (int)vec.size();
	std::vector<int> res(vecl - k + 1);
	std::deque<int> deq;
	for (int i = 0; i < k; ++i) {
		while (!deq.empty() && vec[deq.back()] <= vec[i]) deq.pop_back();
		deq.push_back(i);
	}
	res[0] = vec[deq.front()];
	for (int i = k; i < vecl; ++i) {
		while (!deq.empty() && vec[deq.back()] <= vec[i]) deq.pop_back();
		deq.push_back(i);
		if (deq.front() == i - k) deq.pop_front();
		res[i - k + 1] = vec[deq.front()];
	}
	return res;
}



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

	Vi P(N);
	for (int i = 0; i < N; ++i) {
		cin >> P[i];
	}

	// スライド最小値・最大値を使った解法
	Vi P_mink = slide_min(P, K - 1);
	Vi P_maxk = slide_max(P, K - 1);
	
	int ans = 1;
	for (int i = 0; i + K < N; ++i) {
		if (!(P[i] < P_mink[i + 1] && P_maxk[i + 1] < P[i + K])) ++ans;
	}

	int cnt = 1;
	int dup = 0;
	for (int i = 0; i < N - 1; ++i) {
		if (P[i] < P[i + 1]) ++cnt;
		else cnt = 1;
		if (cnt == K) ++dup;
	}

	if (dup > 0) ans -= dup - 1;

	cout << ans << endl;

	return 0;
}

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

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

int n, k, r, s, p;
string t;

int getpoint(int i)
{
    char c = t.at(i);
    if (c == 'r')
    {
        return p;
    }
    else if (c == 's')
    {
        return r;
    }
    else
    {
        return s;
    }
}

int main(int argc, char const *argv[])
{
    cin >> n >> k >> r >> s >> p >> t;
    int rr, ss, pp;
    vector<bool> iswin(n);
    int point(0);
    rep(i, n)
    {
        if (i >= k)
        {
            if (t.at(i) == t.at(i - k))
            {
                if (iswin[i - k])
                {
                    // ng
                }
                else
                {
                    //ok
                    point += getpoint(i);
                    iswin[i] = true;
                }
            }
            else
            {
                // ok
                point += getpoint(i);
                iswin[i] = true;
            }
        }
        else
        {
            // ok
            point += getpoint(i);
            iswin[i] = true;
        }
    }
    cout << point << endl;
    return 0;
}


Measured memory_bytes: 512
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

#[allow(non_snake_case)]
fn main() {
    input! {R:usize}
    println!("{}", 2.0 * R as f64 * std::f64::consts::PI);
}


Measured memory_bytes: 2144