akhauriyash/Code-Regression huggingface dataset:
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
signed main()
{
	int n,k,c;
	cin>>n>>k>>c;
	string s;
	cin>>s;
	int dpl[n+1];
	int dpr[n+1];
	dpl[0]=0;dpr[0]=0;
	int index=INT_MIN;
	for(int i=1;i<=n;i++)
	{
		if(s[i-1]=='x')
			dpl[i]=dpl[i-1];
		else if(index+c<i)
		{
			dpl[i]=dpl[i-1]+1;
			index=i;
		}
		else
			dpl[i]=dpl[i-1];
	}
	dpr[0]=0;
	index=INT_MIN;
	for(int i=1;i<=n;i++)
	{
		if(s[n-i]=='x')
			dpr[i]=dpr[i-1];
		else if(index+c<i)
		{
			dpr[i]=dpr[i-1]+1;
			index=i;
		}
		else
			dpr[i]=dpr[i-1];
	}
	for(int i=0;i<n;i++)
	{
		int left=i;
		int right=n-i-1;
		if(s[i]=='o' && dpl[left]+dpr[right]+1==k)
			cout<<i+1<<endl;
	}
}












Measured memory_bytes: 6840
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int sumP = 0, sumQ = 0, cnt = 0;

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] temp = input.Split(',');
                int p = int.Parse(temp[0]);
                int q = int.Parse(temp[1]);

                sumP += p * q;
                sumQ += q;
                cnt++;
            }

            decimal ave = (decimal)sumQ / cnt;

            Console.WriteLine(sumP + "\n" + Math.Round(ave, 0, MidpointRounding.AwayFromZero));
        }
    }
}

Measured memory_bytes: 9480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = (1LL<<60);

const P mx = P(-INF,-INF);

int size=400;
P A[160000],B[400];

void Set(int i,P x){
  A[i]=x;
  B[i/size]=mx;  
  for(int j=0;j<size;j++){
    B[i/size]=max(B[i/size],A[i/size*size+j]);
  }
}

P Get(int l,int r){
  int i=l;
  P res=mx;
  while(i<r){
    if(i%size==0&&i+size<=r){
      res=max(res,B[i/size]);
      i+=size;
    }else{
      res=max(res,A[i]);
      i++;
    }
  }
  return res;
}

int n;
int t[100005];

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>t[i];
    Set( t[i] , P(1,t[i]) );
    P tmp=Get(0, t[i] );
    if( tmp != mx ){
      tmp.first += 1;
      tmp.second += t[i];
      
      Set( t[i], max(tmp,P(1,t[i])) );
    }
  }
  

  P tmp = Get(0,100005);
  cout<<tmp.second<<endl;

  return 0;
}



Measured memory_bytes: 6000
import sys
input = sys.stdin.buffer.readline

n = int(input())
a = list(map(int, input().split()))
b = []
for i, v in enumerate(a):
    b.append([v, i])
b.sort(reverse = True)
dp = [[0] * (n+1) for _ in range(n+1)]
ans = 0

for i in range(n+1):
    for j in range(n+1-i):
        if i > 0:
            dp[i][j] = max(dp[i][j], dp[i-1][j] + b[i+j-1][0] * (b[i+j-1][1] - (i - 1)))
        if j > 0:
            dp[i][j] = max(dp[i][j], dp[i][j-1] + b[i+j-1][0] * ((n - j) - b[i+j-1][1]))

for i in range(n+1):
    ans = max(ans, dp[i][n-i])

print(ans)

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

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


Measured memory_bytes: 3096
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] n = br.readLine().split(" ");
		br.close();

		String a ="1974";
		for (int i = 0; i < 4; i++) {
			a = a.replaceAll(n[i], "");
		}

		if (a.length() == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int main() {
  int w;
  cin >> w;
  string ans = "0";

  rep(i, 1, w + 1) {
    dep(j, ans.length() - 1, 0) {
      if(ans[j] == '-' || ans[j] == '0') {
        ans[j] = ans[j] == '-' ? '0' : '+';
        rep(k, j + 1, ans.length()) {
          ans[k] = '-';
        }
        break;
      }
      if(j == 0 && ans[j] == '+') {
        int c = ans.length();
        ans = '+';
        rep(k, 0, c) ans += '-';
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3184
#include <iostream>

using namespace std;


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


Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#define MAXA 100000
#define MAX 20000000000
#define s(i) scanf("%d", &(i))
#define p(i) printf("%d", (i))
#define ps() printf(" ") 
#define rer(i,j,k) for((i)=(j);(i)<=(k);++(i))
#define ret(i,j,k) for((i)=(j);(i)>=(k);--(i))
using namespace std;
//10000 5000 1000
int main(){
	int n, y, a1 = 0, a2 = 0, a3 = 0, i, j, t, is = 0;;
	cin >> n >> y;
	rer(i,0,n){
		rer(j,0,n-i){
			rer(t,0,n-i-j){
				if(1000*i+5000*j+10000*t==y&&(i+j+t)==n){
					is = 1;
					cout << t << " " << j << " " << i << endl;
					break;
				}
			}
			if(is){
				break;
			}
		}
		if(is){
			break;
		}
	}
	if(!is){
		cout << "-1 -1 -1" << endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(){
	int n, l;
	scanf("%d %d", &n, &l);
	vector<string> s;
	for(int i=0; i<n; i++){
		char tmp[l+1];
		scanf("%s", tmp);
		s.push_back(tmp);
	}
	sort(s.begin(), s.end());

	for(int i=0; i<n; i++){
		printf("%s", s[i].c_str());
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

vec l(1e5+5),r(1e5+5),num(1e5+5);

int main() {
  ll n;
  cin >> n;
  for(ll i=1;i<=n;i++) {
    ll tmp;
    cin >> tmp;
    num[tmp]=i;
    l[i]=i-1;
    r[i]=i+1;
  }
  ll ans=0;
  for(ll i=1;i<=n;i++) {
    ll x=l[num[i]],w=l[x];
    ll y=r[num[i]],z=r[y];
    if(x!=0) ans+=1LL*(x-w)*(y-num[i])*i;
    if(y!=n+1) ans+=1LL*(z-y)*(num[i]-x)*i;
    l[y]=x;
    r[x]=y;
  }
  cout << ans << endl;
}

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

#define MAX_N 4000000
#define MAX_LEN 4000000

using namespace std;

typedef long long lint;

const lint MOD = (lint)(1e9) + 7;

lint r1, c1;
lint r2, c2;

lint s;
lint s2;
void euclid(lint a, lint b, lint &x, lint &y, lint &d)

{

    if(b == 0)

    {

        x = 1;

        y = 0;



        d = a;

        return;

    }



    lint xx, yy, q = a / b;

    euclid(b, a % b, xx, yy, d);

    x = yy;

    y = xx - yy * q;

}



void poz(lint &n)

{

    if(n < 0)

    {

        n = MOD + n % MOD;

    }

}



lint fact[MAX_LEN + 1];

lint inv[MAX_LEN + 1];
lint invf[MAX_LEN + 1];



void getInv()

{

    fact[0] = inv[0] = invf[0] = 1;

    for(lint i = 1; i <= MAX_LEN; i ++)

        fact[i] = 1LL * fact[i - 1] * i % MOD;



    lint x, y, d;

    euclid(fact[MAX_LEN], MOD, x, y, d);

    poz(x);

    inv[MAX_LEN] = x * fact[MAX_LEN - 1] % MOD;
    invf[MAX_LEN] = x;


    for(lint i = MAX_LEN - 1; i >= 1; i --)

    {

        invf[i] = invf[i + 1] * (i + 1) % MOD;

        x = x * (i + 1) % MOD;

        inv[i] = x * fact[i - 1] % MOD;

    }

}

lint getComb(lint n, lint k)
{
    lint rez = 1;
    rez = fact[n] * invf[k] % MOD * invf[n - k] % MOD;

    return rez;
}

lint getRez(lint a, lint b, lint c, lint d)
{
    return fact[c + d] * invf[c] % MOD * invf[d] % MOD;
}

int main()
{
    getInv();

    cin >> r1 >> c1 >> r2 >> c2;
    r1 ++;
    c1 ++;
    r2 ++;
    c2 ++;

    lint rez = getRez(1, 1, r2, c2);

    rez -= getRez(1, 1, r2, c1 - 1);
    rez -= getRez(1, 1, r1 - 1, c2);
    rez += getRez(1, 1, r1 - 1, c1 - 1);

    while(rez < 0)
        rez += MOD;

    rez %= MOD;

    cout << rez << "\n";


    return 0;
}


Measured memory_bytes: 93952
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;

vector<string> board;
int H, W, K;
void func(int &su, int num, vector<bool> row, vector<bool> column) {
    if (num == H + W) {
        int cnt = 0;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (row[i] == 1) continue;
                if (column[j] == 1) continue;
                if (board[i][j] == '#') cnt++;
            }
        }
        if (cnt == K) su++;
        return;
    }

    if (num < H) {
        func(su, num + 1, row, column);
        row[num] = 1;
        func(su, num + 1, row, column);
    }
    else {
        func(su, num + 1, row, column);
        column[num - H] = 1;
        func(su, num + 1, row, column);
    }
    return;
}

int main() {
    cin >> H >> W >> K;
    board.resize(H);
    for (int i = 0; i < H; i++) cin >> board[i];
    int su = 0, num = 0;
    vector<bool> row(H, 0), column(W, 0);
    func(su, num, row, column);
    cout << su << endl;
}

Measured memory_bytes: 3664
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
     string[] str=Console.ReadLine().Split(' ');
      int[] input=str.Select(int.Parse).ToArray();
      int A=int.Parse(str[0]);
      int B=int.Parse(str[1]);
      int C=int.Parse(str[2]);
      Console.WriteLine(A*B/2);
    }
    
  }

}


Measured memory_bytes: 28212
#!/usr/bin/env python3
import sys
import heapq
INF = float("inf")


# 無向グラフを仮定する。
class Graph(object):
    def __init__(self, N):
        self.N = N
        self.V = list(range(N))
        self.E = [[] for _ in range(N)]

    def add_edge(self, edge):
        """辺を加える。edgeは(始点, 終点、重み)からなるリスト
        重みがなければ、重み1とする。
        """
        if len(edge) == 2:
            edge.append(1)
        elif len(edge) != 3:
            print("error in add_edge")
            pass

        s, t, w = edge
        self.E[s].append([t, w])

        pass


def shortestPath(g: Graph, s: int):
    """ グラフgにおいて、始点sから各頂点への最短路を求める
    引数
    g: グラフ, s: 始点
    返り値
    dist: 始点からの距離が格納されたリスト
    prev: 始点から最短経路で移動する場合、各頂点に至る前の頂点のリスト
    """
    dist = [INF]*g.N
    dist[s] = 0

    prev = [None]*g.N
    Q = []
    heapq.heappush(Q, (dist[s], s))

    while len(Q) > 0:
        _, u = heapq.heappop(Q)
        for v, w in g.E[u]:
            if dist[v] > dist[u]+w:
                dist[v] = dist[u]+w
                prev[v] = u
                heapq.heappush(Q, (dist[v], v))
    return dist, prev


def solve(N: int, M: int, u: "List[int]", v: "List[int]", S: int, T: int):
    g1 = Graph(3*N)
    for from_, to_ in zip(u, v):
        g1.add_edge((from_-1, N+to_-1, 1))
        g1.add_edge((N+from_-1, 2*N+to_-1, 1))
        g1.add_edge((2*N+from_-1, to_-1, 1))

    dist1, prev1 = shortestPath(g1, S-1)
    # print(dist1)
    # print(dist1)
    m = INF
    for i in range(3):
        if dist1[i*N+T-1] % 3 == 0 and m > (dist1[i*N+T-1]//3):
            m = dist1[i*N+T-1]//3
    if m == INF:
        print(-1)
    else:
        print(m)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    u = [int()] * (M)  # type: "List[int]"
    v = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        u[i] = int(next(tokens))
        v[i] = int(next(tokens))
    S = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(N, M, u, v, S, T)


if __name__ == '__main__':
    main()


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

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

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

vector<int>v[100009];
int col[100009],start;
int n,x;
bool used[100009];

int dfs(int now,int pre){ //cout<<"  "<<now<<endl;
  
  if(used[now]){
    start = now;
    return pre;
  }
  
  used[now]=1;
  r(i,v[now].size()){
    
    int nex = v[now][i];
    if(nex==pre)continue;
    
    int tmp=dfs(nex,now);
    if(tmp!=-1)return tmp;
    
  }
  return -1;
}

int dfs2(int now,int pre){ //cout<<"  "<<now<<" "<<pre<<endl;
  
  if(now==x)return col[now]=1;
  
  r(i,v[now].size()){
    
    int nex = v[now][i];
    if(nex==pre)continue;
    
    col[now] = dfs2(nex,now);
    if(col[now])return 1;
  }

  return 0;
  
}

int main(){
  cin>>n;
  r(i,n){
    int a,b;
    cin>>a>>b;
    a--;b--;
    v[b].push_back(a);
    v[a].push_back(b);
  }
  
   x = dfs(n/2,-1);
   // cout<<start<<"  "<<x<<endl;
   dfs2(start,x);
   

   //r(i,n)cout<<col[i]<<endl;
   int q;
   cin>>q;
   while(q--){
     int a,b;
     cin>>a>>b;
     a--;b--;
     if(col[a]&&col[b])cout<<2<<endl;
     else cout<<1<<endl;
   }
}


Measured memory_bytes: 13824
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
  string S;
  cin >> S;
  bool answer = false;
  for(int i = 0; i < 3; i++){
    if(S[i] == S[i+1]) answer = true;
  }

  cout << (answer? "Bad" : "Good") << endl;

  return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	int i=0;
	int ans=0;
	int best=0;
	while (i<s.size()){
		if (s[i]=='R') ans++; 
		if (s[i]=='S') best=max(ans,best),ans=0;
		i++;
	}
	best=max(best,ans);	
	cout<<best<<endl;
	return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  int a[n], c[n], ans = 0, j = 0, max = -1;
  for (int i=0; i<n; i++) scanf("%d", a+i);
  for (int i=n-1; i>=0; i--) {
    if (a[i]>=max) {
      c[ans++] = a[i];
      max = a[i];
      continue;
    }
    for (j=0; j<ans; j++) {
      if (a[i]<c[j]) {
        c[j] = a[i];
        if (j == ans-1) max = a[i];
        break;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define MAX 100005
#define pb push_back
#define INF 2147483647
#define MOD 1000000007
using namespace std;

typedef long long ll;

vector<int> factorize(int n)
{
    vector<int> v;
    for(int i = 2; i * i <= n; i++){
        while(n % i == 0){
            v.pb(i);
            n /= i;
        }
    }

    if(n != 1)
        v.pb(n);
    return v;
}

ll powMod(ll a, ll b)
{
    ll res = 1;
    while(b > 0){
        if(b & 1)
            res = (res * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }

    return res;
}

ll fact(int n)
{
    ll res = 1;
    for(int i = 1; i <= n; i++){
        res = (res * i) % MOD;
    }

    return res;
}

ll solve(int n, int r)
{
    ll res = 1;
    n = n + r - 1;
    for(int i = n; i >= n - r + 1; i--){
        res = (1LL * res * i) % MOD;
    }
    res = (res * powMod(fact(r), MOD - 2)) % MOD;
    return res;
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n, m;

    cin>>n>>m;

    map<ll, ll> mp;
    vector<int> factor = factorize(m);
    
    for(int i = 0; i < factor.size(); i++){
        mp[factor[i]]++;
    }

    ll ans = 1;
    for(map<ll, ll> :: iterator it = mp.begin(); it != mp.end(); it++){
        ans = (ans * solve(n, it->second)) % MOD;
        //cout<<solve(n, it->second)<<endl;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.Reader;
import java.io.InputStreamReader;
import java.util.Scanner;

import java.util.List;
import java.util.ArrayList;

public class Main {

    public static void main(String[] args) throws IOException {
        MyWriter writer = new MyWriter();
        Reader inputReader = new InputStreamReader(System.in);
        Scanner reader = new Scanner(inputReader);
        reader.useDelimiter("\n");

        CipherReader cipherReader = new CipherReader();
        cipherReader.addKeyword("the");
        cipherReader.addKeyword("this");
        cipherReader.addKeyword("that");

        while (reader.hasNext()) {
            final String line = reader.next();

            writer.write(cipherReader.read(line) + "\n");
        }

        writer.print();
    }

}

class Method {

    static final char WORD_BEGIN = 'a';
    static final char WORD_END = 'z';
    static final int WORD_RANGE = WORD_END - WORD_BEGIN + 1;

    private Method(){}

    public static int positiveRemain(int divident, int divisor) {
        int result = divident % divisor;
        if (result < 0) {
            result += divisor;
        }

        return result;
    }

    public static String displace(String text, int count) {
        if (count == 0) { return text; }

        String result = "";

        for (char word : text.toCharArray()) {
            char newWord;
            if (WORD_BEGIN <= word && word <= WORD_END) {
                newWord = (char) (positiveRemain(word - WORD_BEGIN + count, WORD_RANGE) + WORD_BEGIN);
            } else {
                newWord = word;
            }
            result += newWord;
        }

        return result;
    }

}

class CipherReader {

    private List<String> keywords;
    private static int OUT_OF_RANGE = Integer.MAX_VALUE;

    public CipherReader() {
        keywords = new ArrayList<String>();
    }

    public void addKeyword(String word) {
        keywords.add(word);
    }

    public String read(String cipherText) {
        final int shift = getShiftCount(cipherText);
        if (shift == OUT_OF_RANGE) { return null; }

        return Method.displace(cipherText, shift);
    }

    private int getShiftCount(String text) {
        String[] words = text.split("[ .]");

        for (final String word : words) {
            final int wordsLength = word.length();
            for (final String keyword : this.keywords) {
                if (wordsLength != keyword.length()) { continue; }

                final int shift = keyword.compareTo(word);
                if (!Method.displace(word, shift).equals(keyword)) { continue; }

                return shift;
            }
        }

        return OUT_OF_RANGE;
    }

}

// Not important

class MyWriter {
    private StringBuilder stringBuilder;
    public MyWriter() {
        this.stringBuilder = new StringBuilder();
    }
    public <T> void write(T text) {
        this.stringBuilder.append(text);
    }
    public void print() {
        System.out.print(stringBuilder);
    }
}

Measured memory_bytes: 26128
import heapq
X,Y,Z,K= map(int,input().split())
K = min(X*Y*Z,K)

A =sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int,input().split())),reverse=True)
C = sorted(list(map(int,input().split())),reverse=True)
pque =[(-(A[0]+B[0]+C[0]),(0,0,0))] 
memo= {}
cnt = 0

while pque:
    value, position = heapq.heappop(pque)
    if memo.get(position) is None :
        memo[position] = True
        cnt += 1 
        if cnt > K:
            break
    else: 
        continue
    print(-value)
    for patern in [[1,0,0],[0,1,0],[0,0,1]]:
        i,j,k = [v1+v2 for v1,v2 in zip(patern,position)]
        if i<X and j<Y and k<Z:
            heapq.heappush(pque,(-(A[i]+B[j]+C[k]),(i,j,k)))

Measured memory_bytes: 4720
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, p;
  cin >> s >> p;

  do {
    s = s + s;
  } while (s.size() < p.size());

  string answer = "No";
  if (s.find(p) < s.size()) {
    answer = "Yes";
  }
  cout << answer << endl;
  return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-7
//#define endl "\n"
using namespace std;
using namespace __gnu_pbds;

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

int main() 
{
    fastio
    int n;
    cin>>n;
    string s;
    cin>>s;

    ordered_set r, g, b;
    for(int i = 0; i<n; ++i) {
        if(s[i]=='R') r.insert(i);
        if(s[i]=='B') b.insert(i);
        if(s[i]=='G') g.insert(i);
    }

    ull ans = 0;
    for(int i = 0; i<n; ++i) {
        for(int j = i+1; j<n; ++j) {
            char first = s[i];
            char sec = s[j];
            if(first==sec) continue;

            char third = ('R'+'G'+'B') - (first+sec);
            //cout<<third<<endl;
            ll cur = 0;
            if(third=='R') {
                cur = r.size()-r.order_of_key(j);
                cur -= (r.find(2*j-i) != r.end());
            }
            else if(third=='G') {
                cur = g.size()-g.order_of_key(j);
                cur -= (g.find(2*j-i)!=g.end());
            }
            else if(third=='B') {
                cur = b.size()-b.order_of_key(j);
                cur -= (b.find(2*j-i)!=b.end());
            }

            ans += cur;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3816
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <iterator>
#include <math.h>
#include <cstdlib>
#include <cmath>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define dump(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
int main(){
  int A,B,C,D,X,Y;
  cin >> A >> B >> C >> X >> Y;
  int cost = 0;
  if(A+B >= 2 * C){
    int cost1 = 0,cost2 = 0;
    cost1 += min(X,Y) * C * 2;
    if(X < Y){
      cost1 += (Y-X)* B;
    }else{
      cost1 += (X-Y)* A;
    }
    cost2 = max(X,Y)*C *2;
    cost = min(cost1,cost2);
  }else{
    cost = X * A + Y * B;
  }
  cout << cost << endl;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;
bool cmp(int x,int y)
{
	return x>y;
}
int n,k,s;
int a[55];
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=k;i++) s+=a[i];
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;

int main(void) {
  long long int n;
  cin >> n;
  long long int m = n;
  cout << n << ":";
  for(int i=2; i*i<m; i++){
    while( n % i == 0 ){
      n /= i;
      cout << " " << i;
    }
  }
  if( n != 1 ) cout << " " << n;
  cout << endl;

  return 0;
}





// EOF

Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();

		String replace = String.valueOf(n);

		replace = replace.replace("1", "x");
		replace = replace.replace("9", "1");
		replace = replace.replace("x", "9");

		System.out.println(replace);

		sc.close();
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;

typedef vector<int> vi;
typedef vector<ui> vui;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vui> vvui;
typedef vector<vll> vvll;
typedef vector<vull> vvull;
typedef vector<vs> vvs;

typedef string ss;
#define forr(i,b) for(int i = 0; i < b; i++)
#define ford(i,b) for(int i = b; i >= 0; i--)
#define ff for(;;)

template<typename T> int sgn(T val) { return (T(0) < val) - (val < T(0)); }
int gcd(int a, int b) { if(a == 0) return b; return gcd(b % a, a); }
int ncr(int n, int k) { int r = 1; if(k > n - k) k = n - k; for(int i=0;i<k;i++) { r *= n - i; r /= i + 1; } return r; }
template<typename T> void printa(vector<T> arr) { for(ui i = 0; i < arr.size(); i++) if(i != arr.size() - 1) cout << arr[i] << ' '; else cout << arr[i] << '\n'; }

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

    int s,w;
    cin >> s >> w;

    printf("%s\n",s>w?"safe":"unsafe");

    return 0;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  //約数列挙
  vector<int64_t> div(0);
  for(int n=1; n*n<=N; n++){
    if(N %n == 0){
      div.push_back(n);
      if(N /n != n){
        div.push_back(N /n);
      }
    }
  }
  
  int64_t ansA = -1;
  int64_t ansB = -1;
  
  for(int i=0; i<div.size(); i++){
    for(int64_t a = 0; a <= 200; a++){
      int64_t b = a - div[i];
      int64_t c = pow(a,4) + pow(a,3)*b + pow(a,2)*pow(b,2) + pow(b,3)*a + pow(b,4);
      if(c*div[i] == N){
        ansA = a;
        ansB = b;
      }
    }
  }
  
  cout << ansA << " " << ansB << endl;
}


Measured memory_bytes: 4232
import java.util.*;
public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int data[]=new int[n];
    int count=0;
    for(int i=0;i<n;i++){
      data[i]=sc.nextInt();
    }
    for(int i=0;i<n;i++){
      if(data[i]>=k){
        count++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 47992
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    int ans = 0;
    rep(i,x){
        int a, b;
        cin >> a >> b;
        if(y<=a&&z<=b){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[3];
int main(){
    ios::sync_with_stdio(false);
    cin>>a[0]>>a[1]>>a[2];
    int ans=0;
    while (a[0]!=a[1]||a[0]!=a[2]||a[1]!=a[2]){
        sort(a,a+3);
        if (a[0]!=a[1])a[0]+=2;
        else
            a[0]++,a[1]++;
        ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
import static java.util.Arrays.deepToString;

import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	
	public void run() {
		int[] ans = new int[100];
		
		PriorityQueue<Event> pq = new PriorityQueue<Event>();
		int[] table = new int[17];
		Arrays.fill(table, -1);
		int nextGroup = 0;
		for (int i = 0; i < 100; i++) {
			Event e = new Event();
			e.id = i;
			e.move = Event.ARRIVE;
			e.initTime = i * 5;
			e.time = i * 5;
			e.num = i % 5 == 1 ? 5 : 2;
			e.duration = 17*(i%2) + 3*(i%3)+19;
			pq.add(e);
		}
		while (!pq.isEmpty()) {
			Event e = pq.poll();
			if (e.move == Event.LEAVE) {
				for (int i = 0; i < table.length; i++) {
					if (table[i] == e.id) table[i] = -1;
				}
			} else if (e.move == Event.ARRIVE) {
				int pos = -1;
				if (nextGroup == e.id) {
					for (int i = 0; i + e.num <= table.length; i++) {
						boolean ok = true;
						for (int j = 0; j < e.num; j++) {
							if (table[i+j] != -1) {
								ok = false;
								break;
							}
						}
						if (ok) {
							pos = i;
							break;
						}
					}
				}
				if (pos >= 0) {
					// 座る
					ans[e.id] = e.time - e.initTime;
					for (int j = 0; j < e.num; j++) {
						table[pos + j] = e.id;
					}
					e.time += e.duration;
					e.move = Event.LEAVE;
					pq.add(e);
					nextGroup++;
				} else {
					// 空いてなければ待つ。時刻+1して席が空くのを待つ手抜き実装
					e.time++;
					pq.add(e);
				}
			}
		}
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			System.out.println(ans[n]);
		}
	}
	
	class Event implements Comparable<Event> {
		static final int LEAVE = 0;
		static final int ARRIVE = 1;
		int id;
		int initTime;
		int move;
		int time;
		int num;
		int duration;
		@Override
		public int compareTo(Event o) {
			int c = time - o.time;
			if (c == 0) c = move - o.move;
			if (c == 0) c = id - o.id;
			return c;
		}
	}
}

Measured memory_bytes: 19220
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int b = 0;
    for (int i = 1; i < 10; i++) {
        if (n % i == 0 && n / i < 10) {
            b = 1;
            break;
        }
    }

    cout << (b ? "Yes" : "No") << endl;

    return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> s(n);

    int sum = 0;
    rep(i, n) {
        cin >> s.at(i);
        sum+= s.at(i);
    }
    if (sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    }

    sort(s.begin(), s.end());
    rep(i, n) {
        int tmp = 0;
        tmp = sum - s.at(i);
        if (tmp % 10 != 0) {
            cout << tmp << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}

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


  

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> l(m),r(m);
  rep(i,m) cin >> l.at(i) >> r.at(i);
  sort(all(l));
  sort(all(r));
  
  int ans = r.at(0)-l.at(m-1)+1;
  ans > 0 ? cout << ans : cout << 0;
}

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

int linearSearch(int *,int);

int N,M;

int main(){
  int count=0,a;
  int i,*arrayS,*arrayT;
  
  scanf("%d",&N);
  arrayS = (int *)malloc(sizeof(int) * N);
  for(i=0;i<N;i++){
    scanf("%d",&arrayS[i]);
  }

  scanf("%d",&M);
  arrayT = (int *)malloc(sizeof(int) * M);
  for(i=0;i<M;i++){
    scanf("%d",&arrayT[i]);
  }

  for(i=0;i<M;i++){
    a = linearSearch(arrayS,arrayT[i]);
    count+=a;
  }
  
  printf("%d\n",count);

free(arrayS);
free(arrayT);

return 0;
}

int linearSearch(int arrayS[],int key){
  int i;

  for(i=0;i<N;i++){
    if(arrayS[i] == key) return 1;
  }
  return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
int sz = 100002;
float n, i;
//vector<int>tree[sz];
int main() {
// freopen("input.txt", "r", stdin); 
// freopen("output.txt", "w", stdout); 
	cin>>n;
	cout<<fixed<<setprecision(10)<<2*M_PI*n;
}


Measured memory_bytes: 3800
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
data = [[] for _ in range(n)]
for i in range(n-1):
    a,b = mi()
    data[a-1].append((b-1,i))
    data[b-1].append((a-1,i))
    if i == 0:
        num = a-1
        col = 0

ans = [0]*(n-1)
from collections import deque
ima = deque()
ima.append([num,col])
while ima:
    num,col = ima.popleft()
    tmp = 1
    for lis in data[num]:
        if ans[lis[1]] != 0:
            continue
        if tmp == col:
            tmp += 1
        ans[lis[1]] = tmp
        ima.append([lis[0],tmp])
        tmp += 1
a = 0        
for i in range(n-1):
    a = max(a,ans[i])
print(a)
for i in range(n-1):
    print(ans[i])

        


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

using namespace std;

typedef long long int ll;

ll M = 1e9 + 7;

int main()
{
    ll n;
    cin >> n;
    ll dp[2005] = {0};

    dp[0] = 1;
    dp[1] = 0;
    dp[2] = 0;
    if(n<3)
        cout << 0 <<"\n";
    else
    {
        for(int i=3 ; i<=n ; i++)
        {
            dp[i] = dp[i-3];
            dp[i-2] += dp[i-3];
            dp[i-2] %= M;
        }
        cout << dp[n-3];
    }
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    int a;cin >> a;
    ll n[a],ans=1;
    bool zero = false ;

    for(int i=0;i<a;i++){
        cin >> n[i];
        if(n[i]==0){
            zero=true;
        }
    }

    if(zero){
        cout << 0 << endl;
        return 0;
    }
    
    for(int i=0;i<a;i++){
        if(n[i]<=1000000000000000000/ans){
            ans = ans *n[i];
        }
        else{
            cout << -1 << endl;
            return 0;
        }
    }
    
     cout << ans <<endl;
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

int main() {
  double a, b, x;
  double theta;
  cin >> a >> b >> x;

  if(x > (a * a * b)/2){
    theta = atan( 2*(a*a*b - x) / (a*a*a) );
  }else{
    theta = atan((a*b*b)/(2*x));
  }

  double PI = 3.14159265358979;
  theta = theta * 180 / PI;
  cout << fixed << setprecision(10) << theta;

  return 0;

}

Measured memory_bytes: 4068
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N; 
  int a, b, c, d;
  while(cin>>N && N){
    cin>>a>>b>>c>>d;
    a--; b--; c--; d--;
    int x[4], y[4] = {};
    int ans = INF;
    for(int w = 1; w <= N; w++){
      int nx = 0, ny = 0;
      REP(iter, N){
        if(iter == a){
          x[0] = nx, y[0] = ny;
        }else if(iter == b){
          x[1] = nx, y[1] = ny;
        }else if(iter == c){
          x[2] = nx, y[2] = ny;
        }else if(iter == d){
          x[3] = nx, y[3] = ny;
        }
        nx++;
        if(nx == w){
          nx = 0;
          ny++;
        }
      }
      ans = min(ans, abs(x[0] - x[1]) + abs(x[2] - x[3]) + abs(y[0] - y[1]) + abs(y[2] - y[3]));
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
n,m = (int(x) for x in input().split())
memo = [0]*n
pena = [0]*n
ans2 = 0
for i in range(m):
    p,s = (str(x) for x in input().split())
    p = int(p)
    if s=="AC":
        memo[p-1] = 1
    elif s=="WA":
        if memo[p-1]==0:
            pena[p-1] += 1

for j in range(n):
    if memo[j]==1:
        ans2 += pena[j]

print("{} {}".format(sum(memo),ans2))

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<ll, int>;

const ll INF = 1LL<<59;
int di[] = {-1, 0, 1, 0};
int dj[] = {0, -1, 0, 1};

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    int si, sj, ti, tj;
    cin >> si >> sj >> ti >> tj;
    --si, --sj, --ti, --tj;
    vector<string> g(h);
    rep(i,h) cin >> g[i];

    auto toID = [&](int i, int j, int v){
        return (i * w + j) * 4 + v;
    };
    auto modCeilK = [&](ll x){
        return (x + k - 1)/k * k;
    };

    vector<ll> dist(h * w * 4, INF);
    priority_queue<P, vector<P>, greater<P>> q;

    auto push = [&](int i, int j, int v, ll x){
        int id = toID(i,j,v);
        if(dist[id] <= x) return;
        dist[id] = x;
        q.emplace(x, id);
    };

    rep(v,4) push(si, sj, v, 0);
    while(!q.empty()){
        ll d = q.top().first;
        int id = q.top().second;
        q.pop();
        if(dist[id] != d) continue;
        int i = id/w/4;
        int j = id/4%w;
        int v = id%4;
        rep(nv,4) push(i,j,nv,modCeilK(d));
        {
            int ni = i + di[v], nj = j + dj[v];
            if(0 <= ni && ni < h && 0 <= nj && nj < w){
                if(g[ni][nj] == '.'){
                    push(ni, nj, v, d+1);
                }
            }
        }
    }
    ll ans = INF;
    rep(v,4) ans = min(ans, dist[toID(ti, tj, v)]);
    if(ans == INF){
        cout << -1 << endl;
    }else{
        ans = modCeilK(ans)/k;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 44220
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    string t; cin >> t;
    rep(i,t.size()) {
        if (t[i]=='?') t[i] = 'D';
    } 
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3752
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using Atcoder.AtCoderBeginnerContest101.Questions;
using Atcoder.AtCoderBeginnerContest101.Extensions;

namespace Atcoder.AtCoderBeginnerContest101
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answer = question.Solve(Console.In);
            Console.WriteLine(answer);
        }
    }
}

namespace Atcoder.AtCoderBeginnerContest101.Questions
{
    // ここにQuestionクラスをコピペ
    public class QuestionC : AtCoderQuestionBase
    {
        public override string Solve(TextReader inputStream)
        {
            var nk = inputStream.ReadIntArray();
            var n = nk[0];
            var k = nk[1];

            return ((int)(Math.Ceiling((n - 1.0) / (k - 1.0)) + double.Epsilon)).ToString();
        }
    }

    #region Base Classes

    public interface IAtCoderQuestion
    {
        string Solve(string input);
        string Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public string Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract string Solve(TextReader inputStream);
    }

    #endregion
}

#region Extensions

namespace Atcoder.AtCoderBeginnerContest101.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REP_REV(i,a,b) for (int i = a; i >= b; i--)
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;

ll MOD = 1e9 + 7;

struct Rect {
	ll x1 = 0, y1 = 0, x2 = 0, y2 = 0;
	ll area() { return (x2 - x1) * (y2 - y1); }
};

Rect intersect(Rect p, Rect q) {
	Rect inter;
	inter.x1 = max(p.x1, q.x1);
	inter.y1 = max(p.y1, q.y1);
	inter.x2 = min(p.x2, q.x2);
	inter.y2 = min(p.y2, q.y2);
	if (inter.x1 >= inter.x2 || inter.y1 >= inter.y2) {
		Rect empty;
		return empty;
	}
	return inter;
}

bool iscovered(int x, int y, int x1, int y1, int x2, int y2) {
	return (x <= x2 && x >= x1 && y <= y2 && y >= y1);
}

void solve() {
	ll n; cin >> n;
	vl a(n);
	REP(i, 0, n - 1) cin >> a[i];
	ll sum = 0;
	REP(i, 0, n - 1) sum += a[i];
	ll ans = 0;
	REP(i, 0, n - 1) {
		sum -= a[i];
		ans += (sum % MOD * a[i]) % MOD;
		ans %= MOD;
	}
	cout << ans;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	//freopen("billboard.in", "r", stdin);
	//freopen("billboard.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//ll t; cin >> t;
	//while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 4724
import sys
bbn=1000000007
	
#+++++
		
def main():
	s = input()
	ret=s[0]+str(len(s)-2)+s[-1]
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38256
fun main (args : Array<String>) {
	val (n, m, x, y) = readLine()!!.split(" ")
	val X : Int = x.toInt()
	val Y : Int = y.toInt()
	val list1 = readLine()!!.split(" ")
	val list2 = readLine()!!.split(" ")
	var xList : MutableList<Int> = mutableListOf()
	var yList : MutableList<Int> = mutableListOf()
	var flag : Boolean = false
	for (i in list1) {
		xList.add(i.toInt())
	}
	for (i in list2) {
		yList.add(i.toInt())
	}
	xList.sort()
	yList.sort()
	for (i in xList[xList.size - 1]..yList[0]) {
		if ((i > X) && (i <= Y) && (i > xList[xList.size - 1]) && (i <= yList[0])) {
			flag = true
			break
		}
	}
	if (flag) {
		return println("No War")
	} else {
		return println("War")
	}
}

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

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    if (s[0] == '1')
        ans++;
    if (s[1] == '1')
        ans++;
    if (s[2] == '1')
        ans++;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,v,l[200005],b,e;
int main()
{
    cin>>n;
    b=ceil((double)(n+1)/2);
    e=(n%2==0)?(-1):(1);
    for(int i=1;i<=n;i++){
        cin>>v;
        l[b]=v;
        b+=i*e;
        e*=-1;
    }
    for(int i=1;i<=n;i++)
    cout<<l[i]<<" ";
    return 0;
}

Measured memory_bytes: 3452
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N;
string S;
int dp[500001][3];
const int MI = INT_MIN / 4;

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

    rep(i, N + 1)rep(j, 3)dp[i][j] = MI;
    dp[0][0] = 0;
    int cur;
    rep(i, N)rep(j, 3) if((cur=dp[i][j])>MI){
        if (j == 0) {
            smax(dp[i + 1][0], cur);
            if (S[i] == '1')smax(dp[i + 1][1], cur - 1);
            if (i + 2 <= N && S[i] == '1'&&S[i + 1] == '0')smax(dp[i + 2][2], cur);
        } else if (j == 1) {
            if (i + 2 <= N && S[i] == '0'&&S[i + 1] == '1')smax(dp[i + 2][0], cur + 2);
            if (S[i] == '1')smax(dp[i + 1][j], cur + 1);
        } else {
            if (S[i] == '1') {
                smax(dp[i + 1][0], cur + 1);
                smax(dp[i + 1][2], cur + 1);
            }
        }
    }
    cout << dp[N][0] << endl;
}


Measured memory_bytes: 6812
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var (
	sc = bufio.NewReader(os.Stdin)
)

func main() {
	N := scanInt()
	X := scanInt()
	T := scanInt()
	t := 0
	for {
		t += T
		N -= X
		if N <= 0 {
			break
		}
	}
	fmt.Println(t)
}

func abs(a int) int         { return int(math.Abs(float64(a))) }
func scan(a ...interface{}) { _, err := fmt.Fscan(sc, a...); pnc(err) }
func scanStr() (s string)   { scan(&s); return }
func scanInt() int          { i, err := strconv.Atoi(scanStr()); pnc(err); return i }
func scanFloat() float64    { f, err := strconv.ParseFloat(scanStr(), 64); pnc(err); return f }
func pnc(err error) {
	if err != nil {
		panic(err)
	}
}


Measured memory_bytes: 1844