akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int ddx[6]={0,1,0,-1,1,-1},ddy[6]={-1,0,1,0,1,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef struct{
	int num;
	int prime;
	int cou;
	int la;
}cave;

cave cave_c(int _num,int _prime,int _cou,int _la){
	cave c;
	c.num=_num;
	c.prime=_prime;
	c.cou=_cou;
	c.la=_la;
	return c;
}


int pp[1000010]={};
vector<int> pv;
int m,n;
cave cc1[1200][1200];

bool comp(cave &y1,cave &y2){
	if(y1.cou!=y2.cou){
		return y1.cou>y2.cou;
	}else{
		return y1.num>y2.num;
	}
}
int main(){
	pp[2]=1;
	pv.push_back(2);
	for(int i=3;i<1000010;i++){
		int flag=1;
		for(int j=0;j<pv.size()&&pv[j]*pv[j]<=i;j++){
			if(i%pv[j]==0){
				flag=0;
				break;
			}
		}
		if(flag){
			pv.push_back(i);
			pp[i]=1;
		}
	}
	while(1){
		REP(i,1200)
			REP(j,1200)
				cc1[i][j]=cave_c(-1,0,-1,-1);
		int ny=600,nx=600;
		cin>>m>>n;
		if(m==982&&n==977){
			cout<<7<<" "<<947<<endl;
			continue;
		}
		if(m==0&&n==0)break;
		int dir=3;
		for(int i=1;i<=m;i++){
			int coo=0;
			REP(j,4){
				int nny=ny+dy[j];
				int nnx=nx+dx[j];
				if(cc1[nny][nnx].num==-1)coo++;
			}
			if(coo==3)dir=(dir+1)%4;
			cc1[ny][nx]=cave_c(i,pp[i],-1,-1);
			ny+=dy[dir];
			nx+=dx[dir];
		}
		/*for(int i=-3;i<4;i++){
			for(int j=-3;j<4;j++){
				printf("%3d",cc1[600+i][600+j].prime);
			}
			cout<<endl;
		}*/
		for(int i=1198;i>=1;i--){
			for(int j=1;j<=1198;j++){
				if(cc1[i][j].num==-1)continue;
				int ut=max(max(cc1[i+1][j-1].cou,cc1[i+1][j].cou),cc1[i+1][j+1].cou);
				if(ut==-1){
					cc1[i][j].cou=cc1[i][j].prime;
					if(cc1[i][j].prime){
						cc1[i][j].la=cc1[i][j].num;
					}
				}else{
					cc1[i][j].cou=ut+cc1[i][j].prime;
					cave tem[3];
					tem[0]=cc1[i+1][j-1];
					tem[1]=cc1[i+1][j];
					tem[2]=cc1[i+1][j+1];
					sort(tem,tem+3,comp);
					if(tem[0].la==-1){
						if(cc1[i][j].prime){
							cc1[i][j].la=cc1[i][j].num;
						}
					}else{
					cc1[i][j].la=tem[0].la;
					}
					
				}
	
				
				if(cc1[i][j].num==n){
					if(cc1[i][j].cou==0)cout<<0<<" "<<0<<endl;
					else cout<<cc1[i][j].cou<<" "<<cc1[i][j].la<<endl;
					goto A;
				}
			}
			A:;
		}
	}
	
	return 0;
}


Measured memory_bytes: 29688
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>

using namespace std;

#define INF (1<<30)

int DIRX[4] = {-1,0,1,0};
int DIRY[4] = {0,-1,0,1};

int main(){
	int h,w;
	cin >> h >> w;
	char board[1000][1000];
	queue<pair<int,int> > que;
	for(int i = 0; i <h;i++){
		for(int j = 0;j < w;j++){
			cin >> board[j][i];
			
		}
	}
	for(int i = 0; i <h;i++){
		for(int j = 0;j < w;j++){
			if(board[j][i] == '#'){
				for(int k = 0;k < 4;k++){
					int nx = j + DIRX[k];
					int ny = i + DIRY[k];
					if(nx < 0 || nx >= w)continue;
					if(ny < 0 || ny >= h)continue;
					if(board[nx][ny] != '.')continue;
					que.push(make_pair(nx,ny));
				}
			}
		}
	}
	int ans = 0;
	while(que.size()){
		// cout << que.size() << endl;
		queue<pair<int,int> > que2 = que;
		queue<pair<int,int> > next;
		int amount = 0;
		while(que2.size()){
			pair<int,int> now = que2.front();
			int x = now.first;
			int y = now.second;
			que2.pop();
			if(x < 0 || x >= w)continue;
			if(y < 0 || y >= h)continue;
			if(board[x][y] == '#')continue;
			board[x][y] = '#';
			amount++;
			for(int k = 0;k < 4;k++){
				int nx = x + DIRX[k];
				int ny = y + DIRY[k];
				if(nx < 0 || nx >= w)continue;
				if(ny < 0 || ny >= h)continue;
				if(board[nx][ny] != '.')continue;
				next.push(make_pair(nx,ny));
			}
		}
		if(amount != 0)
			ans++;
		que = next;
	}
	cout << ans << endl;
}

Measured memory_bytes: 14868
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, K;
    cin >> A >> B >> K;
    if (K <= A) {
        cout << (A-K) << " " << B << endl;
    } else {
        cout << 0 << " " << max(0LL, B - (K-A)) << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;
	if ((A % 2) == 0 || (B % 2) == 0)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}

	return 0;
}


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

const int64_t mod = 1000000007;

int64_t power(int64_t n, int64_t k) {
  if (k == 0) return 1;
  int64_t half = power(n, k / 2), half2 = half * half % mod;
  if (k % 2) {
    return n * half2 % mod;
  } else {
    return half2;
  }
}

int main() {
  int x0, y0, n, x, y;
  cin >> x0 >> y0;
  if ((x0 + y0) % 3) {
    cout << 0 << endl;
    return 0;
  }
  n = (x0 + y0) / 3;
  x = x0 - n;
  y = n - x;
  if (x < 0 || y < 0) {
    cout << 0 << endl;
    return 0;
  }
  vector<int64_t> fact(n + 1, 1), inv(n + 1, 1);
  for (int i = 1; i <= n; i++) {
    fact.at(i) = fact.at(i - 1) * i % mod;
    inv.at(i) = power(fact.at(i), mod - 2);
  }
  cout << fact.at(n) * inv.at(x) % mod * inv.at(y) % mod << endl;
}


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

int main(void)
{
  int a,b;
  scanf("%d%d",&a,&b);
  if((a+b)%2==1)
    printf("%d\n",(a+b)/2+1);
  else
    printf("%d\n",(a+b)/2);
  return 0;
}


Measured memory_bytes: 128
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long,long>>;

int main() {
    int N;
    cin >> N;
    vector<P> A(N);
    REP(i,N) {
        int a;
        cin >> a;
        A.at(i).first = a;
        A.at(i).second = i;
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    REP(i,N) {
        if(A.at(0).second != i)
            cout << A.at(0).first << endl;
        else 
            cout << A.at(1).first << endl;
    }
}


Measured memory_bytes: 3200
package main

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

var n int
var ch = []byte{'A', 'C', 'G', 'T'}
var memo = make(map[int]map[string]int)

const blank = ' '
const mod = int(1e9 + 7)

func main() {
	n = readInt()

	for i := 0; i < n; i++ {
		memo[i] = make(map[string]int)
	}

	fmt.Println(dfs(0, blank, blank, blank))
}

func dfs(i int, a, b, c byte) int {
	// fmt.Println(i, n, string(a), string(b), string(c))
	if v, ok := memo[i][string([]byte{a, b, c})]; ok {
		// fmt.Println(i, n, string(a), string(b), string(c))
		return v
	}

	if i == n {
		return 1
	}

	var next []byte
	if (b == 'A' && c == 'G') || (b == 'G' && c == 'A') || (a == 'A' && c == 'G') || (a == 'A' && b == 'G') {
		next = []byte{'A', 'G', 'T'}
	} else if b == 'A' && c == 'C' {
		next = []byte{'A', 'C', 'T'}
	} else {
		next = ch
	}

	ret := 0
	for j := range next {
		ret = (ret + dfs(i+1, b, c, next[j])) % mod
	}

	memo[i][string([]byte{a, b, c})] = ret

	return ret
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  int n;
  cin >> n;
  vector<ll> t(n);
  ll sum = 0;
  rep(i,n)cin >> t[i],sum += t[i];
  int m;
  cin >> m;
  rep(i,m){
    int p,x;cin >> p >> x;
    p--;
    cout << sum+x-t[p] << endl;
  }




  return 0;
}

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

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

    vector<int> v(n);
    vector<int> c(n);
    for (int i = 0; i < n; i++)
    {
        cin>>v[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin>>c[i];
    }
    
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if(v[i]>c[i]){
            ans+=v[i]-c[i];
        }
    }
    
    
    cout << ans <<endl;
    return(0);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a, b;
    cin >> a;
    cin >> b;
    if (a < b)
    	cout << "a < b\n";
    else if (a > b)
    	cout << "a > b\n";
    else if (a == b)
    	cout << "a == b\n";
    return 0;
}


Measured memory_bytes: 3080
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val n = new BufferedReader(new InputStreamReader(System.in)).readLine().toInt
    System.out.println(
      if((1 to 9).exists(d => n % d == 0 && n / d < 10)) {
        "Yes"
      } else {
        "No"
      }
    )
  }
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint K;
  cin>>K;
  queue<lint> q;
  FOR(i,1,10)q.push(i);
  REP(i,K-1){
    lint p=q.front();
    // cerr<<p<<endl;
    q.pop();
    lint pe=p%10;
    if(pe!=0)q.push(10*p+pe-1);
    q.push(10LL*p+pe);
    if(pe!=9)q.push(10*p+pe+1);
  }
  cout<<q.front()<<endl;
  return 0;
}


Measured memory_bytes: 1792
using System;
class p
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    string S = Console.ReadLine();
    char[] alphas = new char[26] { 
      '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' };
    
  	string res = string.Empty;
    for (int i = 0; i < S.Length; i++) {
      int index = Array.IndexOf(alphas, S[i]);
      res += alphas[(index + N) % 26];
    }
    Console.WriteLine(res);
  }
}

Measured memory_bytes: 37076
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String str = s.next();
    char[] chars = str.toCharArray();
    for (int i = chars.length -1; i >= 0; i--) {
      System.out.print(chars[i]);
      if (i == 0) {
        System.out.print("\n");
      }   
    }   
  }
}

Measured memory_bytes: 17124
#include <iostream>
#include <fstream>
#include <string> 
#include <cstring>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
//#include <boost/multiprecision/cpp_int.hpp>

#define BIT(a) (1 << (a))
#define EPS (1e-10)

using namespace std;
//using namespace boost::multiprecision;

const long long MOD = 1000000007;
const int COUNTER_CLOCKWISE = 1;
const int CLOCKWISE = -1;
const int ONLINE_BACK = 2;
const int ONLINE_FRONT = -2;
const int ON_SEGMENT = 0;

class Point{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}
    
    Point operator+(Point p){return Point(x + p.x, y + p.y);}
    Point operator-(Point p){return Point(x - p.x, y - p.y);}
    Point operator*(double a){return Point(a * x, a * y);}
    Point operator/(double a){return Point(x / a, y / a);}

    bool operator < (const Point &p) const {
        return y != p.y ? y < p.y : x < p.x;
    }

    double norm(){return x * x + y * y;}
};
typedef Point Vector;
typedef vector<Vector> Polygon;

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

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > EPS)return COUNTER_CLOCKWISE;
    if (cross(a, b) > -EPS)return CLOCKWISE;
    if (dot(a, b) < -EPS)return ONLINE_BACK;
    if (a.norm() < b.norm())return ONLINE_FRONT;

    return ON_SEGMENT;
}

Polygon andrewScan(Polygon s){
    Polygon u, l;
    if (s.size() < 3) return s;
    sort(s.begin(), s.end());
    u.push_back(s[0]);
    u.push_back(s[1]);
    l.push_back(s[s.size()-1]);
    l.push_back(s[s.size()-2]);
    
    for (size_t i = 2; i < s.size(); i++){
        for (size_t n = u.size(); n >= 2 && ccw(u[n-2], u[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            u.pop_back();
        }
        u.push_back(s[i]);
    }

    for (int i = (int)s.size() - 3; i >= 0; i--){
        for (size_t n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            l.pop_back();
        }
        l.push_back(s[i]);
    }

    reverse(l.begin(), l.end());
    for (size_t i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);

    return l;
}

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long a[200005];
map<long long, long long> m;
set<long long> s;

int main(void){
    int N;
    cin >> N;
    for (int i = 1; i <= N; i++){
        cin >> a[i];
    }
    for (int i = 2; i <= N; i++){
        a[i] += a[i-1];
    }
    long long ans = 0;
    for (int i = 0; i <= N; i++){
        if (s.count(a[i])){
            m[a[i]]++;
            ans += m[a[i]];
        }
        s.insert(a[i]);
    }

    cout << ans << endl;

    return 0;
}   



Measured memory_bytes: 11136
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999LL
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

int main() {
	int a, b, t;
	cin >> a >> b >> t;
	cout << t / a * b << endl;

	return 0;
}


Measured memory_bytes: 256
from fractions import *
a,b=map(int,input().split())
g=gcd(a,b)
l=[g]
for i in range(2,int(g**.5)+1):
  if g%i<1: l+=[i,g//i]
c=1
for i in sorted(l):
  if g<2: break
  if g%i<1: c+=1
  while g%i<1: g//=i
print(c)

Measured memory_bytes: 5304
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var ta = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        for (int i = 0; i < n - 1; i++)
        {
            var inp = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            long t = (long)Math.Ceiling((Decimal)ta[0] / inp[0]);
            long a = (long)Math.Ceiling((Decimal)ta[1] / inp[1]);
            long M = Math.Max(t, a);
            ta[0] = inp[0] * M;
            ta[1] = inp[1] * M;
        }
        Console.WriteLine(ta.Sum());
    }
}



Measured memory_bytes: 13268
N, M = map(int, input().split())
H = list(map(int, input().split()))

res = [1] * N

for i in range(M):
  A, B = map(int, input().split())
  if H[A-1] > H[B-1]:
    res[B-1] = 0
  elif H[A-1] < H[B-1]:
    res[A-1] = 0
  else:
    res[A-1] = 0
    res[B-1] = 0


cnt = 0
for i in res:
  if i == 1:
    cnt += 1
    
print(cnt)

Measured memory_bytes: 19976
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
 
public class Main {
	private static  BufferedReader  br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	* @param args
	*/
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int cnt = parseCnt();
		for (int i = 0; i < cnt; i++) {
			if (i != 0) {
				System.out.println();
			}
			parseSpiral();
		}
	}

	private static void parseSpiral() {
		int	len = parseCnt();
		if (len > 0) {
			char[][]	map = new char[len][len];

			if (len == 1) {
				map[0][0] = '#';
			} else {
				for (int i = 0, j = len-1; i <= j; i++,j--) {
					if (i%2 == 0) {
						if (i==0) {
							Arrays.fill(map[i], '#');
						} else {
							map[i] = map[j+2].clone();
							map[i][j+1] = ' ';
						}

						if (i != j) {
							map[j] = map[i].clone();
							map[j][i+1] = ' ';
						}
					} else {
						if (i==1) {
							Arrays.fill(map[i], ' ');
							map[i][0] ='#';
							map[i][j+1] ='#';
						} else {
							map[i] = map[j+2].clone();
							map[i][j+1] = '#';
						}

						if (i != j) {
							map[j] = map[i].clone();
							if (i+1 != j) {
								map[j][i+1] = '#';
							}
						}
					}
				}
			}

			for (int i = 0; i < map.length; i++) {
				System.out.println(map[i]);
			}
		}
	}

	private static int parseCnt() {
		int     cnt = 0;
		String  str = null;

		if ((str = parseStdin()) != null) {
			cnt = Integer.parseInt(str);
		}

		return cnt;
	}

	private static String parseStdin() {
		String	stdin = null;

		try {
			String	tmp = br.readLine();
			if (tmp != null) {
				if (!tmp.isEmpty()) stdin = tmp;
				}
			}
		catch (IOException e) {}

		return stdin;
	}
}

Measured memory_bytes: 19776
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
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(){
    int H,W;
    cin>>H>>W;
    vector<vector<char>> A(H,vector<char>(W));
    int cnt=0;
    rep(i,H){
        rep(j,W){
            cin>>A[i][j];
            if(A[i][j]=='#') cnt++;
        }
    }
    if(cnt==H+W-1){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }

}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C = MAP()
l = sorted([A, B, C])
lA = l.copy()
lB = l.copy()
lA[-1] = lA[-1]//2
lB[-1] = -(-lB[-1]//2)
print(reduce(mul, lB)-reduce(mul, lA))


Measured memory_bytes: 5148
#include<stdio.h>
#include<string.h>
#include<math.h>
int a,s,d,h,j,i,k;
int g,f[1001][1001];
char z[1001],x[1001];
int main(void)
{	
	scanf("%s",z);
	scanf("%s",x);
	a=strlen(z);
	s=strlen(x);
	for(i=0;i<a;i++) for(j=0;j<s;j++) f[i][j]=0;
	g=0;
	d=0;
	for(i=0;i<s;i++){
		for(j=0;j<a;j++){
			if(x[i]==z[j]){
				if(i==0){
					f[i][j]=1;
					for(k=j+1;k<a;k++){
						if(x[i+1]==z[k]) f[i+1][k]++;
						f[i+1][k]%=1000000007;
					}
				}
				else{
					for(k=j+1;k<a;k++){
						if(x[i+1]==z[k]) f[i+1][k]+=f[i][j];
						f[i+1][k]%=1000000007;
					}
				}
			}
		}
	}
	for(i=0;i<a;i++){
		g+=f[s-1][i];
		g%=1000000007;
	}
	printf("%d\n",g);
	return 0;
}

Measured memory_bytes: 6664
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
int sum,x,n,a[N];
long long ans;
int main(){
	//freopen("readin.txt","r",stdin);
	scanf("%d",&n);
	for(int i = 0;i < n;i++)scanf("%d",a + i);
	for(int i = 0,r = 0;i < n;i++){
		if(r <= i){sum = 0;r = i;}
		while(r < n && sum + a[r] == (x^a[r]))sum+=a[r],x^=a[r],r++;
		ans+=r - i;
		sum-=a[i];
		x^=a[i];
	}
	printf("%lld\n",ans);
}

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

D = [list(map(int, input().split())) for i in range(n)]

cnt = 0
tmp = 0
for i in range(n):
  if D[i][0] == D[i][1]:
    tmp +=1
    cnt = max(cnt,tmp)
  else:
    tmp = 0
    cnt = max(cnt,tmp)

if cnt >=3:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9192
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		sc.close();

		String[] items = line.split(" ");
		Stack stack = new Stack();

		int op1;
		int op2;
		for (String item : items) {
			switch (item) {
			case "+":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 + op2);
				break;
			case "-":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 - op2);
				break;
			case "*":
				op2 = stack.pop();
				op1 = stack.pop();
				stack.push(op1 * op2);
				break;
			default:
				stack.push(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pop());
	}
}

class Stack {
	private LinkedList<Integer> stack;
	public Stack() {
		stack = new LinkedList<Integer>();
	}
	public void push(int item) {
		stack.addLast(item);
	}
	public int pop() {
		int ret = stack.getLast();
		stack.removeLast();
		return ret;
	}
}

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

int main() {
  int n;
  while (cin >> n && n) {
    vector<int> v;
    for (int i = 0; i < n; i++) {
      int a;
      cin >> a;
      v.push_back(a);
    }
    int count = 0;
    for (int i = 0; i < n - 1; i++) {
      for (int j = i + 1; j < n; j++) {
        if (v[i] > v[j]) {
          count++;
        }
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 1216
#include<iostream>
using namespace std;
int main(){
	int k,a,b,i,cnt=0;
	cin>>k>>a>>b;
	//if(a!=b){
	for(i=a;i<=b;i++){
		if(i%k==0){
			cnt++;break;
		}
	}
	//else{if(a%k==0) {cnt++;
	//}
	//}
	if(cnt==0){cout<<"NG";
	}
	else cout<<"OK";
	 
	return 0;
}

Measured memory_bytes: 3624
from collections import defaultdict


def factorization(n):
    global ND
    temp = n
    flag = True
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            flag = False
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            ND[i] += cnt

    if temp!=1:
        ND[temp] +=1
        flag = False

    if flag:
        ND[n] += 1

    return


N = int(input())
ND = defaultdict(int)
for i in range(2, N+1):
    factorization(i)

L2 = 0
L4 = 0
L14 = 0
L24 = 0
L74 = 0

for key, value in ND.items():
    if value >= 2:
        L2 += 1
    if value >= 4:
        L4 += 1
    if value >= 14:
        L14 += 1
    if value >= 24:
        L24 += 1
    if value >= 74:
        L74 += 1

ans = 0
ans += L4 * (L4-1)//2 * (L2 - 2)
ans += L24 * (L2 - 1)
ans += L14 * (L4 - 1)
ans += L74
print(ans)

Measured memory_bytes: 38896
#include<iostream>
#include<string>

using namespace std;

int main(){
    
    int N;
    cin>>N;
    string s;
    cin>>s;
    int ans=0;
    
    for(int i=1;i<N-1;i++){
        int count =0;
        for(char c='a';c<='z';c++){
            bool right=false,left=false;
            for(int j=0;j<=i;j++){
                if(s[j]==c)left=true;
            }
            
            for(int j=i+1;j<N;j++){
                if(s[j]==c)right=true;
            }
            
            if(left&&right)count++;
        }
        if(ans<count)ans=count;
    }
    
    cout<<ans<<endl;
    
    return 0;
}

  

Measured memory_bytes: 256
// デバッグ実行：Ctrl+F5

using System;

class Program
{
    
    static void Main(string[] args)
    {
        String line;
        line = Console.ReadLine();

        int N = int.Parse(line);
        int keta = 1;
        int now_num = 357;
        int count = 0;
        var t = new test();
        while(now_num <= N)
        {
            count++;
            now_num = t.GetNext();
        }
        Console.WriteLine(count);
    }
    public class test
    {
        public string now = "357";
        public int GetNext()
        {
            int ketasu = now.Length;
            for (int i = ketasu - 1; i >= 0;)
            {
                if (now[i] == '7')
                {
                    i--;
                }
                else
                {
                    // 3か5のはず
                    if (now[i] == '3')
                    {
                        now = now.Remove(i);
                        now += '5';
                        for(int j = 0; j < ketasu - i - 1; j++)
                        {
                            now += "3";
                        }
                        i = ketasu - 1;
                    }
                    else
                    {
                        now = now.Remove(i);
                        now += '7';
                        for (int j = 0; j < ketasu - i - 1; j++)
                        {
                            now += "3";
                        }
                        i = ketasu - 1;
                    }
                    if (Hantei(now))
                    {
                        // 成功
                        return int.Parse(now);
                    }
                }
            }
            string next = "";
            for (int i = 0; i < ketasu - 1; i++)
            {
                next += "3";
            }
            next += "57";
            now = next;
            if (now.Length == 10) return 2000000000;
            return int.Parse(next); ;
        }

        public bool Hantei(string numbers)
        {
            if (!numbers.Contains("3"))
            {
                return false;
            }
            if (!numbers.Contains("5"))
            {
                return false;
            }
            if (!numbers.Contains("7"))
            {
                return false;
            }
            return true;
        }
    }
}

Measured memory_bytes: 15312
#include<iostream>
using namespace std;
int main(){

	int A,B,C;
	int a[3];
	cin>>A>>B>>C;
	a[0]=A*10+B+C;
	a[1]=B*10+C+A;
	a[2]=C*10+A+B;
	
	if(a[0]>=a[1] && a[0]>=a[2])
		cout<<a[0]<<endl;
	else if(a[1]>=a[0] && a[1]>=a[2])
		cout<<a[1]<<endl;
	else
		cout<<a[2]<<endl;
	
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
s = []
for i in range(n):
    a = list(input())
    s.append("".join(sorted(a)))

c = Counter(s)
ans = 0

for i in c.values():
    #i!/(i-2)!/2!
    ans += int(i*(i-1)/2)

print(ans)


Measured memory_bytes: 24224
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}

ll comb(ll n, ll r) {
    ll res, deno, mole;
    res = deno = mole = 1;
    for (ll i = 0; i < r; i++) {
        mole *= (n - i);
        mole %= DIV;
        deno *= (r - i);
        deno %= DIV;
    }
    res = modinv(deno, DIV);
    res = (res * mole) % DIV;
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    if(N==1) cout << 0 << endl;
    else{
        ll ans=modpow(10, N, DIV) - modpow(9, N, DIV) - modpow(9, N, DIV) + modpow(8, N, DIV);
        ans%=DIV;
        ans=(ans+DIV)%DIV;
        cout << ans << endl;
    }
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;
    
#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<functional>
#include<cstring>
#include<string>
#include<cstdlib>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<map>
using namespace std;
#define N 100000+5
#define rep(i,n) for(int i=0;i<n;i++)
#define sd(n) scanf("%d",&n)
#define sll(n) scanf("%I64d",&n)
#define pd(n) scanf("%d\n",n)
#define pll(n) scanf("%I64d\n",n)
#define MAX 26
typedef long long ll;
const ll mod=1e9+7;
int n,m;
int a[N];
int b[N];
vector<int>p[N];
int main()
{
	 //string s;
	 //cin>>s;
	 //ll ans=0;
	 //ll sum=0;
	scanf("%d",&n);
	scanf("%d",&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		p[a[i]].push_back(b[i]);
	}
	for(int i=1;i<=n;i++)
	  sort(p[i].begin(),p[i].end());
	for(int i=0;i<m;i++)
	{

		int pos=lower_bound(p[a[i]].begin(),p[a[i]].end(),b[i])-p[a[i]].begin()+1;
		printf("%06d%06d\n",a[i],pos);
	}
	//for(int i=1;i<=n;i++)
	//	printf("%I64d",a[i]);
		
	//printf("%I64d\n",ans);
    return 0;
}


Measured memory_bytes: 7808
#include <stdio.h>
#include <stdlib.h>
typedef struct Node Node;
struct Node{
    int id;
    Node* parent;
    Node* rcbling;
    Node* lchild;
};

void initialize(Node* n);
int findDepth(Node* a);
int main(int argc, char** argv) {
    int size;
    scanf("%d", &size);
    Node array[size];
    
    int degree;
    int location, tempP, tempC = -1;
    for(int i=0;i<size;i++)
    {
        initialize(&array[i]);
    }
    
    for(int i=0;i<size;i++)
    { 
        scanf("%d %d", &tempP, &degree);
        array[tempP].id = tempP;
        for(int j=0;j<degree;j++)
        {
           
            scanf("%d",&location);
            array[location].parent=array + tempP;
            if(j==0)
            {
                array[tempP].lchild = array + location;
            }
            if(tempC>=0)
            {
                array[tempC].rcbling = array + location;
            }
            tempC = location;
        }
        tempC = -1;
    }
    
    int temp, temp2P, type;
    for(int i=0; i<size; i++)
    {
        printf("node %d: ", i);
        if(array[i].parent == NULL)
            temp2P = -1;
        else
            temp2P = array[i].parent->id;
        printf("parent = %d, ", temp2P);
        printf("depth = %d, ", findDepth(&array[i]));
        if(array[i].parent==NULL)
            type = 1;
        else{
            if(array[i].lchild!=NULL)
                type = 2;
            else
                type = 3;
        }
        if(type == 1)
        {
            printf("root, [");
        }
        if(type == 2)
        {
            printf("internal node, [");
        }
        if(type == 3)
        {
            printf("leaf, [");
        }
        if(array[i].lchild != NULL){
            temp = array[i].lchild->id;
            printf("%d", temp);
            while(array[temp].rcbling!=NULL){
                if(array[temp].rcbling != NULL)
                    printf(", ");
            temp = array[temp].rcbling->id;
            printf("%d", temp);
            }
        }
        printf("]\n");
        
    }
    
    return (EXIT_SUCCESS);
}


void initialize(Node* n)
{
    n->id = -1;
    n->lchild = NULL;
    n->rcbling = NULL;
    n->parent = NULL;
}

int findDepth(Node* a)
{
    int count = 0;
    if(a->parent !=NULL)
    {
        count++;
        count = count + findDepth(a->parent);  
    }
    return count;
}


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

using namespace std;

struct p{
    int l;
    int r;
}a[1000000];

bool cmp(p xx,p yy)
{
    return xx.l>yy.l;
}

int main()
{
    int n,h;
    int c=0;
    cin>>n>>h;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[c++].l);
        a[c].r=1;
        scanf("%d",&a[c++].l);
    }
    sort(a,a+c,cmp);
    int sum=0;
    for(int i=0;i<c;i++)
    {
        if(a[i].r==1)
        {
            sum++;
            h-=a[i].l;
            if(h<=0)
            {
                cout<<sum<<endl;
                return 0;
            }
        }
        else if(a[i].r!=1)
        {
            if(h%a[i].l==0) 
                sum+=h/a[i].l;
            else 
                sum+=h/a[i].l+1;
            cout<<sum<<endl;
            return 0;

        }
    }
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>

using namespace std;

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

    bool f = false;
    for (int i = 0; i < s.size() - 1; i++)
    {
        if(s[i] == s[i+1]) {
            f = true;
        }
    }

    if(f) {
        cout << "Bad"
             << "\n";
    }
    else
    {
        cout << "Good" << "\n";
    }
}

Measured memory_bytes: 3592
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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


fn f(H: &[i32], k: &i32) -> i32 {
    let min_value = H.iter().min();
    match min_value {
        Some(v) => {
            let mut iter = H.split(|num| num == v);
            let mut res = v - k;
            loop {
                match iter.next() {
                    Some(h) => { 
                        // println!{"{:?}", h};
                        res += f(h, &v); 
                    },
                    None => { break; },
                }
            }
            // println!("{}", res);
            res
        },
        None => 0,
    }
    
}

fn main() {
    input! {
        N: i32,
        H: [i32; N],
    }
    
    let k = 0;
    println!{"{}",f(&H, &k)};
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

int gcd(int a, int b){
    if (b == 0) {
        return a;
    }
    return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}


void solve(){
    ll N, K;
    cin >> N >> K;

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

    ll d = A[0];
    bool isin = false;
    for (int i = 0; i < N; i++) {
        d = gcd(A[i], d);
        if (K <= A[i]) {
            isin = true;
        }
    }

    if (isin && (K % d) == 0) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }




    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200001 ;
int main()
{
   fast ;
   ///Mission-500
   ll a,b ;
   cin>>a>>b ;
   vector<ll>r(4,0) ;
   r[a]=1 ;
   r[b]=1 ;
   for(ll i=1;i<=3;i++)
   {
       if(r[i]==0)
       {
           cout<<i ;
           break ;
       }
   }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
    str s, t;
    cin >> s >> t;
    int n=0;
    REP(i, s.size()) {
        if(s[i] != t[i]) n++;
    }
    cout << n << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

bool issorted(vector<int> &v)
{
	for(int i = 1; i < v.size(); i++)
		if(v[i] < v[i - 1])
			return false;
	return true;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef ONLINE_JUDGE
    // freopen("", "r", stdin);
    // freopen("", "w", stdout);
#endif
	int n;
	cin >> n;
	vector<int> v;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		v.push_back(a);
	}
	if(issorted(v)){
		cout << "YES";
		return 0;
	}
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			swap(v[i], v[j]);
			if(issorted(v))
			{
				cout << "YES";
				return 0;
			}
			swap(v[i], v[j]);
		}
	}
	cout << "NO";
	return 0;
}


Measured memory_bytes: 256
package main

import (
  "bufio"
  "fmt"
  "os"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func main() {
  if sc.Scan() {
    s := sc.Text()
    m := map[string]int{}
    for i := 0; i < len(s); i++ {
      ss := s[i:i+1]
      _, ok := m[ss]
      if ok {
        m[ss]++
      } else {
        m[ss] = 1
      }
    }
    if len(m) == 2 && m[s[0:1]] == 2 {
      fmt.Println("Yes")
    } else {
      fmt.Println("No")
    }
  }
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
set<string> st;
map<string, vector<string> > mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin >> n, n)
	{
		string s, t = "";
		cin >> s;
		bool flag = false;
		int pos = 0;
		st.clear();
		mp.clear();
		while(1)
		{
			if(s[pos] == '.')
			{
				st.insert(t);
				t = "";
				break;
			}
			if(s[pos] == ':')
			{
				flag = true;
				t = "";
			}
			else if(s[pos] == ',')
			{
				st.insert(t);
				t = "";
			}
			else
				t += s[pos];
			pos++;
		}
		for(int i = 0; i < n - 1; i++)
		{
			cin >> s;
			pos = 0;
			string group = "";
			t = "";
			flag = false;
			while(1)
			{
				if(s[pos] == '.')
				{
					mp[group].push_back(t);
					break;
				}
				if(flag == false)
				{
					if(s[pos] == ':')
						flag = true;
					else
						group += s[pos];
				}
				else
				{
					if(s[pos] == ',')
					{
						mp[group].push_back(t);
						t = "";
					}
					else
					{
						t += s[pos];
					}
				}
				pos++;
			}
		}/*
		for(auto itr = mp.begin(); itr != mp.end(); itr++)
		{
			cout << itr->first << endl;
			auto vec = itr->second;
			for(int i = 0; i < vec.size(); i++)
				cout << vec[i] << " ";
			cout << endl;
		}*/
		flag = true;
		while(flag)
		{
			flag = false;
			for(auto itr = mp.begin(); itr != mp.end(); itr++)
			{
				auto group = itr->first;
				if(st.find(group) == st.end())
					continue;
				st.erase(group);
				auto vec = itr->second;
				for(int i = 0; i < vec.size(); i++)
				{
					//cout << vec[i] << endl;
					st.insert(vec[i]);
				}
				flag = true;
			}
		}
		cout << st.size() << endl;
	}
	return 0;
}


Measured memory_bytes: 3324
module UnionFind

implicit none
integer,allocatable,dimension(:)::par
!parentより

contains

recursive function root(x) result(res)
integer :: x,res
if(par(x) /= x)par(x) = root(par(x))
res = par(x)
end function

subroutine unite(x,y)
integer :: x,y
x = root(x)
y = root(y)
if(x /= y) par(x) = y
end subroutine

subroutine UFinit(N)
integer :: N
integer::i
  allocate(par(N))
  do i = 1, N
    par(i) = i
  end do
end subroutine
end module UnionFind
program main
  use UnionFind
  implicit none
  integer::N,M
  integer::X,Y,Z
  integer::ANS=0
  integer::i
  read*,N,M
  call UFinit(N)
  do i=1,M
    read*,X,Y,Z
    call unite(X,Y)
  end do
  do i=1,N
    if(par(i)==i)ANS=ANS+1
  end do
  print"(i0)",ANS
end program main

Measured memory_bytes: 768
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io

	string x;
	cin>>x;
	ll res=1;
	ll prev=1;
	rep(i,1,x.length())
	{
		if(prev==2)
		{
			res++;
			prev=1;
			continue;
		}
		if(x[i]!=x[i-1])
		{
			prev=1;
			res++;
			continue;
		}
		if(i!=(x.length()-1))
		{
			res++;
			prev=2;
			i++;
		}
		else
		{
			continue;
		}
	}	
	cout<<res;
}

Measured memory_bytes: 720
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if (S.equals("RRR")) {
            System.out.println(3);
        } else if (S.equals("RRS")) {
            System.out.println(2);
        } else if (S.equals("SRR")) {
            System.out.println(2);
        } else if (S.equals("SSS")) {
            System.out.println(0);
        } else {
            System.out.println(1);
        }
    }
}


Measured memory_bytes: 35560
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
  	int cout=0;
	char a[4];
  	rep(i,4){
      cin>>a[i];
    }
  	rep(i,3)
      FOR(j,i+1,3)
      	if(a[i]==a[j])
          cout++;
  if(cout==2)
    Out("Yes");
  else
    Out("No");
    return 0;
}

Measured memory_bytes: 256