akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//







int main(void) {

    string s; cin >> s;
    int l = 'z' - 'a' + 1; 
    bool flag[l];
    rep(i,l) flag[i] = false;
    rep(i,s.size()) {
        int num = s[i] - 'a';
        flag[num] = true;
    }
    bool flag_2 = true;
    rep(i,l) {
        if (!flag[i]) {
            char c = i + 'a';
            out(c);
            flag_2 = false;
            break;
        }
    }
    if (flag_2) cout << "None" << endl;

    
    
    return 0;
}











Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

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

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

int main()
{
    int a,p;
    cin >> a >> p;
    cout << (a * 3 + p) /2 << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	ll n, x, m; cin >> n >> x >> m;
    vector<vector<ll>> nxt(m, vector<ll>(55, 0)), sum(m, vector<ll>(55, 0));
    rep(i, m) {
        nxt[i][0] = (i * i) % m;
        sum[i][0] = i;
    }
    for(int j = 0; j < 50; ++ j) {
        rep(i, m) {
            nxt[i][j + 1] = nxt[nxt[i][j]][j];
            sum[i][j + 1] = sum[i][j] + sum[nxt[i][j]][j];
        }
    }
    ll ans = 0;
    ll now = x;
    rep(i, 50) {
        if(n & (1LL<<i)) {
            ans += sum[now][i];
            now = nxt[now][i];
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

using namespace std;

#define EPS (1e-8)
#define INF 101010

struct Point {
    double x, y;
    
    Point () {}
    Point (double x, double y) : x(x), y(y) {}

    Point operator - (const Point &p) const {
        return Point(x - p.x, y - p.y);
    }
};

double cross(const Point &a, const Point &b)
{
    return a.x * b.y - a.y * b.x;
}

int ccw(const Point &p0, const Point &p1, const Point &p2)
{
    Point a = p1 - p0, b = p2 - p0;
    if (cross(a, b) > EPS)  return -1; // COUNTER CLOCK WISE
    return +0;
}

#define next(G,i) (G[(i+1)%G.size()])

double get_area(double l, double r, int W)
{
    vector<Point> pg(4);
    pg[0] = Point(0, 0);
    pg[1] = Point(W, 0);
    pg[2] = Point(W, r);
    pg[3] = Point(0, l);
    
    double res = 0;
    for (int i = 0; i < (int)pg.size(); i++) {
	res += cross(pg[i], next(pg, i));
    }
    return abs(res)/2.0;
}


int main()
{
    int N, M, W, H, S;
    while (cin >> N >> M >> W >> H >> S, N) {
        vector<double> l(M+1), r(M+1);
        l[0] = r[0] = 0;
        
        vector<int> s(M+1, 0);
        for (int i = 1; i <= M; i++) {
            cin >> l[i] >> r[i];
            s[i] = get_area(l[i], r[i], W);
        }        

        vector<int> choco(M+1, 0);
        
        Point p;
        for (int i = 0; i < N; i++) {
            cin >> p.x >> p.y;
            int lb = 0, ub = M+1;
            while (ub - lb > 1) {
                int mid = (lb + ub) / 2;
                if (ccw(Point(0, l[mid]), Point(W, r[mid]), p) == -1) {
                    lb = mid;
                } else {
                    ub = mid;
                }
            }
            choco[ub]++;
        }

        for (int i = 1; i <= M; i++) {
            choco[i] += choco[i-1];
        }
        int res = INF;
        for (int i = 0; i <= M; i++) {
            int lb = i, ub = M+1;
            int ns = s[i];
            while (ub - lb > 1) {
                int mid = (lb + ub) / 2;
                if (ns + (s[M] - s[mid]) < S) {
                    ub = mid;
                } else {
                    lb = mid;
                }
            }

            if (ns + (s[M] - s[lb]) >= S) {
                res = min(res, choco[M] - (choco[lb] - choco[i]));
            }
        }
        cout << res << endl;
    }        
    return 0;
}

Measured memory_bytes: 3756
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = input[0];
            int B = input[1];
            int C = input[2];
            int D = input[3];

            if (A * B == C * D)
            {
                Console.WriteLine(A * B);
            }
            else
            {
                Console.WriteLine(Math.Max(A * B, C * D));
            }
        }
    }
}

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

using namespace std;

int mod = 1e9 + 7;

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

    int n, frq[26] = {}, ans = 1;
    string s;

    cin >> n >> s;

    for (char c : s)
        frq[c - 'a']++;

    for (int i = 0; i < 26; i++)
        ans = (1ll * ans * (frq[i] + 1)) % mod;

    ans = (ans - 1 + mod) % mod;

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;
typedef int Direction;
typedef char Command;
int h,w;
enum Dir{UP,RIGHT,LEFT,DOWN};
class Tank{
public:
	Direction dir;
	int x;
	int y;
	string getDir(){
		if(dir==UP)return "UP";
		if(dir==RIGHT)return "RIGHT";
		if(dir==LEFT)return "LEFT";
		if(dir==DOWN)return "DOWN";
		else return "NAN";
	}
	void printCondition(){
		cout<<"-- tank -----"<<endl;
		cout<<" dir:"<<getDir()<<endl;
		cout<<"   x:"<<x<<endl;
		cout<<"   y:"<<y<<endl;
		cout<<"-------------"<<endl;
	}

};
Tank tank;

char map[21][21];
Command command;
Direction judgeDir(char c){
	if(c=='^')return UP;
	if(c=='v')return DOWN;
	if(c=='>')return RIGHT;
	if(c=='<')return LEFT;

}
char getCharDir(){
	if(tank.dir==UP)return '^';
	if(tank.dir==DOWN)return 'v';
	if(tank.dir==RIGHT)return '>';
	if(tank.dir==LEFT)return '<';

}
void init(){
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)map[i][j]='N';
	}
}
void shoot(){
	//cout<<"shoot()"<<endl;
	Direction dy=0;
	Direction dx=0;
	if(tank.dir==UP)dy=-1;
	if(tank.dir==DOWN)dy=1;
	if(tank.dir==RIGHT)dx=1;
	if(tank.dir==LEFT)dx=-1;
	int x=tank.x;
	int y=tank.y;
	for(;;){
		if(x+dx<0||x+dx>w||y+dy<0||y+dy>h||map[y+dy][x+dx]=='#')break;

		x+=dx;
		y+=dy;
		//cout<<" gun["<<y<<"]["<<x<<"]"<<endl;
		if(map[y][x]=='*'){
			map[y][x]='.';
			break;
		}
	}
	return ;

}
void next(Command command){
	map[tank.y][tank.x]='.';
	//cout<<"tank("<<tank.x<<","<<tank.y<<")"<<endl;
	if(command=='U'){
	//	cout<<"   UP"<<endl;
		tank.dir=UP;
		if(tank.y-1>=0 && map[tank.y-1][tank.x]=='.'){
			tank.y=tank.y-1;
		}
	}
	else if(command=='D'){
	//	cout<<"   DOWN"<<endl;
		tank.dir=DOWN;
		if(tank.y+1<h && map[tank.y+1][tank.x]=='.'){
			tank.y=tank.y+1;
		}

	}
	else if(command=='L'){
	//	cout<<"   LEFT"<<endl;
		tank.dir=LEFT;
		if(tank.x-1>=0 && map[tank.y][tank.x-1]=='.'){
			tank.x=tank.x-1;
		}
	}
	else if(command=='R'){
	//	cout<<"   RIGHT"<<endl;
		tank.dir=RIGHT;
		if(tank.x+1<w && map[tank.y][tank.x+1]=='.'){
			tank.x=tank.x+1;
		}
	}
	else if(command=='S'){
	//	cout<<"   SHOOT"<<endl;
		shoot();
	}
	map[tank.y][tank.x]='@';
}
void printMap(){
	cout<<"-- MAP --------"<<endl;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout<<map[i][j];
		}
		cout<<endl;
	}
	cout<<"---------------"<<endl;
}
int main(){
	int d;
	cin>>d;
	for(int k=0;k<d;k++){
		if(k)cout<<endl;
		cin>>h>>w;
		init();
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>map[i][j];
				if(map[i][j]=='^'|| map[i][j]=='v'
						||map[i][j]=='>'||map[i][j]=='<'){
					tank.dir=judgeDir(map[i][j]);
					tank.x=j;
					tank.y=i;
					map[i][j]='.';
				}
			}
		}
		int commandNum;
		cin>>commandNum;
//		tank.printCondition();
		for(int i=0;i<commandNum;i++){
			cin>>command;
			next(command);
			//printMap();
			//tank.printCondition();
		}
		//		cout<<"==========END============"<<endl;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(map[i][j]=='@')cout<<getCharDir();
				else cout<<map[i][j];
			}
			cout<<endl;
		}

		//		cout<<"========================="<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF INT_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
lint d[205][205]={0};
lint n,m,r;
vector<lint> vr;
int res=INF;
int main(){
    cin>>n>>m>>r;
    rep(i,n){
        rep(j,n){
            if(i!=j){
                d[i][j]=INF;
            }
        }
    }
    vr.resize(r);
    rep(i,r) {
        cin>>vr[i];
        vr[i]--;
    }   
    rep(i,m){  
        lint a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        d[a][b]=c;
        d[b][a]=c;
    }     
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
             for(int j=0;j<n;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }  
        }
    }
    sort(vr.begin(),vr.end());
    do{
        int sum=0;
        for(int i=0;i<r-1;i++){
            sum+=d[vr[i]][vr[i+1]];
        }
        res=min(res,sum);
    }while (next_permutation(vr.begin(), vr.end()));
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h=sc.nextInt();
    int w=sc.nextInt();
    StringBuilder[] a=new StringBuilder[h];
    for(int i=0;i<h;i++){
      String s=sc.next();
      if(s.indexOf('#')==-1){
        i--;
        h--;
      }else{
        a[i]=new StringBuilder(s);
      }
    }
    
    for(int i=0;i<w;i++){
      boolean flag=true;;
      for(int j=0;j<h;j++){
        if(a[j].charAt(i)=='#'){
          flag=false;
          break;
        }
      }
      if(flag){
        for(int j=0;j<h;j++){
          a[j].deleteCharAt(i);
        }
        i--;
        w--;
      }
    }
    
    for(int i=0;i<h;i++){
      System.out.println(a[i]);
    }
  }
}

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

int n,m,q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
    if (A.size() == n + 1) {
        int now = 0;
        for(int i=0;i < q;i++){
            if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans ,now);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= m) {
        dfs(A);
        A.back()++;
    }
    
}

int main(){
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    for(int i=0;i < q;i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
    dfs(vector<int>(1,1));
    cout << ans << endl;
}

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

int main(){
  string a, b;
  cin >> a >> b;
  if(a.at(0) == b.at(2) && a.at(2) == b.at(0) && a.at(1) == b.at(1)){
    cout << "YES" << endl;
  }else{
    
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
from functools import reduce
from operator import add


def mul(inp):
    return int(inp * 2)


if __name__ == '__main__':
    n = int(input())
    a = list(map(mul, map(int, input().split())))
    res = [0] * n
    minus = reduce(add, [a[i] for i in range(1, n, 2)])
    plus = reduce(add, [a[i] for i in range(2, n, 2)])
    res[0] = int((a[0] + plus - minus) / 2)
    for x in range(1, n):
        res[x] = a[x - 1] - res[x - 1]
    print(' '.join(map(str, res)))


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

int main(){
	int a, b, c, dc, x, y;
	ll ans = 0;
	cin >> a >> b >> c >> x >> y;
	dc = 2 * c;
	if(dc < a + b){
		int amari;
		if(x < y){
			ans = c * 2 * x;
			amari = y - x;
			if(dc < b){
				ans += dc * amari;
			}else{
				ans += b * amari;
			}
		}else{
			ans = c * 2 * y;
			amari = x - y;
			if(dc < a){
				ans += dc * amari;
			}else{
				ans += a * amari;
			}
		}
	}else{
		ans = a*x;
		ans += b*y;
	}
	cout << ans << endl;
	return 0;
}

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


int main() {
    int p;
    int pp[111]={0};
    int cnt=0;

    for(int i=0;i<3;i++){
        scanf(" %d",&p);
        pp[p]=1;
    }

    for(int i=0;i<101;i++){
        if(pp[i]!=0)cnt++;
    }

    cout << cnt << endl;

    return 0;

}


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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	set <string> s;
	while (n--){
		string t;
		cin >> t;
		s.insert(t);
	}
	cout << s.size() << '\n';
	return 0;
}


Measured memory_bytes: 19220
# -*- coding: utf-8 -*-


def main():
    from bisect import bisect_right
    from bisect import bisect_left

    n = int(input())
    t = list(map(int, input().split()))
    a = list(map(int, input().split()))[::-1]
    t_candidates = [1 for _ in range(n)]
    a_candidates = [1 for _ in range(n)]
    ans = 1

    if max(t) != max(a):
        print(0)
        exit()
    else:
        if bisect_left(t, max(t)) > (n - bisect_left(a, max(a)) - 1):
            print(0)
            exit()

    for i in range(1, n):
        if t[i] == t[i - 1]:
            t_candidates[i] = t[i]

        if a[i] == a[i - 1]:
            a_candidates[i] = a[i]

    for t_candidate, a_candidate in zip(t_candidates, a_candidates[::-1]):
        ans *= min(t_candidate, a_candidate)
        ans %= 10 ** 9 + 7

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19000
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] nums = new int[n];
		for(int i=0; i<nums.length; i++) {
			nums[i] = sc.nextInt();
		}
		Arrays.sort(nums);
		int min = Integer.MAX_VALUE;
		
		for(int i=0; i+k<=nums.length; i++) {
			min = Math.min(min, nums[i+k-1]-nums[i]);
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 50664
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >>n;
  int x=0;
  for(int i=0;i<n;i++){
    int a;
    cin >>a;
    if(a%2!=0&&(i+1)%2!=0){
      x++;
    }
  }
  cout<<x;
  return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0325
int men[6], d[6];
int main(){
  int k=0;
  for(int i=0;i<6;i++){
    int a,b;
    scanf("%d%d", &a,&b);
    if(a>b)swap(a,b);
    // printf("%d,%d\n",a,b);
    men[i] = a + b * 1001;
    // printf("%d\n",men[i]);
    for(int j=0;j<i;j++){
      if(men[i]==men[j]){
        d[k++]=a;
        d[k++]=b;
        men[j]=men[i]=-1;
        break;
      }
    }
  }
  if(k==6){
    bool c=false;
    for(int i=0;i<2;i++){
      for(int j=0;j<2;j++){
        c=c||(d[0]==d[2]&&d[1]==d[4]&&d[3]==d[5]);
        c=c||(d[0]==d[4]&&d[1]==d[2]&&d[3]==d[5]);
        // for(int r=0;r<6;r++)printf("%d,",d[r]);
        // printf("\n");
        swap(d[2],d[3]);
      }
      swap(d[4],d[5]);
    }
    if(c)printf("yes\n");
    else printf("no\n");
  }
  else printf("no\n");
}

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

const string decimals = "753";

bool check(string& s, long n) {
	if (stoll(s) > n) {
		return false;
	}
	for (char c : decimals) {
		if (s.find(c) == string::npos) {
			return false;
		}
	}
	return true;
}

int dfs(string s, long n) {
	int res = 0;
	if (!s.empty()) {
		if (check(s, n)) {
			++res;
		} else if (stoll(s) > n) {
			return 0;
		}
	}
	for (char next : decimals) {
		res += dfs(s + next, n);
	}
	return res;
}

int solve(long n) {
	return dfs("", n);
}

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

	cout << solve(n) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define N 6

int main(void){
    int a[N];
    int ans[N]={1,2,2,3,3,4};
    int cnt=0;

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

    sort(a,a+N);

    for(int i=0;i<N;i++){
        if(a[i]==ans[i])
            cnt++;
    }
    if(cnt==N)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

dp[200000];

int main()
{
    int a[12]={1,6,9,36,81,216,729,1296,6561,7776,46656,59049},n,x,y;

    scanf("%d",&n);

    for(y=0;y<12;y++){
        for(x=0;x+a[y]<=100000;x++){
            if(dp[x+a[y]]==0||dp[x+a[y]]>dp[x]+1){
                dp[x+a[y]]=dp[x]+1;
            }
        }
    }

    printf("%d\n",dp[n]);




    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
#define PI acos(-1.0)
using namespace std;
void comp() {
	ll i,j,k,n,l;
	double a,b,h,m;
	double angle;
	cin>>a>>b>>h>>m;
	double temp1,temp2;
	temp1=(double)(60*h+m)*(double)(0.5);
	temp2=(double)(m)*(double)(6);
	if(temp1>temp2) swap(temp1,temp2);
	temp2-=temp1;
	if(temp2>180) {
		temp2=360-temp2;
	}
	double ans;
	double degree=temp2*PI/180.0;
	ans=b*b+a*a-cos(degree)*(double)2*a*b;
	ans=sqrt(ans);
	cout<<fixed<<setprecision(12)<<ans<<"\n";

}

int main() {
    speedup;
    ll i=0,t;
    t=1;
    //cin>>t;
    while(t--) {
        comp();
    }
    return 0;
}

Measured memory_bytes: 4244
//In the name of Allah the Most Merciful
//Astagfirullahil laji Rabbi Minkulli Jamio Watubi elai
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define MX 10000008
#define cs int t;cin>>t;while(t--)
int i,j,k;
int r,s;
main()
{
 int n;cin>>n;string s;cin>>s;
 int c=0;
 for(i=0;i<s.length();i++)
 {
     if(s[i]==s[i+1]) continue;
     else c++;
 }
 cout<<c<<endl;
}


Measured memory_bytes: 3736
fn main() {
    let n: usize = readln();
    let a: Vec<i64> = readln();
    let mut c = HashMap::new();
    for &x in &a {
        *c.entry(x).or_insert(0) += 1;
    }
    let mut b: Vec<i64> = Vec::new();
    for (k, mut v) in c {
        while v >= 2 {
            b.push(k);
            v -= 2;
        }
    }
    b.sort();
    b.reverse();
    if b.len() >= 2 {
        println!("{}", b[0] * b[1]);
    } else {
        println!("{}", 0);
    }
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 12540
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
#define PI 3.14159265359
#define dij priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>
typedef long long ll;
//
int main(){
    int n,m;cin>>n>>m;
    vector<vector<int>> v(m);
    rep(i,m){
        int k;cin>>k;
        rep(j,k){
            int s;cin>>s;
            v[i].push_back(s);
        }
    }
    vector<int> che;
    rep(i,m){
        int p;cin>>p;
        che.push_back(p);
    }
    int ans=0;

    rep(i,1<<n){
        bool flag=false;
        int co=0;
        vector<int> vv;
        rep(j,n){
            int mask=1;
            if(i&mask<<j)vv.push_back(j);
        }
//        for(auto e:vv)cout<<e;cout<<endl;
        rep(j,m){
            int co2=0;
            for(auto e:vv){
                if(find(all(v[j]),e+1)!=v[j].end())co2++;
            }
//            cout<<co2<<endl;
            if(co2%2==che[j])co++;
        }
//        cout<<co<<endl;
        if(co==m)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3604
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int a, b;
	cin >> a >> b;
	int l, r,cnt=0;
	for (int i = a; i <= b; i++) {
		l = i / 1000;
		r = i % 100;
		if (l/10 == r%10 && l%10 == r/10)cnt++;
	}
	cout << cnt << endl;
	return 0;
}



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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;

bool read() {
    if (!(cin >> n))
        return false;

    return true;
}

void solve() {
    if ((n & (n - 1)) == 0) {
        cout << "No\n";
        return ;
    }

    cout << "Yes\n";
    // pizdec
    
    auto pw = 1;
    for (; n % (2 * pw) == 0; pw *= 2) { }

    if (pw == 1) {
        cout << n + 1 << ' ' << 2 << endl;
 
        for (int i = 2; i < n; i += 2) {
            cout << i << ' ' << i + 1 << endl;
            cout << i + 1 << ' ' << 1 << endl;
            cout << 1 << ' ' << n + i << endl;
            cout << n + i << ' ' << n + i + 1 << endl;
        }

        return ;
    }

    // (n) - (n ^ pw) - (pw) - (n) - (n ^ pw)
    cout << n << ' ' << (n ^ pw) << endl;
    cout << (n ^ pw) << ' ' << pw << endl;
    cout << pw << ' ' << n + n << endl;
    cout << n + n << ' ' << n + (n ^ pw) << endl;

    // n + pw + 1
    cout << n + n << ' ' << (n ^ pw) + 1 << endl;
    cout << 1 << ' ' << n + (n ^ pw) + 1 << endl;

    // vetochka
    cout << pw << ' ' << pw + 1 << endl;
    cout << pw + 1 << ' ' << n + 1 << endl;
    cout << pw << ' ' << 1 << endl;
    cout << 1 << ' ' << n + pw + 1 << endl;
    cout << n + pw + 1 << ' ' << n + pw << endl;

    for (int i = 2; i < n; i += 2) {
        if (i == pw || i == (n ^ pw))
            continue;

        cout << i << ' ' << i + 1 << endl;
        cout << i + 1 << ' ' << 1 << endl;
        cout << 1 << ' ' << n + i << endl;
        cout << n + i << ' ' << n + i + 1 << endl;
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 2304
a, b = map(int, input().split())

x = a * 100 / 8
if int(x) < x:
    x = int(x)+1
else:
    x = int(x)
y = b * 100 / 10
if int(y) < y:
    y = int(y)+1
else:
    y = int(y)

while x * 10 // 100 < b and x * 8 // 100 == a:
    x += 1
    
if x * 10 // 100 == b and x * 8 // 100 == a:
    print(x)
else:
    print(-1)

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

int main(){
    string s;
    cin >> s;
    if(s == "A") cout << "T" << endl;
    if(s == "C") cout << "G" << endl;
    if(s == "G") cout << "C" << endl;
    if(s == "T") cout << "A" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
int a[200000];
signed main(){
  int n,k,q;
  cin >> n >> k >> q;
  REP(i,q){
    int k2;
    cin >> k2;
    a[k2]++;
  }
  for(int i=1;i<=n;i++){
    if(k-q+a[i]>0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
include Math
n = gets.to_i
x = gets.split.map(&:to_i)
y = gets.split.map(&:to_i)

d1 = 0
d2 = 0
d3 = 0
dc = 0

for i in 0..(n-1)
 d = (x[i] - y[i]).abs
 d1 += d
 d2 += d ** 2
 d3 += d ** 3
 dc = d if dc < d
end

 d2 = sqrt(d2)
 d3 = d3 ** (1.0/3.0)

printf "%f\n", d1
printf "%f\n", d2
printf "%f\n", d3
printf "%f\n", dc


Measured memory_bytes: 6940
#include <stdio.h>
#include <math.h>
#define N 10000 
int PrimeNumbers(int);
 
int main(){
  int a[N],i,n,c=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(PrimeNumbers(a[i])==1){
    c++;
    }
  }
 printf("%d\n",c);
 return 0;
}
     
int PrimeNumbers(int a){
  int i;
  if(a==2)return 1;
  if(a<=1||a%2==0)return 0;
  
  for(i=2;i*i<=a;i++){
    if(a%i==0)return 0;
    
  }
  return 1;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>

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

  int R,S,P;
  cin >> R >> S >> P;

  string T;
  cin >> T;

  int ans = 0;
  string Q;

  rep(i,T.size()){
    char p = T.at(i); //出す手
    if(i > (K-1)){
      if(p == 'r'){
        if(Q.at(i-K) == 'p'){
          Q += '-';
        }else{
          ans += P;
          Q += 'p';
        }
      }

      if(p == 's'){
        if(Q.at(i-K) == 'r'){
          Q += '-';
        }else{
          ans += R;
          Q += 'r';
        }
      }
      if(p == 'p'){
        if(Q.at(i-K) == 's'){
          Q += '-';
        }else{
          ans += S;
          Q += 's';
        }
      }
    }else{
      if(p == 'r'){
        ans += P;
        Q += 'p';
      } 
      if(p == 's'){
        ans += R;
        Q += 'r';
      }
      if(p == 'p'){
       ans += S;
       Q += 's';
      }
    }


  }

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

Measured memory_bytes: 640
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define repd(i,x,y) for(int i=x; i>=y; --i)
#define int long long

using namespace std;
const int N=1<<18,mod=998244353;
typedef long long LL;
const LL inv2=(mod+1)/2;
int n;
LL tot,p[N],f[N],_f[N];
LL L[N],R[N],_L[N],_R[N],ans[N];

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

LL getmi(LL a,LL x)
{
    LL rt=1;
    while(x)
    {
        if(x&1) rt=rt*a%mod;
        a=a*a%mod,x>>=1;
    }
    return rt;
}

void FWT(LL a[],int n)
{
    for(int i=1; i<n; i<<=1)
        for(int j=0; j<n; j+=i<<1)
            rep(k,0,i-1)
            {
                LL x=a[j+k],y=a[i+j+k];
                a[j+k]=(x+y)%mod,a[i+j+k]=(x-y)%mod;
            }
}

void IFWT(LL a[],int n)
{
    for(int i=1; i<n; i<<=1)
        for(int j=0; j<n; j+=i<<1)
            rep(k,0,i-1)
            {
                LL x=a[j+k],y=a[i+j+k];
                a[j+k]=inv2*(x+y)%mod;
                a[i+j+k]=inv2*(x-y)%mod;
            }
}

signed main()
{
	n=getint();
	rep(i,0,(1<<n)-1) tot+=(p[i]=getint());
	tot=getmi(tot,mod-2);
	rep(i,0,(1<<n)-1) p[i]=p[i]*tot%mod;
	FWT(p,1<<n);

	rep(i,0,(1<<n)-1) L[i]=R[i]=1-p[i];
	rep(i,1,(1<<n)-1) L[i]=L[i]*L[i-1]%mod;
	repd(i,(1<<n)-2,0) R[i]=R[i]*R[i+1]%mod;

	rep(i,0,(1<<n)-1)
	{
		LL x=1;
		if(i>0) x=L[i-1],_L[i]=_L[i-1]*(1-p[i])%mod;
		_L[i]=(_L[i]+x*(-p[i]))%mod;
	}

	repd(i,(1<<n)-1,0)
	{
		LL x=1;
		if(i<(1<<n)-1) x=R[i+1],_R[i]=_R[i+1]*(1-p[i])%mod;
		_R[i]=(_R[i]+x*(-p[i]))%mod;
	}

	rep(i,0,(1<<n)-1)
	{
		LL l=i>0?L[i-1]:1;
		LL _l=i>0?_L[i-1]:0;
		LL r=i<(1<<n)-1?R[i+1]:1;
		LL _r=i<(1<<n)-1?_R[i+1]:0;
		f[i]=l*r%mod,_f[i]=(l*_r+_l*r)%mod;
	}
	
	IFWT(f,1<<n),IFWT(_f,1<<n);
	rep(i,0,(1<<n)-1)
	{
		LL x=(_f[i]*f[0]-f[i]*_f[0])%mod;
		LL y=getmi(f[0]*f[0]%mod,mod-2);
		ans[i]=(x*y%mod+mod)%mod;
		printf("%lld\n",ans[i]);
	}
	return 0;
}

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

const int MAX = 1e5 + 5;

int N, L, a[MAX];
vector<int> ans;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> N >> L;
	for (int i = 1; i <= N; ++i) cin >> a[i];

	for (int i = 1; i < N; ++i) {
		if (a[i] + a[i + 1] >= L) {
			ans.push_back(i);
			for (int j = i - 1; j >= 1; --j) ans.push_back(j);
			for (int j = i + 1; j < N; ++j) ans.push_back(j);

			printf("Possible\n");
			for (int j = (int)ans.size() - 1; j >= 0; --j) {
				printf("%d\n", ans[j]);
			}
			return 0;
		}
	}
	printf("Impossible\n");
}

Measured memory_bytes: 1784
str   = gets.chomp
array = gets.chomp.split(" ")
array.map!(&:to_i)

def can_division_2?(array)
  array.size == array.reject { |n| n.odd? }.size
end

output = 0

while can_division_2?(array)
  output += 1
  array.map! { |n| n / 2 }
end

puts output




Measured memory_bytes: 1788
#include<stdio.h>
#include<iostream>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<string>
#include<vector>

using namespace std;

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

int n,m;
int ldist[203][203];
int sdist[203][203];
int z[1003];
int dp[1003][203];

void solve() {
    rep(i,203) rep(j,203) ldist[i][j]=sdist[i][j]=INF;
    rep(i,203) ldist[i][i]=sdist[i][i]=0;
    rep(i,m) {
        int s,t,cost;
        char c;
        cin>>s>>t>>cost>>c;
        if(c=='L') ldist[s][t]=ldist[t][s]=min(ldist[s][t],cost);
        if(c=='S') sdist[s][t]=sdist[t][s]=min(sdist[s][t],cost);
    }
    rep(k,n+1) rep(i,n+1) rep(j,n+1) { 
        ldist[i][j]=min(ldist[i][j],ldist[i][k]+ldist[k][j]);
        sdist[i][j]=min(sdist[i][j],sdist[i][k]+sdist[k][j]);
    }

    int R;
    cin>>R;
    rep(i,R) cin>>z[i];
    //集配順,船の位置のDP

    rep(i,1003) rep(j,203) dp[i][j]=INF;
    dp[0][z[0]]=0;

    for(int i=1;i<R;i++) rep(j,n+1) {
        dp[i][j]=min(dp[i][j],dp[i-1][j]+ldist[z[i-1]][z[i]]);
        rep(k,n+1) {
            dp[i][k]=min(dp[i][k],dp[i-1][j]+ldist[z[i-1]][j]+
                    sdist[j][k]+ldist[k][z[i]]);
        }
    }
    int ans=INF;
    rep(i,n+1) ans=min(ans,dp[R-1][i]);
    cout<<ans<<endl;


    
}
int main() {
    while(cin>>n>>m) {
        if(n+m==0) return 0;
        solve();
    }

    return 0;
}

Measured memory_bytes: 2280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, m;
    cin >> n;

    if (n < 10)
    {
    	cout << n;
    }
    else if (9 < n && n < 100)
    {
    	cout << 9;
    }
    else if (99 < n && n < 1000)
    {
    	m = 9 + n - 100 + 1;
    	cout << m;
    }
    else if (999 < n && n < 10000)
    {
    	cout << 909;
    }
    else if (9999 < n && n < 100000)
    {
    	m = 909 + n - 10000 + 1;
    	cout << m;
    }
    else if (99999 < n)
    {
    	cout << 90909;
    }


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int desc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}
int main(){
  int N, M;
  cin >> N >> M;
  int A[N];
  long double all=0;
  double ok;
  for(int i=0;i<N;i++){ 
    cin >> A[i];
    all+=A[i];
  }
  qsort(A , N , sizeof( int ), desc );
  ok=all/(4*M);
  for(int i=0;i<M;i++){
    if(A[i]<ok){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, d;
	cin>>n>>d;
	int at = 0;
	int cnt = 0;
	while(at < n)
	{
		at+=d*2+1;
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <numeric>
#include <map>
#include <iomanip>
using namespace std;

int main() {
  int N; cin >> N;
  string str = "";
  while (N != 0) {
    int r = N % 2;
    if (r < 0) r += 2;
    N = (N - r) / (-2);
    str += (char)('0' + r);
  }
  reverse(str.begin(), str.end());
  if (str == "") str = "0";
  cout << str << endl;
}

Measured memory_bytes: 256
from itertools import accumulate

N = int(input())
count = {}
count.setdefault(0, 1)
for i in accumulate([int(x) for x in input().split()]):
    count.setdefault(i, 0)
    count[i] += 1
ans = 0
for i in count.values():
    ans += (i*(i-1)) // 2
print(ans)


Measured memory_bytes: 39056
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using namespace std;

struct edge { int to, cost; };
typedef pair<int, int> P;

const int INF = 1e+9;
const int MAX_V = 100;

int n, m;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

int prim(){
	bool vis[MAX_V];
	V = n;
	int res = 0;
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, INF);
	fill(vis, vis + V, false);
	d[0] = 0;
	que.push(P(0, 0));
	while(!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;
		if(vis[v]) continue;
		vis[v] = true;
		res += p.first;
		for(int i=0;i<G[v].size();i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost){
				d[e.to] = e.cost;
				que.push(P(e.cost, e.to));
			}
		}
	}
	return res;
}


/*
int cost[MAX_V][MAX_V];
int mincost[MAX_V];
bool used[MAX_V];

int prim(){
	for(int i=0 ; i < n ; i++ ){
		mincost[i] = INF;
		used[i] = false;
	}
	mincost[0] = 0;
	int res = 0;
	
	while( true ){
		int v = -1;
		for(int u=0 ; u < n ; u++ ){
			if( !used[u] && (v == -1 || mincost[u] < mincost[v]) ){
				v = u;
			}
		}
		
		if(v == -1) break;
		used[v] = true;
		res += mincost[v];
		
		for(int u=0 ; u < n ; u++ ){
			mincost[u] = min( mincost[u] , cost[v][u] );
		}
	}
	return res;
}
*/
// 文字列sを文字c区切りで分割して返す
vector<string> split_string(string s, char c){
	string str;
	vector<string> vs;
	s.push_back( c );
	
	for(int i=0 ; i < s.size() ; i++ ){
		if( s[i] == c ){
			if( !str.empty() ){
				vs.push_back( str );
				str.clear();
			}
		}else{
			str.push_back( s[i] );
		}
	}
	return vs;
}

// stringをintに変換
int s_to_i(string s){
	int n=0;
	for(int i=0 ; i < s.size() ; i++ ){
		n *= 10;
		n += s[i] - '0';
	}
	return n;
}

void add_edge(int u, int v, int c){
	G[u].push_back((edge){v, c});
	G[v].push_back((edge){u, c});
	//cost[u][v] = cost[v][u] = c;
}

void init(){
	for(int i=0;i<MAX_V;i++) G[i].clear();
	//fill(cost[0], cost[MAX_V], INF);
}

int main(){
	while( cin >> n , n ){
		init();
		cin >> m;
		cin.ignore();
		for(int i=0 ; i < m ; i++ ){
			string s;
			getline(cin,s);
			vector<string> vs = split_string( s , ',' );
			int u = s_to_i( vs[0] );
			int v = s_to_i( vs[1] );
			int c = (s_to_i( vs[2] ) - 100) / 100;
			add_edge(u, v, c);
		}
		int ans = prim();
		cout << ans << endl;
	}
}

Measured memory_bytes: 1356
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int l = Integer.parseInt(sc.next());
		sc.close();
		int min = 200 + 100;
		int rin = 0;
		int sum=0;
		for(i=0;i<n;i++) {
			rin = l + i;
			sum+=rin;
//			System.out.println(rin);
			if(Math.abs(rin)<Math.abs(min))min=rin;
		}
		System.out.println(sum-min);
	}
}


Measured memory_bytes: 22100
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    while(true){
      int H=sc.nextInt();
      int W=sc.nextInt();
      if(H==0 && W==0) break;
      for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
          System.out.print("#");
        }
        System.out.println();
      }
      System.out.println();
    }
  }
}



Measured memory_bytes: 33540
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

# Li-1 = [Li // A[i]] * A[i]
# Ri-1 = [Ri // A[i]] * A[i] + A[i] - 1

K = getN()
A = getList()
A = A[::-1]
if A[0] != 2:
    print(-1)
    exit()
mi = A[0]
mx = A[0] * 2 - 1
for i in range(1, K):
    ai = A[i]
    mi = (mi + ai - 1) // ai
    mx = mx // ai
    if mi > mx:
        print(-1)
        exit()
    else:
        mi = mi * ai
        mx = (mx + 1) * ai - 1
print(mi, mx)

Measured memory_bytes: 22556
L=list()
def Base_10_to_n(X, n):
  X_dumy = X
  out = ''
  while X_dumy>0:
    L.append(str(X_dumy%n))
    X_dumy = int(X_dumy/n)
  return(L)
N=int(input())
L=Base_10_to_n(N, 26)
L=list(map(int,L))
for i in range(len(L)-1):
  if L[i]<=0:
    L[i]+=26
    L[i+1]=L[i+1]-1
if L[-1]==0:
  L.pop()
L=reversed(L)
R=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
P=[R[i-1] for i in L]
print("".join(P))

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

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

    FOR(i, x, 200000) {
        bool flag = false;
        for(ll j=2; j*j<=i; ++j) {
            if(i%j==0) flag = true;
        }
        if(!flag) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

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

using namespace std;

const int mo=1e9+7;
const int inv2=(mo+1)>>1;

int f[3001][3001],n,q,a[3001];

int main()
{
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j) f[i][j]=a[i]>a[j];
	for(int i=1;i<=q;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		f[x][y]=f[y][x]=1ll*(f[y][x]+f[x][y])*inv2%mo;
		for(int i=1;i<=n;i++)
			if((x!=i)&&(y!=i))
			{
				f[i][x]=f[i][y]=1ll*(f[i][x]+f[i][y])*inv2%mo;
				f[x][i]=f[y][i]=1ll*(f[x][i]+f[y][i])*inv2%mo;
			}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++) ans=(ans+f[i][j])%mo;
	for(int i=1;i<=q;i++) ans=1ll*ans*2%mo;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if (a+b==c||b+c==a||a+c==b){
    cout<<"Yes"<<endl;
  }
  else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        int[] pathNum = new int[5];
        
        
        
        for(int i = 0; i < 3; i++)
        {
            int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            for(int j = 0; j < 2; j++)
            {
                pathNum[a[j]]++;
            }
        }
        
        bool flag = true;
        for(int i = 1; i < 5; i++)
        {
            if(pathNum[i] >= 3) flag = false;
            
        }
        
        if(flag == true) Console.WriteLine("YES");
        else Console.WriteLine("NO");

        
    }
}

Measured memory_bytes: 13268
import java.util.*;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++) {
            char[] x = sc.next().toCharArray();
            char[] y = sc.next().toCharArray();
            int[][] dp = new int[x.length+1][y.length+1];
            for (int j = 1; j <= x.length; j++) {
                for (int k = 1; k <= y.length; k++) {
                    if(x[j-1] == y[k-1]) dp[j][k] = dp[j-1][k-1] + 1;
                    else dp[j][k] = Math.max(dp[j-1][k], dp[j][k-1]);
                }
            }
            sb.append(dp[x.length][y.length] + "\n");
        }
        System.out.print(sb.toString());
        sc.close();

    }

}



Measured memory_bytes: 64104
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);		
		String str = in.nextLine();
		String[] ary = str.split(" ");
		char c = ary[1].charAt(0);
		
		while(c != '?'){
			int a = Integer.parseInt(ary[0]);
			int b = Integer.parseInt(ary[2]);
			
			switch(c){
			case '+':
				System.out.println(a+b);
				break;
			case '-':
				System.out.println(a-b);
				break;
			case '*':
				System.out.println(a*b);
				break;
			case '/':
				System.out.println(a/b);
				break;
				default:
					break;
			}
			
			str = in.nextLine();
			String[] ary2 = str.split(" ");
			for(int i=0; i<3; i++){
				ary[i] = ary2[i];
			}
			c = ary[1].charAt(0);
		}
		in.close();
	}
}

Measured memory_bytes: 17180
N,K=map(int,input().split())
list=[0 for i in range(100001)]
for i in range(N):
  a,b=map(int,input().split())
  list[a]+=b

sum=0
for i in range(100001):
  sum+=list[i]
  if(sum>=K):
    print(i)
    break
    

Measured memory_bytes: 11664
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;

int main() {
	int a[10][5];
	int b;
	while (cin >> b, b) {
		for (int c = 0; c < b; c++) {
			for (int d = 0; d < 5; d++) {
				scanf("%d", &a[c][d]);
			}
		}
		bool S;
		int sum = 0;
		do {
			S = false;
			bool k[10][5]{};
			for (int c = 0; c < b; c++) {
				for (int d = 0; d <= 2; d++) {
					if (a[c][d] == a[c][d + 1]&&a[c][d] == a[c][d + 2] && a[c][d] != 0) {
						k[c][d] = k[c][d + 1] = k[c][d + 2] = true;
						S = true;
					}
				}
			}
			for (int c = 0; c < 5; c++) {
				for (int d = 0; d < b; d++) {
					if (k[d][c]) {
						sum += a[d][c];
						for (int e = d; e > 0; e--) {
							a[e][c] = a[e - 1][c];
						}
						a[0][c] = 0;
					}
				}
			}
		} while (S);
		cout << sum << endl;
	}
}

Measured memory_bytes: 3172
#include<iostream>
#include<string>
#include<vector>
#include<cctype>
int main(void) {
	std::vector<int> CountingCharactor('z' - 'a' + 1, 0);
	std::string Input;
	while (1) {
		std::getline(std::cin, Input);
		if (!(Input[0])) { break; }
		for (unsigned int i = 0; i < Input.size(); i++) {
			Input[i] = std::tolower(Input[i]);
			int element = Input[i] - 'a';
			if (0 <= element&&element <= 'z' - 'a') { ++CountingCharactor[element]; }
		}
			}
	for (int i = 0; i <= 'z' - 'a'; ++i) {
		char Charactor = 'a' + i;
		std::cout << Charactor << " : " << CountingCharactor[i] << std::endl;
	}
	//	system("pause");
	return 0;
}

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;
const long long MOD = 1000000007;

long long dat[2 * MAX_N - 1];

//A
int main(void) {
	ll k, x;
	cin >> k >> x;
	string s = 500 * k >= x ? "Yes" : "No";
	cout << s << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

int n, m;
int a[50], b[50], c[50], d[50];

int main(){
	scanf("%d %d", &n, &m);
	for(int i=0; i<n; ++i) scanf("%d %d", &a[i], &b[i]);
	for(int i=0; i<m; ++i) scanf("%d %d", &c[i], &d[i]);
	for(int i=0; i<n; ++i){
		int tmp = 1e9;
		int ans = -1;
		for(int j=0; j<m; ++j){
			int dist = abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(dist < tmp){
				tmp = dist;
				ans = j+1;
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 128