akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int count = Integer.parseInt(line);
      
      int ac = 0;
      int wa = 0;
      int tle = 0;
      int re = 0;
      for(int i=0;i<count;i++){
        String judge = sc.nextLine();
        if(judge.equals("AC")){
            ++ac;
        } else if(judge.equals("WA")){
            ++wa;
        } else if(judge.equals("TLE")){
            ++tle;
        } else {
            ++re;
        }
      }
      
      System.out.println("AC x "+String.valueOf(ac));
      System.out.println("WA x "+String.valueOf(wa));
      System.out.println("TLE x "+String.valueOf(tle));
      System.out.println("RE x "+String.valueOf(re));
    }
}

Measured memory_bytes: 60852
use num_integer::Integer;
use whiteread::parse_line;

fn main() {
    let (_n, start): (usize, isize) = parse_line().unwrap();
    let x: Vec<isize> = parse_line().unwrap();
    let mut ans = 0;

    for xi in x {
        ans = ans.gcd(&(xi - start));
    }
    println!("{}", ans);
}


Measured memory_bytes: 3956
n = int(input())

for i in range(10**5):
    if 2 * n == i ** 2 - i:
        k = i
        break
    elif 2 * n < i ** 2 - i:
        print('No')
        exit()

k = int(k)
print('Yes')
print(k)
num, ans = 1, [[] for _ in range(k)]
for i in range(k):
    for j in range(i + 1, k):
        ans[i].append(num)
        ans[j].append(num)
        num += 1
    print(k - 1, *ans[i])


Measured memory_bytes: 76800
package main
import "fmt"
func main() {
  var n int
  var p float64
  fmt.Scan(&n)
  var dp [][]float64 = make([][]float64,n+1)
  for i:=0;i<n+1;i++ { dp[i] = make([]float64,n+1) }
  dp[0][0] = 1
  for i:=1;i<n+1;i++ {
    fmt.Scan(&p)
    for j:=0;j<i;j++ { dp[i][j] += dp[i-1][j]*(1-p) }
    for j:=1;j<=i;j++ { dp[i][j] += dp[i-1][j-1]*p }
  }
  p = 0
  for i:=n/2+1;i<=n;i++ { p += dp[n][i] }
  fmt.Printf("%.12f\n",p)
}

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

using namespace std;
constexpr int INF = 1000000001;

char color[] = "RGB";

int main() {
  int n;
  cin>>n;
  vector<pair<int,int>> s;
  REP(i,n) {
    int h,w;
    cin>>h>>w;
    s.emplace_back(h,w);
  }
  string t;
  REP(i,4) {
    string s;
    cin>>s;
    t += s;
  }
  vector<int> dp(1<<16, INF);
  dp[0] = 0;
  REP(i,1<<16) {
    REP(j,n) {
      int h,w;
      tie(h,w) = s[j];
      FOR(y,-h+1,4)FOR(x,-w+1,4) {
        int bits = 0;
        REP(k,h)REP(l,w) {
          int py = y + k;
          int px = x + l;
          if (px < 0 || px >=4 || py < 0 || py >= 4) continue;
          int index = px + 4*py;
          if ((i >> index) & 1) continue;
          bits |= 1 << index;
        }
        if (bits == 0) continue;
        REP(k,3) {
          bool ok = true;
          REP(l,16) {
            if ((bits >> l) & 1) {
              if (t[l] != color[k]) {
                ok = false;
                break;
              }
            }
          }
          if (ok) {
            dp[i|bits] = min(dp[i|bits], dp[i] + 1);
          }
        }
      }
    }
  }
  cout << dp[(1<<16)-1] << endl;
  return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

ll n,k,sum = 0;
cin >> n >> k;
vector<long long> h(n);
repll(i,n) cin >> h[i];
Sort(h);

if(n < k) cout << 0 << endl;
else{
    repll(i,n-k) sum += h[i];

    cout << sum << endl;
}

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;


int main(){
  bool flag=false;
  string s;
  int a,b;
  cin>>a>>b>>s;

  for(int i=0;i<a+b+1;i++){
    if(i!=a){
      if(s[i]-'0'<=9 && s[i]-'0'>=0) continue;
      else{
        flag=true; break;
      }
    }else if(s[i]!='-'){
      flag=true; break;
    }
  }
  if(flag) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;


class Magatro
{
    static int sx, sy, tx, ty;
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        sx = int.Parse(s[0]);
        sy = int.Parse(s[1]);
        tx = int.Parse(s[2]);
        ty = int.Parse(s[3]);
        StringBuilder ans = new StringBuilder();
        ans.Append('U', ty - sy);
        ans.Append('R', tx - sx);
        ans.Append('D', ty - sy);
        ans.Append('L', tx - sx + 1);
        ans.Append('U', ty - sy+1);
        ans.Append('R', tx - sx+1);
        ans.Append("DR");
        ans.Append('D', ty - sy+1);
        ans.Append('L', tx - sx + 1);
        ans.Append('U');
        Console.WriteLine(ans.ToString());
     //   Console.WriteLine(ans.ToString().Length == "UURRURRDDDLLDLLULUUURRURRDDDLLDL".Length);
        



    }
}


Measured memory_bytes: 2776
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,d;
    cin>>n>>d;
    int x,y;
    int cnt=0;
    for(int i=0;i<n;i++) {
        cin>>x>>y;
        long dist=pow(x,2)+pow(y,2);
        double di=(1.0*sqrt(dist));
        if(di<=d)
        cnt++;
    }
    cout<<cnt;
}


Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main
{
	public static void main(String arg[])throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();
		System.out.println(str.toUpperCase());
	}

}

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

#define int long long
#define endl '\n'

const int M = 1e9 + 7;

int sum(int x) {
    if (x < 0)  return 0;
    return 1ll * x * (x + 1) / 2ll;
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n, k; cin >> n >> k;
    int ans = 0;
    for (int i = k; i <= n + 1; i++) {
        int mn = sum(i - 1), mx = sum(n) - sum(n - i);
        ans += mx - mn + 1;
        ans %= M;
    }
    cout << ans;
}

Measured memory_bytes: 3656
def union(x, y):
    link(findSet(x), findSet(y))

def link(x, y):
    if r[x] > r[y]:
        p[y] = x
    else:
        p[x] = y
        if r[x] == r[y]: r[y] = r[y] + 1

def findSet(x):
    if x != p[x]:
        p[x] = findSet(p[x])
    return p[x]


if __name__ == '__main__':

    p = [];
    r = [];

    n_set, n_quare = map(int, input().split())

    for i in range(n_set):
        p.append(i)
        r.append(0)


    for i in range(n_quare):
        q, x, y = map(int, input().split())

        if q == 0:
            union(x, y)

        else:
            print(int(findSet(x) == findSet(y)))



Measured memory_bytes: 6156
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val (a, b, m) = intList()
    val aa = intList()
    val bb = intList()
    val notDiscount = aa.min()!! + bb.min()!!
    val discount = 0.until(m).map {
        val (x, y, c) = intList()
        aa[x - 1] + bb[y - 1] - c
    }.min()!!
    val min = Math.min(notDiscount, discount)
    println(min.toString())
}

Measured memory_bytes: 92128
import java.util.Scanner;
class Main
{
public static void main (String [] args)
{
Scanner sc=new Scanner(System.in);
char c=sc.next().charAt(0);
char d=sc.next().charAt(0);char ans='=';
if(c<d)
ans='<';
else if(c>d)
ans='>';
System.out.println(ans);
}
}

Measured memory_bytes: 21844
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_A
  * ??§?°???¢???
  * ???????????´??° a, b ?????????????????§???a ??¨ b ?????§?°???¢??????????????????????????°?????????????????????????????????
  */
object Main {
  def main(args: Array[String]): Unit = {
    val intPair = io.StdIn.readLine().split(" +").map(_.toInt).toSeq
    val (a, b) = intPair match {
      case Seq(x, y) => (x, y)
    }
    val relationShipString = getRelationshipString(a, b)
    println(s"a $relationShipString b")
  }

  def getRelationshipString[A: Ordering](a: A, b: A): String = {
    implicitly[Ordering[A]].compare(a, b) match {
      case -1 => "<"
      case 0 => "=="
      case 1 => ">"
    }
  }
}

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

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

int N;
char S[101];

int main(void){
    cin >> N;
    for(int i=0;i<N;i++)    cin >> S[i];
    
    string ans = "Three";
    for(int i=0;i<N;i++){
        if(S[i] == 'Y'){
            ans = "Four";
            break;
        }
    }
    
    cout << ans << endl;
}

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

int main(){

	int n,a,b, c = 0;
	cin >> n;
	bool ok = 0;
	for(int i = 0; i < n; i++){
		cin >> a >> b;
		if(a == b)
			c++;
		else
			c = 0;
		if(c >= 3)
			ok = 1;
	}
	if(ok)
		cout << "Yes\n";
	else
		cout << "No\n";
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

typedef pair<int, int> P;
#define INF 1e9
#define INF_LL 1LL<<60
#define ll long long

int main() {
    ll a, b, k;
    cin >> a >> b >> k;

    if(a >= k) {
        cout << a-k << " " << b << endl;
    } else if (a+b >= k) {
        cout << "0" << " " << b - (k-a) << endl;
    } else {
        cout << "0 0" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

int main(){
   string S;
   cin>>S;
   int ans=INF;
   rep(chr,26){
      char s='a'+chr;
      int mx_len=0,len=0;
      rep(i,sz(S)){
         if(S[i]==s){
            len=0;
         }
         else{
            len++;
         }
         chmax(mx_len,len);
      }
      chmin(ans,mx_len);
   }
   cout<<ans<<endl;
}

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

int main(){
    int chr[26] = {0};
    string str;
    
    while(1){
        getline(cin, str);
        
        if(str[0] == NULL) break;
        
        for(int i = 0; i < str.size(); i++){
            if(str[i] >= 'a' && str[i] <= 'z') chr[str[i] - 'a']++;
            else if(str[i] >= 'A' && str[i] <= 'Z') chr[str[i] - 'A']++;
        }
    }
    
    for(int i = 0; i < 26; i++){
        cout << (char)('a' + i) << " : " << chr[i] << endl;
    }
}


Measured memory_bytes: 3208
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 	3.14159265358979323846

int main(){
	ll ans = 0;
	string w;
	cin >> w;
	REP(i,w.size()){
			if(65<w[i]&&w[i]<91){
				w[i] += 32;
			}
		}
	while(1){
		string s;
		cin >> s;
		if(s=="END_OF_TEXT"){
			cout << ans << endl;
			return 0;
		}
		if(s.size()==w.size()){
			REP(i,s.size()){
				if(64<s[i]&&s[i]<91){
					s[i] += 32;
				}
			}
			//cout << s << endl;
			if(s==w){
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

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

	int n;
	cin >> n;

	vector<int> a(n + 1), b(n + 1), c(n);
	
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	
	for(int i = 1; i <= n; i++) {
		cin >> b[i];
	}
	
	for(int i = 1; i < n; i++) {
		cin >> c[i];
	}

	int prev = -1, ans = 0;

	for(int i = 1; i <= n; i++) {
		int cur = a[i];
		ans += b[cur];
		if(cur == prev + 1) {
			ans += c[prev];
		}
		prev = cur;
	}

	cout << ans << '\n';


	return 0;
}


Measured memory_bytes: 256
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    n,i = map(int,input().split())
    print(n-i+1)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 39020
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Trim();
            var p = Console.ReadLine().Trim();
            s += s;

            if (s.Contains(p))
            {
                System.Console.WriteLine("Yes");
            }
            else
            {
                System.Console.WriteLine("No");
            }
        }
}
}

Measured memory_bytes: 9736
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int a = scanner.nextInt();
			String op = scanner.next();
			int b = scanner.nextInt();
			if (op.equals("?")){
			    break;
			}
			int answer = 0;
			if (op.equals("+")){
			    answer = a + b;
			}else if (op.equals("-")){
			    answer = a - b;
			}else if (op.equals("*")){
			    answer = a * b;
			}else{
			    answer = a / b;
			}
			System.out.println(answer);

		}
	}
}



Measured memory_bytes: 26368
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6+5;
const ll N = 1e3+5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;

set<string>se;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans1=0;
    while(a>0){
        ans1++;
        a-=d;
    }
    int ans2=0;
    while(c>0){
        ans2++;
        c-=b;
    }
    if(ans1<ans2) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>

#define MOD 1000000007

using namespace std;

string replace_with_str(string str, string str_from, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(str_from, pos), pos != string::npos) {
        str.replace(pos, str_from.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(int argc, char const *argv[]){
    map<char, string> s;
    cin >> s['a'];
    cin >> s['b'];
    cin >> s['c'];
    
    char next = 'a';
    while(true){
        char now = next;
        if(s[now].size() == 0){
            printf("%c\n", now + 'A'-'a');
            return 0;
        }
        next = s[now][0];
        s[now].erase(0, 1);
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

#define for_in(i, l, u) for (i = l; i <= u; ++i)
#define for_step(i, l, u, s) for (i = l; i <= u; i += s)
#define is_in(i, l, u) ((l) <= (i) && (i) <= (u))
#define times(N) for (int itr##N = 0; itr##N < N; ++itr##N)

using namespace std;

int main()
{
    int dif = 0;
    int sum = 0;
    times(5)
    {
        int i;
        cin >> i;
        int j = ((i - 1) / 10 + 1) * 10;
        int _dif = j - i;
        if (_dif > dif)
        {
            dif = _dif;
        }
        sum += j;
    }
    sum -= dif;

    cout << sum << endl;
}


Measured memory_bytes: 256
# 各数値の取得
a,b,c,d = map(int,input().split())

#各条件に沿ってメッセージを出力
#1:aとcの差分の絶対値がd以下の場合、直接会話が可能であるため「Yes」を出力
if abs(a-c) <= d:
    print("Yes")
#2:aとbの差分及びbとcの差分がd以下の場合、関節会話が可能であるため「Yes」を出力
elif abs(a-b) <=d and abs(b-c) <= d:
    print("Yes")
# 1及び2のどちらの条件にも当てはまらない場合、会話が不可能のため「No」を出力
else:
    print("No")

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define N 200011
int n;
LL a[N],b[N],k,ans;
bool cmp(int x,int y){
	return x>y;
}
bool check(LL tmp){
	LL tp=k;
	for(int i=1;i<=n;i++){
		if(a[i]*b[i]>tmp){
			LL tp1=a[i]-tmp/b[i];
			tp-=tp1;
		}
		if(tp<0) return 0;
	}
	return 1;
}
int main(){
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)scanf("%lld",&b[i]);
	sort(a+1,a+n+1);sort(b+1,b+n+1,cmp);
	LL mx=0;
	for(int i=1;i<=n;i++) mx=max(mx,a[i]*b[i]);
	LL l=0;LL r=mx;
	while(l<=r){
		LL mid=(l+r)>>1ll;
		if(check(mid)){
			ans=mid;
			r=mid-1;
		}else l=mid+1;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 3328
#include <iostream>

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

const int SIZE = 45;
int f[SIZE];

int fib(int n) {
  if (f[n]) return f[n];

  if (n == 0 || n == 1) return f[n] = 1;
  return f[n] = fib(n - 1) + fib(n - 2);
}

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

  std::cout << fib(n) << '\n';
  return 0;
}



Measured memory_bytes: 3100
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())

    # 各頂点の次数
    deg = [0 for _ in range(n)]
    # グラフ
    edge = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        edge[a - 1].append(b - 1)
        deg[b - 1] += 1

    # 入力辺を持たないノードの集合
    que = deque([])
    for i in range(n):
        if deg[i] == 0:
            que.append(i)

    # トポロジカルソートを行いながら、入力辺を持たないノードからの最長経路を求める
    dp = [0 for _ in range(n)]
    while que:
        v = que.popleft()
        for nv in edge[v]:
            # 入力辺を一つ消す
            deg[nv] -= 1
            if deg[nv] == 0:
                que.append(nv)
                dp[nv] = max(dp[nv], dp[v] + 1)

    print(max(dp))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 23184
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
int n,m,memo[100000];
vector<int> adj[100000];

int dfs(int i){
	if(memo[i] != -1) return memo[i];
	memo[i] = 0;
	for(auto v : adj[i]){
		memo[i] = max(memo[i],1+dfs(v));
	}
	return memo[i];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	memset(memo,-1,sizeof(memo));
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		x--; y--;
		adj[x].push_back(y);
	}
	for(int i=0;i<n;i++){
		if(memo[i] == -1){
			dfs(i);
		}
	}
	int ans = 1;
	for(int i=0;i<n;i++) ans = max(ans,memo[i]);
	cout<<ans<<"\n";
	return 0;
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N, M;
    cin>>N>>M;
    vvi G(N);
    REP(i, 0, M){
        int A, B;
        cin >> A >> B;
        A--; B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    vi ans(N, -1);
    queue<int> que;
    que.push(0);
    while(!que.empty()){
       auto p = que.front(); que.pop();
       for(int x: G[p]){
           if(ans[x] == -1){
               ans[x] = p+1;
               que.push(x);
           }
        }
    }
    REP(i, 0, N){
        if(ans[i] == -1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    REP(i, 1, N){    
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 10124
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

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

int main() {
  for (;;) {
      cin >> ws;
      if (cin.eof())break;
      int hand[5];
      REP(i, 5) cin >> hand[i];
      if(hand[0] == 0) break;
      REP(i, 5) hand[i]--;

      int exist = 0;
      REP(i, 5) exist |= 1 << hand[i];

      REP(i, 5) {
          if (exist == 7) cout << 3 << endl;
          else if (exist == 1 || exist == 2 || exist == 4) cout << 3 << endl;
          else {
              int win = 0;
              REP(j, 5) if (hand[i] != hand[j]) {
                  if ((hand[j] - hand[i] + 3) % 3 == 1) win = 1;
              }
              if (win) cout << 1 << endl;
              else cout << 2 << endl;
          }
      }


  }
  return 0;
}

Measured memory_bytes: 0
#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>
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)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll dp[3030][3030];
ll a[3030];

ll rec(int x,int y){
    if(dp[x][y]!=longinf)return dp[x][y];
    if(x==y)return a[x];
    return dp[x][y]=max(a[x]-rec(x+1,y),a[y]-rec(x,y-1));
}

int main(){
    int n;
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n)rep(j,n)dp[i][j]=longinf;
    cout<<rec(0,n-1)<<endl;
    return 0;
}


Measured memory_bytes: 72064
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
map<P,P> mp;
int main(){
  for(int i=1;i<=150;i++){
    for(int j=i+1;j<=150;j++){
      mp[P(i*i+j*j,i)]=P(i,j);
    }
  }
while(1){
  ll h,w;
  cin>>h>>w;
  if(h==0||w==0)return 0;
  auto ite=mp.find(P(h*h+w*w,h));
  ite++;
  cout<<ite->se.fi<<" "<<ite->se.se<<"\n";
}
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  string c;
  cin >> c;
  int key = 0;
  for(int i = 0;i<a;i++){
    if(c.at(i) == '-')
      key = 1;
  }
  if(c.at(a) != '-')
    key = 1;
  for(int i = a+1;i<a+b+1;i++){
    if(c.at(i) == '-')
      key = 1;
  }
  if(key == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int x,y;

int main()
{
  cin >> x >> y;
  bool check = false;
  rep(i,x)
  {
    if(2*i+4*(x-i) == y || 4*i+2*(x-i) == y) check= true;
  }
  if(check) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> l(1100),r(1100);
  for(int i=0;i<N;i++){
    cin >> l.at(i);
    cin >> r.at(i);
  }
  int sum;
  sum=0;
  int j=0;
  while(j<N){
    sum+=r.at(j)+1-l.at(j);
    j++;
  }
  cout << sum << endl;}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

    	Scanner sc = new Scanner(System.in);
    	String[] S = sc.next().split("");
    	int ans = 753;
    	for(int i = 0; i < S.length-2; i++){
    		String str = S[i] + S[i+1] + S[i+2];
    		int num = Math.abs(753 - Integer.parseInt(str));
    		ans = Math.min(num, ans);
    	}
    	System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <iomanip>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;


int main(){

  int n, m;
  cin >> n >> m;
  vector<int> p(m), y(m);
  
  vector<int> v[n];
  REP(i,m){
    cin >> p[i] >> y[i];
    v[p[i]-1].push_back(y[i]);
  }

  REP(i,n){
    sort(ALL(v[i]));
  }
  
  REP(i,m){
    cout << right << setw(6) << setfill('0') << p[i];
    cout << right << setw(6) << setfill('0') << (lower_bound(ALL(v[p[i]-1]), y[i]) - v[p[i]-1].begin()) + 1;
    cout << setfill(' ');
    cout << "\n";
  }

  return 0;
}



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

int main() {
  string s;
  cin >> s;
  int c = 0, f = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'C') c = 1;
    else if (s[i] == 'F' && c) {
      f = 1;
      break;
    }
  }
  if (f) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


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

int m,d,M,D;
cin >> m >> d;
cin >> M >> D;
if(M!=m)fin(1);else fin(0);


//////////////////////////////////////////////////////
return 0;}

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

int main()
{
	int n;
	cin >> n;
	int ps[n];
	for (auto &p : ps)
	{
		cin >> p;
		p--;
	}
	int qs[n];
	for (int i = 0; i < n; i++)
	{
		qs[ps[i]] = i;
	}
	int maxi = 1;
	for (int i = 1, j = 1; i < n; i++)
	{
		if (qs[i - 1] > qs[i])
		{
			maxi = max(maxi, j);
			j = 1;
		}
		else
		{
			j++;
		}
		if (i + 1 == n)
		{
			maxi = max(maxi, j);
		}
	}
	cout << n - maxi << endl;
	return 0;
}

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


struct dice {
    int sai[6];
    void direc(char c) {
        int b;
        if (c == 'N')
        {
            b = sai[0];
            sai[0] = sai[1];
            sai[1] = sai[5];
            sai[5] = sai[4];
            sai[4] = b;
        }
        if (c == 'E')
        {
            b = sai[0];            //
            sai[0] = sai[3];
            sai[3] = sai[5];
            sai[5] = sai[2];
            sai[2] = b;
        }
        if (c == 'W')
        {
            b = sai[0];
            sai[0] = sai[2];
            sai[2] = sai[5];
            sai[5] = sai[3];
            sai[3] = b;
        }
        if (c == 'S')
        {
            b = sai[0];
            sai[0] = sai[4];
            sai[4] = sai[5];
            sai[5] = sai[1];
            sai[1] = b;
        }
    }
    int top() {
        return sai[0];

    }
};
int main() {
    dice dic;
    int i;
    for (i = 0; i < 6; i++)
        cin >> dic.sai[i];
    string sai;
    cin >> sai;
    for (i = 0; i < sai.size(); i++)
        dic.direc(sai[i]);
    cout << dic.top() << endl;
    return 0;
}


Measured memory_bytes: 3212
import java.util.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		B(sc);
	}
	
	public static void B(Scanner sc) {
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int counter = 0;
		for(int a=0;a<=A;a++){
			for(int b=0;b<=B;b++) {
				int c = (X-(500*a+100*b))/50;
				if(0<=c && c<=C) counter++;
			}
		}
		out.println(counter);
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b)
        cout<<"a > b"<<endl;
    else
        if(a==b)
            printf("a == b\n");
        else
            printf("a < b\n");
    return 0;
}


Measured memory_bytes: 3084
#include <stdio.h>
int main()
{
    int n, m;
    char a[51][51], b[51][51];
    int i, j, k, l;
    scanf("%d %d",&n,&m);
    for (i = 0; i < n; i++)
        //for (j = 0; j < n; j++)
        {
            {
                scanf("%s", a[i]);
            }
        }
    for (i = 0; i < m; i++)
       //for (j = 0; j < m; j++)
        {
            {
                scanf("%s", b[i]);
            }
        }
        int flag=0;
    for (l = 0; l < n - m + 1; l++)
    {
        for (k = 0; k < n - m + 1; k++)
        {
            flag=0;
            for (i = 0; i < m; i++)
            {
                for (j = 0; j < m; j++)
                {
                    if (b[i][j] != a[l + i][k + j])
                    {
                        flag=1;
                    }
                }
            }
            if(flag==0)
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    if(flag==1)
    {
        printf("No\n");
    }
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; ++i) cin >> l[i];
    int res = 0;
    for (int a = 0; a < n; ++a) {
        for (int b = a+1; b < n; ++b) {
            for (int c = b+1; c < n; ++c) {
                if (l[a] != l[b] &&
                    l[b] != l[c] &&
                    l[c] != l[a] && 
                    l[a] + l[b] > l[c] && 
                l[b] + l[c] > l[a] && 
                l[c] + l[a] > l[b]) {
                    ++res;
                    //cout << l[a] << ',' << l[b] << ',' << l[c] << endl;
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector< pair < int, int > > pairs(N);
    vector<int> a(N);
    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        pairs[i] = make_pair(tmp, i+1);
        a[i]=tmp;
    }
    sort(pairs.begin(), pairs.end());
    if(pairs[0].first>=0){
        cout << N-1 << endl;
        for(int i=0; i<N-1; i++){
            cout << i+1 << ' ' << i+2 << endl;
        }
        return 0;
    }else if(pairs[N-1].first<=0){
        cout << N-1 << endl;
        for(int i=0; i<N-1; i++){
            cout << N-i << ' ' << N-1-i << endl;
        }
        return 0;
    }else if(pairs[0].first+pairs[N-1].first>=0){
        cout << 2*N-2 << endl;
        for(int i=0; i<N; i++){
            if(i+1==pairs[N-1].second) continue;
            cout << pairs[N-1].second << ' ' << i+1 << endl;
        }
        for(int i=0; i<N-1; i++){
            cout << i+1 << ' ' << i+2 << endl;
        }
        return 0;
    }else{
        cout << 2*N-2 << endl;
        for(int i=0; i<N; i++){
            if(i+1==pairs[0].second) continue;
            cout << pairs[0].second << ' ' << i+1 << endl;
        }
        for(int i=0; i<N-1; i++){
            cout << N-i << ' ' << N-1-i << endl;
        }
        return 0;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;
long long a,b;
int main()
{
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0){cout<<"Possible";return 0;}
	else cout<<"Impossible";
	
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long long int ans, a, b, n;
  ans=0;
  cin >> a >> b >> n;
  if(b-1>n){
   	ans = (a*n)/b;
  }else{
    ans = a*(b-1)/b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
 int main()
{	
lli n,i,j;
cin >> n;
string s;
cin >> s;
if(s.size()<=n)cout << s << '\n';
else {
	string s2="";
	for(i=0;i<n;i++){
		s2=s2+s[i];
	}
	s2=s2+'.'+'.'+'.';
	cout << s2 << '\n';
}


return 0;}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vll p(A), q(B), r(C);
    rep(i, A) cin >> p[i];
    rep(i, B) cin >> q[i];
    rep(i, C) cin >> r[i];

    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());

    priority_queue<ll, vector<ll>, greater<ll>> pq;

    rep(i, X) pq.push(p[i]);
    rep(i, Y) pq.push(q[i]);

    for(auto rx : r) {
        if(pq.top() <= rx) {
            pq.pop();
            pq.push(rx);
        }
    }

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


Measured memory_bytes: 4724
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    int n; cin >> n;
    string s, t;
    cin >> s >> t;
    int i = 1;

    ll ans = n*2;
    Rep(i, 1, n){
        string l, r;
        l = s.substr(n-i, i);
        r = t.substr(0, i);
        if(l == r) ans = n*2 - i;
    }

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

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #define USE_INT_LONG_LONG
#ifdef USE_INT_LONG_LONG
#define int long long
    #define inf (1ll<<60)
#else
    #define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m;
    cin>>n>>m;
    if(!n)return;
    vi c(m);
    rep(i,m)cin>>c[i];
    vi x(n);
    rep(i,n)cin>>x[i];
    vvi dp(n+1,vi(256));
    rep(i,n+1)rep(j,256)dp[i][j]=inf;
    dp[0][128]=0;
    REP(i,1,n){
        rep(j,256){
            if(dp[i-1][j]==inf)continue;
            rep(k,m){
                int t=min(255,max(0,j+c[k]));
                dp[i][t]=min(dp[i][t],dp[i-1][j]+(x[i-1]-t)*(x[i-1]-t));
            }
        }
    }
    int ans=inf;
    rep(i,256)ans=min(ans,dp[n][i]);
    cout<<ans<<endl;
    run();
}


Measured memory_bytes: 96352
N, Q = map(int, input().split())
S = input()
ns = [-1]*N
n = 0
ns[0] = n
for i in range(N-1):
  if S[i:i+2] == "AC":
    n += 1
  ns[i+1] = n
#print(ns)
for i in range(Q):
  l, r = map(int, input().split())
  l, r = l-1, r-1
  c = ns[r]-ns[l]
  print(c)


Measured memory_bytes: 6060
#include<bits/stdc++.h>
#define MAXN 99999
#define INF 101
using namespace std;
inline int read(){
 char c=getchar();int x=0,f=1;
 while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
 while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
 return x*f;
}
int a,b,c,tot;
int main()
{
	a=read();
	b=read();
	c=read();
	for(int i=1;i<=b;++i)
	 {
	 	if(a*i%b==c)
	 	 {
   			cout<<"YES\n";	
			return 0;
		 } 
	 }
	cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;

int main (void)
{
	int n,a,b,x;

	x = 0;
	cin >> n >> a >> b;

	x = n - a;

	for (int i = 0; i < 100; i++)
	{
		if (x < i * b)
		{
			cout << x - ((i - 1) * b) << endl;
			break;
		}
		else if (x == i * b)
		{
			cout << x - (i * b) << endl;
			break;
		}
	}
}


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

template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

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

int main(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    if(n <= k){
        cout << n * x << endl;
        return 0;
    }
    int ans = k * x + (n-k) * y;
    cout << ans << endl;
}

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

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

        public void Solve(ConsoleInput cin)
        {
            var FirstLine = cin.ReadLine.Split(' ');
            int N = int.Parse(FirstLine[0]);
            int Q = int.Parse(FirstLine[1]);
            var S = cin.ReadLine;
            List<int> resultList = new List<int>();

            List<int> targetSums = new List<int>();
            int len = S.Length;
            int ATcounter = 0;
            for (int i = 0; i < len; i++)
            {
                targetSums.Add(ATcounter);
                if (len - 1 == i)
                {                    
                    break;
                }
                if (S[i] == 'A' && S[i+1] == 'C')
                {
                    ++ATcounter;
                }
            }
            for (int i = 0; i <= Q - 1; i++)
            {
                var temp = cin.ReadLine.Split(' ');
                int l = int.Parse(temp[0]);
                int r = int.Parse(temp[1]);
                var tempStr = targetSums[r-1]-targetSums[l-1];

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

Measured memory_bytes: 20292